/* Staff area: plain and calm, usable on a phone in the warehouse. */

:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --line: #e2ddd4;
  --accent: #2f2a24;
  --error: #a3261b;
  --radius: 6px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 1rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 700; letter-spacing: 0.08em; text-decoration: none; }
.brand span { color: var(--muted); font-weight: 400; letter-spacing: normal; margin-left: 0.35rem; }
.logout { display: flex; align-items: center; gap: 0.75rem; margin: 0; }
.nav { display: flex; gap: 1.25rem; margin-right: auto; margin-left: 1.5rem; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.who { color: var(--muted); }

.page { max-width: 72rem; margin: 0 auto; padding: 1.5rem 1rem; }
.page-wide { max-width: none; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.narrow { max-width: 24rem; margin: 2rem auto; }

label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 500; }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
button { font: inherit; cursor: pointer; }
button.primary {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.65rem;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
}
button.link { padding: 0; color: var(--text); background: none; border: 0; text-decoration: underline; }

.error { color: var(--error); margin-bottom: 0.5rem; }
.messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.messages li { padding: 0.6rem 0.8rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.messages li.error { color: var(--error); }

/* --- Stock grid ---------------------------------------------------------- */

:root { --warn: #8a5a00; --warn-bg: #fbf1dc; }
.muted { color: var(--muted); }
small.warn { color: var(--warn); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.filters input[type="search"] { flex: 1 1 14rem; padding: 0.5rem 0.6rem; font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.filters select { padding: 0.45rem; font: inherit; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); max-width: 100%; }
.filters .check { display: inline-flex; gap: 0.35rem; align-items: center; margin: 0; font-weight: 400; }
.filters button, .inline-form button[type="submit"] { padding: 0.45rem 0.9rem; color: #fff;
  background: var(--accent); border: 0; border-radius: var(--radius); }

.item { display: grid; grid-template-columns: 7rem 1fr; gap: 1rem; margin-bottom: 0.75rem;
  padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.item-photo { text-align: center; }
.item-photo img { max-width: 100%; max-height: 7rem; object-fit: contain; display: block; margin: 0 auto; }
.item-photo small { display: block; margin-top: 0.25rem; color: var(--muted); font-size: 0.75rem; }
.no-photo { display: grid; place-items: center; height: 6rem; color: var(--muted); font-size: 0.85rem;
  border: 1px dashed var(--line); border-radius: var(--radius); }
.item-main { min-width: 0; }
.item-name { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.erp { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }

.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; margin: 0.5rem 0 0; padding: 0; }
.badges li { padding: 0.1rem 0.5rem; font-size: 0.8rem; color: var(--warn); background: var(--warn-bg);
  border-radius: 999px; }

.lots { width: 100%; margin-top: 0.75rem; border-collapse: collapse; font-size: 0.9rem; }
.lots th { text-align: left; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); }
.lots th, .lots td { padding: 0.35rem 0.5rem 0.35rem 0; vertical-align: top; }
.lots tr.inactive td { color: var(--muted); }
.lots button.link { margin-left: 0.4rem; font-size: 0.85rem; }

.inline-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.inline-form input[type="text"] { width: auto; flex: 1 1 8rem; padding: 0.4rem 0.5rem; }
.inline-form .error { flex-basis: 100%; margin: 0; }

.pager { display: flex; gap: 1rem; justify-content: center; margin: 1.25rem 0; }

/* Phones: photo above, each lot as a small labelled block. */
@media (max-width: 40rem) {
  .item { grid-template-columns: 1fr; }
  .item-photo img { max-height: 10rem; }
  .lots thead { display: none; }
  .lots tr { display: grid; grid-template-columns: 1fr 1fr; padding: 0.5rem 0; border-top: 1px solid var(--line); }
  .lots td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.75rem; }
}

/* --- Details line and form (brand, category, size, sex, description) ------ */

.details { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: baseline;
  margin-top: 0.4rem; font-size: 0.9rem; }
.details .description { flex-basis: 100%; margin: 0; color: var(--muted); }
.details-form { display: grid; gap: 0.5rem; width: 100%; }
.details-field { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.details-field > label:first-child { min-width: 6rem; margin: 0; }
.details-field input[type="text"], .details-field select {
  flex: 1 1 12rem; max-width: 24rem; padding: 0.4rem 0.5rem; font: inherit; }
.details-field textarea { flex: 1 1 100%; padding: 0.4rem 0.5rem; font: inherit; }
.details-field .error { flex-basis: 100%; margin: 0; }
.details-form button.save, .new-entry button.primary-small { padding: 0.45rem 0.9rem;
  color: #fff; background: var(--accent); border: 0; border-radius: var(--radius); }
.new-entry { padding: 0.5rem 0.75rem; border-left: 3px solid var(--accent);
  background: var(--bg); }
.new-entry p { margin: 0.25rem 0; }
.new-entry .similar button { margin: 0.15rem 0.25rem 0.15rem 0; }

/* --- Customs line and form ----------------------------------------------- */

.customs { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: baseline;
  margin-top: 0.4rem; font-size: 0.9rem; }
.customs-missing { color: var(--muted); }
.customs-form { display: grid; gap: 0.5rem; width: 100%; }
.customs-field { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.customs-field > label:first-child { min-width: 6rem; margin: 0; }
.customs-field input[type="text"] { width: auto; padding: 0.4rem 0.5rem; }
.customs-field .error { flex-basis: 100%; margin: 0; }
.customs-form .hint { margin: 0; font-size: 0.85rem; }
.customs-form button.save { padding: 0.45rem 0.9rem; color: #fff; background: var(--accent);
  border: 0; border-radius: var(--radius); }

/* --- Lot actions, sold elsewhere, photo upload ----------------------------- */

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }
.actions { white-space: nowrap; }
.actions button, label.button {
  display: inline-flex; align-items: center; min-height: 2.25rem; margin: 0 0.3rem 0.3rem 0;
  padding: 0.3rem 0.7rem; font: inherit; font-size: 0.85rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.actions button.primary-small { color: #fff; background: var(--accent); border-color: var(--accent); }
label.button { margin: 0.5rem 0 0; font-weight: 400; }
label.button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-upload { margin: 0; }
.actions .error { white-space: normal; }

.sold-form { display: grid; gap: 0.35rem; white-space: normal; min-width: 14rem; }
.sold-form label { margin: 0; font-weight: 500; }
.sold-form input { padding: 0.45rem 0.5rem; font: inherit; border: 1px solid var(--line);
  border-radius: var(--radius); }
.sold-form .row { display: flex; gap: 0.75rem; align-items: center; }
.sold-form button.save { padding: 0.5rem 0.9rem; color: #fff; background: var(--accent);
  border: 0; border-radius: var(--radius); }

/* --- Photo strip: all of an item's photos --------------------------------------- */
.photos-open { display: block; margin: 0.4rem auto 0; font-size: 0.85rem; }
.photo-strip { grid-column: 1 / -1; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.strip-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.strip-head button.link { margin-left: auto; }
.strip-sub { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.85rem; }
.strip { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }
.strip li { display: grid; gap: 0.3rem; width: 9rem; align-content: start; }
.strip img { display: block; width: 100%; height: 7rem; object-fit: contain; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius); }
.strip small { color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
.strip-actions { display: flex; gap: 0.3rem; }
.strip-actions button { min-width: 2.25rem; min-height: 2.25rem; padding: 0.2rem 0.5rem; font-size: 0.85rem;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.strip-actions button:disabled { opacity: 0.35; cursor: default; }
.strip-actions button.danger { margin-left: auto; color: var(--error); }

/* Phones: big enough to tap (44 px), the sold form across the full width. */
@media (max-width: 40rem) {
  .actions { grid-column: 1 / -1; white-space: normal; }
  .actions button, label.button { min-height: 2.75rem; font-size: 0.95rem; }
  .strip li { width: calc(50% - 0.375rem); }
  .strip-actions button { min-width: 2.75rem; min-height: 2.75rem; font-size: 0.95rem; }
  .sold-form { min-width: 0; }
  .sold-form input { min-height: 2.75rem; }
}

/* --- Imports (computer work: the preview table scrolls sideways if needed) ------- */
h2 { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
.messages li + li { margin-top: 0.4rem; }
.messages li.success { border-color: #b8d8b8; }
.messages li.warning { color: var(--warn); }
.crumbs { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.9rem; }
.crumbs a { color: inherit; }
.upload-card { max-width: 36rem; }
.upload-card p { margin-top: 0; }
.upload-card .help { display: block; margin-top: 0.25rem; font-size: 0.85rem; }
.upload-card button.save, .import-actions button.save, .button-link {
  display: inline-block; margin-top: 1rem; padding: 0.55rem 1rem; color: #fff; background: var(--accent);
  border: 0; border-radius: var(--radius); text-decoration: none; }
.list { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); }
.list th, .list td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); }
.list th { font-weight: 500; color: var(--muted); }

.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); }
.import-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.import-table th { text-align: left; font-weight: 500; color: var(--muted); }
.import-table th, .import-table td { padding: 0.3rem 0.4rem; vertical-align: top;
  border-bottom: 1px solid var(--line); }
.import-table input[type="text"] { width: auto; max-width: 100%; padding: 0.15rem 0.25rem;
  font-size: 0.8rem; }
/* Wide enough that messages wrap over a few lines, not one word per line. */
.import-table .result { width: 20rem; min-width: 16rem; }
.notes summary { color: var(--muted); cursor: pointer; }
.msg-info { color: var(--muted); }
.lvl-error { background: #f7dcd9; }
.lvl-warning { background: var(--warn-bg); }
.row-excluded td { opacity: 0.5; }
.from-file { display: block; font-size: 0.7rem; color: var(--muted); }
.msg-error { color: var(--error); }
.msg-warning { color: var(--warn); }
.import-summary { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; padding: 0; list-style: none; }
.pictures { white-space: nowrap; }
.pictures figure { display: inline-block; margin: 0 4px 4px 0; text-align: center; }
.pictures img { display: block; height: 60px; width: auto; }
.pictures figcaption { font-size: 0.65rem; color: var(--muted); }
.pictures .in-vap { padding-top: 4px; border-top: 1px dashed var(--line); }
.import-currency { margin: 0.5rem 0 1rem; }
.import-currency label { display: inline; margin-right: 0.4rem; }
.import-currency select { width: auto; }
.import-currency .rate { margin-left: 0.75rem; color: var(--muted); }
.banner { margin: 0.75rem; padding: 0.75rem; border-left: 4px solid var(--error); background: #f7dcd9; }
.banner label { display: inline; font-weight: 400; }
.import-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 1rem; }
.import-actions button { padding: 0.55rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); }
.import-actions button.save { margin-top: 0; border-color: var(--accent); }
.import-actions button.save:disabled { opacity: 0.45; cursor: default; }
.import-actions button.danger { margin-left: auto; color: var(--error); }

/* Two-factor login */
.steps { padding-left: 1.25rem; }
.steps li { margin: 0.5rem 0; }
.qr { margin: 0.75rem 0; }
.qr svg { display: block; width: 12rem; height: auto; }
.secret { display: block; margin-top: 0.4rem; font-size: 0.95rem; letter-spacing: 0.05em; word-break: break-all; }
details.backup { margin-top: 1.25rem; }
details.backup summary { color: var(--muted); cursor: pointer; }
details.backup button { margin-top: 0.75rem; padding: 0.55rem 1rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); }
.backup-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem 1rem; padding: 0;
  list-style: none; font-size: 1.05rem; }
.logout a { color: var(--muted); }
@media print { .topbar { display: none; } }

/* --- Lists page (Managers) ------------------------------------------------- */

.list-section h2 { margin: 0 0 0.75rem; font-size: 1.1rem; font-weight: 600; }
.list-section + .list-section { margin-top: 1.25rem; }
.list-add { margin-bottom: 0.75rem; max-width: 28rem; }
.list-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.list-table th { text-align: left; font-weight: 500; color: var(--muted);
  border-bottom: 1px solid var(--line); }
.list-table th, .list-table td { padding: 0.4rem 0.5rem 0.4rem 0; vertical-align: top; }
.list-table tbody tr + tr td { border-top: 1px solid var(--line); }
.list-actions { display: flex; flex-wrap: wrap; gap: 0.4rem 0.75rem; align-items: center; }
.list-actions summary { cursor: pointer; color: var(--accent); }
.list-actions select { padding: 0.35rem; font: inherit; }
.new-entry .primary-small + a { margin-left: 0.5rem; }

@media (max-width: 40rem) {
  .list-table thead { display: none; }
  .list-table tr { display: grid; grid-template-columns: 1fr auto; padding: 0.5rem 0; }
  .list-table td.list-actions { grid-column: 1 / -1; }
}

/* --- Pricing page (Managers) and price history ----------------------------- */

.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; }
.tabs a { padding: 0.4rem 0.9rem; color: var(--muted); text-decoration: none;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tabs a[aria-current="page"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.tabs .count { display: inline-block; min-width: 1.4rem; margin-left: 0.25rem; padding: 0 0.35rem;
  font-size: 0.8rem; text-align: center; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }
.tabs a[aria-current="page"] .count { background: #fff; }
.price-now { margin: 0.5rem 0 0.25rem; font-size: 1.05rem; }
.price-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.25rem 0 0.5rem; }
.price-actions form { margin: 0; }
.price-actions .inline-form input[type="text"] { flex: 0 1 7rem; }
button.secondary { padding: 0.45rem 0.9rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--accent); border-radius: var(--radius); }
.file-prices span, .file-prices small { display: block; }
.file-prices small.warn { color: var(--warn); font-weight: 600; }
.pricing-lots tr.needs-check td { background: var(--warn-bg); }
.pricing-lots .inline-form input[type="text"] { flex: 0 1 6rem; }
p.small { font-size: 0.85rem; margin: 0.4rem 0 0; }
.price-history { margin-top: 0.6rem; font-size: 0.9rem; }
.price-history summary { color: var(--muted); cursor: pointer; }
.history-table { width: 100%; margin-top: 0.4rem; border-collapse: collapse; font-size: 0.85rem; }
.history-table th { text-align: left; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); }
.history-table th, .history-table td { padding: 0.25rem 0.5rem 0.25rem 0; vertical-align: top; }

@media (max-width: 40rem) {
  .history-table thead { display: none; }
  .history-table tr { display: grid; grid-template-columns: 1fr 1fr; padding: 0.4rem 0;
    border-top: 1px solid var(--line); }
  .history-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.75rem; }
}

/* HTMX's loading indicators ("Uploading…"): hidden until a request runs.
   HTMX would inject these rules as a <style> tag, which the Content Security
   Policy blocks, so they live here (includeIndicatorStyles is off). */
.htmx-indicator { opacity: 0; visibility: hidden; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator {
  opacity: 1; visibility: visible; transition: opacity 200ms ease-in;
}
