:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --ink: #1c1917;
  --muted: #78716c;
  --card: #fffcf7;
  --line: #e7e0d4;
  --accent: #c2410c;
  --accent-ink: #fff7ed;
  --danger: #b91c1c;
  --shadow: 0 18px 50px rgba(28, 25, 23, 0.08);
  font-family: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #fff8ee, var(--bg) 42%);
  color: var(--ink);
}
main { padding: 2rem 1.25rem 3rem; }
h1 { margin: 0.15rem 0 0.5rem; font-size: 1.8rem; letter-spacing: -0.03em; }
p { color: var(--muted); }
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card {
  width: min(100%, 22rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}
.auth-copy { margin: 0 0 1.25rem; }
.auth-error {
  margin: 0 0 1rem;
  color: var(--danger);
  font-weight: 600;
}
.pin-input {
  width: 100%;
  letter-spacing: 0.7em;
  text-align: center;
  font-size: 1.6rem;
  padding: 0.7rem 0.5rem 0.7rem 1.1rem;
  border-radius: 0.9rem;
  border: 1px solid var(--line);
  background: #fff;
  margin-bottom: 1rem;
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}
.pin-pad button {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 0.9rem;
  min-height: 3.2rem;
  font-size: 1.15rem;
  font-weight: 650;
  cursor: pointer;
}
.pin-pad button:hover { background: #fff7ed; }
.pin-enter {
  background: var(--accent) !important;
  color: var(--accent-ink);
  border-color: transparent !important;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.topbar form { margin: 0; }
.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.55rem 0 0.65rem;
}
.nav-active,
a.nav-active:hover {
  background: var(--accent) !important;
  color: var(--accent-ink) !important;
  border-color: transparent !important;
}
.status-cancelled {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}
.ghost {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}
button.ghost.danger { color: var(--danger); border-color: #fecaca; }
button.primary, .primary {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-weight: 650;
}
button.primary.danger { background: var(--danger); color: #fff; }
a.primary { text-decoration: none; display: inline-block; }
.form-error {
  margin: 0 0 1rem;
  color: var(--danger);
  font-weight: 600;
}
.product-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.85rem 1rem;
  margin: 0 0 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.product-form label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 650;
}
.product-form .form-wide { grid-column: 1 / -1; }
.product-form input,
.product-form select,
.product-form textarea {
  appearance: none;
  min-height: 2.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 550;
}
.product-form textarea { min-height: 8rem; resize: vertical; }
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.form-actions a.ghost { text-decoration: none; color: inherit; }
.draft-saved {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.product-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--muted);
}
.product-form.htmx-request,
.product-form.htmx-request button {
  opacity: 0.65;
  pointer-events: none;
}
.lede { margin: 0; font-size: 0.92rem; }
.kicker { margin: 0 0 0.2rem; font-size: 0.85rem; }
.kicker a { color: var(--accent); text-decoration: none; font-weight: 650; }
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.7rem;
  margin: 0 0 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 650;
}
.filters .filter-q { flex: 1 1 16rem; min-width: 12rem; }
.filters select,
.filters input[type="search"],
.filters input[type="text"],
.filters input[type="number"],
.filters input[type="date"] {
  appearance: none;
  min-height: 2.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 550;
}
.filters a.ghost { text-decoration: none; color: inherit; }
.catalog td.empty {
  text-align: center;
  padding: 1.5rem 0.7rem;
  color: var(--muted);
  font-weight: 550;
}
.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 16rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}
table.catalog {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.catalog th, .catalog td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.catalog th {
  position: sticky;
  top: 0;
  background: #fff7ed;
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  z-index: 1;
}
.catalog th a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  white-space: nowrap;
}
.catalog th a:hover { color: var(--accent); }
.catalog th.sorted a { color: var(--accent); }
.catalog td.name { min-width: 14rem; font-weight: 600; }
.catalog tr.review-approved td { background: #f0fdf4; }
.catalog tr.review-rejected td,
.catalog tr.sale-short td { background: #fef2f2; }
.sale-stock-note { color: var(--danger); font-size: 0.85rem; }
.actions form.inline { display: inline; }
.actions .review-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.product-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.catalog .thumb-link {
  flex: 0 0 2.75rem;
  line-height: 0;
  border-radius: 0.45rem;
  text-decoration: none;
  color: inherit;
}
.catalog .thumb {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  object-fit: cover;
  object-position: center;
  border-radius: 0.45rem;
  border: 1px solid var(--line);
  background: #fff;
}
.catalog .thumb-link:hover .thumb { border-color: var(--accent); }
.catalog .thumb-empty { display: block; }
.catalog .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.diff-pos { color: #15803d; font-weight: 650; }
.diff-neg { color: var(--danger); font-weight: 650; }
.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.detail-actions { margin-bottom: 1.25rem; }
.chip {
  display: inline-block;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
}
a.chip:hover, button.chip:hover { background: #fff7ed; border-color: var(--accent); color: var(--accent); }
button.chip {
  appearance: none;
  font: inherit;
  cursor: pointer;
}
.chip-danger { color: var(--danger); background: #fef2f2; border-color: #fecaca; }
button.chip.chip-danger:hover { background: #fee2e2; border-color: var(--danger); color: var(--danger); }
.chip-disabled { color: #a8a29e; background: #f5f5f4; }
.match-exact { color: #15803d; background: #f0fdf4; border-color: #bbf7d0; }
.match-partial { color: #a16207; background: #fffbeb; border-color: #fde68a; }
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.85rem 1.25rem;
  margin: 0 0 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.facts div { margin: 0; }
.facts dt { margin: 0; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.facts dd { margin: 0.15rem 0 0; font-weight: 650; }
.facts dd.review-approved { color: #15803d; }
.facts dd.review-rejected { color: var(--danger); }
.notes-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.notes-text { white-space: pre-wrap; }
.notes-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0 0 0.9rem;
  font-size: 0.85rem;
}
.notes-field textarea,
.notes-field input,
.notes-field select {
  width: 100%;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--ink);
}
.notes-field textarea {
  min-height: 7rem;
  resize: vertical;
}
.notes-field input,
.notes-field select {
  min-height: 2.4rem;
}
h2 { font-size: 1.05rem; margin: 1.5rem 0 0.7rem; }
.desc { white-space: pre-wrap; }
.thumbs { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.thumb-btn {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  border-radius: 0.75rem;
  line-height: 0;
}
.thumbs img {
  width: 7.5rem;
  height: 7.5rem;
  object-fit: cover;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: #fff;
}
.thumb-btn:hover img { border-color: var(--accent); }
html.lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 2.5rem 1.25rem 1.25rem;
  background: rgba(28, 25, 23, 0.72);
}
.lightbox-img {
  max-width: min(96vw, 72rem);
  max-height: min(88vh, 56rem);
  object-fit: contain;
  border-radius: 0.85rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  background: #fff;
}
.lightbox-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  appearance: none;
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: #fff7ed; color: var(--accent); }
.confirm-dialog {
  width: min(100%, 26rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1.4rem 1.3rem 1.2rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}
.confirm-dialog h2 { margin: 0 0 0.45rem; }
.confirm-dialog p { margin: 0 0 1.1rem; }
.confirm-dialog .form-actions { margin: 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.catalog-dialog {
  width: min(100%, 52rem);
  max-height: min(88vh, 48rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 1rem;
}
.catalog-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.catalog-dialog-head h2 { margin: 0; }
.catalog-search { display: block; margin-bottom: 0.75rem; }
.catalog-search input[type="search"] {
  width: 100%;
  margin-top: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.45rem 0.65rem;
  font: inherit;
}
.catalog-dialog-list { max-height: min(56vh, 28rem); }
.lightbox[hidden] { display: none !important; }
.inline-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin: 0;
}
.qty-input,
.money-input {
  width: 5.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  padding: 0.25rem 0.4rem;
  font: inherit;
}
.money-input { width: 8rem; }
.catalog tfoot td {
  font-weight: 700;
  background: #fff7ed;
  border-bottom: 0;
}
