/* ═══════════════════════════════════════════════════════════════
   refurbish — design system
   Aesthetic: Precision Sourcing — modern, efficient, warm-edged
   Fonts: Bricolage Grotesque (display) + Hanken Grotesk (body)
   Theme: Warm light — outdoor & desk readability, CV-showcase
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,200..800&family=Hanken+Grotesk:ital,wght@0,300..700;1,300..500&display=swap');

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  /* Background layers */
  --bg:       oklch(97.2% 0.007 68);
  --bg-2:     oklch(93.5% 0.010 68);
  --card:     oklch(99.5% 0.003 68);

  /* Text */
  --fg:       oklch(17%  0.024 58);
  --fg-2:     oklch(36%  0.018 58);
  --muted-fg: oklch(56%  0.014 62);

  /* Borders */
  --border:   oklch(87%  0.009 66);
  --border-2: oklch(78%  0.013 64);

  /* Accent — terracotta / burnt sienna */
  --accent:        oklch(56%  0.152 40);
  --accent-hover:  oklch(50%  0.152 40);
  --accent-dim:    oklch(93%  0.030 52);
  --accent-fg:     oklch(98%  0.004 78);

  /* Semantic */
  --good:      oklch(50%  0.128 150);
  --good-bg:   oklch(95%  0.024 148);
  --warn:      oklch(63%  0.152 72);
  --warn-bg:   oklch(97%  0.028 78);
  --danger:    oklch(50%  0.185 22);
  --danger-bg: oklch(97%  0.020 18);

  /* Typography */
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body:    'Hanken Grotesk', system-ui, sans-serif;

  /* Spacing (4pt scale) */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radius */
  --r-sm: 4px;
  --r:    8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Elevation */
  --shadow-sm: 0 1px 3px oklch(17% 0.024 58 / 0.07);
  --shadow:    0 3px 10px oklch(17% 0.024 58 / 0.09);
  --shadow-lg: 0 8px 28px oklch(17% 0.024 58 / 0.11);

  /* Motion */
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:   cubic-bezier(0.7, 0, 0.84, 0);
  --dur:       180ms;
  --dur-slow:  320ms;

  /* Layout */
  --header-h:     56px;
  --bottom-nav-h: 64px;
  --content-max:  1200px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* clip (not hidden) prevents horizontal page scroll without creating a
     stacking context — position:fixed children still anchor to viewport */
  overflow-x: clip;
}
img, video, svg { max-width: 100%; }

/* ── Base ───────────────────────────────────────────────────── */
body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  /* Subtle grain overlay */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); letter-spacing: -0.025em; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; margin-top: var(--sp-8); margin-bottom: var(--sp-4); color: var(--fg); }
/* First h2 on page needs no top margin */
h1 + h2, .page-header + h2 { margin-top: var(--sp-6); }
h3 { font-size: 0.95rem; font-weight: 700; letter-spacing: -0.005em; color: var(--fg); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { line-height: 1.65; max-width: 70ch; }

/* ── Header ─────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--fg);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-6);
  box-shadow: 0 1px 0 oklch(100% 0 0 / 0.06);
}
.crawl-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent);
  opacity: 0.8;
  animation: crawl-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes crawl-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent) !important;
  letter-spacing: -0.02em;
  text-decoration: none !important;
  flex-shrink: 0;
}
header nav {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
}
header nav a {
  color: oklch(75% 0.008 68);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 400;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-sm);
  transition: color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
header nav a:hover {
  color: oklch(95% 0.006 68);
  background: oklch(100% 0 0 / 0.07);
  text-decoration: none;
}

/* ── Bottom Navigation (mobile) ─────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--fg);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid oklch(100% 0 0 / 0.08);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: oklch(60% 0.010 66);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color var(--dur) var(--ease-out);
  padding: var(--sp-2) 0;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav a:hover, .bottom-nav a.active {
  color: var(--accent);
}
.bottom-nav a svg { width: 22px; height: 22px; }

/* ── Main ───────────────────────────────────────────────────── */
main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6);
  animation: pageFadeIn var(--dur-slow) var(--ease-out) both;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
