/* Shared design tokens and components. */
:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #f1ece2;
  --ink: #1d1b18;
  --muted: #6f685d;
  --line: #e2dbcd;
  --gold: #a87d2c;
  --gold-ink: #7a5715;
  --gold-soft: #f3e7cc;
  --ok: #2f7a4b;
  --ok-soft: #e1f1e6;
  --warn: #9a6a00;
  --warn-soft: #fbf0d4;
  --bad: #b23b32;
  --bad-soft: #f8e1de;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(30 25 15 / 6%), 0 6px 20px rgb(30 25 15 / 6%);
  --font: "Manrope", system-ui, sans-serif;
  --font-display: "Cormorant Garamond", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15130f; --surface: #1e1b16; --surface-2: #27231c; --ink: #f1ebe0; --muted: #a59b8b;
    --line: #3a342a; --gold: #d3a64e; --gold-ink: #e9c47a; --gold-soft: #3a2f19;
    --ok: #6fc28e; --ok-soft: #1d3326; --warn: #e2b54c; --warn-soft: #3a2f14;
    --bad: #ef8178; --bad-soft: #3d1f1c; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--gold-ink); }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.2rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4em; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: .55em 1em; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: var(--gold-ink); border-color: var(--gold-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { padding: .3em .7em; font-size: .88em; }
