:root {
  --bg: #f6f4f0;
  --surface: #fff;
  --text: #1a1a1a;
  --muted: #666;
  --border: #e0dcd4;
  --accent: #c44b28;
  --accent-hover: #a33d20;
  --ok: #2d6a4f;
  --error: #b00020;
  --highlight: #fff8e6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.nav .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}

.nav .brand-logo {
  height: 1.1rem;
  width: auto;
  display: block;
}

.nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a.active, .nav a:hover { color: var(--accent); }
.logout-form { margin-left: auto; }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; margin-bottom: 0.75rem; }

.muted { display: block; color: var(--muted); font-size: 0.85rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.stat-highlight {
  background: var(--highlight);
  border-color: #e8c96a;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.section { margin-top: 1rem; }

.section-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.count { color: var(--muted); font-size: 0.9rem; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table-hint {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

th, td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.cell-with-thumb {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cell-with-thumb > div:last-child {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.list-thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--bg);
}

.list-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  line-height: 1.1;
  padding: 0.2rem;
}

.public-notice {
  margin: -0.5rem 0 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--highlight);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

th { background: var(--bg); font-weight: 600; font-size: 0.85rem; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-stock { background: #e8f0fe; color: #1a56db; }
.badge-vendu { background: #fff3cd; color: #856404; }
.badge-paye { background: #d4edda; color: #155724; }
.badge-repris { background: #e2e3e5; color: #383d41; }
.badge-perte { background: #f8d7da; color: #721c24; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filters a {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
  text-decoration: none;
}

.filters a.active, .filters a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 12rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.search-form .btn-link {
  padding: 0.45rem 0.25rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-danger {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
  margin-top: 0.75rem;
}
.btn-danger:hover { background: #8f0018; text-decoration: none; color: #fff; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.card-danger {
  border-color: #f5c2c7;
  background: #fff5f5;
}

.card-danger h3 { color: var(--error); }
.card-danger p { font-size: 0.9rem; margin-bottom: 0.75rem; }

.form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.form input, .form select, .form textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.span-2 { grid-column: span 2; }

.form-actions {
  display: flex;
  gap: 0.75rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.inline-form label { margin: 0; }
.inline-form input[type="date"],
.inline-form input[type="number"] {
  width: auto;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.actions { min-width: 220px; }

.action-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error { background: #fde8ea; color: var(--error); }
.alert-ok { background: #e6f4ed; color: var(--ok); }

.empty { color: var(--muted); padding: 1rem; text-align: center; }

.quick-action { margin-bottom: 1rem; }

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card label { text-align: left; margin-top: 1rem; }
.login-card input { width: 100%; margin-top: 0.25rem; margin-bottom: 1rem; }

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 0.6rem 1rem;
  text-align: center;
  background: #856404;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
}

.offline-banner.online {
  background: #2d6a4f;
}

.container-narrow {
  max-width: 520px;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.back-link:hover { color: var(--accent); }

.vente-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.vente-header h1 {
  margin-bottom: 0.25rem;
}

.vente-img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--bg);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* ─── Catalogue ─────────────────────────────────────────────────────────── */

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
}

.catalog-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
}

.catalog-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  text-decoration: none;
}

.catalog-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
  background: var(--bg);
}

.catalog-placeholder {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 600;
}

.catalog-body {
  padding: 0.75rem;
}

.catalog-body strong {
  display: block;
  margin-bottom: 0.2rem;
}

.catalog-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.catalog-price {
  font-weight: 600;
  color: var(--accent);
}

.catalog-type {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ─── Page publique ───────────────────────────────────────────────────────── */

.nav-public {
  justify-content: space-between;
}

.nav-public .btn {
  margin-left: auto;
}

body.public .page-header h1 {
  font-size: 1.75rem;
}

.image-preview {
  margin-bottom: 1rem;
}

.image-preview img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: var(--bg);
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}

.discogs-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.discogs-block h4 { margin: 0 0 0.75rem; font-size: 0.95rem; }

.discogs-results {
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  max-height: 14rem;
  overflow-y: auto;
}

.discogs-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.discogs-result:last-child { border-bottom: none; }
.discogs-result:hover { background: var(--bg); }

.discogs-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: normal;
  margin: 0;
}