main > section,
main > .detail-grid,
main > .cards,
main > .board,
main > .stats {
  animation: pageFadeIn var(--dur-slow) var(--ease-out) both;
}
main > *:nth-child(1) { animation-delay: 0ms; }
main > *:nth-child(2) { animation-delay: 40ms; }
main > *:nth-child(3) { animation-delay: 80ms; }
main > *:nth-child(4) { animation-delay: 120ms; }
main > *:nth-child(5) { animation-delay: 160ms; }
main > *:nth-child(n+6) { animation-delay: 180ms; }

section { margin: var(--sp-8) 0; }
section:first-child { margin-top: 0; }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.header-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.5rem 1rem;
  background: var(--fg);
  color: oklch(95% 0.006 68);
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background var(--dur) var(--ease-out), transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  min-height: 40px;
}
.btn:hover {
  background: oklch(25% 0.024 58);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { transform: scale(0.97); }

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  transition: color var(--dur), background var(--dur);
  text-decoration: none;
  white-space: nowrap;
}
.btn-link:hover { background: var(--accent-dim); text-decoration: none; }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { background: var(--danger-bg); }
.btn-link.muted { color: var(--muted-fg); }
.btn-link.muted:hover { background: var(--bg-2); }
.btn-link.primary { color: var(--accent); font-weight: 600; }

/* ── Utility ─────────────────────────────────────────────────── */
.muted    { color: var(--muted-fg); }
.small    { font-size: 0.85rem; }
.tiny     { font-size: 0.78rem; }
.err      { color: var(--danger); font-size: 0.875rem; }
.hidden   { display: none !important; }
.mono     { font-family: 'Courier New', monospace; font-size: 0.8rem; white-space: nowrap; }
.meta     { font-size: 0.875rem; color: var(--muted-fg); display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }
.inline   { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.inline input, .inline select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  background: var(--card);
  color: var(--fg);
  min-width: 0;
  flex: 1 1 120px;
  min-height: 40px;
}
.inline input[type="file"] { flex: 1 1 auto; }

/* ── Hint / Warning / Info ───────────────────────────────────── */
.hint {
  font-size: 0.82rem;
  color: var(--muted-fg);
  line-height: 1.55;
  margin-top: var(--sp-2);
  /* Reset label's uppercase/tracking so hint reads normally */
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}
.warn {
  color: var(--warn);
  background: var(--warn-bg);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  font-size: 0.9rem;
}
.toast {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r);
  font-size: 0.9rem; margin-bottom: var(--sp-4);
}
.toast-info { background: oklch(93% 0.04 240); color: oklch(35% 0.12 240); }

/* ── Stats ───────────────────────────────────────────────────── */
.stats { display: flex; gap: var(--sp-4); flex-wrap: wrap; margin: var(--sp-4) 0 var(--sp-8); }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-6);
  border-radius: var(--r-lg);
  flex: 1 1 140px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease-out);
}
.stat:hover { box-shadow: var(--shadow); }
.stat span { display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted-fg); margin-bottom: var(--sp-1); }
.stat b { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; color: var(--fg); line-height: 1; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; width: 100%; }
.table-wrap table { min-width: 480px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--bg-2); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-fg); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-bought      { background: oklch(91% 0.04  240); color: oklch(35% 0.12  240); }
.badge-in_progress { background: oklch(94% 0.06  78);  color: oklch(40% 0.14  72);  }
.badge-done        { background: var(--good-bg);        color: var(--good);          }
.badge-listed      { background: oklch(93% 0.04  290); color: oklch(38% 0.12  290); }
.badge-sold        { background: oklch(92% 0.05  150); color: oklch(32% 0.13  148); }
.badge-dropped     { background: var(--bg-2);           color: var(--muted-fg);      }
.badge-new         { background: oklch(91% 0.04  240); color: oklch(35% 0.12  240); }
.badge-scored      { background: oklch(93% 0.04  290); color: oklch(38% 0.12  290); }
.badge-pushed      { background: var(--good-bg);        color: var(--good);          }
.badge-ignored     { background: var(--bg-2);           color: var(--muted-fg);      }

