/* Garage Sale Lister — warm, big, and easy on the eyes.
   Designed for one hand on an iPhone in a parking lot:
   19px body, 52px tap targets, strong contrast, lots of air. */

:root {
  --bg: #FFF8EC;
  --card: #FFFFFF;
  --ink: #2B1D10;
  --muted: #6E5F4E;
  --line: #E8DCC6;
  --amber: #F6B83C;
  --amber-soft: #FDECC4;
  --primary: #B8441F;
  --primary-dark: #963415;
  --green: #2F7D4E;
  --green-soft: #DDF1E3;
  --blue: #1F5FA8;
  --blue-soft: #DCE9F8;
  --grey-soft: #EEE9DF;
  --red: #C0392B;
  --red-soft: #FADBD7;
  --radius: 16px;
  --tap: 52px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 19px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--primary); }

.wordmark {
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):active { background: var(--primary-dark); }
.btn-secondary { background: var(--card); border-color: var(--ink); color: var(--ink); }
.btn-light { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-big { font-size: 1.25rem; min-height: 64px; width: 100%; }
.btn-block { width: 100%; }
.btn-copy {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--ink);
  min-height: 48px;
  padding: 8px 16px;
  white-space: nowrap;
}
.btn-small { min-height: 44px; padding: 8px 14px; font-size: 0.95rem; }

/* ---------- login ---------- */
.login {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 32px 24px;
  text-align: center;
}
.login-icon { border-radius: 22px; }
.login .wordmark { font-size: 2rem; }
.login-sub { color: var(--muted); font-size: 1.1rem; }
.login-input {
  width: 100%;
  max-width: 360px;
  font-size: 2rem;
  letter-spacing: 0.25em;
  text-align: center;
  padding: 14px;
  min-height: 72px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
}
.login .btn { max-width: 360px; }
.login-error { color: var(--red); font-weight: 700; }

