:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --ink: #101214;
  --soft: #3e4448;
  --muted: #6d747a;
  --line: #d8d9d2;
  --accent: #174b72;
  --accent-2: #2d6e9f;
  --risk: #a6412f;
  --warn: #8a6424;
  --ok: #24614b;
  --shadow: 0 20px 60px rgba(16, 18, 20, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(244, 244, 241, 0.94)),
    radial-gradient(circle at 12% 10%, rgba(23, 75, 114, 0.14), transparent 30%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 0.98;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.15;
}

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
}

.topbar,
.mission-band,
.rail-panel,
.decision-panel,
.info-panel,
.ops-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 16px;
}

.brand-lockup,
.topbar-actions,
.sku-header,
.approval-row,
.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 7px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
}

.topbar-actions {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(23, 75, 114, 0.18);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(23, 75, 114, 0.08);
  font-weight: 800;
}

.ghost-button,
.primary-button,
.secondary-button,
.scenario-button,
.agent,
.info-dot {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
}

.mission-band {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 340px);
  gap: 20px;
  align-items: end;
  margin-top: 16px;
  padding: 28px;
  overflow: hidden;
}

.mission-band p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--soft);
  font-size: 17px;
  line-height: 1.55;
}

.offer-card {
  position: relative;
  min-height: 164px;
  padding: 18px;
  border: 1px solid rgba(23, 75, 114, 0.22);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(23, 75, 114, 0.1), rgba(255, 255, 255, 0.9)),
    var(--surface);
}

.offer-card span,
.offer-card small,
.metric-grid span,
.loop-grid span,
.scenario-button small,
.build-stack li,
.decision-card span {
  color: var(--muted);
}

.offer-card strong {
  display: block;
  max-width: 250px;
  margin: 16px 0 8px;
  font-size: 28px;
  line-height: 1;
}

.command-grid {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 330px;
  gap: 14px;
  margin-top: 14px;
}

.rail-panel,
.decision-panel,
.info-panel,
.ops-card {
  padding: 18px;
}

.rail-panel,
.info-panel {
  align-self: start;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading.tight {
  margin-bottom: 12px;
}

.info-dot {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--accent);
  font-weight: 900;
}

.info-dot:hover,
.info-dot.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

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

.scenario-button {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  width: 100%;
  min-height: 92px;
  padding: 12px;
  text-align: left;
}

.scenario-button span {
  color: var(--accent);
  font-weight: 900;
}

.scenario-button strong,
.scenario-button small {
  grid-column: 2;
  display: block;
}

.scenario-button.active,
.scenario-button:hover,
.agent.active,
.agent:hover,
.ghost-button:hover,
.secondary-button:hover {
  border-color: rgba(23, 75, 114, 0.36);
  background: rgba(23, 75, 114, 0.07);
}

.build-stack {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.build-stack ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.decision-panel {
  min-height: 640px;
}

.scenario-summary {
  max-width: 760px;
  color: var(--soft);
  font-size: 17px;
  line-height: 1.55;
}

.decision-card,
.troubleshooter-card,
.activity-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.decision-card {
  padding: 18px;
}

.sku-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sku-header strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border: 8px solid rgba(23, 75, 114, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
}

.score-ring span {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.score-ring small {
  margin-top: -8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.evidence-item {
  min-height: 102px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.evidence-item strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 22px;
  line-height: 1;
}

.evidence-item small {
  color: var(--muted);
}

.proof-box {
  margin-top: 12px;
  padding: 14px;
  border-left: 4px solid var(--accent);
  background: #fff;
}

.proof-box p {
  margin: 6px 0 0;
  color: var(--soft);
  line-height: 1.5;
}

.approval-row {
  flex-wrap: wrap;
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 900;
}

.primary-button {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  transform: translateY(-1px);
  background: var(--accent-2);
  box-shadow: 0 12px 28px rgba(23, 75, 114, 0.22);
}

.primary-button.compact {
  min-width: 128px;
}

.troubleshooter-card {
  margin-top: 14px;
  padding: 16px;
}

.input-row {
  align-items: stretch;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}

.steps-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.step-item {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.step-item span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.step-item p {
  margin-bottom: 0;
  color: var(--soft);
  line-height: 1.45;
}

.info-panel p {
  color: var(--soft);
  line-height: 1.55;
}

.info-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--soft);
  line-height: 1.45;
}

.activity-card {
  margin-top: 18px;
  padding: 14px;
}

.activity-log {
  display: grid;
  gap: 8px;
}

.activity-log div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.4;
}

.operations-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.ops-card.wide {
  grid-column: 1 / -1;
}

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

.agent {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  font-weight: 850;
}

.agent span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(23, 75, 114, 0.12);
}

.agent-output {
  min-height: 72px;
  margin: 14px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--soft);
  background: var(--surface-2);
  line-height: 1.5;
}

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

.metric-grid div {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.metric-grid strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1;
}

.live-data-panel {
  grid-column: 1 / -1;
  overflow: hidden;
}

.live-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.live-metrics div,
.source-status-grid div {
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.live-metrics span,
.source-status-grid span,
.product-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.live-metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1;
}

.competitor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.competitor-tab {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  font-weight: 850;
}

.competitor-tab.active,
.competitor-tab:hover {
  border-color: rgba(23, 75, 114, 0.36);
  background: rgba(23, 75, 114, 0.08);
}

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