/* ── Cards (listings) ────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-4); margin: var(--sp-4) 0; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--bg-2); }
.card-body { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; }
.card-score {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
}
.card-score b {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--fg);
}
.card-score span {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted-fg);
  letter-spacing: 0;
}
.card.score-5 .card-score b, .card.score-4 .card-score b { color: var(--good); }
.card.score-3 .card-score b { color: oklch(48% 0.14 148); }
.card.score-2 .card-score b { color: oklch(52% 0.14 55); }
.card.score-1 .card-score b, .card.score-0 .card-score b { color: var(--muted-fg); }
.card.score-4 { box-shadow: 0 0 0 1.5px var(--good), var(--shadow-sm); }
.card.score-3 { box-shadow: 0 0 0 1.5px oklch(58% 0.12 148), var(--shadow-sm); }
.card.score-2 { box-shadow: 0 0 0 1.5px var(--warn), var(--shadow-sm); }
.card .meta   { font-size: 0.82rem; color: var(--fg-2); }
.actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; }

/* ── Photos ──────────────────────────────────────────────────── */
.photos { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin: var(--sp-4) 0; }
.photos img {
  width: 200px; height: 200px; object-fit: cover;
  border-radius: var(--r); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: box-shadow var(--dur), transform var(--dur);
}
.photos img:hover { box-shadow: var(--shadow); transform: scale(1.02); }

/* ── Photo management grid ───────────────────────────────────── */
.photos-manage {
  display: flex; gap: var(--sp-3); flex-wrap: wrap; margin: var(--sp-4) 0;
}
.photo-thumb {
  position: relative; cursor: grab; user-select: none;
  border-radius: var(--r); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); overflow: hidden;
  width: 160px; height: 160px; flex-shrink: 0;
  transition: box-shadow var(--dur), transform var(--dur);
}
.photo-thumb:active { cursor: grabbing; }
.photo-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none;
}
.photo-thumb.photo-dragging {
  opacity: 0.5; box-shadow: var(--shadow); transform: scale(1.04);
}
.photo-badge {
  position: absolute; top: var(--sp-2); left: var(--sp-2);
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; pointer-events: none;
}
.photo-delete {
  position: absolute; top: var(--sp-2); right: var(--sp-2);
  width: 24px; height: 24px; border-radius: 50%;
  background: oklch(20% 0 0 / .65); color: #fff;
  border: none; font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--dur);
}
.photo-thumb:hover .photo-delete,
.photo-thumb:focus-within .photo-delete { opacity: 1; }
.photo-delete-form { margin: 0; display: contents; }

/* ── Kanban Board ────────────────────────────────────────────── */
.board-scroll {
  overflow-x: auto;
  margin: 0 calc(-1 * var(--sp-6));
  padding: 0 var(--sp-6) var(--sp-4);
}
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: var(--sp-3);
  align-items: start;
  min-width: 900px;
}
.column {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-3);
  min-height: 140px;
}
.column h3 {
  margin: 0 0 var(--sp-3);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-fg);
  font-family: var(--font-body);
}
.column-body { min-height: 60px; }

.item-card {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: var(--sp-2);
  background: var(--card);
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.item-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.item-card:active { cursor: grabbing; }
.item-card img { width: 48px; height: 48px; object-fit: cover; border-radius: var(--r-sm); flex-shrink: 0; }
.item-card-body { flex: 1; min-width: 0; }
.item-card-nr { font-size: 0.7rem; color: var(--muted-fg); font-family: 'Courier New', monospace; }
.item-card a { text-decoration: none; color: inherit; }
.item-card b { display: block; font-size: 0.82rem; line-height: 1.35; }
.drag-ghost { opacity: 0.35; background: var(--accent-dim) !important; }

/* ── Items Table (list view) ─────────────────────────────────── */
.items-table { font-size: 0.875rem; }
.items-table tbody tr { transition: background var(--dur); cursor: pointer; }
.items-table tbody tr:hover { background: var(--bg-2); }

/* ── Forms ───────────────────────────────────────────────────── */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  max-width: 600px;
}
/* Buttons are inline — never stretch to form width */
.form > .btn,
.form > button {
  align-self: flex-start;
}
/* Button row (multiple actions) */
.form-actions {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
  margin-top: var(--sp-2);
}
.form .row { display: flex; gap: var(--sp-4); }
.form .row label { flex: 1; min-width: 0; }
.form label {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.form input,
.form textarea,
.form select {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 400;
  color: var(--fg);
  background: var(--card);
  transition: border-color var(--dur), box-shadow var(--dur);
  min-height: 44px;
}
.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(56% 0.152 40 / 0.12);
}
.form .checkbox { flex-direction: row; align-items: center; gap: var(--sp-3); text-transform: none; letter-spacing: 0; }
.form .checkbox input { min-height: auto; width: 18px; height: 18px; accent-color: var(--accent); }
.form textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.form-section {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-fg);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
  margin-top: var(--sp-4);
}

