/* Feuille de style unique. Palette sobre, surfaces blanches sur fond crème, accent bleu, un seul rayon. */
:root {
  --bg: #f4f3ee;
  --surface: #ffffff;
  --surface-2: #f9f8f4;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e3e1da;
  --accent: #2563eb;
  --accent-bg: #e8effd;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 10px 28px -18px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
h1 { margin: 0 0 16px; font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { margin: 28px 0 12px; font-size: 1.15rem; }
small { font-size: 0.85em; }

/* Barre de navigation */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--accent); }

.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }

/* Blocs */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.panel { margin-top: 24px; background: var(--surface-2); }
.panel h2 { margin-top: 0; }
.narrow { max-width: 420px; margin: 48px auto; }

/* Formulaires */
label { display: block; margin-bottom: 12px; font-weight: 500; }
label small { font-weight: 400; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { resize: vertical; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 8px 14px;
  background: var(--surface);
  color: inherit;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1d4ed8; color: #fff; }
button.danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
button.danger:hover { background: var(--danger-bg); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
form.inline { display: inline; }
a.button { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; color: inherit; background: var(--surface); }
a.button.danger { color: var(--danger); border-color: var(--danger); }
a.button.danger:hover { background: var(--danger-bg); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 24px; }
.narrow button.primary { width: 100%; }

.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.copy-form button.primary { margin-top: 4px; }

/* Messages */
.alert { padding: 10px 12px; border-radius: 6px; background: var(--danger-bg); color: var(--danger); }
.flash { padding: 10px 12px; margin: 0 0 16px; border-radius: 6px; background: var(--ok-bg); color: var(--ok); }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 4px; font-size: 0.9rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Badges */
.badge {
  display: inline-block;
  padding: 1px 7px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
  vertical-align: middle;
}
.badge.owned { background: var(--ok-bg); color: var(--ok); }

/* Accueil */
.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 32px;
  margin-bottom: 24px;
}
.hero p { margin: 0; }
.quick-search { display: flex; gap: 8px; flex: 1 1 360px; max-width: 520px; }
.quick-search input { margin: 0; }
.quick-search button { white-space: nowrap; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.total:hover { border-color: var(--accent); }
.total.mine { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-bg), var(--surface) 70%); }
.total-label { font-size: 0.85rem; color: var(--muted); }
.total-main { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.total-value { font-weight: 500; }
.total-estimate { font-size: 0.9rem; }

.recent { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.recent-item:hover { border-color: var(--accent); }

/* Vignettes et images */
.thumb { width: 40px; height: 56px; object-fit: cover; border-radius: 3px; background: var(--surface-2); flex: none; display: inline-block; }
.thumb-empty { border: 1px dashed var(--border); }
.tile-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 63 / 88;
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* Filtres */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filters label { margin: 0; flex: 0 1 180px; font-size: 0.9rem; }
.filters label.grow { flex: 1 1 260px; }
.filters select, .filters input { margin-top: 2px; }
.filters button { height: 40px; }

/* Grille catalogue */
.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.tile a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 10px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.tile a:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.tile img { width: 100%; height: auto; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.tile-name { font-weight: 600; margin-top: 4px; }
.tile-meta { font-size: 0.85rem; }
.tile .badge { align-self: flex-start; margin-top: 4px; }
.tile-price { font-weight: 600; font-size: 0.9rem; margin-top: 2px; }
.pager { display: flex; justify-content: center; gap: 24px; margin-top: 24px; }

/* Fiche carte */
.card-page { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 32px; align-items: start; }
.card-media img { width: 100%; height: auto; border-radius: 12px; box-shadow: var(--shadow); }
.card-media .tile-empty.large { font-size: 1rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 16px; margin: 0; }
.facts div { padding: 8px 0; border-bottom: 1px solid var(--border); }
.facts dt { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.facts dd { margin: 0; font-weight: 500; }

/* Prix (fiche carte) : dollars en évidence, euros en estimation */
.prices { margin-top: 20px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.prices h2 { margin-top: 0; }
.price-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0; }
.price-usd { font-size: 1.7rem; letter-spacing: -0.01em; }
.price-eur { font-size: 1.1rem; color: var(--muted); }
.price-meta { flex-basis: 100%; font-size: 0.9rem; }
.price-variants { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 20px; }
.sparkline { margin: 14px 0 0; color: var(--accent); }
.sparkline svg { display: block; max-width: 100%; height: auto; }
.sparkline figcaption { margin-top: 4px; font-size: 0.85rem; }
.small { font-size: 0.85rem; }
.prices p.small { margin: 12px 0 0; }
.prices h3 { margin: 18px 0 8px; font-size: 1rem; }
.price-table { margin-top: 10px; }
.price-table td, .price-table th { white-space: nowrap; }
.up { color: var(--ok); }
.down { color: var(--danger); }
.product-image { width: 100%; max-width: 220px; height: auto; border-radius: 12px; box-shadow: var(--shadow); }

/* Collection */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.tabs { display: inline-flex; flex-wrap: wrap; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.tab { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 500; }
.tab small { color: var(--muted); margin-left: 4px; }
.tab.active { background: var(--accent); color: #fff; }
.tab.active small { color: rgba(255, 255, 255, 0.8); }
.totals-line { margin: 0 0 12px; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 8px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table th { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table.compact th, .table.compact td { padding: 6px 8px; }
.cell-thumb { width: 48px; }

/* Petits écrans */
@media (max-width: 720px) {
  .container { padding: 16px 12px 40px; }
  .card-page { grid-template-columns: 1fr; }
  .card-media { max-width: 260px; margin: 0 auto; }
  .field-row { grid-template-columns: 1fr; }
  .filters label { flex: 1 1 140px; }
  .table { display: block; overflow-x: auto; }
  .nav { gap: 12px; font-size: 0.95rem; }
}

/* Scan (page caméra, pensée pour le téléphone) */
.hero .hero-actions { margin-top: 10px; }
.scan-settings label { flex: 1 1 120px; }
.scan-camera { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; }
.scan-viewport {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 63 / 88;
  overflow: hidden;
  border-radius: var(--radius);
  background: #000;
}
.scan-viewport video { display: block; width: 100%; height: 100%; object-fit: cover; }
.scan-guide { position: absolute; inset: 4%; border: 2px dashed rgba(255, 255, 255, 0.85); border-radius: 10px; pointer-events: none; }
.scan-button { width: min(100%, 360px); padding: 14px; font-size: 1.05rem; }
#scan-status { margin: 0; text-align: center; }
#scan-error { margin: 0 0 12px; }
.scan-read { margin: 0 0 8px; word-break: break-word; }
.candidates { list-style: none; padding: 0; margin: 0 0 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.candidate {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.candidate.added { border-color: var(--ok); background: var(--ok-bg); }
.candidate-link { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.candidate img { width: 100%; height: auto; aspect-ratio: 63 / 88; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.candidate .badge { align-self: flex-start; }
.candidate button { margin-top: auto; width: 100%; padding: 10px; }
.scan-added h2 { margin-top: 8px; }
.qr { display: flex; justify-content: center; margin: 16px 0; }
.qr svg { width: 100%; max-width: 280px; height: auto; }
.qr-page code { word-break: break-all; }
