:root {
  --primary: #1D6FA5;
  --primary-light: #EBF4FA;
  --success: #2E7D32;
  --success-bg: #E8F5E9;
  --warning-bg: #FFF8E1;
  --danger-bg: #FFEBEE;
  --border: #DDEAF4;
  --text: #1A2B3C;
  --muted: #6B7E8F;
  --white: #FFFFFF;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(29, 111, 165, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #F4F7FA;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Layout ───────────────────────────────────────────────── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 16px;
}

.card {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}

/* ── Admin link in navbar ─────────────────────────────────── */
.nav-admin-link {
  text-decoration: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
}
.nav-admin-link:hover { background: var(--primary-light); }

/* ── Country field ────────────────────────────────────────── */
.country-field {
  margin-bottom: 20px;
}
.country-field label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}
.country-field .req { color: #C62828; }
.country-field select {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
}
.country-field .country-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Drop zone ────────────────────────────────────────────── */
.drop-zone {
  border: dashed 2px var(--primary);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
}

.drop-zone.dragover {
  background: var(--primary-light);
}

.drop-zone.has-file {
  border-style: solid;
  border-color: var(--success);
}

.drop-icon {
  margin-bottom: 10px;
}

.drop-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.drop-hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.drop-filename {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
}

#preview-img {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  display: none;
  margin: 16px auto 0;
  border-radius: 6px;
}

