:root {
  --bg: #EDE6D3;
  --bg-card: #FFFDF8;
  --ink: #24211D;
  --ink-soft: #6B6355;
  --teal: #1F5C52;
  --teal-dark: #163F38;
  --mustard: #D9A441;
  --rust: #A63A2F;
  --sage: #5C7A5E;
  --line: #D8CBA8;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  padding-bottom: 76px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, .eyebrow-title { font-family: 'Fraunces', serif; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 14px;
  background: var(--teal);
  color: #F6F1E4;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 1.25rem; font-weight: 600; margin: 0; flex: 1; letter-spacing: 0.02em; }
.tag-punch {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #F6F1E4;
  background: var(--teal);
}
.icon-btn {
  background: none; border: none; color: #F6F1E4;
  font-size: 1.1rem; cursor: pointer; padding: 4px 8px;
}

main { max-width: 560px; margin: 0 auto; padding: 16px; }

.view { display: none; }
.view.active { display: block; }

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin: 18px 0 6px;
}
.eyebrow:first-child { margin-top: 0; }

/* ---- Mode toggle ---- */
.mode-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 4px;
}
.mode-pill {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-family: 'Inter', sans-serif;
}
.mode-pill.active { background: var(--teal); color: #F6F1E4; }

/* ---- Batch intake ---- */
.batch-add-row { display: flex; gap: 10px; margin: 10px 0; }
.btn-batch-add { flex: 1; text-align: center; }

.batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.batch-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.batch-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.batch-thumb .remove-x {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px;
  background: rgba(36,33,29,0.75);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 0.75rem;
  line-height: 20px;
  text-align: center;
  padding: 0;
}
.batch-thumb .status-dot {
  position: absolute; bottom: 3px; left: 3px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--line);
}
.batch-thumb .status-dot.pending { background: var(--ink-soft); }
.batch-thumb .status-dot.working { background: var(--mustard); }
.batch-thumb .status-dot.done { background: var(--sage); }
.batch-thumb .status-dot.error { background: var(--rust); }
.batch-thumb .add-detail {
  position: absolute; bottom: 2px; right: 2px;
  width: 20px; height: 20px;
  background: var(--teal);
  color: #fff; border: none; border-radius: 50%;
  font-size: 0.85rem; line-height: 20px; text-align: center; padding: 0;
}
.batch-thumb .photo-count {
  position: absolute; top: 2px; left: 2px;
  background: rgba(36,33,29,0.75); color: #fff;
  font-size: 0.6rem; font-family: 'JetBrains Mono', monospace;
  padding: 1px 4px; border-radius: 3px;
}

.stepper-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.btn-link {
  background: none; border: none; color: var(--teal);
  font-size: 0.82rem; font-weight: 600; font-family: 'Inter', sans-serif;
}
.review-photo {
  width: 100%; max-height: 260px; object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 10px;
}

/* ---- Scan card ---- */
.scan-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.05), 0 6px 18px rgba(36,33,29,0.08);
  border: 1px dashed var(--line);
}

.photo-drop { position: relative; margin-bottom: 12px; }
.photo-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.photo-slot-wrap { display: flex; flex-direction: column; }
.slot-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.photo-drop-sm { margin-bottom: 0; }
.photo-drop-sm .photo-placeholder { height: 130px; font-size: 0.78rem; }
.photo-drop-sm .camera-glyph { font-size: 1.6rem; }
.photo-drop-sm img { height: 130px; width: 100%; object-fit: cover; border-radius: var(--radius); display: block; }
.photo-drop .remove-x {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px;
  background: rgba(36,33,29,0.75);
  color: #fff; border: none; border-radius: 50%;
  font-size: 0.8rem;
}
.photo-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  height: 220px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: #F7F2E4;
  color: var(--ink-soft);
  cursor: pointer;
  text-align: center;
  font-size: 0.9rem;
}
.camera-glyph { font-size: 2.2rem; }
#photoPreview {
  width: 100%; max-height: 340px; object-fit: cover;
  border-radius: var(--radius);
  display: block;
}