/* ---------- layout ---------- */
.screen { max-width: 640px; margin: 0 auto; padding: 16px 16px 120px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 16px;
}
.topbar .wordmark { font-size: 1.35rem; }
.back-row { padding: 4px 0 12px; }
.back-row .btn { padding-left: 4px; }
h2.screen-title { font-size: 1.6rem; font-weight: 800; margin: 4px 0 14px; }
h3.section-title { font-size: 1.15rem; font-weight: 800; margin: 24px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.muted { color: var(--muted); }
.small { font-size: 0.95rem; }
p + p { margin-top: 10px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}
.stat-num { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-num.good { color: var(--green); }
.stat-num.bad { color: var(--red); }
.stat-label { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }

/* ---------- filters ---------- */
.chips { display: flex; gap: 8px; margin: 16px 0 12px; overflow-x: auto; padding-bottom: 4px; }
.chip {
  min-height: 48px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--card);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- item list ---------- */
.list { display: flex; flex-direction: column; gap: 12px; }
.row {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  text-decoration: none;
  color: inherit;
  min-height: 108px;
}
.row-thumb {
  width: 84px; height: 84px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--grey-soft);
}
.row-thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.6rem; }
.row-title { font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.row-price { font-weight: 800; }
.pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.pill-draft { background: var(--grey-soft); color: var(--muted); }
.pill-listed { background: var(--blue-soft); color: var(--blue); }
.pill-sold { background: var(--green-soft); color: var(--green); }
.pill-working { background: var(--amber-soft); color: #8A5A00; }
.pill-error { background: var(--red-soft); color: var(--red); }
.empty-state { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- forms ---------- */
.field { margin-bottom: 18px; }
.field label, .field .label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}
.field-hint { color: var(--muted); font-size: 0.95rem; margin-top: 6px; }
.input, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 1.05rem;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--ink); }
.textarea { min-height: 120px; line-height: 1.45; resize: vertical; }
.textarea.tall { min-height: 260px; }
.money { position: relative; }
.money .input { padding-left: 34px; }
.money::before { content: "$"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); }
.field-row { display: flex; gap: 10px; align-items: stretch; }
.field-row .input, .field-row .textarea { flex: 1; min-width: 0; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.field-head label { margin: 0; }
.count { font-size: 0.95rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.over { color: var(--red); font-weight: 800; }

/* ---------- photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.photo-cell { position: relative; aspect-ratio: 1; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; background: var(--grey-soft); }
.photo-remove {
  position: absolute; top: -8px; right: -8px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--ink);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}
.photo-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.photo-strip img { width: 110px; height: 110px; flex: none; object-fit: cover; border-radius: 12px; background: var(--grey-soft); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

/* ---------- identification ---------- */
.ident-name { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.ident-line { margin-top: 6px; }
.confidence { display: inline-block; margin-top: 10px; padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 0.95rem; }
.confidence-high { background: var(--green-soft); color: var(--green); }
.confidence-medium { background: var(--amber-soft); color: #8A5A00; }
.confidence-low { background: var(--red-soft); color: var(--red); }
.check-list { margin: 10px 0 0 0; padding-left: 0; list-style: none; }
.check-list li { padding: 8px 0 8px 34px; position: relative; border-top: 1px solid var(--line); }
.check-list li::before { content: "☐"; position: absolute; left: 4px; font-size: 1.3rem; line-height: 1.1; }
.price-big { font-size: 2.2rem; font-weight: 800; line-height: 1; margin: 6px 0; }
.price-range { font-weight: 700; color: var(--muted); }
.note-box { background: var(--amber-soft); border-radius: 12px; padding: 12px 14px; margin-top: 12px; font-size: 0.98rem; }

/* ---------- item specifics ---------- */
.spec-row { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 8px; margin-bottom: 8px; align-items: stretch; }
.spec-row .input { padding: 10px 12px; font-size: 1rem; }
.spec-remove { min-height: 48px; min-width: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--muted); font-size: 1.2rem; }

/* ---------- status ---------- */
.status-now { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-weight: 700; }
.status-btns { display: flex; flex-direction: column; gap: 10px; }
.sale-summary { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; margin-bottom: 12px; }
.sale-summary dt { color: var(--muted); }
.sale-summary dd { text-align: right; font-weight: 700; }

/* ---------- sticky save ---------- */
.save-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex;
  gap: 10px;
  justify-content: center;
}
.save-bar .btn { max-width: 640px; }

/* ---------- alerts ---------- */
.alert { border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; font-weight: 600; }
.alert-error { background: var(--red-soft); color: #7A1F15; }
.alert-info { background: var(--blue-soft); color: #143F73; }
.alert-working { background: var(--amber-soft); color: #5A3A00; display: flex; align-items: center; gap: 12px; }

/* ---------- progress overlay ---------- */
.progress {
  position: fixed; inset: 0;
  background: rgba(43, 29, 16, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 50;
}
.progress-card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px 24px;
  width: 100%; max-width: 380px;
  text-align: center;
}
.progress-spinner, .spinner {
  width: 56px; height: 56px;
  border: 6px solid var(--amber-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: spin 1s linear infinite;
}
.spinner { width: 28px; height: 28px; border-width: 4px; margin: 0; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-title { font-size: 1.3rem; font-weight: 800; }
.progress-sub { color: var(--muted); margin-top: 8px; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0;
  background: #000;
  z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}
.lightbox img { max-height: calc(100dvh - 120px); object-fit: contain; }
.lightbox .btn { max-width: 300px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 70;
  max-width: 90vw;
  text-align: center;
}

/* ---------- report page ---------- */
.rep-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.rep-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.rep-controls select { min-height: var(--tap); padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); }
.rep-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.rep-table caption { text-align: left; font-weight: 800; font-size: 1.1rem; padding: 0 0 8px; }
.rep-table th, .rep-table td { padding: 12px 10px; border-top: 1px solid var(--line); text-align: left; }
.rep-table thead th { background: var(--grey-soft); border-top: none; font-size: 0.9rem; color: var(--muted); }
.rep-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rep-table tfoot th, .rep-table tfoot td { font-weight: 800; border-top: 2px solid var(--ink); }
.rep-none { color: var(--muted); padding: 20px; text-align: center; }
.rep-note { color: var(--muted); font-size: 0.95rem; }

@media print {
  body { background: #fff; font-size: 12pt; padding: 0; }
  .no-print, .toast, .save-bar { display: none !important; }
  .screen { padding: 0; max-width: none; }
  .rep-table { border: none; }
  .rep-table th, .rep-table td { padding: 6px 8px; }
}

@media (min-width: 700px) {
  body { font-size: 20px; }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
}
