:root {
  --bg: #f4f2ee; --card: #ffffff; --ink: #1d1f22; --muted: #6b6f76; --line: #e3e0da;
  --accent: #0f8a5f; --accent-soft: #e2f4ec; --warn: #b4610b; --warn-soft: #fcefdc;
  --danger: #c0392b; --ebay: #0064d2; --vinted: #09797f;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416; --card: #1c1e21; --ink: #ecebe8; --muted: #9a9ea6; --line: #2c2f33;
    --accent: #3ccf91; --accent-soft: #163327; --warn: #f0a24b; --warn-soft: #3a2a17;
    --danger: #ff6b5b; --ebay: #5ea3ff; --vinted: #3fc3c9; --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 1.15rem; margin: 0; } h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
h4 { margin: 1rem 0 .4rem; font-size: .95rem; }
.wrap { max-width: 1150px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); } .grow { flex: 1; } .sep { width: 1px; height: 18px; background: var(--line); }

/* header */
.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; gap: 16px; height: 58px; }
.brand { font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; }
nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
nav a { color: var(--muted); padding: 7px 12px; border-radius: 9px; white-space: nowrap; font-weight: 500; }
nav a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
nav a.on { background: var(--accent-soft); color: var(--accent); }

/* status bar */
.statusbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 4px;
  color: var(--muted); font-size: .9rem; }
.statusbar b { color: var(--ink); font-weight: 600; }
.statusbar form { margin: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.dot.live { box-shadow: 0 0 0 4px var(--accent-soft); }
.dot.busy { background: var(--warn); animation: pulse 1s infinite alternate; }
.dot.paused { background: var(--muted); }
@keyframes pulse { to { opacity: .3; } }

main { padding-top: 14px; padding-bottom: 60px; }
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.flash.error { background: var(--warn-soft); color: var(--warn); }

/* bits */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.pill { font-size: .78rem; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); font-weight: 600; }
.pill.good { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 10px; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.small { padding: 6px 12px; font-size: .86rem; border-radius: 8px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.err { color: var(--warn); font-size: .86rem; }
.accent-text { color: var(--accent); }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--radius); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-head:first-child { margin-top: 6px; }

/* setup + stats */
.setup h2 { margin-bottom: 8px; }
.steps { margin: 0; padding-left: 22px; } .steps li { margin: 4px 0; } .steps span { color: var(--muted); font-size: .9rem; }
.steps li.done a { color: var(--muted); text-decoration: line-through; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.7rem; line-height: 1.1; } .stat span { color: var(--muted); font-size: .85rem; }
.stat.accent b { color: var(--accent); }

/* listing cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  color: var(--ink); display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .12s; }
.item:hover { text-decoration: none; transform: translateY(-2px); }
.item.bargain { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thumb { aspect-ratio: 1; background: var(--bg); position: relative; display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.plat { position: absolute; top: 8px; left: 8px; font-size: .72rem; font-weight: 700; color: #fff; padding: 2px 8px; border-radius: 99px; }
.plat.ebay { background: var(--ebay); } .plat.vinted { background: var(--vinted); }
.plat-text { font-weight: 700; font-size: .85rem; } .plat-text.ebay { color: var(--ebay); } .plat-text.vinted { color: var(--vinted); }
.item .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.price { font-weight: 800; font-size: 1.15rem; } .price small { font-weight: 500; font-size: .72rem; color: var(--muted); }
.title { font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.why { font-size: .8rem; color: var(--accent); font-weight: 600; }
.meta { font-size: .76rem; color: var(--muted); }

/* tables */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; } .table tr.off { opacity: .55; }

/* searches */
.search-list { display: grid; gap: 14px; }
.search.off { opacity: .6; }
.search-top { display: flex; justify-content: space-between; gap: 12px; }
.search-top form { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip { font-size: .8rem; background: var(--bg); padding: 3px 10px; border-radius: 99px; }
.chip.accent { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.plats { border-top: 1px solid var(--line); }
.platline { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.actions form { margin: 0; }
.actions.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.switch { width: 44px; height: 26px; border-radius: 99px; border: 0; background: var(--line); position: relative; cursor: pointer; flex-shrink: 0; }
.switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on { background: var(--accent); } .switch.on span { left: 21px; }

/* forms */
.form { display: grid; gap: 16px; }
.form .card { display: grid; gap: 12px; }
fieldset { border: 0; border-top: 1px solid var(--line); padding: 14px 0 0; margin: 0; display: grid; gap: 10px; }
legend { font-weight: 700; font-size: .95rem; padding-right: 8px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; } .field.narrow { max-width: 220px; }
.field > span { font-weight: 600; font-size: .88rem; } .field em { color: var(--danger); font-style: normal; }
.field small, .check small { color: var(--muted); font-size: .8rem; }
input:not([type=checkbox]), select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check.tiny { font-size: .8rem; color: var(--muted); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
details { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
details[open] > *:not(summary) { margin-top: 10px; }
summary { cursor: pointer; font-weight: 700; font-size: .95rem; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select { width: auto; }

@media (max-width: 640px) {
  .top-inner { height: auto; flex-wrap: wrap; padding: 10px 16px 6px; gap: 6px; }
  nav { margin-left: 0; width: 100%; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; } .stat { padding: 10px; } .stat b { font-size: 1.3rem; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .sep { display: none; }
}

/* login + logout */
nav .logout { margin: 0; }
nav .logout button { font: inherit; font-weight: 500; color: var(--muted); background: none; border: 0; padding: 7px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
nav .logout button:hover { background: var(--bg); color: var(--ink); }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-box { width: 100%; max-width: 380px; padding: 0; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 20px; }
.auth-brand h1 { font-size: 1.4rem; margin: 0; }
.logo.big { width: 42px; height: 42px; border-radius: 12px; font-size: 1.3rem; }
.btn.full { width: 100%; justify-content: center; padding: 11px; }

/* remove (hide) button on listing cards */
.item-wrap { position: relative; display: flex; }
.item-wrap > .item { flex: 1; }
.hide-form { position: absolute; top: 8px; right: 8px; margin: 0; z-index: 2; }
.hide-form button { width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer; font-size: 14px; line-height: 1;
  background: rgba(0,0,0,.55); color: #fff; opacity: .8; }
.hide-form button:hover { opacity: 1; background: var(--danger); }