/* ── Field group (detail pages) ─────────────────────────────── */
.field-group {
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border);
}
.field-group:last-child { border-bottom: none; }
.field-group.warn { background: var(--warn-bg); padding: var(--sp-3) var(--sp-4); border-radius: var(--r); border-bottom: none; margin-bottom: var(--sp-3); }
.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-fg);
}

/* ── run-pending row ─────────────────────────────────────────── */
.run-pending td { color: var(--muted-fg); }

/* ── Detail page ─────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin: var(--sp-6) 0;
}
.detail-section h2 { margin-top: 0; }
.detail-table { width: 100%; font-size: 0.875rem; border-collapse: collapse; }
.detail-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.detail-table td:first-child { color: var(--muted-fg); width: 42%; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 500; }

/* ── Margin table ────────────────────────────────────────────── */
.margin tr.sum td { border-top: 2px solid var(--border-2); font-weight: 700; }
.margin tr.margin-row td { color: var(--good); font-size: 1.1rem; font-family: var(--font-display); }

/* ── Filters ─────────────────────────────────────────────────── */
.filters { display: flex; gap: var(--sp-3); margin: var(--sp-4) 0; flex-wrap: wrap; }

/* ── Profile filter chips ────────────────────────────────────────────────── */
.sort-chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.sort-chip {
  padding: var(--sp-1) var(--sp-3); border-radius: 999px;
  font-size: 0.78rem; font-weight: 500;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--muted-fg); text-decoration: none;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.sort-chip:hover { background: var(--bg-2); color: var(--fg); text-decoration: none; }
.sort-chip.active { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.profile-filter { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin: var(--sp-4) 0; }
.profile-chip {
  padding: var(--sp-1) var(--sp-3); border-radius: 999px;
  font-size: 0.8rem; font-weight: 500;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--muted-fg); text-decoration: none;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.profile-chip:hover { background: var(--bg-2); color: var(--fg); text-decoration: none; }
.profile-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.filters select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  background: var(--card);
  color: var(--fg);
}

/* ── Listing Draft (AI) ──────────────────────────────────────── */
.listing-draft {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.listing-title-row { display: flex; align-items: baseline; gap: var(--sp-4); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.listing-title { font-family: var(--font-display); font-size: 1.15rem; }
.listing-price { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.listing-text { white-space: pre-wrap; line-height: 1.7; color: var(--fg-2); margin-bottom: var(--sp-3); max-width: 65ch; }

/* ── Sourcing / Analysis Result ──────────────────────────────── */
.result {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  margin-top: var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.result.decision-buy            { box-shadow: 0 0 0 2px var(--good), var(--shadow-sm); }
.result.decision-buy_if_negotiate { box-shadow: 0 0 0 2px var(--warn), var(--shadow-sm); }
.result.decision-skip           { box-shadow: 0 0 0 2px var(--danger), var(--shadow-sm); }

/* ── Loading state for AI buttons ────────────────────────────── */
.btn.loading {
  opacity: 0.7;
  cursor: wait;
  pointer-events: none;
}
.btn.loading::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: var(--sp-2);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Desktop: hide bottom nav (mouse + hover = not a touch device) ── */
@media (hover: hover) and (pointer: fine) {
  .bottom-nav { display: none; }
  main { padding-bottom: var(--sp-8); }
}

/* ── Responsive: Mobile ──────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sp-6: 16px; --sp-8: 24px; }

  main {
    padding: var(--sp-6);
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + var(--sp-4));
  }

  header nav a { display: none; }

  .form .row { flex-direction: column; gap: var(--sp-3); }
  .stats { gap: var(--sp-3); }
  .stat { flex: 1 1 calc(50% - var(--sp-3)); }

  .detail-grid { grid-template-columns: 1fr; gap: var(--sp-3); }
  .photos img { width: 140px; height: 140px; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.1rem; }

  table { font-size: 0.82rem; }
  th, td { padding: var(--sp-2) var(--sp-3); }
}

@media (max-width: 480px) {
  .stat { flex: 1 1 100%; }
  .cards { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .photos img { width: 110px; height: 110px; }
}

/* ── Reduced Motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
