/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg:        #f5f4f0;
  --c-surface:   #ffffff;
  --c-border:    #d8d5ce;
  --c-text:      #1a1814;
  --c-muted:     #6b6760;
  --c-accent:    #4a6741;   /* sage green — inventory / nature */
  --c-accent-lt: #e8f0e6;
  --c-danger:    #b33a3a;
  --c-warn:      #b36a00;
  --c-warn-bg:   #fff8e6;
  --c-scout:     #2d5a8e;   /* blue for scout mode */
  --c-scout-lt:  #e8f0f9;
  --radius:      8px;
  --shadow:      0 1px 4px rgba(0,0,0,.10);
  --gap:         1rem;
  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: .75rem var(--gap);
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--c-accent);
  flex: 1;
}
.site-header nav {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  font-size: .875rem;
}
.logout-link { color: var(--c-muted); }

.main-content {
  flex: 1;
  padding: var(--gap);
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.site-footer {
  text-align: center;
  padding: .75rem;
  color: var(--c-muted);
  font-size: .75rem;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--gap);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--gap); }
.card-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: .5rem;
}

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2em .6em;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-scouted       { background: #e8eaf0; color: #444; }
.badge-passed        { background: #f0e8e8; color: #800; }
.badge-capturing     { background: #fff3e0; color: #8a4700; }
.badge-researching   { background: #e3f0ff; color: #1a4080; }
.badge-ready_to_list { background: var(--c-accent-lt); color: var(--c-accent); }
.badge-listed        { background: #e8f4e8; color: #2a6a2a; }
.badge-shipped       { background: #f0f0f0; color: #555; }

/* ── Dashboard stats ──────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .75rem;
  margin-bottom: var(--gap);
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: .75rem;
  text-align: center;
}
.stat-card .count { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .label { font-size: .75rem; color: var(--c-muted); margin-top: .25rem; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .875rem; }
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--c-border); }
th { background: var(--c-bg); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafaf8; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: .875rem; }
.form-group label {
  display: block;
  font-size: .825rem;
  font-weight: 600;
  margin-bottom: .3rem;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
input[type=text], input[type=password], input[type=search],
input[type=number], textarea, select {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color .15s;
}
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-lt);
}
textarea { min-height: 100px; resize: vertical; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  font-size: .9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.92); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--c-accent);  color: #fff; }
.btn-scout     { background: var(--c-scout);   color: #fff; font-size: 1.05rem; padding: .7rem 1.4rem; }
.btn-outline   { background: transparent; color: var(--c-accent); border: 1.5px solid var(--c-accent); }
.btn-danger    { background: var(--c-danger);  color: #fff; }
.btn-sm        { padding: .35rem .75rem; font-size: .8rem; }
.btn-block     { width: 100%; justify-content: center; }

/* ── Alerts / notices ─────────────────────────────────────────────────────── */
.alert {
  padding: .65rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: var(--gap);
}
.alert-warn   { background: var(--c-warn-bg);  color: var(--c-warn);   border-left: 3px solid var(--c-warn); }
.alert-error  { background: #fdf0f0;            color: var(--c-danger); border-left: 3px solid var(--c-danger); }
.alert-info   { background: var(--c-scout-lt); color: var(--c-scout);  border-left: 3px solid var(--c-scout); }
.alert-ok     { background: var(--c-accent-lt); color: var(--c-accent); border-left: 3px solid var(--c-accent); }

.disclaimer {
  font-size: .8rem;
  color: var(--c-warn);
  font-style: italic;
  margin-top: .3rem;
}

/* ── Photo grid ───────────────────────────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: .5rem;
}
.photo-thumb {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--c-border);
  background: #eee;
  aspect-ratio: 1;
}
.photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb .photo-tag {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .65rem;
  padding: .2em .4em;
  text-align: center;
}
.photo-thumb .photo-del {
  position: absolute;
  top: 2px; right: 2px;
  background: rgba(0,0,0,.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: .75rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Scout mode ───────────────────────────────────────────────────────────── */
.scout-page {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 2rem;
}
.scout-header {
  background: var(--c-scout);
  color: #fff;
  padding: 1rem var(--gap);
  border-radius: var(--radius);
  margin-bottom: var(--gap);
  text-align: center;
}
.scout-header h1 { font-size: 1.2rem; }
.scout-header p  { font-size: .8rem; opacity: .85; margin-top: .2rem; }

.comp-result {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--gap);
  margin-top: var(--gap);
}
.value-range {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--c-accent);
  margin: .5rem 0;
}
.comp-list { list-style: none; font-size: .875rem; }
.comp-list li { padding: .3rem 0; border-bottom: 1px solid var(--c-border); }
.comp-list li:last-child { border-bottom: none; }
.comp-list .price { font-weight: 600; float: right; }

/* ── Voice transcript ─────────────────────────────────────────────────────── */
.voice-bar {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  margin-bottom: .5rem;
}
.voice-bar textarea { flex: 1; min-height: 80px; }
.voice-btn {
  flex-shrink: 0;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--c-accent);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.voice-btn.recording { background: var(--c-danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.6} }

/* ── Comps block on item page ─────────────────────────────────────────────── */
.comps-section .active-listings { margin-bottom: 1rem; }
.listing-item {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  padding: .4rem 0;
  border-bottom: 1px solid var(--c-border);
  font-size: .875rem;
}
.listing-item:last-child { border-bottom: none; }
.listing-item .listing-price { font-weight: 700; white-space: nowrap; }

/* ── Research versions ────────────────────────────────────────────────────── */
.research-version {
  border-left: 3px solid var(--c-accent);
  padding-left: .75rem;
  margin-bottom: .75rem;
  font-size: .875rem;
}
.research-version h4 { font-size: .8rem; color: var(--c-muted); margin-bottom: .25rem; }
.research-version p  { margin-bottom: .25rem; }

/* ── QR code ──────────────────────────────────────────────────────────────── */
.qr-block {
  display: inline-block;
  background: #fff;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
}

/* ── Upload drop zone ─────────────────────────────────────────────────────── */
.upload-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 2px dashed var(--c-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-height: 60px;
  text-align: center;
  color: var(--c-muted);
  font-size: .9rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
  -webkit-user-select: none;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--c-accent);
  background: var(--c-accent-lt);
  color: var(--c-accent);
}
.upload-zone input[type=file] { display: none; }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.flex-row  { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.flex-end  { justify-content: flex-end; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--c-muted); font-size: .85rem; }
.text-sm    { font-size: .85rem; }
.hidden     { display: none !important; }
.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: var(--gap); }
.listing-code-badge {
  display: inline-block;
  font-family: monospace;
  background: #f0f0ee;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: .15em .5em;
  font-size: .9rem;
  letter-spacing: .05em;
}

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-wrap {
  max-width: 360px;
  margin: 3rem auto;
}
.login-wrap .brand-lg {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-accent);
  margin-bottom: 1.5rem;
}

/* ── Purchase grid ────────────────────────────────────────────────────────── */
.purchase-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: .75rem;
  align-items: start;
}
@media (max-width: 480px) {
  .purchase-grid { grid-template-columns: 1fr; }
}

/* ── Input with $ prefix ──────────────────────────────────────────────────── */
.input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-prefix {
  position: absolute;
  left: .75rem;
  color: var(--c-muted);
  font-size: .95rem;
  pointer-events: none;
  line-height: 1;
}
.input-prefix-wrap input[type=number] {
  padding-left: 1.6rem;
}

/* ── Receipt thumbnails ───────────────────────────────────────────────────── */
.receipt-thumb {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--c-border);
  background: #f5f5f5;
  aspect-ratio: 3/4;
  cursor: pointer;
  transition: border-color .15s;
}
.receipt-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.receipt-thumb .pdf-icon {
  display:flex; align-items:center; justify-content:center;
  height:100%; font-size:2rem; color:var(--c-muted);
}
.receipt-thumb.selected { border-color: var(--c-accent); box-shadow: 0 0 0 2px var(--c-accent-lt); }
.receipt-thumb .check {
  position:absolute; top:4px; right:4px;
  background: var(--c-accent); color:#fff;
  border-radius:50%; width:20px; height:20px;
  font-size:.7rem; display:none;
  align-items:center; justify-content:center;
}
.receipt-thumb.selected .check { display:flex; }

/* ── Responsive tweaks ────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .main-content { padding: .75rem; }
  .site-header nav { gap: .5rem; font-size: .8rem; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .btn { font-size: .85rem; padding: .5rem .9rem; }
}
