:root {
  --bg: #f4f1ea;
  --bg-card: #fffdf8;
  --ink: #1f2933;
  --muted: #5f6b76;
  --line: #e4ddd0;
  --primary: #0f6b5c;
  --primary-hover: #0b5448;
  --accent: #c45c26;
  --sale: #1d4f91;
  --danger: #a12b2b;
  --warn: #8a6d1d;
  --success-bg: #e7f6ef;
  --warning-bg: #fff6df;
  --error-bg: #fdecec;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
  --font: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 107, 92, 0.08), transparent 30%),
    radial-gradient(circle at top right, rgba(196, 92, 38, 0.08), transparent 28%),
    var(--bg);
  min-height: 100vh;
}

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

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.brand-mark {
  font-size: 1.6rem;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  background: #e8f4f1;
  border-radius: 12px;
}

.brand strong { display: block; line-height: 1.1; }
.brand small { color: var(--muted); }

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

nav a {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

nav a:hover,
nav a.active {
  background: var(--primary);
  color: white;
  text-decoration: none;
}

nav a.nav-shop {
  background: #eef4ff;
  border: 1px solid #c5d4f0;
  color: var(--sale);
}

nav a.nav-shop:hover {
  background: var(--sale);
  color: white;
  border-color: var(--sale);
}

/* Sign-out is a POST form for CSRF safety */
nav form.nav-logout-form {
  display: inline;
  margin: 0;
  padding: 0;
}

nav button.nav-logout-btn {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

nav button.nav-logout-btn:hover {
  background: var(--primary);
  color: white;
}

.container {
  /* Use most of a widescreen so inventory/transaction tables fit without side-scroll */
  width: min(1760px, calc(100% - 2rem));
  max-width: 100%;
  margin: 1.25rem auto 3rem;
}

@media (min-width: 2000px) {
  .container {
    width: min(1920px, calc(100% - 3rem));
  }
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0 1rem 2rem;
}

.page-header { margin-bottom: 1.25rem; }
.page-header h1 { margin: 0 0 0.35rem; font-size: 1.9rem; }
.page-header p { margin: 0; color: var(--muted); max-width: 60ch; }
.row-between {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
}

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

.panel-header h2,
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.panel-header h2 { margin: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.stat-grid.compact { margin: 1rem 0; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.stat-card.accent { border-color: rgba(15, 107, 92, 0.35); background: #f1faf7; }
.stat-card.accent-sale { border-color: rgba(29, 79, 145, 0.3); background: #f2f6fc; }
.stat-card.warn { border-color: rgba(138, 109, 29, 0.35); background: #fff9eb; }

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.55rem;
  line-height: 1.1;
}

.stat-card small {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: #f7f3ea; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-warn {
  background: #c47a1a;
  border-color: #c47a1a;
  color: white;
}
.btn-warn:hover { background: #a86512; border-color: #a86512; }
.hidden { display: none !important; }
.small-line {
  font-size: 0.8rem;
  margin-top: 0.2rem;
  line-height: 1.25;
  max-width: 12rem;
}
.btn-ghost { background: transparent; }
.btn-lg { padding: 0.8rem 1.25rem; font-size: 1.05rem; width: 100%; margin-top: 0.5rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.flash-stack { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.flash {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.flash-success { background: var(--success-bg); border-color: #b7e2cb; }
.flash-warning { background: var(--warning-bg); border-color: #f0d58a; }
.flash-error { background: var(--error-bg); border-color: #f0b4b4; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Keep scroll affordance visible on trackpads / narrow screens */
  overscroll-behavior-x: contain;
}
table {
  width: 100%;
  border-collapse: collapse;
  /* Fixed column budget: scroll sideways on small screens instead of wrapping */
  table-layout: fixed;
  min-width: 1100px;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  /* Default: single-line cells; only notes may wrap (see .col-notes) */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
  overflow-wrap: normal;
}
th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
/* Notes: only column allowed to wrap; keep a readable min width */
th.col-notes,
td.col-notes {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  word-break: break-word;
  overflow-wrap: break-word;
  min-width: 12rem;
  line-height: 1.35;
}
/* Actions stay a real table-cell so row borders line up with Notes / other cols */
td.row-actions,
td.tx-actions-col {
  overflow: visible;
  text-overflow: unset;
  /* Never use display:flex on <td> — it breaks border alignment */
  display: table-cell;
  vertical-align: middle;
  text-align: right;
  white-space: nowrap;
}

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f0ebe1;
}
.thumb.large { width: 96px; height: 96px; }
.thumb.placeholder,
.detail-photo.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #efe9de;
}

.qty {
  display: inline-block;
  min-width: 2rem;
  text-align: center;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #e8f4f1;
}
.qty-low { background: #fff1d6; color: var(--warn); }
.qty-zero { background: #fdecec; color: var(--danger); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-purchase { background: #e8f4f1; color: var(--primary); }
.badge-sale { background: #e8eef8; color: var(--sale); }
.badge-adjustment { background: #f3efe7; color: var(--muted); }

.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 2rem; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}

.filter-bar input[type="search"] {
  flex: 1 1 240px;
}

.page-header-compact {
  margin-bottom: 0.65rem;
}
.page-header-compact h1 {
  margin-bottom: 0.15rem;
}
.page-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

label {
  display: block;
  font-weight: 650;
  margin: 0.75rem 0 0.35rem;
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="file"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: white;
}

textarea { resize: vertical; }

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  margin: 0;
}

.checkbox input { width: auto; }

.form-grid {
  display: grid;
  gap: 0.25rem 1rem;
}
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.scan-layout,
.detail-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.barcode-input {
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  font-family: var(--mono);
}

.steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.55;
}

.steps li { margin-bottom: 0.55rem; }

.success-panel { border-color: #b7e2cb; background: var(--success-bg); }

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

.detail-photo {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 12px;
  background: #efe9de;
  border: 1px solid var(--line);
}

.detail-photo.placeholder {
  min-height: 220px;
}

.side-stack {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.notes-box {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  background: #f7f3ea;
  border-radius: 12px;
}

.notes-box h3 { margin: 0 0 0.35rem; font-size: 0.95rem; }
.notes-box p { margin: 0; white-space: pre-wrap; }

.current-photo {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: white;
}

.filter-bar select {
  width: auto;
  min-width: 10rem;
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.btn-ai {
  margin-top: 0.55rem;
  width: 100%;
  background: #eef4ff;
  border-color: #c5d4f0;
  color: var(--sale);
}

.btn-ai:hover {
  background: #e0ebff;
}

.btn-ai-heavy {
  background: #f3e9f7;
  border-color: #d4b8e8;
  color: #6b3d8a;
}

.btn-ai-heavy:hover {
  background: #eadcf4;
}

.ai-lookup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.ai-lookup-actions .btn-ai {
  margin-top: 0;
  width: 100%;
  font-size: 0.9rem;
  padding: 0.55rem 0.5rem;
}

.lookup-mode-fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem 0.9rem;
  margin: 0.85rem 0 0.5rem;
  background: #faf8f4;
}

.lookup-mode-fieldset legend {
  font-weight: 700;
  padding: 0 0.35rem;
  font-size: 0.92rem;
}

.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0.45rem 0 0;
  font-weight: 500;
  cursor: pointer;
}

.radio-row input {
  width: auto;
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.radio-row span {
  line-height: 1.35;
}

.ai-banner {
  margin-bottom: 1rem;
}

.ai-banner p {
  margin: 0.35rem 0 0;
}

.status-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.detail-status {
  margin-top: 0.65rem;
}

.badge-completion-completed {
  background: #e8f4f1;
  color: var(--primary);
}

.badge-completion-not_completed {
  background: #fff1d6;
  color: var(--warn);
}

.badge-intent-for_sale {
  background: #e8eef8;
  color: var(--sale);
}

.badge-intent-keeper {
  background: #f3e9f7;
  color: #6b3d8a;
}

.badge-missing-missing_pieces,
.badge-missing-yes {
  background: #fdecec;
  color: var(--danger);
}
.badge-missing-verified_complete,
.badge-missing-no {
  background: #e8f4f1;
  color: var(--primary);
}
.badge-missing-bought_as_complete,
.badge-missing-bought_complete,
.badge-missing-nib {
  background: #e8eef8;
  color: var(--sale);
}
.badge-missing-unverified {
  background: #fff1d6;
  color: var(--warn);
}

.badge-status-in_stock {
  background: #e8f4f1;
  color: var(--primary);
}
.badge-status-pending_sale {
  background: #fff1d6;
  color: #9a5b00;
}
.badge-status-sold {
  background: #e8eef8;
  color: var(--sale);
}
.badge-status-removed {
  background: #f3efe7;
  color: var(--muted);
}

.pending-group { margin-bottom: 1rem; }
.pending-group-header h2 {
  font-size: 1.1rem;
  word-break: break-word;
}
/* Button row inside action cells — inline, not flex-on-td */
.row-actions .inline-form {
  display: inline-block;
  margin: 0 0 0 0.35rem;
  vertical-align: middle;
  line-height: 1;
}
.row-actions > a.btn,
.row-actions > .btn {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.35rem;
}
.row-actions > a.btn:first-child,
.row-actions > .btn:first-child,
.row-actions > .inline-form:first-child {
  margin-left: 0;
}
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.88rem;
  min-height: auto;
  font-weight: 600;
  line-height: 1.2;
  box-sizing: border-box;
}
.small-line {
  font-size: 0.85rem;
  margin-top: 0.15rem;
  /* nested sub-lines under nowrap cells still single-line */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* -------- Transactions table: fixed column sizes -------- */
.tx-table {
  min-width: 1180px;
}
.tx-table .tx-photo-col {
  width: 56px;
  padding-right: 0.35rem;
  overflow: visible;
}
.tx-table .tx-when-col { width: 9.75rem; }
.tx-table .tx-type-col { width: 7.75rem; }
.tx-table .tx-puzzle-col { width: 16rem; }
.tx-table .tx-qty-col { width: 3.25rem; text-align: center; }
.tx-table .tx-price-col { width: 5.25rem; }
.tx-table .tx-party-col { width: 9.5rem; }
.tx-table .tx-notes-col {
  width: 15rem;
  min-width: 12rem;
}
.tx-table .tx-actions-col {
  width: 9.25rem;
  text-align: right;
}

/* Unit detail history (no photo col) */
.tx-unit-table {
  min-width: 980px;
}
.tx-unit-table .tx-when-col { width: 9.75rem; }
.tx-unit-table .tx-type-col { width: 7.75rem; }
.tx-unit-table .tx-qty-col { width: 3.25rem; text-align: center; }
.tx-unit-table .tx-price-col { width: 5.25rem; }
.tx-unit-table .tx-party-col { width: 9.5rem; }
.tx-unit-table .tx-notes-col {
  width: 14rem;
  min-width: 12rem;
}
.tx-unit-table .tx-actions-col {
  width: 9.25rem;
  text-align: right;
}

/* Inventory list: fixed column sizes */
.inv-table {
  min-width: 1180px;
}
.inv-table .inv-photo-col { width: 56px; overflow: visible; }
.inv-table .inv-unit-col { width: 10.5rem; }
.inv-table .inv-title-col { width: 16rem; }
.inv-table .inv-brand-col { width: 8rem; }
.inv-table .inv-artist-col { width: 8rem; }
.inv-table .inv-pieces-col { width: 4.5rem; }
.inv-table .inv-condition-col { width: 9rem; }
.inv-table .inv-status-col { width: 8rem; }
.inv-table .inv-role-col { width: 5.5rem; }
.inv-table .inv-cost-col,
.inv-table .inv-sale-col { width: 5rem; }

/* Dashboard recent tx */
.dash-tx-table {
  min-width: 640px;
}
.dash-tx-table .tx-when-col { width: 9.75rem; }
.dash-tx-table .tx-type-col { width: 7rem; }
.dash-tx-table .tx-puzzle-col { width: auto; }
.dash-tx-table .tx-qty-col { width: 3.25rem; }
.dash-tx-table .tx-price-col { width: 5.25rem; }

.tx-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f0ebe3;
  display: block;
}
.tx-thumb.large {
  width: 72px;
  height: 72px;
  border-radius: 10px;
}
.tx-thumb-placeholder {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px dashed var(--line);
  background: #f7f3ea;
  font-size: 1.2rem;
}
.tx-thumb-placeholder.large {
  width: 72px;
  height: 72px;
  font-size: 1.6rem;
}
.tx-edit-identity {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.35rem;
}
.tx-voided {
  opacity: 0.62;
}
.tx-voided td {
  text-decoration: none;
}
.badge-voided {
  background: #f3e8e8;
  color: var(--danger);
  margin-left: 0.25rem;
}

/* Feature ideas page */
.idea-list {
  display: grid;
  gap: 0.85rem;
}
.idea-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  background: #fffdf8;
}
.idea-card-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}
.idea-body {
  margin-top: 0.55rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
  color: var(--ink);
}
.badge-priority-low {
  background: #f3efe7;
  color: var(--muted);
}
.badge-priority-normal {
  background: #e8f4f1;
  color: var(--primary);
}
.badge-priority-high {
  background: #fff1d6;
  color: #9a5b00;
}
.badge-priority-urgent {
  background: #fdecec;
  color: var(--danger);
}

.lookup-panel {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.lookup-code {
  font-size: 1.35rem;
  margin: 1rem 0 0.5rem;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-block {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.9rem;
  background: #2b1d1d;
  color: #f7d4d4;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
}

.debug-details {
  margin-top: 0.85rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 0.65rem;
}

.debug-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}

.debug-details summary:hover {
  color: var(--ink);
}

.debug-details[open] summary {
  margin-bottom: 0.35rem;
}

.pricing-box {
  margin: 0.75rem 0 0.25rem;
  padding: 0.75rem 0.9rem;
  background: #f1faf7;
  border: 1px solid #b7e2cb;
  border-radius: 12px;
}

.pricing-box p {
  margin: 0.35rem 0 0;
}

.pricing-box strong {
  display: block;
  margin-bottom: 0.15rem;
}

.field-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field-tag.public {
  background: #e8f4f1;
  color: var(--primary);
}

.field-tag.private {
  background: #f3e9f7;
  color: #6b3d8a;
}

.notes-box.public-box {
  background: #f1faf7;
}

.notes-box.private-box {
  background: #f7f1fa;
  border: 1px solid #e4d4ef;
}

.danger-zone {
  border-color: #f0b4b4;
  background: #fff8f8;
  margin-top: 1.25rem;
}

.danger-zone h2 {
  color: var(--danger);
}

.reset-list {
  margin: 0.5rem 0 1rem;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.5;
}

.reset-form {
  max-width: 28rem;
}

.reset-form input[type="text"] {
  font-family: var(--mono);
  letter-spacing: 0.06em;
}

@media (max-width: 800px) {
  .scan-layout,
  .detail-layout,
  .form-grid.two {
    grid-template-columns: 1fr;
  }
  .form-grid .full { grid-column: auto; }
}

/* ==========================================================================
   Inventory filters (LAST so they beat global select/label width:100%)
   Short dropdowns nested horizontally — do not stretch full page width.
   ========================================================================== */
form.inventory-filters {
  display: block;
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-sizing: border-box;
}

form.inventory-filters .inv-toolbar {
  display: block;
  margin: 0 0 0.45rem;
  line-height: 2.1rem;
}

form.inventory-filters input.inv-search[type="search"] {
  display: inline-block !important;
  width: 18rem !important;
  max-width: calc(100% - 10rem) !important;
  min-width: 10rem !important;
  vertical-align: middle;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.85rem !important;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
  margin: 0 0.4rem 0.25rem 0 !important;
}

form.inventory-filters .btn-compact {
  display: inline-block !important;
  vertical-align: middle;
  width: auto !important;
  padding: 0.4rem 0.9rem !important;
  min-height: 2.1rem;
  margin: 0 0.25rem 0.25rem 0;
  font-size: 0.9rem;
}

form.inventory-filters .inv-count {
  display: inline-block;
  vertical-align: middle;
  margin: 0 0 0.25rem 0.35rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Horizontal row of short chips (inline-block is more reliable than flex here) */
form.inventory-filters .inv-selects {
  display: block !important;
  width: 100%;
  font-size: 0; /* remove inline-block gaps weirdness; reset on children */
}

form.inventory-filters label.inv-chip {
  display: inline-block !important;
  vertical-align: top;
  width: 8rem !important;
  max-width: 8rem !important;
  margin: 0 0.4rem 0.45rem 0 !important;
  padding: 0 !important;
  font-size: 0.8rem;
  font-weight: 650;
  box-sizing: border-box;
}

form.inventory-filters label.inv-chip.inv-chip-wide {
  width: 9.5rem !important;
  max-width: 9.5rem !important;
}

form.inventory-filters label.inv-chip > span {
  display: block !important;
  font-size: 0.65rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
  margin: 0 0 0.15rem !important;
  white-space: nowrap;
}

form.inventory-filters label.inv-chip select,
form.inventory-filters label.inv-chip > select,
form.inventory-filters select {
  display: block !important;
  width: 100% !important;          /* of the 8rem chip only */
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem 0.35rem !important;
  font: inherit;
  font-size: 0.8rem !important;
  font-weight: 500;
  background: #fff;
  min-height: 1.9rem;
  margin: 0 !important;
  color: var(--ink);
}

@media (max-width: 520px) {
  form.inventory-filters label.inv-chip,
  form.inventory-filters label.inv-chip.inv-chip-wide {
    width: calc(50% - 0.35rem) !important;
    max-width: calc(50% - 0.35rem) !important;
  }
  form.inventory-filters input.inv-search[type="search"] {
    width: 100% !important;
    max-width: 100% !important;
  }
}
