:root {
  --green: #1f7a4d;
  --green-dark: #155c39;
  --bg: #f4f5f3;
  --card: #ffffff;
  --line: #e2e5e0;
  --text: #1c2120;
  --muted: #6b7470;
  --danger: #b3261e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.grow { flex: 1; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--green); color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.brand { font-weight: 700; font-size: 1.15rem; }
.badge { width: 11px; height: 11px; border-radius: 50%; background: #ccc; }
.badge.ok { background: #8ff0b0; }
.badge.off { background: #ffd27d; }

button {
  font: inherit; cursor: pointer; border: none; border-radius: 8px;
  padding: 8px 14px; background: #e8eae6; color: var(--text);
}
button.primary { background: var(--green); color: #fff; }
button.primary:hover { background: var(--green-dark); }
button.big { width: 100%; padding: 12px; font-size: 1rem; margin: 6px 0 4px; }
button.ghost { background: transparent; color: inherit; }
button.danger { color: var(--danger); }
select, input, textarea {
  font: inherit; padding: 8px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--text); width: 100%;
}
.topbar select { width: auto; color: var(--text); }
.topbar .search { width: auto; min-width: 200px; max-width: 320px; color: var(--text); }
@media (max-width: 600px) { .topbar .search { min-width: 120px; flex: 1; } }

/* Login page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 26px;
  width: min(360px, 100%); display: grid; gap: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.08);
}
.login-brand { font-size: 1.3rem; font-weight: 700; text-align: center; color: var(--green-dark); }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: .84rem; color: var(--muted); }
.login-error { color: var(--danger); font-size: .85rem; min-height: 18px; text-align: center; }
.whoami { font-size: .82rem; opacity: .9; }

.grid {
  display: grid; gap: 12px; padding: 16px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; cursor: pointer; transition: transform .08s, box-shadow .08s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.10); }
.card .thumb {
  aspect-ratio: 1; background: #eef0ec center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
  font-size: 2rem;
}
.card .meta { padding: 8px 10px; }
.card .title { font-size: .9rem; font-weight: 600; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px; font-size: .8rem; color: var(--muted); }
.card .sub.loc { font-size: .72rem; color: var(--green-dark); }
.price { font-weight: 700; color: var(--green-dark); }
.pill { font-size: .68rem; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.pill.draft { background: #eceff0; color: #555; }
.pill.listed { background: #d9eefe; color: #1c5e93; }
.pill.sold { background: #d7f5df; color: #1c7a3f; }
.pill.archived { background: #efe7d7; color: #7a5a1c; }

/* Overlay sheet */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; justify-content: center; align-items: flex-start; z-index: 10; overflow: auto;
}
.sheet {
  background: var(--bg); width: min(900px, 100%); min-height: 100%;
  display: flex; flex-direction: column;
}
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); z-index: 2; }
.sku { font-weight: 700; color: var(--green-dark); }
.sheet-body { padding: 16px; display: grid; gap: 18px; }
@media (min-width: 760px) {
  .sheet-body { grid-template-columns: 1fr 1fr; }
  .packets { grid-column: 1 / -1; }
}

.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-strip .ph { position: relative; width: 96px; height: 96px; border-radius: 8px;
  background: #ddd center/cover no-repeat; border: 1px solid var(--line); }
.photo-strip .ph button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: 50%; padding: 0; background: #fff; border: 1px solid var(--line); line-height: 1; }
.uploader { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  padding: 10px 14px; border: 1.5px dashed var(--green); border-radius: 10px;
  color: var(--green-dark); cursor: pointer; width: fit-content; }

.fields { display: grid; gap: 10px; }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); }
.fields label input, .fields label textarea, .fields label select { color: var(--text); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 110px; }
.hint { font-size: .8rem; color: var(--muted); line-height: 1.4; margin: -2px 0 2px; }
.gen-status { font-size: .85rem; min-height: 18px; color: var(--muted); }
.gen-status.error { color: var(--danger); }
.gen-status.busy { color: var(--green-dark); }

.step-buttons { display: flex; gap: 8px; margin: 6px 0 4px; }
.step-buttons .big { margin: 0; }
#identifyBtn { background: #e4efe9; color: var(--green-dark); }
#identifyBtn:hover { background: #d4e7dd; }

.id-summary {
  background: #eef6f1; border: 1px solid #cfe6da; border-radius: 10px;
  padding: 10px 12px; font-size: .86rem; line-height: 1.4; display: grid; gap: 6px;
}
.id-head { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.id-sub { color: var(--muted); font-size: .82rem; }
.conf { font-size: .68rem; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.conf.high { background: #d7f5df; color: #1c7a3f; }
.conf.medium { background: #fdeccb; color: #8a5a12; }
.conf.low { background: #fbdcd9; color: #9a2820; }

.pricing-box {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  display: grid; gap: 10px;
}
.pricing-row { display: flex; gap: 8px; text-align: center; }
.pricing-row span { flex: 1; padding: 8px 4px; border-radius: 8px; background: #f4f5f3; font-size: .82rem; }
.pricing-row span.rec { background: var(--green); color: #fff; }
.pricing-text { font-size: .85rem; line-height: 1.45; color: var(--text); }

.listed { grid-column: 1 / -1; display: grid; gap: 8px; }
.section-label { font-weight: 700; font-size: .9rem; }
.listed-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.mkt { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; }
.mkt.on { border-color: #bcdccd; background: #f3f9f5; }
.mkt.sold { border-color: #cde8d4; background: #eaf7ee; }
.mkt-head { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; cursor: pointer; }
.mkt-head input { width: auto; }
.mkt-body { display: flex; gap: 6px; margin-top: 8px; }
.mk-url { flex: 1; font-size: .8rem; padding: 6px 8px; }
.mk-sold { white-space: nowrap; font-size: .8rem; padding: 6px 10px; }
.mk-sold.is-sold { background: var(--green); color: #fff; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mkt-badge { font-size: .66rem; padding: 2px 6px; border-radius: 6px; background: #e4efe9; color: var(--green-dark); }
.mkt-badge.sold { background: var(--green); color: #fff; }

.packets { display: grid; gap: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button.active { background: var(--green); color: #fff; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: .9rem; z-index: 50; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 60px 20px; }
