:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f0f4f8;
  --text: #14171a;
  --muted: #64707d;
  --line: #dce2e8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --blue: #2563eb;
  --orange: #c05621;
  --danger: #b42318;
  --ok: #157f3b;
  --shadow: 0 12px 36px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

input {
  cursor: text;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 20px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.status {
  min-width: 168px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(128px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

input,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

input,
select {
  width: 100%;
  padding: 0 12px;
}

button {
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 800;
}

button:hover {
  background: var(--accent-strong);
}

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

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric strong {
  display: block;
  margin-bottom: 4px;
  font-size: 24px;
}

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

.store-tabs {
  margin: 0 0 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.store-tab-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.store-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  min-height: 66px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
}

.store-tab:hover,
.store-tab.active {
  border-color: var(--accent);
  background: #e8f3f1;
}

.store-tab strong {
  font-size: 14px;
}

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

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

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

.grid.flat {
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}

.store-group {
  display: grid;
  gap: 12px;
}

.store-group + .store-group {
  margin-top: 10px;
}

.store-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.store-group-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.store-group-head p {
  color: var(--muted);
  font-size: 13px;
}

.store-group-action {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--accent);
}

.store-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.product {
  display: grid;
  grid-template-rows: 150px 1fr;
  min-height: 390px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.product-media {
  position: relative;
  background: var(--surface-soft);
}

.product-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-media .placeholder {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.source-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  max-width: calc(100% - 20px);
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.product-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.product-title {
  min-height: 46px;
  font-size: 16px;
  line-height: 1.42;
}

.summary {
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.price-row,
.stock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.category {
  color: var(--muted);
  font-size: 12px;
}

.stock {
  color: var(--ok);
  font-weight: 800;
}

.stock.out {
  color: var(--danger);
}

.sold {
  color: var(--muted);
  font-size: 12px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
}

.tag {
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 7px;
  background: #e8f3f1;
  color: #0f5d56;
  font-size: 12px;
  font-weight: 700;
}

.tag.risk {
  background: #fff3e8;
  color: var(--orange);
}

.product-actions {
  margin-top: auto;
}

.product-actions a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  background: var(--text);
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}

.product-actions a:hover {
  background: #2f3740;
}

.insights {
  position: sticky;
  top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.compare-item {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.compare-item:first-child {
  border-top: 0;
}

.compare-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 900;
}

.compare-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 5px 0;
  color: var(--muted);
  font-size: 13px;
}

.compare-line a {
  overflow: hidden;
  color: var(--blue);
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.empty {
  padding: 42px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1040px) {
  .toolbar,
  .layout,
  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .search {
    grid-column: 1 / -1;
  }

  .layout > section,
  .insights {
    grid-column: 1 / -1;
  }

  .insights {
    position: static;
  }
}

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

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

  .store-group-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .store-group-action {
    width: 100%;
  }
}
