:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #646b75;
  --primary: #2f5bea;
  --primary-text: #ffffff;
  --ok: #157a3e;
  --ok-bg: #e5f5eb;
  --warn: #8a5a00;
  --warn-bg: #fdf3dc;
  --danger: #c0352b;
  --danger-bg: #fdecea;
  --idle: #5b626b;
  --idle-bg: #eceef1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #1a1d22;
    --surface-2: #22262c;
    --border: #2e333a;
    --text: #e8eaed;
    --muted: #9aa1ab;
    --primary: #6d8cff;
    --primary-text: #0d1020;
    --ok: #5fd08e;
    --ok-bg: #173324;
    --warn: #f0c060;
    --warn-bg: #3a2e12;
    --danger: #ff7b70;
    --danger-bg: #3b1d1b;
    --idle: #aab1ba;
    --idle-bg: #2a2e35;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.5rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.1rem; margin: 0; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.85em; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0.5rem 0 0; font-size: 0.9rem; }

/* ---------- Buttons & inputs ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn.block { width: 100%; justify-content: center; margin-top: 1rem; }

label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 0.3rem; }

input, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
input.invalid { border-color: var(--danger); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; }
.tabs { display: flex; gap: 0.25rem; flex: 1; }
.tab { padding: 0.35rem 0.75rem; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tab.active { background: var(--surface-2); color: var(--text); }

.container { max-width: 880px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.intro { margin-bottom: 1.25rem; }
.steps { margin: 0; padding-left: 1.2rem; color: var(--muted); }

.banner { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-weight: 500; word-break: break-word; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.error { background: var(--danger-bg); color: var(--danger); }

/* ---------- Cards ---------- */
.cards { display: grid; gap: 1rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem 0.5rem; }
.card-title { display: flex; align-items: center; gap: 0.75rem; }
.logo {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; color: #fff; flex-shrink: 0;
}
.logo.ETSY { background: #f1641e; }
.logo.SHOPIFY { background: #5e8e3e; }
.logo.EBAY { background: #0064d2; }
.sub { margin: 0; color: var(--muted); font-size: 0.85rem; }

.badge { font-size: 0.8rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.idle { background: var(--idle-bg); color: var(--idle); }

.card-body { padding: 0 1.25rem 1rem; }
.status-line { color: var(--muted); font-size: 0.875rem; margin: 0 0 0.75rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.result { margin-top: 0.75rem; padding: 0.6rem 0.8rem; border-radius: 8px; font-size: 0.9rem; word-break: break-word; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.error { background: var(--danger-bg); color: var(--danger); }

.section { border-top: 1px solid var(--border); padding: 1rem 1.25rem; }
.section > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.section > summary::-webkit-details-marker { display: none; }
.section > summary::after { content: "Show"; color: var(--primary); font-weight: 500; font-size: 0.9rem; }
.section[open] > summary::after { content: "Hide"; }
.section h3 { font-size: 0.95rem; margin: 0 0 0.75rem; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1rem; margin-top: 1rem; }
.field.wide { grid-column: 1 / -1; }
.field[hidden] { display: none; }
.help { color: var(--muted); font-size: 0.8rem; margin: 0.25rem 0 0; }
.input-row { display: flex; gap: 0.4rem; }
.input-row input { flex: 1; min-width: 0; }
.form-foot { display: flex; justify-content: flex-end; margin-top: 1rem; }

.urls { display: grid; gap: 0.75rem; }
.url-item .help { margin: 0 0 0.3rem; }
.copy { display: flex; align-items: center; gap: 0.5rem; background: var(--surface-2); border-radius: 8px; padding: 0.4rem 0.4rem 0.4rem 0.75rem; }
.copy code { flex: 1; overflow-x: auto; white-space: nowrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 0.6rem 1rem; border-radius: 8px; font-weight: 500;
  max-width: calc(100vw - 32px); z-index: 10;
}

@media (max-width: 640px) {
  .fields { grid-template-columns: 1fr; }
  .topbar { gap: 0.75rem; }
  .card-head { flex-wrap: wrap; }
}
