:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #dfe6f0;
  --text: #162033;
  --muted: #738099;
  --accent: #e11b22;
  --blue: #1685ff;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

.embed-body {
  background: #fff;
}

.topbar {
  align-items: end;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 28px 32px 24px;
}

.page {
  margin: 0 auto;
  max-width: 1440px;
  padding: 28px 32px 40px;
}

.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
  text-transform: uppercase;
}

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

h1 {
  font-size: 34px;
}

h2 {
  font-size: 24px;
}

a {
  color: inherit;
  text-decoration: none;
}

.ghost-link {
  color: var(--muted);
  font-weight: 600;
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.message,
.notice {
  background: #fff3cd;
  border: 1px solid #f2df92;
  border-radius: 10px;
  color: #6e5614;
  padding: 12px 14px;
}

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

.metric,
.panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 34px rgba(23, 32, 51, 0.05);
}

.metric {
  padding: 22px;
}

.metric span,
.metric small,
.service-note,
.meta,
.advertiser,
.status-stack span,
.run-item span,
.run-item small,
.muted {
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 32px;
  margin: 12px 0 8px;
}

.layout {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.panel {
  padding: 24px;
}

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

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(240px, 1fr) 220px 160px 120px;
  margin-bottom: 18px;
}

input,
select,
textarea,
button {
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  min-height: 46px;
  padding: 0 14px;
}

textarea {
  min-height: 120px;
  padding: 12px 14px;
  resize: vertical;
}

button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

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

.context-form {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

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

.context-form label {
  color: var(--muted);
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.context-summary {
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 14px;
}

.context-summary span {
  color: var(--muted);
  display: block;
  font-size: 14px;
}

.context-summary strong {
  display: block;
  margin-top: 4px;
}

.product-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.image-wrap {
  align-items: center;
  background: #fff;
  display: flex;
  justify-content: center;
  min-height: 220px;
  padding: 24px;
}

.image-wrap img {
  max-height: 180px;
  max-width: 100%;
  object-fit: contain;
}

.image-placeholder {
  color: var(--muted);
}

.image-fallback {
  align-items: center;
  background: linear-gradient(135deg, #eef4ff 0%, #f8fbff 100%);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  justify-content: center;
  min-height: 180px;
  padding: 24px;
  text-align: center;
  width: 100%;
}

.image-fallback strong {
  font-size: 22px;
  line-height: 1.1;
}

.image-fallback span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.card-body {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.card-body h3 {
  font-size: 26px;
  line-height: 1.2;
}

.meta {
  display: flex;
  gap: 12px;
}

.price {
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
}

.advertiser {
  font-size: 18px;
  font-weight: 700;
}

.deal-button {
  align-items: center;
  background: var(--accent);
  border-radius: 10px;
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  width: fit-content;
}

.deal-button-disabled {
  background: #cbd5e1;
  color: #475569;
  cursor: default;
}

.embed-shell {
  background: #fff;
  border: 1px solid var(--line);
  margin: 0 auto;
  max-width: 1120px;
  padding: 0;
}

.embed-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px 22px;
}

.embed-head-right {
  align-items: center;
  display: flex;
  gap: 14px;
}

.embed-head h2 {
  font-size: 18px;
}

.embed-selector {
  margin: 0;
}

.embed-selector select {
  min-height: 42px;
}

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

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

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

.embed-card {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.embed-card:last-child {
  border-right: 0;
}

.embed-image-wrap {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 230px;
  padding: 22px;
}

.embed-image-wrap img {
  max-height: 185px;
  max-width: 100%;
  object-fit: contain;
}

.embed-image-wrap .image-fallback {
  min-height: 185px;
}

.embed-card-body {
  display: grid;
  gap: 10px;
  padding: 0 22px 22px;
}

.embed-card-body h3 {
  font-size: 22px;
  line-height: 1.25;
}

.embed-meta {
  color: var(--muted);
  display: flex;
  gap: 10px;
}

.embed-price-stack {
  display: grid;
  gap: 4px;
}

.embed-previous-price {
  color: var(--muted);
  font-size: 14px;
  text-decoration: line-through;
}

.side-panel h3 {
  font-size: 18px;
  margin: 26px 0 14px;
}

.status-stack,
.run-list {
  display: grid;
  gap: 14px;
}

.status-stack strong,
.run-item strong {
  display: block;
  margin-top: 4px;
}

.run-item {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.run-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.embed-builder {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.embed-builder label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.snippet-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px;
}

.snippet-box span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.snippet-box code {
  background: #f6f8fc;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
  padding: 10px;
}

.embed-preview-frame {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 560px;
  width: 100%;
}

.empty-state {
  color: var(--muted);
  padding: 18px 0;
}

.login-card {
  max-width: 460px;
  padding: 32px;
  width: 100%;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

@media (max-width: 1120px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .embed-grid,
  .embed-grid-2,
  .embed-grid-3 {
    grid-template-columns: 1fr;
  }

  .embed-card {
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }

  .embed-card:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 760px) {
  .page,
  .topbar {
    padding-left: 18px;
    padding-right: 18px;
  }

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

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

  .embed-head,
  .embed-head-right {
    align-items: stretch;
    flex-direction: column;
  }
}
