/*
 * Ported from shy_inventory's original app/assets/stylesheets/application.css
 * during the Rails-engine migration into shy_hub.
 *
 * Deliberately DROPPED from the original file: the global element resets
 * (body/a/h1-h3/p/small) and the whole page-shell/sidebar/nav/flash system
 * (.app-shell, .sidebar*, .nav-link, .nav-icon, .content, .flash*, etc).
 * Those assumed this stylesheet owned the entire page; now shy_hub's own
 * layout + Shared::SidebarComponent + Shared::FlashComponent own that chrome, and
 * this file (like every engine's own stylesheet) is pulled in globally via
 * `stylesheet_link_tag :all` -- letting element-level rules like `body {}`
 * survive here would leak into every other page in the app, including
 * shy_hub's own dashboard and any other engine's views.
 *
 * Palette: this engine was originally a standalone dark-only theme. Its
 * variable names are now thin aliases onto shy_hub's shared `--shy-*`
 * design tokens (defined in the host's app/assets/stylesheets/
 * application.css). Every rule below still says `var(--surface)`,
 * `var(--accent)`, etc. -- they now resolve to the shared system, which
 * is light by default and switches to a dark palette under
 * prefers-color-scheme. Change colors there, not here.
 */
:root {
  --bg:             var(--shy-bg);
  --surface:        var(--shy-surface);
  --surface-2:      var(--shy-surface-alt);
  --surface-3:      var(--shy-surface-sunken);
  --border:         var(--shy-border);
  --border-strong:  var(--shy-border-strong);

  --text:           var(--shy-text);
  --text-dim:       var(--shy-text-muted);
  --text-faint:     var(--shy-text-faint);

  --accent:         var(--shy-brand);
  --accent-strong:  var(--shy-brand-hover);
  --accent-bg:      var(--shy-brand-tint);
  --accent-border:  var(--shy-brand-ring);

  --success:        var(--shy-success);
  --success-bg:     var(--shy-success-tint);
  --success-border: var(--shy-success);

  --warn:           var(--shy-warning);
  --warn-bg:        var(--shy-warning-tint);
  --warn-border:    var(--shy-warning);

  --danger:         var(--shy-danger);
  --danger-bg:      var(--shy-danger-tint);
  --danger-border:  var(--shy-danger);

  --radius-sm:  var(--shy-radius-sm);
  --radius:     var(--shy-radius);
  --radius-lg:  var(--shy-radius-lg);

  --shadow: var(--shy-shadow);
  --font:      var(--shy-font);
  --font-mono: var(--shy-font-mono);
}

* { box-sizing: border-box; }

.text-faint { color: var(--text-faint); }
.field small { display: block; margin-top: 0.35rem; font-size: 0.78rem; }

/* iOS Safari zooms the page on focusing any input smaller than 16px. */
@media (max-width: 860px) {
  .field input, .field select, .field textarea,
  .bulk-table input, .weight-field input, .colorway-name-input {
    font-size: 16px;
  }

  .stat-row, .form-row { flex-direction: column; }
}
/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge-reorder { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge-alert { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge-ok { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }

/* Stat tiles / cards */

.stat-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  flex: 1;
  min-width: 190px;
  box-shadow: var(--shadow);
}

.stat h3 {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0 0 0.85rem;
  font-weight: 600;
}

.stat .value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .label {
  color: var(--text-faint);
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

/* Forms */

form.inline { display: inline; }

.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.field textarea { resize: vertical; min-height: 4.5rem; }

.actions { margin-top: 1.1rem; }

/* Scoped to .engine-inventory (set on <main> for /inventory/* pages) so
   these bare element selectors don't style buttons on the dye engine or
   host pages, which are pulled the same global stylesheet by :all. */
.engine-inventory .actions button,
.engine-inventory .actions input[type="submit"],
.engine-inventory input[type="submit"],
.engine-inventory button[type="submit"] {
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--shy-brand-contrast);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
}

.engine-inventory .actions button:hover,
.engine-inventory .actions input[type="submit"]:hover,
.engine-inventory input[type="submit"]:hover,
.engine-inventory button[type="submit"]:hover {
  background: var(--accent-strong);
}

.engine-inventory .actions button:active,
.engine-inventory .actions input[type="submit"]:active,
.engine-inventory input[type="submit"]:active,
.engine-inventory button[type="submit"]:active {
  transform: translateY(1px);
}

/* Delete buttons (button_to) get no wrapping .actions class; give them a
   quieter, ghost danger treatment instead of the default filled button. */
form.inline button[type="submit"],
button.inline[type="submit"] {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-border);
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
}

