/* Toploader embedded admin UI.
   Deliberately plain CSS, not Polaris — it renders inside Shopify admin, so it
   borrows admin's neutral palette and stays out of the way. */

:root {
  --bg: #f6f6f7;
  --panel: #fff;
  --ink: #202223;
  --muted: #6d7175;
  --line: #e1e3e5;
  --accent: #2c6ecb;
  --ok: #007f5f;
  --warn: #b98900;
  --warn-bg: #fff8e6;
  --danger: #d72c0d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 1px 6px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Chrome ─────────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 650; letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 550;
}
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.is-active { background: var(--ink); color: #fff; }
.quota { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.quota.is-low { color: var(--warn); font-weight: 600; }

main { padding: 20px 16px 64px; max-width: 1100px; margin: 0 auto; }
.view { display: none; }
.view.is-active { display: block; }

.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; font-size: 13px; border-bottom: 1px solid var(--line);
}
.banner--warn { background: var(--warn-bg); color: #6b4d00; }

/* ── Controls ───────────────────────────────────────────────────────── */

.btn {
  border: 1px solid transparent; background: var(--ink); color: #fff;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font: inherit; font-weight: 550; white-space: nowrap;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--small { padding: 4px 10px; font-size: 12px; }

input, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.searchbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.searchbar input { flex: 1 1 260px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg__btn { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font: inherit; color: var(--muted); }
.seg__btn.is-active { background: var(--ink); color: #fff; }

.searchopts {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 10px;
}
.searchopts label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.searchopts .hint { margin: 0; }
.more { text-align: center; margin-top: 16px; }

.hint { color: var(--muted); font-size: 13px; margin: 10px 0; }
.hint code {
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 5px; font-size: 12px;
}
.hint--muted { font-size: 12px; }
.rowhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
h2 { font-size: 15px; margin: 0 0 4px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0 14px; }
.checks label { display: flex; align-items: center; gap: 6px; }

.status { font-size: 13px; margin-top: 8px; min-height: 1.2em; }
.status.is-ok { color: var(--ok); }
.status.is-error { color: var(--danger); }

.empty { color: var(--muted); text-align: center; padding: 48px 16px; }

/* ── Search results ─────────────────────────────────────────────────── */

.results {
  display: grid; gap: 12px; margin-top: 16px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.result {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  font: inherit; color: inherit; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.result:hover { border-color: var(--accent); }
.result__img {
  aspect-ratio: 5 / 7; background: var(--bg) center/contain no-repeat;
  display: block; width: 100%;
}
.result__img--sealed { aspect-ratio: 4 / 3; }
.result__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.result__name { font-weight: 600; line-height: 1.3; }
.result__meta { color: var(--muted); font-size: 12px; }
.result__price { margin-top: auto; padding-top: 8px; font-weight: 650; font-variant-numeric: tabular-nums; }
.result__price small { color: var(--muted); font-weight: 400; }
.result__grade {
  align-self: flex-start; margin-top: 4px; font-size: 11px; font-weight: 650;
  padding: 1px 7px; border-radius: 999px; background: #1a1a1a; color: #fff;
}

/* ── Stock list ─────────────────────────────────────────────────────── */

.stockrow {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 8px;
}
.stockrow__img { width: 48px; height: 64px; object-fit: contain; background: var(--bg); border-radius: 4px; }
.stockrow__title { font-weight: 600; }
.stockrow__meta { color: var(--muted); font-size: 12px; }
.stockrow__vars { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pill {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.pill--zero { opacity: .5; }

/* ── Dialog ─────────────────────────────────────────────────────────── */

dialog {
  border: 0; border-radius: 14px; padding: 0; max-width: 560px; width: calc(100% - 32px);
  box-shadow: 0 12px 40px rgba(0,0,0,.24);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
.dialog__inner { padding: 20px; margin: 0; }
.dialog__head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.dialog__head img { width: 64px; border-radius: 6px; }
.dialog__head h3 { margin: 0; font-size: 15px; }
.dialog__head .hint { margin: 2px 0 0; }
.dialog__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.dialog__actions { display: flex; gap: 8px; }

.line {
  display: grid; grid-template-columns: 64px 1fr 1fr 1fr; gap: 8px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.line__cond { font-weight: 600; }
.line__market { color: var(--muted); font-size: 11px; font-weight: 400; display: block; }
.line input { width: 100%; }
.line__labels { display: grid; grid-template-columns: 64px 1fr 1fr 1fr; gap: 8px; font-size: 11px; color: var(--muted); }
.line__section {
  margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--ink);
  font-weight: 650; font-size: 13px;
}
.line__section small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.line__more { margin-top: 10px; width: 100%; }
.line__note { font-size: 11px; color: var(--warn); margin-top: 8px; }

#add-lines { max-height: 52vh; overflow-y: auto; }

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; }
  .quota { width: 100%; margin-left: 0; }
  .line, .line__labels { grid-template-columns: 52px 1fr 1fr; }
  .line__cost { display: none; }
}
