:root {
  color-scheme: dark;
  --bg: #101112;
  --panel: #181a1d;
  --panel-soft: #22252a;
  --ink: #f2f2ee;
  --muted: #a9a59b;
  --line: #31343a;
  --accent: #5aa7ff;
  --accent-ink: #ffffff;
  --good: #7fd79b;
  --warn: #f1be68;
  --danger: #ff8a7d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

button:disabled { cursor: not-allowed; opacity: 0.45; }

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 22px clamp(18px, 4vw, 42px);
}

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

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.65rem, 3vw, 2.4rem);
  line-height: 1.05;
  margin: 0;
}

main {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px clamp(14px, 3vw, 34px) 42px;
}

.icon-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.icon-button svg {
  fill: none;
  height: 21px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 21px;
}

.text-button {
  border-radius: 8px;
  padding: 9px 14px;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  border-radius: 8px;
  color: var(--accent-ink);
  font-weight: 700;
  padding: 9px 14px;
}

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

.summary > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.summary-label {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.summary strong { font-size: 1.35rem; }

.status {
  color: var(--muted);
  margin: 12px 0 16px;
  min-height: 24px;
}

.status.error { color: var(--danger); }

.groups {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.group-header {
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 0 10px;
  padding-bottom: 6px;
}

.group-header h2 {
  font-size: 1.1rem;
  margin: 0;
}

.group-status {
  color: var(--muted);
  font-size: 0.82rem;
}

.group-status.loading { color: var(--warn); }
.group-status.error { color: var(--danger); }

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

.item {
  align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 84px minmax(0, 1fr);
  padding: 12px;
}

.item-image {
  align-items: center;
  background: var(--panel-soft);
  border-radius: 6px;
  display: flex;
  justify-content: center;
  min-height: 84px;
  overflow: hidden;
}

.item-image img {
  display: block;
  height: 100%;
  max-height: 96px;
  max-width: 100%;
  object-fit: contain;
}

.item-main { min-width: 0; }

.item-title h3 {
  font-size: 0.96rem;
  line-height: 1.25;
  margin: 0 0 4px;
}

.item-title h3 a {
  color: inherit;
  text-decoration: none;
}

.item-title h3 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.item-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.82rem;
  gap: 6px 12px;
  margin-bottom: 8px;
}

.skus {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.sku-row {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  padding: 6px 10px;
  font-size: 0.84rem;
}

.sku-cond { color: var(--muted); }

.sku-qty { color: var(--ink); }

.sku-price { font-weight: 700; }
.sku-market { color: var(--muted); }

.sku-row.undercut { border-color: #8e3730; }
.sku-row.undercut .sku-price { color: var(--danger); }

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

.sku-actions { display: inline-flex; gap: 6px; }

.sku-actions button {
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 8px;
}

.sku-actions .match { background: #1c3a5a; border-color: #2a5b88; color: #b9dcff; }
.sku-actions .beat { background: #4a2024; border-color: #8e3730; color: #ffb7af; }
.sku-actions .match:hover:not(:disabled) { background: #234c75; }
.sku-actions .beat:hover:not(:disabled) { background: #5e2930; }

.sku-row.staged {
  border-color: var(--accent);
  background: #142233;
}

.sku-row.staged .sku-price { color: var(--accent); }

.staged-from {
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: line-through;
  margin-right: 6px;
}

.staging-bar {
  align-items: center;
  background: var(--panel);
  border-top: 1px solid var(--line);
  bottom: 0;
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.4);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  left: 0;
  padding: 14px clamp(18px, 4vw, 42px);
  position: sticky;
  right: 0;
  z-index: 5;
}

.staging-bar[hidden] { display: none; }

.staging-actions { display: inline-flex; gap: 10px; }

.no-pricing {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

.auth-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  max-width: 560px;
  padding: 22px;
  width: calc(100% - 32px);
}

.auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.auth-dialog h2 { margin: 0 0 8px; }

.auth-dialog .muted {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 12px;
}

.auth-dialog code {
  background: var(--panel-soft);
  border-radius: 4px;
  padding: 1px 5px;
}

.auth-dialog textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  padding: 10px;
  resize: vertical;
  width: 100%;
}

.auth-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

@media (max-width: 720px) {
  .summary { grid-template-columns: 1fr; }
  .sku-row { grid-template-columns: minmax(0, 1fr) auto; }
}
