:root {
  --bg: #f6f6f4; --surface: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --border: #e3e2de;
  --accent: #e8590c; --accent-text: #ffffff; --accent-soft: #fff1e8;
  --ok: #1f7a4d; --ok-soft: #e6f4ec; --warn: #9a6700; --warn-soft: #fff6dc;
  --bad: #b42318; --bad-soft: #fdecea; --info: #175cd3; --info-soft: #e8f0fe;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1d1b; --text: #ecebe7; --muted: #a3a29c; --border: #34332f;
    --accent: #ff7a33; --accent-text: #1a0d05; --accent-soft: #3a2113;
    --ok: #5cc98f; --ok-soft: #15301f; --warn: #e5b94a; --warn-soft: #33290f;
    --bad: #f47a6e; --bad-soft: #3b1714; --info: #7fa9f5; --info-soft: #162442;
    --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", sans-serif; }
a { color: var(--accent); }
img { max-width: 100%; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .inner { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.nav a:hover, .nav a.active { color: var(--text); background: var(--bg); }
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .9rem; }
main { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
footer { text-align: center; padding: 24px 16px; color: var(--muted); font-size: .85rem; }

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 8px; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.link { border: 0; background: none; color: var(--muted); padding: 0; }
.inline { display: inline; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 14px 0 6px; }
input[type=text], input[type=number], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
textarea { min-height: 160px; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
input:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.notice { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--bad-soft); color: var(--bad); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge.SYNCED { background: var(--ok-soft); color: var(--ok); }
.badge.QUEUED, .badge.SYNCING { background: var(--info-soft); color: var(--info); }
.badge.FAILED { background: var(--bad-soft); color: var(--bad); }
.badge.plan { background: var(--accent-soft); color: var(--accent); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { text-decoration: none; color: var(--muted); padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: .88rem; }
.tabs a.active { color: var(--text); border-color: var(--text); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--bg); display: block; }
.title-cell a { color: var(--text); text-decoration: none; font-weight: 500; }
.title-cell a:hover { text-decoration: underline; }
.error-text { color: var(--bad); font-size: .82rem; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } .account .domain { display: none; } }

.price-input { width: 110px !important; text-align: right; }
.plan-card .price { font-size: 1.8rem; font-weight: 700; margin: 8px 0; }
.plan-card.current { border-color: var(--accent); }
.token { font-family: ui-monospace, Menlo, monospace; background: var(--bg); border: 1px dashed var(--border); padding: 10px; border-radius: 8px; word-break: break-all; }

/* landing */
.hero { max-width: 560px; margin: 64px auto; text-align: center; }
.hero h1 { font-size: 2.1rem; }
.hero p { color: var(--muted); font-size: 1.05rem; }
.hero form { display: flex; gap: 8px; margin-top: 24px; }
.hero form input { flex: 1; }
.features { max-width: 860px; margin: 0 auto; }
.legal { max-width: 760px; }
.legal h2 { margin-top: 1.5rem; }

/* utilities (no inline styles: the CSP forbids them) */
.mt { margin-top: 16px; } .mt-0 { margin-top: 0; } .mb { margin-bottom: 16px; }
.center { justify-content: center; } .between { justify-content: space-between; }
progress.meter { display: block; width: 100%; height: 6px; border: 0; border-radius: 999px; overflow: hidden; appearance: none; background: var(--bg); }
progress.meter::-webkit-progress-bar { background: var(--bg); }
progress.meter::-webkit-progress-value { background: var(--accent); }
progress.meter::-moz-progress-bar { background: var(--accent); }

.desc-preview { width: 100%; min-height: 180px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
details summary { cursor: pointer; margin: 8px 0; }

/* ---- products list ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.stat:hover { border-color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-bad .stat-value { color: var(--bad); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 220px; width: auto; }
.toolbar select { width: auto; flex: 0 1 220px; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.bulkbar #selected-count { margin-right: auto; }
.meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); }
.meta a { color: var(--muted); }
.meta a:hover { color: var(--accent); }
table.products .title-cell { max-width: 520px; }
table.products .title-cell > a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
tbody tr:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); }

/* ---- product page ---- */
.crumbs { margin-bottom: 8px; } .crumbs a { color: var(--muted); }
.head-title { min-width: 0; flex: 1 1 480px; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.actions { flex-wrap: wrap; }
.overview { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; margin-bottom: 8px; }
@media (max-width: 860px) { .overview { grid-template-columns: 1fr; } }
.side { display: flex; flex-direction: column; gap: 16px; }
.media .hero { display: block; }
.media .hero img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--border); }
.thumbs { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding-bottom: 4px; }
.thumbs button { all: unset; cursor: pointer; flex: 0 0 64px; height: 64px; border-radius: 6px; border: 2px solid transparent; overflow: hidden; }
.thumbs button.active, .thumbs button:hover { border-color: var(--accent); }
.thumbs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.facts dl { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: .8rem; }
.facts dd { margin: 2px 0 0; font-weight: 600; }
.links { margin-top: 14px; gap: 16px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); background: var(--bg); }
.seller-name { font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.chip { font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.docs { margin: 0; padding-left: 18px; }
.docs li { margin: 4px 0; }
.warn-text { color: var(--warn); font-weight: 600; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; justify-content: flex-end; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-top: 16px; box-shadow: 0 -4px 12px rgba(0,0,0,.08); }
.savebar #dirty-note { margin-right: auto; }
.savebar.dirty #dirty-note { color: var(--warn); font-weight: 600; }

/* ---- layout fixes from review ---- */
.overview > *, .two-col > * { min-width: 0; }
@media (max-width: 860px) { .overview { grid-template-columns: minmax(0, 1fr); } }
.media .hero img { max-height: 460px; }
.thumb { flex: none; min-width: 48px; }
table.products td:nth-child(2) { width: 60px; }
table.products .error-text { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- alerts, AI, push options ---- */
.badge.warn, .badge.PRICE_UP, .badge.OUT_OF_STOCK, .badge.VARIANT_REMOVED { background: var(--warn-soft); color: var(--warn); }
.badge.PRICE_DOWN, .badge.BACK_IN_STOCK, .badge.VARIANT_ADDED { background: var(--ok-soft); color: var(--ok); }
.stat-warn .stat-value { color: var(--warn); }
.changes { margin-bottom: 20px; border-color: var(--warn); }
.change-list { list-style: none; margin: 8px 0; padding: 0; }
.change-list li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--border); opacity: .6; }
.change-list li.open { opacity: 1; }
.change-list li:last-child { border-bottom: 0; }
.suggestion { border-color: var(--accent); margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.span-2 { grid-column: 1 / -1; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
label.check input { margin-top: 3px; }
#ai h2 { margin-bottom: 12px; }
