:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #20242a;
  --muted: #626a73;
  --line: #dfe4ea;
  --line-strong: #c9d1da;
  --brand: #e6531f;
  --brand-dark: #b93b12;
  --blue: #2463a6;
  --green: #12704a;
  --red: #b42318;
  --amber: #98640f;
  --shadow: 0 12px 26px rgba(20, 31, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
.buttonLink {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

button:hover,
.buttonLink:hover {
  background: var(--brand-dark);
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
}

button.secondary {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line-strong);
}

button.secondary:hover {
  background: #eef2f6;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbarIntro {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

p {
  margin: 0;
}

.topActions,
.actionGrid,
.formGrid {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.tenantPicker {
  min-width: 220px;
}

.contextPills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.contextPill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contextPill.is-primary {
  color: var(--brand-dark);
  background: #fff1ea;
  border-color: #f2d7ca;
}

.contextPill.is-ok {
  color: var(--green);
  background: #edf8f3;
  border-color: #cde9db;
}

.contextPill.is-warn {
  color: var(--amber);
  background: #fff7e8;
  border-color: #f1dfb1;
}

.shell {
  max-width: 1420px;
  margin: 0 auto;
  padding: 16px 24px 40px;
}

.runBar,
.toolbar,
.tabs,
.metrics,
.split,
.panel {
  margin-top: 14px;
}

.runBar,
.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 8px;
  min-width: 170px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
}

.checkLine {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  min-height: 40px;
  min-width: 190px;
  color: var(--ink);
}

.checkLine input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.runStatus {
  min-height: 40px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

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

.metric {
  min-height: 82px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

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

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.tab.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

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

.panelHead p,
.summaryLine,
.noticeBar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.platformList {
  display: grid;
  gap: 10px;
}

.platformItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.platformItem strong {
  display: inline-block;
  margin-right: 6px;
}

.platformItem span {
  color: var(--muted);
  font-size: 13px;
}

.riskPill {
  min-width: 30px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--red);
  background: #fff0ee;
  font-weight: 800;
}

.riskPill.ok {
  color: var(--green);
  background: #edf8f3;
}

.tableWrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 800;
  white-space: nowrap;
}

.status.below_map {
  color: var(--red);
  background: #fff0ee;
}

.status.at_or_above_map {
  color: var(--green);
  background: #edf8f3;
}

.status.missing_price {
  color: var(--amber);
  background: #fff7e8;
}

.status.buybox.below-map {
  color: var(--red);
  background: #fff0ee;
}

.status.buybox.slightly-below {
  color: var(--amber);
  background: #fff7e8;
}

.status.buybox.at-above-map {
  color: var(--green);
  background: #edf8f3;
}

.status.buybox.no-map {
  color: var(--muted);
  background: #edf0f3;
}

.textLink {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.textLink:hover {
  text-decoration: underline;
}

.formGrid {
  align-items: end;
  margin-bottom: 12px;
}

.formGrid label {
  min-width: 240px;
}

.actionGrid {
  align-items: center;
  margin: 12px 0;
}

.secondaryLink {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line-strong);
}

.secondaryLink:hover {
  background: #eef2f6;
}

.buyboxMetrics .metric strong {
  font-size: 22px;
}

.buyboxSplit {
  margin: 14px 0;
}

.insetPanel {
  margin-top: 0;
  box-shadow: none;
  background: #fbfcfd;
}

.detailCard {
  min-height: 174px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.compactActions {
  justify-content: flex-start;
}

.selectedRow td {
  background: #eef5ff;
}

.noticeBar {
  margin: 12px 0;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.fileGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.fileGroup {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.fileGroup h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.fileGroup ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.fileGroup li {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  font-size: 14px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.matchupNotice {
  margin-top: 0;
}

.matchupGrid {
  display: grid;
  grid-template-columns: 170px repeat(3, minmax(220px, 1fr));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

.matchupLabel,
.matchupCell {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.matchupLabel {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.matchupCell:last-child,
.matchupHeaderCell:last-child {
  border-right: 0;
}

.matchupGrid > :nth-last-child(-n + 4) {
  border-bottom: 0;
}

.matchupHeaderCell {
  padding: 18px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.matchupHeaderCell h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.matchupHeaderCell p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.brandPill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.matchupImage {
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  overflow: hidden;
  color: #ffffff;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.matchupImage img {
  width: 100%;
  height: 132px;
  object-fit: contain;
  display: block;
  background: #ffffff;
}

.matchupPrice {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
}

.matchupMeta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.matchupRef {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.matchupDelta {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 800;
}

.matchupDelta.up {
  color: var(--green);
}

.matchupDelta.down {
  color: var(--red);
}

.matchupDelta.flat {
  color: var(--muted);
}

.matchupEmpty {
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: #fbfcfd;
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topActions,
  .topActions button,
  .runBar button,
  .actionGrid button,
  .buttonLink {
    width: 100%;
  }

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

  label,
  .formGrid label {
    width: 100%;
    min-width: 0;
  }

  .tenantPicker {
    min-width: 0;
  }

  .panelHead {
    flex-direction: column;
  }

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

  .matchupLabel,
  .matchupCell,
  .matchupHeaderCell {
    border-right: 0;
  }

  .matchupGrid > :nth-last-child(-n + 4) {
    border-bottom: 1px solid var(--line);
  }

  .matchupGrid > :last-child {
    border-bottom: 0;
  }
}

@media (max-width: 520px) {
  .shell {
    padding: 14px 14px 32px;
  }

  .topbar {
    padding: 16px;
  }

  h1 {
    font-size: 22px;
  }

  .metric {
    min-height: 76px;
  }
}
