:root {
  --bg: #f7fbfa;
  --panel: rgba(255, 255, 255, 0.88);
  --ink: #192333;
  --muted: #6b788c;
  --line: #dfe9ee;
  --mint: #42d6b5;
  --mint-dark: #0f9f82;
  --blue: #4b7dff;
  --blue-soft: #edf3ff;
  --peach: #ffb08a;
  --peach-soft: #fff2eb;
  --lilac: #a989ff;
  --lilac-soft: #f4f0ff;
  --green: #19b37a;
  --red: #ef4e69;
  --amber: #d98a10;
  --surface: #f1f7f6;
  --shadow: 0 18px 48px rgba(45, 64, 89, 0.10);
  --shadow-soft: 0 10px 28px rgba(45, 64, 89, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(66, 214, 181, 0.24), transparent 28%),
    radial-gradient(circle at 92% 2%, rgba(255, 176, 138, 0.26), transparent 24%),
    linear-gradient(180deg, #f9fcfb 0%, #eef8f6 48%, #f7fbfa 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

h1 {
  margin-bottom: 0;
  color: #172033;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: 0;
}

a {
  color: var(--blue);
  text-decoration: none;
}

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

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 20% 20%, rgba(66, 214, 181, 0.28), transparent 30%),
    radial-gradient(circle at 80% 15%, rgba(169, 137, 255, 0.22), transparent 28%),
    radial-gradient(circle at 70% 80%, rgba(255, 176, 138, 0.25), transparent 30%),
    #f8fcfb;
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: min(520px, 100%);
  padding: 34px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(223, 233, 238, 0.9);
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(45, 64, 89, 0.16);
  backdrop-filter: blur(18px);
}

.auth-card h1 {
  font-size: 28px;
}

.auth-brand {
  margin-bottom: 24px;
}

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

.app-shell {
  min-height: 100vh;
}

.app-shell.locked {
  filter: blur(2px);
  pointer-events: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(520px, 1.8fr) minmax(170px, auto);
  gap: 18px;
  align-items: center;
  padding: 18px 34px;
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid rgba(223, 233, 238, 0.86);
  backdrop-filter: blur(18px);
}

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

.brand-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: #ffffff;
  font-size: 18px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--mint), var(--blue));
  border-radius: 8px;
  box-shadow: 0 14px 26px rgba(66, 214, 181, 0.24);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  color: #172033;
  font-size: 17px;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  padding: 7px;
  overflow-x: auto;
  background: rgba(241, 247, 246, 0.82);
  border: 1px solid rgba(223, 233, 238, 0.9);
  border-radius: 8px;
}

.nav-item {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 13px;
  color: #546177;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 8px;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nav-item:hover {
  color: #172033;
  background: #ffffff;
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue), var(--lilac));
  box-shadow: 0 10px 20px rgba(75, 125, 255, 0.18);
}

.credit-card {
  min-width: 166px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #ffffff, var(--peach-soft));
  border: 1px solid rgba(255, 176, 138, 0.36);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.credit-card span,
.credit-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.credit-card strong {
  display: block;
  margin: 2px 0;
  color: #172033;
  font-size: 28px;
  letter-spacing: 0;
}

.main {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 24px 34px 44px;
}

.topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  min-height: 104px;
  margin-bottom: 18px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(237, 243, 255, 0.9)),
    var(--panel);
  border: 1px solid rgba(223, 233, 238, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint-dark);
  font-size: 13px;
  font-weight: 800;
}