form.inline button[type="submit"]:hover,
button.inline[type="submit"]:hover {
  background: var(--danger-bg);
}

.error-messages {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.error-messages ul { margin: 0; padding-left: 1.1rem; }

/* Batch page: full-size runs that don't add up to the defaults
   (batches/_count_check), the day before the drop and on drop day. */
.engine-inventory .count-check {
  background: var(--warn-bg);
  color: var(--text);
  border: 1px solid var(--warn-border);
  border-left-width: 4px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.engine-inventory .count-check strong { color: var(--warn); }
.engine-inventory .count-check small { color: var(--text-dim); }
.engine-inventory .count-check ul { margin: 0.4rem 0; padding-left: 1.1rem; }
.engine-inventory .count-check p { margin: 0; font-size: 0.9rem; color: var(--text-dim); }

/* Bulk row entry */

.bulk-table td { vertical-align: top; }

.bulk-table input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.bulk-table input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.bulk-table input[type="number"] { text-align: right; }

.field-error {
  display: block;
  color: var(--danger);
  margin-top: 0.3rem;
  font-size: 0.72rem;
}

.row-remove {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  font-family: inherit;
}

.row-remove:hover {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.bulk-actions { display: flex; gap: 0.6rem; align-items: center; }

.actions button.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.actions button.btn-ghost:hover {
  background: var(--surface-3);
  border-color: var(--accent-border);
}

/* Sidebar section grouping */

.nav-section-label {
  margin: 1.1rem 0.7rem 0.35rem;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Inline field rows (e.g. batch number + date side by side) */

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.form-row .field { flex: 1 1 12rem; min-width: 0; }

/* Below 860px .form-row becomes a column (see the mobile block near the top
   of this file), and in a column that 12rem basis applies to the HEIGHT --
   it stretched every field to ~192px tall with its label stranded at the
   top, leaving a screenful of dead space between fields on a phone.
   This override MUST come after the rule above: a media query adds no
   specificity, so the same selector earlier in the file just loses. */
@media (max-width: 860px) {
  .form-row .field { flex: 0 0 auto; }
}

/* Data tables. Every inventory table is wrapped in .table-scroll, which
   is both the horizontal scroll container for wide tables AND the visual
   frame (border, rounding, elevation). Scoping the table rules under it
   keeps them from leaking onto other engines' / host pages via
   `stylesheet_link_tag :all`. */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.table-scroll table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-scroll thead th {
  padding: 0.7rem 0.9rem;
  text-align: left;
  vertical-align: bottom;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-scroll tbody td {
  padding: 0.65rem 0.9rem;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.table-scroll tbody tr:first-child td { border-top: none; }

.table-scroll tbody tr:hover td { background: var(--surface-2); }

/* Bulk add/edit tables are dense input grids -- tighten them up. */
.table-scroll .bulk-table thead th,
.table-scroll .bulk-table tbody td { padding: 0.4rem 0.5rem; }
.table-scroll .bulk-table tbody td { vertical-align: top; }

.sub-th {
  background: var(--surface-2);
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: none;
  letter-spacing: normal;
}

/* Colorway entry cards (batch production grid) */

.colorway-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

.colorway-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.colorway-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.65rem 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-3);
}

.colorway-name-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.35rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.colorway-name-input::placeholder { color: var(--text-faint); font-weight: 500; }

.colorway-name-input:focus {
  outline: none;
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

.colorway-card-body { padding: 0.15rem 0.85rem; }

.weight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.weight-row:last-child { border-bottom: none; }

.weight-label {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weight-inputs { display: flex; gap: 0.5rem; flex-shrink: 0; }

.weight-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.weight-field span {
  font-size: 0.62rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* The tap count hangs off the label's right edge, so showing it doesn't
   shift the centred label or the row's height. */
.weight-field-label { position: relative; }

.tap-count {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-left: 0.3rem;
  min-width: 1.4rem;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
}
.tap-count[hidden] { display: none; }

.weight-field input {
  width: 60px;
  padding: 0.4rem;
  text-align: center;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.weight-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ── Dashboard: shopping list ───────────────────────────────────── */
/* Two halves: what to buy, and how to add to it. Collapses to one column
   before the store cards inside the left half get squeezed. */
.engine-inventory .shopping-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 62rem) {
  .engine-inventory .shopping-layout { grid-template-columns: minmax(0, 1fr); }
}

.engine-inventory .request-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.9rem 1rem 1rem;
}

.engine-inventory .request-card__title {
  margin: 0;
  font-size: 1rem;
}

.engine-inventory .request-card__hint {
  margin: 0.25rem 0 0.9rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.engine-inventory .request-card .actions { margin-top: 0.9rem; }

.engine-inventory .shopping-count {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 0.5rem;
}

.engine-inventory .shopping-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  align-items: start;
}

.engine-inventory .shopping-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.75rem 0.9rem;
}

.engine-inventory .shopping-group__store {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.engine-inventory .shopping-list { list-style: none; margin: 0; padding: 0; }

.engine-inventory .shopping-list__row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}
.engine-inventory .shopping-list__row:first-child { border-top: none; }

.engine-inventory .shopping-list__name { flex: 1 1 auto; min-width: 0; }

.engine-inventory .shopping-list__qty {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.engine-inventory .shopping-list__tag {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
}

.engine-inventory .shopping-foot { color: var(--text-dim); font-size: 0.9rem; }

.engine-inventory .shopping-list__buy,
.engine-inventory .shopping-list__confirm,
.engine-inventory .shopping-list__cancel {
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-dim);
  cursor: pointer;
}
.engine-inventory .shopping-list__buy:hover,
.engine-inventory .shopping-list__cancel:hover { color: var(--text); border-color: var(--text-dim); }

/* The confirm is the affirmative action once the row is open, so it reads as
   the primary button -- but it's a submit, and the engine's blanket
   `button[type=submit]` rule is more specific than a bare class, hence the
   element qualifier. */
.engine-inventory button.shopping-list__confirm {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--shy-brand-contrast);
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
}

/* Its own line rather than competing with the item name for the row's
   width -- these cards are only ~15rem wide, and squeezing a name, a
   quantity, a field and two buttons onto one line wrapped the name into the
   number. */
.engine-inventory .shopping-list__buyform {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  flex: 1 0 100%;
  margin-top: 0.15rem;
}
.engine-inventory .shopping-list__buyform[hidden] { display: none; }

.engine-inventory .shopping-list__buyqty {
  width: 4.5rem;
  padding: 0.2rem 0.35rem;
  text-align: right;
  font-family: inherit;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
}


/* ── Unsaved-changes bar (batch form) ───────────────────────────── */
/* The SLOT carries the stickiness and is permanently zero-height, so the
   bar inside it sits outside normal flow -- showing or hiding the bar
   shifts nothing on the page. It rides just below the host shell's own
   sticky top bar (min-height 3rem), with a gap. */
.unsaved-bar-slot {
  position: sticky;
  top: 3.85rem;
  z-index: 25;
  height: 0;
}

/* Always rendered, never `display: none` -- it costs no layout inside a
   zero-height slot, and `display` can't be transitioned, so keeping it in
   the box tree is what lets the fade/slide run in BOTH directions. The
   delayed `visibility` step keeps it un-clickable once faded out (it floats
   over the form) without cutting the fade short. */
.unsaved-bar {
  display: flex;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-0.4rem);
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  /* --warn-bg is a 15%-alpha tint in dark mode, and this bar now floats over
     the form, so composite it onto an opaque surface or the fields beneath
     read straight through it. */
  background: linear-gradient(var(--warn-bg), var(--warn-bg)), var(--surface-2);
  box-shadow: var(--shadow);
}
.unsaved-bar.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s;
}

@media (prefers-reduced-motion: reduce) {
  .unsaved-bar, .unsaved-bar.is-visible { transition-duration: 0s; }
}

.unsaved-bar-text {
  color: var(--warn);
  font-weight: 700;
  font-size: 0.9rem;
}

/* Appearance comes from the engine's own `button[type=submit]` rule above --
   which beats a plain .class selector on specificity anyway. */
.unsaved-bar .unsaved-bar-save { flex: 0 0 auto; }

/* ── Number steppers (batch entry cards) ────────────────────────── */
.stepper { display: flex; align-items: stretch; gap: 0.25rem; }

.stepper-btn {
  width: 2rem;
  flex: 0 0 2rem;
  font-size: 1.1rem;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.stepper-btn:hover { background: var(--surface-3); color: var(--text); }
.stepper-btn:active { transform: translateY(1px); }

/* The header button matches the dashboard's, just sized for the card. */
.colorway-card-header .btn-misfit-link {
  flex: 0 0 auto;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
}

/* ── Dashboard: current batch ───────────────────────────────────── */
.engine-inventory .section-heading {
  margin-top: 2.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.engine-inventory .current-batch {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem 1.1rem 0.35rem;
  margin-bottom: 1.5rem;
}
.engine-inventory .current-batch-none { padding-bottom: 1.1rem; }
.engine-inventory .current-batch h2 { margin: 0; }
.engine-inventory .current-batch-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.engine-inventory .current-batch-sub {
  margin: 0.2rem 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.engine-inventory .current-batch-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.engine-inventory .current-batch-empty { color: var(--text-dim); }

.engine-inventory .colorway-list { list-style: none; margin: 0.9rem 0 0; padding: 0; }
.engine-inventory .colorway-list-item {
  padding: 0.65rem 0;
  border-top: 1px solid var(--border);
}
/* Name and its button share one line with the button pushed to the far
   edge; the weight chips wrap underneath, so every row reads the same way
   however many chips a colorway has. */
.engine-inventory .colorway-list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}
.engine-inventory .colorway-list-name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.engine-inventory .colorway-list-counts {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}

.engine-inventory .weight-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--surface-2);
}
.engine-inventory .weight-chip-name { color: var(--text-dim); }
.engine-inventory .weight-chip-qty { font-weight: 700; }
.engine-inventory .weight-chip.has-misfits { border-color: var(--warn-border); background: var(--warn-bg); }
.engine-inventory .weight-chip-misfit { color: var(--warn); font-weight: 600; }

/* ── Misfit transfer ────────────────────────────────────────────── */
.btn-misfit-link,
.btn-primary-link,
.engine-inventory .btn-ghost-link {
  display: inline-block;
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.engine-inventory .btn-primary-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.engine-inventory .btn-misfit-link { background: var(--surface-2); color: var(--text); }
.btn-misfit-link:hover,
.engine-inventory .btn-ghost-link:hover { background: var(--surface); border-color: var(--text-dim); }

.engine-inventory .colorway-card-misfit {
  padding: 0.5rem 0.85rem 0;
  display: flex;
  justify-content: flex-end;
}

.engine-inventory .misfit-page { max-width: 40rem; }
.engine-inventory .misfit-sub { color: var(--text-dim); margin: -0.4rem 0 1rem; }
.engine-inventory .misfit-help {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.engine-inventory .misfit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  align-items: center;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}
.engine-inventory .misfit-row-head { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.engine-inventory .misfit-weight { font-weight: 700; font-size: 1.05rem; }
.engine-inventory .misfit-current { color: var(--text-dim); font-size: 0.85rem; }

.engine-inventory .misfit-controls { display: flex; align-items: center; gap: 0.4rem; }
.engine-inventory .misfit-step {
  width: 2.6rem;
  height: 2.6rem;
  font-size: 1.35rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.engine-inventory .misfit-step:hover { background: var(--surface); border-color: var(--text-dim); }
.engine-inventory .misfit-step:active { transform: translateY(1px); }
.engine-inventory .misfit-input {
  width: 4.5rem;
  height: 2.6rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.engine-inventory .misfit-preview {
  grid-column: 1 / -1;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.engine-inventory .misfit-row.is-changed .misfit-preview {
  color: var(--warn);
  font-weight: 700;
}

.engine-inventory .misfit-actions { display: flex; gap: 0.75rem; align-items: center; }

/* Steppers make each weight field wider; stack the row on a narrow
   phone so the weight name isn't squeezed to an ellipsis. */
@media (max-width: 26rem) {
  .weight-row { flex-direction: column; align-items: stretch; gap: 0.4rem; }
  .weight-inputs { justify-content: space-between; }
}

@media (max-width: 30rem) {
  .misfit-row { grid-template-columns: 1fr; }
  .misfit-controls { justify-content: flex-start; }
}

/* ── Batch labels (Avery CSV) ───────────────────────────────────── */
.engine-inventory .label-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
}
.engine-inventory .btn-ghost-button {
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.engine-inventory .btn-ghost-button:hover { background: var(--surface-3); border-color: var(--accent-border); }
/* A secondary submit (the labels page's CSV) stays ghost inside .actions,
   whose filled-button rule would otherwise win on specificity. */
.engine-inventory .actions button.btn-ghost-button {
  padding: 0.55rem 1.1rem;
  border-color: var(--border-strong);
  background: transparent;
  color: var(--text);
}
.engine-inventory .actions button.btn-ghost-button:hover { background: var(--surface-3); border-color: var(--accent-border); }
.engine-inventory .actions button.btn-ghost-button:disabled { opacity: 0.5; cursor: not-allowed; }
.engine-inventory .label-total {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.engine-inventory .label-table input[type="number"] { width: 6rem; }
.engine-inventory .label-table .label-all-row td { background: var(--surface-2); }
.engine-inventory .label-symbol-input { width: 4rem; text-align: center; }

.engine-inventory .label-table .label-tick { width: 2.25rem; text-align: center; vertical-align: middle; }
.engine-inventory .label-table .label-tick input { width: auto; }
.engine-inventory .label-table label { cursor: pointer; }
/* An unticked colorway stays editable but reads as left out. */
.engine-inventory .label-table tr.is-unticked td:not(.label-tick) { opacity: 0.45; }

/* Dharma Trading cart on the shopping list (shopping_list/_dharma_cart). */
.engine-inventory .dharma-cart { margin-bottom: 2rem; }
.engine-inventory .dharma-cart__num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.engine-inventory .dharma-cart__table tfoot td {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.engine-inventory .dharma-cart__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.engine-inventory .dharma-cart__actions form { margin: 0; }
.engine-inventory .dharma-cart__open {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--shy-brand-contrast);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
}
.engine-inventory .dharma-cart__open:hover { background: var(--accent-strong); }
/* The second action is the quieter one: it only records what you did. */
.engine-inventory .dharma-cart__actions button[type="submit"] {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
.engine-inventory .dharma-cart__actions button[type="submit"]:hover { background: var(--surface-3); }
.engine-inventory .dharma-cart__on-order { color: var(--text-dim); font-size: 0.9rem; }
.engine-inventory .shopping-list__tag--ordered { background: var(--success-bg); color: var(--success); }
/* Phone: drop the per-unit price so the subtotal fits without scrolling. */
@media (max-width: 600px) {
  .engine-inventory .dharma-cart__each { display: none; }
  .engine-inventory .dharma-cart__table th,
  .engine-inventory .dharma-cart__table td { padding-left: 0.5rem; padding-right: 0.5rem; }
}