.row { display: flex; gap: 10px; margin: 10px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

label {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 8px 0;
  font-weight: 500;
}
input, select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  color: var(--ink);
}
textarea { resize: vertical; }

.btn {
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}
.btn-primary { background: var(--teal); color: #F6F1E4; flex: 1; }
.btn-primary:active { background: var(--teal-dark); }
.btn-ghost { background: transparent; color: var(--teal); border: 1px solid var(--teal); }
.btn-block { width: 100%; margin-top: 14px; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.loading {
  display: flex; align-items: center; gap: 8px;
  color: var(--ink-soft); font-size: 0.85rem; padding: 12px 0;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.confidence-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--mustard);
  color: #3A2A08;
}
.badge.high { background: var(--sage); color: #fff; }
.badge.low { background: var(--rust); color: #fff; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.72rem; }

.ai-notes {
  background: #F7F2E4;
  border-left: 3px solid var(--mustard);
  padding: 8px 10px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  border-radius: 0 6px 6px 0;
  margin: 6px 0 4px;
}

.comp-links { display: flex; flex-direction: column; gap: 6px; }
.comp-links a {
  display: block;
  padding: 9px 12px;
  background: #F7F2E4;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--teal-dark);
  text-decoration: none;
  font-size: 0.85rem;
}
.comp-links a:active { background: var(--line); }

/* ---- Inventory / hang tags ---- */
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-row input { flex: 1; }
.filter-row select { width: auto; }

.tag-list { display: flex; flex-direction: column; gap: 10px; }

.hang-tag {
  position: relative;
  display: flex;
  gap: 12px;
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
}
.hang-tag::before {
  content: "";
  position: absolute;
  left: -6px; top: 50%;
  transform: translateY(-50%);
  width: 12px; height: 12px;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: 50%;
}
.hang-tag img {
  width: 64px; height: 64px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--line);
  flex-shrink: 0;
}
.hang-tag .tag-body { flex: 1; min-width: 0; }
.hang-tag .tag-name { font-weight: 600; font-size: 0.95rem; }
.hang-tag .tag-meta { font-size: 0.78rem; color: var(--ink-soft); margin-top: 2px; }
.hang-tag .tag-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  margin-top: 6px;
}
.stamp {
  position: absolute; top: 10px; right: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 3px;
  transform: rotate(4deg);
  border: 1.5px solid currentColor;
}
.stamp.unlisted { color: var(--ink-soft); }
.stamp.listed { color: var(--teal); }
.stamp.sold { color: var(--rust); }

/* ---- Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-card .stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
}
.stat-card .stat-value {
  font-family: 'Fraunces', serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 4px;
}
.stat-card.profit .stat-value { color: var(--sage); }
.stat-card.loss .stat-value { color: var(--rust); }

.cat-breakdown { display: flex; flex-direction: column; gap: 8px; }
.cat-row {
  display: flex; justify-content: space-between;
  background: var(--bg-card);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

/* ---- Tabbar ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none;
  padding: 10px 0 8px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}
.tab span { font-size: 1.15rem; }
.tab.active { color: var(--teal); }

/* ---- Modal ---- */
.modal {
  position: fixed; inset: 0;
  background: rgba(36,33,29,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 380px;
}

.toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 999px;
  font-size: 0.82rem;
  z-index: 60;
}

.detail-row { display: flex; justify-content: space-between; margin: 10px 0; align-items: center; }
.detail-photo-strip { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; }
.detail-photo-strip img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.ebay-packet {
  background: #F7F2E4;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.82rem;
  white-space: pre-wrap;
  margin: 10px 0;
}

.profit-box {
  background: #F7F2E4;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0 4px;
}
.profit-line {
  display: flex; justify-content: space-between;
  padding: 3px 0;
  font-size: 0.88rem;
}
.profit-line.profit-total {
  border-top: 1px dashed var(--line);
  margin-top: 4px;
  padding-top: 8px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
}
.profit-line.profit-total.profit { color: var(--sage); }
.profit-line.profit-total.loss { color: var(--rust); }
