:root {
  --bg: #0c0e12;
  --surface: #141820;
  --surface-2: #1b202b;
  --surface-3: #232a38;
  --ink: #f3f5f8;
  --ink-2: #b6bfd0;
  --muted: #7f8a9f;
  --border: rgba(255, 255, 255, 0.09);
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --good: #10b981;
  --good-soft: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.15);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: #60a5fa;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  color: #93c5fd;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(12, 14, 18, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge-lane {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hb-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.dot.ok {
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:hover {
  background: var(--surface-3);
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* KPI Bar */
.kpi-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

@media (max-width: 1100px) {
  .kpi-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 640px) {
  .kpi-bar {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kpi-val {
  font-size: 24px;
  font-weight: 800;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}
.kpi-val.good {
  color: #34d399;
}

.kpi-meta {
  font-size: 12px;
  color: var(--ink-2);
}

/* Guardrail Strip */
.guardrail-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.guardrail-items {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.g-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--good-soft);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.search-box input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 8px;
  width: 280px;
  font-size: 12px;
}

/* Listing Cards */
.listings-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sku-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.sku-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.sku-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sku-id {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-weight: 700;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  color: #fff;
}

.sku-cat {
  font-size: 12px;
  color: var(--ink-2);
}

.sku-hts {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  color: var(--muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-badge.staged {
  background: var(--accent-soft);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.status-badge.live {
  background: var(--good-soft);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.sku-body {
  display: grid;
  grid-template-columns: 270px 1.25fr 1fr 1.35fr;
  gap: 18px;
  padding: 18px;
}

@media (max-width: 1240px) {
  .sku-body {
    grid-template-columns: 240px 1fr;
  }
}
@media (max-width: 760px) {
  .sku-body {
    grid-template-columns: 1fr;
  }
}

.media-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.hero-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumb-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.thumb-strip img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #fff;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.col-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 8px;
}

.us-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 10px;
  color: #fff;
}

.comp-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.comp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.comp-row:last-child {
  margin-bottom: 0;
}

.price-highlight {
  font-size: 18px;
  font-weight: 800;
  color: #34d399;
  font-variant-numeric: tabular-nums;
}

.specs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.spec-item {
  background: var(--surface-2);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
}
.spec-item span {
  color: var(--muted);
  display: block;
  font-size: 10px;
}

/* Unit Economics Table */
.econ-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.econ-table td {
  padding: 5px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.07);
}
.econ-table td:last-child {
  text-align: right;
  font-weight: 600;
}
.econ-table tr.econ-total td {
  border-top: 1px solid var(--border);
  border-bottom: none;
  padding-top: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #34d399;
}

/* Factory Cards */
.factory-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.factory-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.factory-card.primary {
  border-left: 3px solid var(--good);
}
.factory-card.backup {
  border-left: 3px solid var(--accent);
}

.f-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.f-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--ink-2);
}

.f-stock {
  font-size: 11px;
  font-weight: 700;
  color: #34d399;
}

.f-name {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.f-variant {
  font-size: 11px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.f-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.f-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.f-links {
  display: flex;
  gap: 10px;
  font-size: 11px;
}

/* Comparison Table View */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

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

.data-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

/* Log Panel */
.log-panel {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.log-header h2 {
  font-size: 14px;
  margin: 0;
}
.log-sub {
  font-size: 12px;
  color: var(--muted);
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
}

.log-item {
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.log-ts {
  color: var(--muted);
  white-space: nowrap;
}
.log-tag {
  font-weight: 700;
  color: #60a5fa;
  white-space: nowrap;
}

.footer {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 24px 36px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}


/* Product Search & Margin Explorer */
.explorer-panel {
  background: var(--surface);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

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

.explorer-header h2 {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 4px;
  color: #fff;
}

.explorer-sub {
  font-size: 12px;
  color: var(--ink-2);
  margin: 0;
}

.explorer-controls input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  width: 340px;
  max-width: 100%;
  font-size: 12px;
}

.custom-calc-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 12px;
}

.custom-calc-bar input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  min-width: 210px;
  flex: 1;
}

.custom-calc-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-weight: 600;
}

.custom-calc-bar input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 5px 8px;
  border-radius: 6px;
  width: 78px;
  font-size: 12px;
  font-weight: 700;
}

.btn-accent {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-accent:hover {
  filter: brightness(1.1);
}

.exp-prod-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.exp-cat {
  font-size: 11px;
  color: var(--muted);
}

.exp-prod-title {
  font-weight: 700;
  color: #fff;
  font-size: 13px;
  margin-bottom: 4px;
}

.exp-prod-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
}

.exp-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-weight: 700;
}

.inline-num {
  background: transparent;
  border: none;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  width: 68px;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.inline-num.inline-kg {
  width: 54px;
}

.exp-sub-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.exp-fee-total {
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.exp-fee-breakdown {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.35;
}

.exp-margin-val {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: 3px;
}
.exp-margin-val.margin-pass {
  color: #34d399;
}
.exp-margin-val.margin-warn {
  color: #fbbf24;
}
.exp-margin-val.margin-fail {
  color: #f87171;
}

.exp-gate-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.exp-gate-pill.margin-pass {
  background: var(--good-soft);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.exp-gate-pill.margin-warn {
  background: var(--warn-soft);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.exp-gate-pill.margin-fail {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Post-Purchase Fulfillment Bridge Summary */
.fulfillment-summary {
  margin-bottom: 14px;
}

.fb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 1000px) {
  .fb-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .fb-grid {
    grid-template-columns: 1fr;
  }
}

.fb-step {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--good);
  border-radius: 8px;
  padding: 10px 12px;
}

.fb-step-head {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.fb-step-body {
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.4;
}

.fb-qc-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
}

.fb-qc-chip {
  background: var(--surface-3);
  color: var(--ink-2);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
}
