:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #16181d;
  --muted: #667085;
  --line: #dfe3e8;
  --accent: #1f5eff;
  --accent-text: #ffffff;
  --good: #147a4b;
  --warn: #9a6700;
  --bad: #b42318;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #20242c;
    --text: #f2f4f7;
    --muted: #a9b0bd;
    --line: #303641;
    --accent: #7597ff;
    --accent-text: #0a1020;
    --good: #63d69a;
    --warn: #f3c969;
    --bad: #ff8a80;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  min-height: 64px;
  padding: 10px clamp(16px, 3vw, 36px);
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 800; text-decoration: none; white-space: nowrap; }
.main-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.main-nav a { padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); }
.main-nav a:hover { background: var(--surface-2); color: var(--text); }
.account-area { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.account-area form { margin: 0; }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 64px; }
.page-heading { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.05; margin-bottom: 8px; }
h2 { line-height: 1.2; }
.eyebrow { margin-bottom: 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

.button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 13px;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.button:hover { background: var(--surface-2); }
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.button-danger { color: var(--bad); }
.button-quiet { border: 0; background: transparent; padding: 6px; }

input, select {
  width: 100%;
  min-height: 42px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
}
label { display: grid; gap: 6px; font-weight: 650; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 750; margin-bottom: 10px; }

.filter-bar, .actions-row, .row-between { display: flex; align-items: center; }
.filter-bar { gap: 10px; margin-bottom: 24px; }
.row-between { justify-content: space-between; }
.gap { gap: 16px; }
.grow { flex: 1; }
.actions-row { gap: 9px; flex-wrap: wrap; }
.actions-row form { margin: 0; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 18px; }
.product-card, .tracking-card, .opportunity-card, .panel, .alert-card, .auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.product-card { overflow: hidden; }
.product-image { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; display: grid; place-items: center; }
.product-image-empty { color: var(--muted); background: var(--surface-2); }
.product-card-body { padding: 16px; }
.product-card h2 { font-size: 1.1rem; margin: 14px 0 6px; }
.product-card h2 a { text-decoration: none; }

.pill, .opportunity-badge, .status-good, .status-warn, .status-bad {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 800;
}
.pill { background: var(--surface-2); color: var(--muted); }
.status-good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.status-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.status-bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }

.detail-layout { display: grid; grid-template-columns: minmax(260px, .85fr) 1.15fr; gap: 36px; margin-bottom: 28px; }
.detail-image { width: 100%; border-radius: var(--radius); background: #fff; object-fit: contain; aspect-ratio: 1; }
.price-large { font-size: 1.8rem; font-weight: 800; }
.facts, .market-facts { display: grid; gap: 10px; }
.facts div, .market-facts div { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 700; text-align: right; }

.panel { padding: 20px; margin-bottom: 20px; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.stack-form { display: grid; gap: 18px; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check-row input { width: auto; min-height: auto; }
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.size-option { position: relative; display: grid; gap: 0; border: 1px solid var(--line); border-radius: 9px; padding: 10px; font-weight: 700; }
.size-option input { position: absolute; top: 8px; right: 8px; width: auto; min-height: auto; }
.size-option small { color: var(--muted); font-weight: 500; }
.size-unavailable { opacity: .65; }
.money-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding-left: 10px; }
.money-input input { border: 0; }

.stack-list { display: grid; gap: 14px; }
.stack-list.compact { gap: 10px; }
.tracking-card { padding: 20px; display: grid; grid-template-columns: 1fr auto; gap: 20px; }
.tracking-intent { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0 18px; color: var(--good); font-weight: 700; }
.current-state { display: flex; gap: 24px; flex-wrap: wrap; }
.current-state div { display: grid; }
.tracking-actions { display: flex; gap: 8px; flex-direction: column; align-items: stretch; }

.opportunity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.opportunity-card { padding: 20px; border-top-width: 4px; }
.opportunity-instant { border-top-color: var(--good); }
.opportunity-strong { border-top-color: var(--accent); }
.opportunity-watch { border-top-color: var(--warn); }
.opportunity-badge { background: var(--surface-2); }
.decision-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.decision-grid section { background: var(--surface-2); border-radius: 10px; padding: 14px; }
.metric-big { font-size: 1.55rem; font-weight: 850; margin: 4px 0; }
.profit-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.profit-strip div { display: grid; background: var(--surface-2); padding: 10px; border-radius: 9px; }
.profit-strip span, .freshness { color: var(--muted); font-size: .82rem; }
.freshness { display: flex; justify-content: space-between; gap: 12px; margin: 14px 0; }

.alert-card { padding: 18px; display: flex; justify-content: space-between; gap: 24px; }
.alert-card h2 { font-size: 1.05rem; margin: 9px 0 4px; }
.alert-card p { margin-bottom: 0; }

.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.error-box, .detail-json { max-height: 220px; overflow: auto; white-space: pre-wrap; background: var(--surface-2); padding: 10px; border-radius: 9px; font-size: .78rem; }
.identity-card { background: var(--surface-2); border-radius: 10px; padding: 14px; }
.identity-products { display: flex; flex-wrap: wrap; gap: 6px; }
.evidence-list { margin-bottom: 0; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.flash { border-radius: 9px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); }
.flash-error { border-color: var(--bad); }
.flash-success { border-color: var(--good); }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 48px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.auth-card { width: min(440px, 100%); margin: 10vh auto 0; padding: 28px; display: grid; gap: 24px; }
.prose { max-width: 800px; }

@media (max-width: 760px) {
  .site-header { align-items: flex-start; flex-wrap: wrap; }
  .main-nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .account-area { margin-left: auto; }
  .page-heading, .filter-bar { align-items: stretch; flex-direction: column; }
  .detail-layout { grid-template-columns: 1fr; }
  .tracking-card { grid-template-columns: 1fr; }
  .tracking-actions { flex-direction: row; flex-wrap: wrap; }
  .decision-grid { grid-template-columns: 1fr; }
  .profit-strip { grid-template-columns: 1fr; }
}

/* R8 operations cockpit keeps high-signal production state scannable without
   introducing a second frontend stack or exposing raw infrastructure controls. */
.ops-score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.ops-score { margin-bottom: 0; display: grid; gap: 4px; }
.ops-score strong { font-size: 1.35rem; }
.ops-facts { margin-top: 14px; }
.ops-host-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.ops-host-grid div { display: grid; gap: 4px; }