.user-pill {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.user-pill span,
.badge,
.site-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  color: #48566d;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(223, 233, 238, 0.95);
  border-radius: 8px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric-card,
.panel,
.store-card {
  background: var(--panel);
  border: 1px solid rgba(223, 233, 238, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.metric-card {
  position: relative;
  min-height: 128px;
  padding: 20px;
  overflow: hidden;
}

.metric-card::after {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 42px;
  height: 42px;
  content: "";
  background: linear-gradient(135deg, rgba(66, 214, 181, 0.22), rgba(169, 137, 255, 0.16));
  border-radius: 8px;
}

.metric-card span,
.metric-card em,
.panel-title span {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 14px 0 8px;
  color: #172033;
  font-size: 36px;
  letter-spacing: 0;
}

.metric-card em {
  font-style: normal;
}

.metric-grid.small .metric-card {
  min-height: 110px;
  padding: 16px;
}

.metric-grid.small .metric-card strong {
  font-size: 30px;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(223, 233, 238, 0.78);
}

.timeline,
.oauth-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.timeline-step,
.oauth-step {
  min-height: 54px;
  padding: 14px 12px;
  color: #56657c;
  text-align: center;
  background: var(--surface);
  border: 1px solid rgba(223, 233, 238, 0.92);
  border-radius: 8px;
}

.timeline-step.done,
.oauth-step.done {
  color: #08735f;
  background: #e9fbf5;
  border-color: #b9f1dd;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar input {
  width: min(420px, 100%);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: #172033;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  box-shadow: 0 1px 0 rgba(25, 35, 51, 0.02);
}

textarea {
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #8db1ff;
  box-shadow: 0 0 0 3px rgba(75, 125, 255, 0.13);
}

input[type="checkbox"] {
  width: 17px;
  min-height: auto;
  height: 17px;
  accent-color: var(--blue);
}

button,
.actions button,
.toolbar button,
.store-card button,
.user-pill button {
  min-height: 38px;
  padding: 9px 14px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--blue), var(--lilac));
  border: 1px solid transparent;
  border-radius: 8px;
  box-shadow: 0 10px 20px rgba(75, 125, 255, 0.16);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(75, 125, 255, 0.20);
}

#registerBtn,
#logoutBtn,
#resetStrategyBtn,
#clearUsedUpcBtn,
.actions button,
.store-card .actions button:not(:first-child) {
  color: #43536b;
  background: #ffffff;
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}

.table-wrap {
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid rgba(223, 233, 238, 0.92);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #eef3f6;
}

th {
  color: #65748a;
  font-size: 13px;
  background: #f8fbfb;
}

tbody tr {
  transition: background 0.14s ease;
}

tbody tr:hover {
  background: #fbfefd;
}

.product-cell {
  display: flex;
  min-width: 360px;
  gap: 14px;
}

.product-cell img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid #e4edf2;
  border-radius: 8px;
}

.product-cell strong {
  display: block;
  max-width: 440px;
  color: #172033;
  line-height: 1.35;
}

.product-cell a {
  display: inline-block;
  margin-top: 6px;
}

.meta-line {
  margin-top: 6px;
  color: #08735f;
  font-size: 12px;
  font-weight: 800;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 64px);
  gap: 6px;
  margin-bottom: 8px;
}

.mini-grid input {
  padding: 7px;
}

.actions {
  display: grid;
  min-width: 150px;
  gap: 8px;
  align-content: start;
}

.actions button.danger {
  color: var(--red);
  background: #fff3f5;
  border-color: #ffd0d8;
}

.workflow-list {
  display: block;
}

.workflow-table th,
.workflow-table td {
  vertical-align: top;
}

.site-results {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.site-result {
  display: inline-flex;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.site-result.ok {
  color: #08735f;
  background: #e9fbf5;
  border-color: #b9f1dd;
}

.site-result.fail {
  color: #a62a3b;
  background: #fff0f3;
  border-color: #ffd0d8;
}

.failure-line {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: #fff8ef;
  border: 1px solid #ffe0bc;
  border-radius: 8px;
}

.failure-line em {
  color: var(--muted);
  font-style: normal;
}

.progress {
  height: 9px;
  overflow: hidden;
  background: #e7eef3;
  border-radius: 8px;
}

.progress div {
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--blue));
}

.store-card {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, auto) 220px;
  gap: 18px;
  align-items: center;
  padding: 20px;
}

.site-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.site-tags span {
  color: #08735f;
  background: #e9fbf5;
  border-color: #b9f1dd;
}

.form-grid,
.detail-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin: 18px 0;
}

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

.form-grid label,
.detail-form label,
.wide {
  color: #46566d;
  font-weight: 800;
}