.source-note {
  margin: 0 0 12px;
  color: var(--soft);
  line-height: 1.5;
}

.product-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.product-table {
  width: 100%;
  min-width: 1220px;
  border-collapse: collapse;
}

.product-table th,
.product-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.product-table td {
  color: var(--soft);
  font-size: 13px;
  line-height: 1.4;
}

.product-table td strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.product-table a {
  color: var(--accent);
  font-weight: 850;
  text-decoration: none;
}

.product-cell {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.image-frame {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background:
    linear-gradient(135deg, rgba(23, 75, 114, 0.08), rgba(36, 97, 75, 0.08)),
    #fff;
}

.image-frame img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
  background: #fff;
}

.image-frame span {
  color: var(--accent);
  font-weight: 900;
}

.product-thumb {
  width: 64px;
  height: 50px;
}

.source-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.source-status-grid strong {
  display: block;
  margin: 8px 0 6px;
}

.source-status-grid p {
  margin: 0;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.4;
}

.source-status-grid small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.response-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(250, 250, 247, 0.95)),
    var(--surface);
}

.response-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 14px;
  align-items: stretch;
}

.response-lead,
.response-stats div,
.response-row,
.response-empty {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.response-lead {
  min-height: 196px;
  padding: 16px;
}

.response-lead h3 {
  margin-bottom: 10px;
  font-size: 26px;
  line-height: 1.05;
}

.response-lead p {
  color: var(--soft);
  line-height: 1.5;
}

.response-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.response-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.response-stats div {
  min-height: 92px;
  padding: 12px;
}

.response-stats span,
.response-row span,
.response-row dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.response-stats strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
}

.response-feed {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.response-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-left-width: 4px;
}

.response-row.beat {
  border-left-color: var(--ok);
}

.response-row.watch {
  border-left-color: var(--warn);
}

.response-row.avoid {
  border-left-color: var(--risk);
}

.response-row strong {
  display: block;
  margin: 6px 0;
  line-height: 1.25;
}

.response-row p {
  margin: 0;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.45;
}

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

.response-row dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-weight: 900;
}

.response-row a {
  color: var(--accent);
  font-weight: 850;
  text-decoration: none;
}

.response-empty {
  padding: 14px;
}

.response-empty p {
  margin: 6px 0 0;
  color: var(--soft);
  line-height: 1.45;
}

.ad-studio-panel {
  grid-column: 1 / -1;
}

.ad-studio-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.ad-studio-metrics div,
.ad-card,
.ad-empty {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.ad-studio-metrics div {
  min-height: 86px;
  padding: 12px;
}

.ad-studio-metrics span,
.ad-meta span,
.ad-price-row span,
.ad-copy-grid span,
.ad-visual > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.ad-studio-metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1;
}

.ad-studio-grid {
  display: grid;
  gap: 12px;
}

.ad-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.ad-visual {
  min-width: 0;
}

.ad-product-image {
  width: 100%;
  aspect-ratio: 4 / 3;
}

.ad-visual > span {
  display: block;
  margin-top: 8px;
}

.ad-body h4 {
  margin: 10px 0 8px;
  font-size: 24px;
  line-height: 1.08;
}

.ad-body p {
  margin-bottom: 0;
  color: var(--soft);
  line-height: 1.45;
}

.ad-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.ad-meta strong {
  color: var(--accent);
}

.ad-price-row,
.ad-copy-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.ad-price-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ad-price-row div,
.ad-copy-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.ad-price-row strong,
.ad-copy-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  line-height: 1.2;
}

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

.ad-copy-grid p {
  margin-top: 6px;
  font-size: 13px;
}

.ad-empty {
  padding: 14px;
}

.ad-empty p {
  margin: 6px 0 0;
  color: var(--soft);
  line-height: 1.45;
}

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

.loop-grid div {
  min-height: 142px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.loop-grid strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 19px;
}

.loop-grid p {
  margin-bottom: 0;
  color: var(--soft);
  line-height: 1.45;
}

.app-shell.is-running .score-ring,
.app-shell.is-running .agent.active span {
  animation: pulse 720ms ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    transform: scale(0.92);
    filter: brightness(0.95);
  }
  to {
    transform: scale(1.08);
    filter: brightness(1.2);
  }
}

@media (max-width: 1160px) {
  .command-grid {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .info-panel {
    position: static;
    grid-column: 1 / -1;
  }

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

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .topbar-actions,
  .mission-band,
  .command-grid,
  .operations-grid,
  .loop-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
    white-space: normal;
  }

  .rail-panel {
    position: static;
  }

  .scenario-list {
    grid-template-columns: 1fr;
  }

  .input-row,
  .approval-row {
    flex-direction: column;
  }

  .primary-button.compact {
    width: 100%;
  }

  .agent-town,
  .metric-grid,
  .live-metrics,
  .ad-studio-metrics,
  .source-status-grid,
  .response-layout,
  .response-stats,
  .response-row,
  .response-row dl,
  .ad-card,
  .ad-price-row,
  .ad-copy-grid {
    grid-template-columns: 1fr;
  }

  .response-actions {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .mission-band,
  .rail-panel,
  .decision-panel,
  .info-panel,
  .ops-card {
    padding: 14px;
  }

  .brand-lockup {
    align-items: start;
  }

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

  .sku-header {
    align-items: start;
    flex-direction: column;
  }

  .step-item {
    grid-template-columns: 1fr;
  }
}

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