.upload-actions {
  margin-top: 20px;
  text-align: center;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: 11px 28px;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-success {
  background: var(--success);
  color: var(--white);
  border: none;
  padding: 11px 28px;
  border-radius: var(--radius);
  width: 100%;
  font-size: 16px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  padding: 11px 28px;
  border-radius: var(--radius);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  margin-top: 10px;
}

.btn-outline:hover {
  background: var(--primary-light);
}

/* ── Processing overlay ───────────────────────────────────── */
.processing-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.processing-overlay[hidden] {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid var(--primary-light);
  border-top: 4px solid var(--primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.status-text {
  margin-top: 16px;
  font-size: 15px;
  color: var(--primary);
  font-weight: 500;
}

/* ── Results ──────────────────────────────────────────────── */
.results-section[hidden] {
  display: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

/* Highlight the Gemini-tokens metric so it stands apart from the counts. */
.metric-tokens {
  background: #eef6fb;
  border: 1px solid #cfe6f5;
}

/* Per-request Gemini token breakdown shown under the metric cards. */
.token-usage {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.token-chip {
  font-size: 12px;
  color: var(--muted);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 4px 12px;
}

.token-chip strong { color: var(--primary); }

.token-chip-total {
  background: var(--primary);
}

.token-chip-total,
.token-chip-total strong { color: #fff; }

/* Empty-shelf state (no products detected). */
.empty-shelf {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: #fafafa;
  color: var(--muted);
}

.empty-shelf-icon { font-size: 40px; line-height: 1; }

.empty-shelf-title {
  margin-top: 12px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text, #333);
}

.empty-shelf-text { margin-top: 4px; font-size: 14px; }

.metric-card {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.metric-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 480px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--primary);
  color: var(--white);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

tr:hover td {
  background: var(--primary-light);
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-high {
  background: #D6F4D6;
  color: #1A6B1A;
}

.badge-medium {
  background: #FFF3CC;
  color: #7A5C00;
}

.badge-low {
  background: #FFE0E0;
  color: #8B0000;
}

.badge-catalog {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-ocr {
  background: #ECECEC;
  color: #555;
}

/* Lookup-source badges (product_master / user table / online vision). */
.badge-master {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-user {
  background: #E3F1DE;
  color: #2E6B2E;
}

.badge-vision {
  background: #EDE3FB;
  color: #5B2EA6;
}

/* ── Live job progress (queue panel) ──────────────────────── */
.queue-item-stage {
  margin-top: 4px;
  color: var(--primary, #1D6FA5);
}

.progress-bar {
  position: relative;
  margin-top: 6px;
  height: 6px;
  width: 100%;
  max-width: 320px;
  background: #E6EaEF;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
  /* A continuously moving stripe so the bar always looks alive, even while a
   * single slow step (e.g. an online lookup) hasn't bumped the percentage. */
  background-image: linear-gradient(
    90deg,
    var(--primary, #1D6FA5) 0%,
    #5aa8d6 50%,
    var(--primary, #1D6FA5) 100%
  );
  background-size: 200% 100%;
  animation: progress-slide 1.1s linear infinite;
}

@keyframes progress-slide {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Editable results table ───────────────────────────────── */
.results-hint {
  margin: 4px 0 12px;
}

.cell-input {
  width: 100%;
  min-width: 90px;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  background: #fff;
}

.cell-input:focus {
  outline: none;
  border-color: var(--primary, #1D6FA5);
  box-shadow: 0 0 0 2px var(--primary-light, #d7ecf8);
}

.btn-mini {
  white-space: nowrap;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--white, #fff);
  background: var(--primary, #1D6FA5);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.btn-mini:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Green flash on an input after its row auto-saves. */
.saved-flash {
  border-color: #2E8B57 !important;
  box-shadow: 0 0 0 2px #d6f0e0 !important;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Clickable, replaceable product image. */
.img-cell { width: 64px; }

.img-edit {
  position: relative;
  width: 56px;
  height: 56px;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
}

.img-edit .result-thumb {
  width: 56px;
  height: 56px;
}

.img-edit .result-thumb.thumb-empty {
  background:
    repeating-linear-gradient(45deg, #f4f4f4, #f4f4f4 6px, #ececec 6px, #ececec 12px);
}

.img-edit-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
  color: #fff;
  background: rgba(29, 111, 165, 0.85);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.img-edit:hover .img-edit-label,
.result-thumb.thumb-empty + .img-edit-label {
  opacity: 1;
}

/* Wider results so the trimmed columns are all comfortably visible. The card
 * breaks out of the 860px container and centers itself. */
.results-section {
  width: min(96vw, 1280px);
  margin-left: 50%;
  transform: translateX(-50%);
}

#results-table { width: 100%; }
#results-table th, #results-table td { vertical-align: middle; }
.cell-input { min-width: 110px; }

@media (max-width: 900px) {
  .results-section {
    width: 100%;
    margin-left: 0;
    transform: none;
  }
}

/* Inline-editable single-product detail page. */
.detail-name-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 22px;
  font-weight: 700;
  padding: 8px 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
}

.detail-name-input:focus {
  outline: none;
  border-color: var(--primary, #1D6FA5);
  box-shadow: 0 0 0 2px var(--primary-light, #d7ecf8);
}

.edit-textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  line-height: 1.5;
}

.edit-hint { margin-bottom: 10px; }

/* Catalog thumbnail shown in the results table. */
.result-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border, #ddd);
  background: #f4f4f4;
  display: block;
}

.results-actions {
  margin-top: 24px;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #C62828;
  color: var(--white);
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 320px;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
}

/* ── Nav links (customer shell) ───────────────────────────── */
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.brand { text-decoration: none; }
.nav-link {
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
}
.nav-link:hover { background: var(--primary-light); color: var(--primary); }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
.nav-user { font-size: 13px; color: var(--muted); margin-left: 4px; }
.nav-logout {
  text-decoration: none;
  color: var(--white);
  background: var(--primary);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
}
.nav-logout:hover { opacity: 0.9; }

/* ── Generic page bits ────────────────────────────────────── */
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty-state {
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}
.back-link { text-decoration: none; color: var(--primary); font-size: 13px; font-weight: 600; }
.btn-block { width: 100%; display: block; margin-top: 8px; }
.btn-outline.inline { width: auto; margin-top: 0; padding: 8px 16px; font-size: 14px; }
.btn-primary.inline { padding: 8px 16px; font-size: 14px; }

/* ── Auth pages (signup / login) ──────────────────────────── */
.auth-wrap {
  max-width: 960px;
  margin: 40px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 28px;
  align-items: stretch;
}
.auth-hero {
  background: linear-gradient(135deg, #1D6FA5 0%, #134d73 100%);
  color: var(--white);
  border-radius: 16px;
  padding: 40px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-hero h1 { font-size: 30px; margin: 0 0 14px; line-height: 1.2; }
.auth-hero p { font-size: 15px; line-height: 1.6; opacity: 0.92; }
.auth-bullets { list-style: none; padding: 0; margin: 22px 0 0; }
.auth-bullets li { font-size: 14px; margin-bottom: 12px; opacity: 0.95; }
.auth-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.auth-card h2 { margin: 0 0 4px; font-size: 22px; }
.auth-sub { margin: 0 0 20px; font-size: 14px; color: var(--muted); }
.auth-sub a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-error {
  background: var(--danger-bg);
  color: #8B0000;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field > span em { color: #C62828; font-style: normal; }
.field > span small { color: var(--muted); font-weight: 400; }
.field input {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
}
.field input:focus { outline: none; border-color: var(--primary); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.55;
  padding: 6px;
}
.pw-toggle.on { opacity: 1; }
.pw-meter {
  display: block;
  height: 5px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
}
.pw-meter-bar { display: block; height: 100%; width: 0; transition: width 0.2s, background 0.2s; }
.pw-hint { display: block; font-size: 12px; margin-top: 5px; min-height: 14px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.check input { margin-top: 2px; }

/* ── Queue panel ──────────────────────────────────────────── */
.queue-card[hidden] { display: none; }
.queue-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.queue-head h2 { margin: 0; font-size: 18px; }
.queue-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
}
.queue-item.status-done { border-color: #BFE3C0; background: #F4FBF4; }
.queue-item.status-error { border-color: #F2C0C0; background: #FDF4F4; }
.queue-item-main { min-width: 0; }
.queue-item-title { font-weight: 600; font-size: 14px; word-break: break-word; }
.queue-item-error { color: #8B0000; font-size: 12px; margin-top: 4px; }
.queue-item-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.qbadge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.qbadge-queued { background: var(--warning-bg); color: #7A5C00; }
.qbadge-processing { background: var(--primary-light); color: var(--primary); }
.qbadge-done { background: #D6F4D6; color: #1A6B1A; }
.qbadge-error { background: #FFE0E0; color: #8B0000; }
.mini-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--primary-light); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; display: inline-block;
}

/* ── Results head ─────────────────────────────────────────── */
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.results-head h2 { margin: 0; font-size: 18px; }

/* ── Storefront grid ──────────────────────────────────────── */
.shop-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.shop-filters select, .shop-filters input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.shop-filters input { flex: 1; min-width: 180px; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.shop-count { margin-bottom: 12px; }
.product-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(29, 111, 165, 0.16);
}
.view-detail { display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 700; color: var(--primary); }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  justify-content: center; margin-top: 26px;
}
.page-btn {
  text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 13px; font-size: 14px; font-weight: 600; background: var(--white);
}
.page-btn:hover { background: var(--primary-light); color: var(--primary); }
.page-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-ellipsis { padding: 0 4px; color: var(--muted); }

/* ── Product detail page ──────────────────────────────────── */
.detail-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 24px;
  align-items: start;
}
.detail-media { padding: 16px; }
.detail-img { width: 100%; border-radius: 8px; display: block; object-fit: contain; max-height: 460px; }
.detail-noimg { height: 320px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.detail-status { margin-bottom: 10px; position: static; }
.detail-status .status-tag { position: static; }
.detail-name { margin: 0 0 4px; font-size: 24px; }
.detail-brand { color: var(--muted); font-size: 15px; margin-bottom: 12px; }
.detail-price { font-size: 22px; font-weight: 700; color: var(--success); margin-bottom: 16px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
.detail-table th {
  text-align: left; width: 42%; color: var(--muted); font-weight: 600;
  padding: 9px 10px; background: transparent; position: static; white-space: normal;
}
.detail-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.detail-table tr th { border-bottom: 1px solid var(--border); }
.detail-notes, .detail-nutrition, .detail-source { margin-top: 18px; }
.detail-notes h3, .detail-nutrition h3, .detail-source h3 { font-size: 15px; margin: 0 0 8px; }
.detail-notes p { margin: 0; font-size: 14px; line-height: 1.6; }
@media (max-width: 720px) {
  .detail-wrap { grid-template-columns: 1fr; }
}
.product-thumb {
  position: relative;
  height: 160px; background: #F0F5FA; display: flex; align-items: center; justify-content: center;
}
.status-tag {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 12px;
  z-index: 1;
}
.status-tag.verified { background: #D6F4D6; color: #1A6B1A; }
.status-tag.new { background: var(--warning-bg); color: #7A5C00; }
.verified-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { color: var(--muted); font-size: 13px; }
.product-body { padding: 12px 14px; }
.product-name { font-weight: 700; font-size: 14px; }
.product-brand { font-size: 13px; color: var(--muted); margin: 3px 0 8px; }
.product-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.price { font-weight: 700; color: var(--success); font-size: 14px; }
.chip { background: var(--primary-light); color: var(--primary); font-size: 11px; padding: 2px 9px; border-radius: 12px; }
.chip.light { background: #EEF2F6; color: var(--muted); }
.nutri-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.nutri { font-size: 11px; color: var(--muted); background: #F4F7FA; padding: 2px 8px; border-radius: 10px; }

/* ── History grid ─────────────────────────────────────────── */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.history-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.history-card:hover { border-color: var(--primary); }
.history-thumb { height: 140px; background: #F0F5FA; }
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.history-body { padding: 12px 14px; }
.history-title { font-weight: 700; font-size: 15px; }
.history-meta { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.cell-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.shelf-full { max-width: 100%; border-radius: 8px; display: block; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 720px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { order: 2; }
}
@media (max-width: 600px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* On narrow screens hide Category (5), Shelf row (8) and Qty visible (9). */
  #results-table th:nth-child(5),
  #results-table td:nth-child(5),
  #results-table th:nth-child(8),
  #results-table td:nth-child(8),
  #results-table th:nth-child(9),
  #results-table td:nth-child(9) {
    display: none;
  }
}