.form-grid input,
.form-grid select,
.detail-form input,
.detail-form textarea {
  margin-top: 7px;
}

.wide,
.detail-form .wide {
  grid-column: 1 / -1;
}

.install-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-top: 16px;
  background: #f8fbfb;
  border: 1px solid rgba(223, 233, 238, 0.92);
  border-radius: 8px;
}

code {
  display: block;
  padding: 14px;
  overflow-x: auto;
  color: #172033;
  background: #eff6f5;
  border: 1px solid rgba(223, 233, 238, 0.92);
  border-radius: 8px;
}

.site-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-option:has(input:checked) {
  background: var(--blue-soft);
  border-color: #a9c1ff;
}

.check-option input {
  margin: 0;
}

.check-option span {
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.check-option small {
  color: var(--muted);
}

.payload-preview {
  max-height: 360px;
  padding: 14px;
  overflow: auto;
  color: #dce8ff;
  white-space: pre-wrap;
  background: #172033;
  border: 1px solid #26364c;
  border-radius: 8px;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  justify-content: flex-end;
  background: rgba(25, 35, 51, 0.38);
  backdrop-filter: blur(4px);
}

.drawer.open {
  display: flex;
}

.drawer-panel {
  width: min(720px, 100vw);
  height: 100%;
  padding: 26px;
  overflow-y: auto;
  background: #ffffff;
  box-shadow: -18px 0 60px rgba(45, 64, 89, 0.16);
}

.icon-button {
  float: right;
  width: 36px;
  height: 36px;
  color: #65748a;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.detail-image {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #f8fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.image-strip img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f8fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.data-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.data-chip {
  max-width: 100%;
  padding: 7px 10px;
  color: #416051;
  background: #ecfbf5;
  border: 1px solid #c9f0df;
  border-radius: 8px;
  font-size: 12px;
}

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

.attribute-grid div {
  min-width: 0;
  padding: 10px;
  background: #f8fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.attribute-grid strong,
.attribute-grid span {
  display: block;
  overflow-wrap: anywhere;
}

.attribute-grid strong {
  color: #546177;
  font-size: 12px;
}

.attribute-grid span {
  margin-top: 4px;
}

.real-publish {
  display: grid;
  gap: 18px;
}

.warning-text,
.category-notice,
.failure-panel,
.publish-result {
  padding: 13px 14px;
  border-radius: 8px;
}

.warning-text {
  color: #8a4b05;
  background: #fff8ef;
  border: 1px solid #ffe0bc;
}

.category-notice {
  color: #075985;
  background: #eff9ff;
  border: 1px solid #c8edff;
  font-weight: 800;
}

.failure-panel {
  display: grid;
  gap: 10px;
  color: #48566d;
  background: #fff8ef;
  border: 1px solid #ffe0bc;
}

.failure-panel h3 {
  margin: 0;
  color: #8a4b05;
}

.failure-table {
  width: 100%;
  overflow: hidden;
  background: white;
  border: 1px solid #ffe0bc;
  border-radius: 8px;
}

.failure-table th,
.failure-table td {
  padding: 10px;
  overflow-wrap: anywhere;
  border-bottom: 1px solid #fff0dd;
}

.failure-table th {
  color: #8a4b05;
  background: #fff3df;
}

.publish-result {
  color: #08735f;
  background: #e9fbf5;
  border: 1px solid #b9f1dd;
}

.publish-result a {
  color: #08735f;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  display: none;
  max-width: 380px;
  padding: 14px 16px;
  color: white;
  background: #172033;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(45, 64, 89, 0.22);
}

.toast.show {
  display: block;
}

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .credit-card {
    width: 100%;
  }
}

@media (max-width: 1040px) {
  .metric-grid,
  .timeline,
  .oauth-flow,
  .site-picker,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 680px) {
  .app-header,
  .main {
    padding-right: 14px;
    padding-left: 14px;
  }

  .topbar,
  .panel-title {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .timeline,
  .oauth-flow,
  .site-picker,
  .form-grid,
  .detail-form,
  .attribute-grid {
    grid-template-columns: 1fr;
  }

  .product-cell {
    min-width: 280px;
  }

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