.icon-btn { border: 0; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .55em .7em; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }
input[type="checkbox"] { width: auto; }
label.field { display: grid; gap: .3em; font-size: .9em; color: var(--muted); }
label.field > span { font-weight: 600; }
.hint { font-size: .82em; color: var(--muted); }
.error-text { color: var(--bad); font-size: .85em; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.badge { display: inline-block; padding: .1em .6em; border-radius: 999px; font-size: .8em; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.active, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.completed { background: var(--gold-soft); color: var(--gold-ink); }
.badge.expired { background: var(--warn-soft); color: var(--warn); }
.badge.cancelled, .badge.bad { background: var(--bad-soft); color: var(--bad); }
.sku { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; color: var(--muted); }
.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: .6em .7em; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid th { font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 25%); }
dialog.modal::backdrop { background: rgb(20 16 10 / 45%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem .4rem; }
.modal-head h2 { margin: 0; }
.modal-body { padding: .4rem 1.2rem 1.2rem; display: grid; gap: .9rem; }
.actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 1000; max-width: calc(100vw - 32px); }
.toast { padding: .7em 1em; border-radius: 8px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: #fff; }

.scan-field { position: relative; }
.scan-field input { padding-left: 2.4em; }
.scan-field::before {
  content: ""; position: absolute; left: .8em; top: 50%; width: 1.1em; height: .9em; transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, var(--muted) 0 1.5px, transparent 1.5px 3px, var(--muted) 3px 4px, transparent 4px 5.5px);
  opacity: .7; pointer-events: none;
}

.stars { white-space: nowrap; font-weight: 600; }
.stars .on { color: var(--gold); letter-spacing: 1px; }
.stars .off { color: var(--line); letter-spacing: 1px; }
.stars.none { color: var(--muted); font-weight: 400; font-size: .9em; }
.star-input { display: inline-flex; gap: 2px; }
.star-btn { border: 0; background: none; font-size: 2rem; line-height: 1; color: var(--line); cursor: pointer; padding: 0 2px; }
.star-btn.on { color: var(--gold); }
.review { padding: 1rem 1.2rem; display: grid; gap: .4rem; }
.review-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: baseline; }
.review-text { white-space: pre-wrap; }
.review-reply { margin-top: .3rem; padding: .7rem .9rem; border-left: 3px solid var(--gold); background: var(--surface-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; }
.review.hidden-review { opacity: .6; }
.reviews { display: grid; gap: .8rem; }

.price-view { display: inline-flex; gap: .45em; align-items: baseline; flex-wrap: wrap; }
.price.sale { color: var(--bad); }
.old-price { color: var(--muted); font-size: .85em; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; padding: .1em .55em; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8em; color: var(--ink); }
.chips.sale .chip { background: var(--bad-soft); border-color: transparent; color: var(--bad); font-weight: 600; }
.pick-many { max-height: 55vh; overflow: auto; display: grid; gap: 2px; }
.pick-row { padding: .3rem .2rem; font-weight: 400; }
.pick-group { margin-top: .5rem; font-size: .78em; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
dialog.modal.wide { width: min(720px, calc(100vw - 32px)); }
.check { display: inline-flex; gap: .45rem; align-items: center; }
.gallery { display: grid; gap: .6rem; align-content: start; }
.gallery-main { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: .4rem; flex-wrap: wrap; }
.gallery-thumbs button { width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--surface-2); }
.gallery-thumbs button.current { border-color: var(--gold); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* Visually hidden but focusable/clickable through its <label> (file inputs). */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Built-in help pages (shared/help.js) */
.help-link { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 1px solid var(--gold); color: var(--gold-ink); font: 700 .9rem var(--font); text-decoration: none; vertical-align: middle; }
.help-link:hover { background: var(--gold-soft); }
.help-intro { color: var(--muted); max-width: 70ch; margin-top: 0; }
.help-layout { display: grid; grid-template-columns: 230px 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 800px) { .help-layout { grid-template-columns: 1fr; } }
.help-side { padding: 1rem; position: sticky; top: 1rem; display: grid; gap: .5rem; }
@media (max-width: 800px) { .help-side { position: static; } }
.help-toc { display: grid; gap: .15rem; }
.help-toc a { color: var(--ink); text-decoration: none; padding: .25em .4em; border-radius: 6px; font-size: .92em; }
.help-toc a:hover { background: var(--surface-2); }
.help-main { display: grid; gap: .6rem; min-width: 0; }
.help-filter input { width: 100%; }
.help-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); scroll-margin-top: 1rem; }
.help-section > summary { cursor: pointer; padding: .9rem 1.1rem; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.help-section > summary::-webkit-details-marker { display: none; }
.help-section > summary::after { content: "+"; color: var(--gold); font-size: 1.2rem; line-height: 1; }
.help-section[open] > summary::after { content: "−"; }
.help-body { padding: 0 1.1rem 1rem; line-height: 1.55; max-width: 75ch; }
.help-body p { margin: .5rem 0; }
.help-body ol, .help-body ul { margin: .4rem 0; padding-left: 1.4rem; display: grid; gap: .3rem; }
.help-tip { background: var(--gold-soft); border-left: 3px solid var(--gold); padding: .6rem .8rem; border-radius: 6px; }

/* Photo viewer (shared/lightbox.js) */
.zoomable { cursor: zoom-in; }
.zoomable:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
html.lb-open { overflow: hidden; }
dialog.lightbox { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgb(14 12 9 / 97%); color: #f4efe7; outline: none; }
dialog.lightbox::backdrop { background: transparent; }
.lb-stage { position: absolute; inset: 56px 64px 52px; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; user-select: none; }
@media (max-width: 600px) { .lb-stage { inset: 52px 0 52px; } }
.lb-img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; border-radius: 4px; transition: opacity .15s; }
.lb-stage.loading .lb-img { opacity: .4; }
.lb-stage.zoomed { display: block; overflow: auto; cursor: grab; }
.lb-stage.zoomed:active { cursor: grabbing; }
.lb-stage.zoomed .lb-img { max-width: none; max-height: none; cursor: zoom-out; border-radius: 0; }
.lb-nav, .lb-close { position: absolute; border: 0; background: rgb(255 255 255 / 10%); color: inherit; cursor: pointer; display: grid; place-items: center; border-radius: 50%; font: 400 2rem/1 var(--font); }
.lb-nav:hover, .lb-close:hover { background: rgb(255 255 255 / 22%); }
.lb-nav:focus-visible, .lb-close:focus-visible { outline: 2px solid var(--gold); }
.lb-nav { top: 50%; width: 48px; height: 48px; transform: translateY(-50%); padding-bottom: 4px; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
@media (max-width: 600px) { .lb-nav { top: auto; bottom: 4px; transform: none; width: 44px; height: 44px; } }
.lb-close { top: 8px; right: 10px; width: 42px; height: 42px; }
.lb-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 52px; display: flex; gap: 1rem; align-items: center; justify-content: center; font-size: .9rem; opacity: .85; padding: 0 64px; text-align: center; }
.lb-caption { font-weight: 700; }
.lb-note { opacity: .7; }
@media (max-width: 600px) { .lb-note, .lb-caption { display: none; } }
.chip.inherited { opacity: .6; border-style: dashed; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .3rem .8rem; }
.warn-text { color: var(--warn); font-size: .85em; font-weight: 600; }
.deal-tag { display: inline-block; margin-top: 2px; padding: .05em .5em; border-radius: 999px; background: var(--gold-soft); color: var(--gold-ink); font-size: .78em; font-weight: 700; }
[hidden] { display: none !important; }
