/* Level Up Hobbies — Buy Pricing
   Brand restyle: tokens lifted from leveluphobbies.com (navy ink + gold + cream),
   adapted to a dark, torch-lit counter theme. Styling only — no logic changes. */

@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700;12..96,800&family=Bowlby+One&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=JetBrains+Mono:wght@500;700&display=swap");

:root {
  /* Page is natively dark — stops browser auto-dark-mode from recoloring it. */
  color-scheme: dark;

  /* --- Brand palette (verbatim from leveluphobbies.com) --- */
  --ink: #0a1f4d;
  --ink-2: #061336;
  --ink-3: #03081c;
  --yellow: #ffc93c;
  --yellow-2: #ffb800;
  --yellow-3: #ffd86b;
  --red: #e53935;
  --cream: #f2ebd8;
  --cream-2: #e8dfc5;
  --paper: #fff8e5;

  /* --- Dark-theme roles --- */
  --bg: var(--ink-3);
  --panel: #0a1838;
  --panel-2: #102452;
  --border: #1c356f;
  --text: var(--cream);
  --text-strong: var(--paper);
  --muted: rgba(242, 235, 216, 0.62);
  --accent: var(--yellow);
  --accent-2: var(--yellow-2);
  --danger: #ff5a52;

  /* Money roles use brand game colors so cash/credit/shelf stay distinct */
  --cash: #22c079; /* green */
  --credit: #b583ff; /* purple */
  --shelf: #5aa9ff; /* blue */
  --mtg: #f97316; /* brand MTG orange */
  --pokemon: #ffc93c; /* brand Pokémon yellow */

  /* --- Type --- */
  --ff: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ff-dis: "Bricolage Grotesque", system-ui, sans-serif;
  --ff-chunk: "Bowlby One", system-ui, sans-serif;
  --ff-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --shadow-hard: 0 4px 0 0 #00030f;
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  overflow-x: hidden; /* never allow sideways scroll on mobile */
  background-color: var(--bg);
  /* Torch-lit dot grid (gold motes on deep navy) */
  background-image: radial-gradient(circle, rgba(255, 201, 60, 0.05) 1px, transparent 1.6px);
  background-size: 22px 22px;
  color: var(--text);
  font-family: var(--ff);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: 40px;
  position: relative;
}

/* Warm torch glow from the top */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 360px;
  background: radial-gradient(ellipse at 50% -10%, rgba(255, 201, 60, 0.12), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(6, 19, 54, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo {
  height: 42px;
  width: auto;
  display: block;
}

.brand-tag {
  font-family: var(--ff-dis);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--ink-3);
  background: var(--accent);
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* --- Toggle groups (game / condition / finish / mode / company) --- */
.game-toggle,
.cond-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--ink-2);
  padding: 5px;
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
}

.cond-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 10px;
  font-weight: 700;
}

.game-btn,
.cond-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--cream);
  font-family: var(--ff-dis);
  font-size: 16px;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  min-height: 44px;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.game-btn:hover,
.cond-btn:hover {
  color: var(--paper);
}

.game-btn.active,
.cond-btn.active {
  background: var(--accent);
  color: var(--ink-3);
}

/* Game-specific accent on the active toggle */
#gameToggle .game-btn[data-game="magic"].active {
  background: var(--mtg);
  color: #1a0c02;
}
#gameToggle .game-btn[data-game="pokemon"].active {
  background: var(--pokemon);
  color: var(--ink-3);
}
#gameToggle .game-btn[data-game="onepiece"].active {
  background: #3b82f6; /* brand One Piece blue */
  color: #fff;
}
#gameToggle .game-btn[data-game="lorcana"].active {
  background: #a855f7; /* brand Lorcana purple */
  color: #fff;
}
#gameToggle .game-btn[data-game="riftbound"].active {
  background: #10b981; /* teal-green */
  color: #06231a;
}

/* --- Controls --- */
.controls {
  padding: 18px 20px 6px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1240px;
  margin: 0 auto;
}

.search-row {
  display: flex;
  gap: 10px;
}

#searchInput {
  flex: 1;
  background: var(--ink-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: var(--ff);
  font-size: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-pill);
  min-height: 56px;
}

#searchInput::placeholder {
  color: var(--muted);
}

#searchInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 201, 60, 0.18);
}

/* Chunky pill button — the brand signature (offset hard shadow) */
.primary,
.add-btn,
.btn-primary {
  appearance: none;
  font-family: var(--ff-dis);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.005em;
  background: var(--accent);
  color: var(--ink-3);
  border: 2.5px solid var(--accent);
  border-radius: var(--radius-pill);
  padding: 0 26px;
  min-height: 56px;
  cursor: pointer;
  box-shadow: var(--shadow-hard);
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), background 0.16s var(--ease);
}

.primary:hover,
.add-btn:hover:not(:disabled),
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 0 #00030f;
  background: var(--yellow-3);
}

.primary:active,
.add-btn:active:not(:disabled),
.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 0 #00030f;
}

.btn-ghost {
  appearance: none;
  font-family: var(--ff-dis);
  font-weight: 700;
  font-size: 15px;
  background: transparent;
  color: var(--cream);
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
  transition: border-color 0.16s var(--ease), color 0.16s var(--ease);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.scan-hint {
  font-size: 13px;
  margin: -6px 0 0;
}

/* Collection intake */
.intake-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.import-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.intake-msg {
  font-size: 13px;
}

.import-unmatched {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
}

.import-unmatched summary {
  cursor: pointer;
  font-family: var(--ff-dis);
  font-weight: 700;
  color: var(--danger);
}

.unmatched-row {
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.bl-qty {
  color: var(--accent);
  font-family: var(--ff-mono);
}

/* "Try another finish" hint on a result card */
.finish-hint {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 13px;
}

.finish-hint-btn {
  background: var(--ink-2);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-pill);
  padding: 3px 12px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--ff);
}

/* Batch paste */
.batch-paste {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
}

.batch-paste summary {
  cursor: pointer;
  font-family: var(--ff-dis);
  font-weight: 700;
  color: var(--cream);
}

.batch-paste textarea {
  width: 100%;
  margin-top: 12px;
  background: var(--ink-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: var(--ff);
  font-size: 17px;
  padding: 12px 14px;
  border-radius: var(--radius);
  resize: vertical;
}

.batch-paste textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Bulk lot form */
.bulk-lot {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
}

.bulk-lot summary {
  cursor: pointer;
  font-family: var(--ff-dis);
  font-weight: 700;
  color: var(--cream);
}

.bulk-form {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 12px;
}

.bulk-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.bulk-form input,
.bulk-form select {
  background: var(--ink-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: var(--ff);
  font-size: 18px;
  padding: 10px 12px;
  border-radius: var(--radius);
  min-height: 48px;
}

.bulk-form select {
  min-width: 280px;
}

.bulk-form input {
  width: 130px;
}

.bulk-add-btn {
  min-height: 48px;
  font-size: 16px;
  padding: 0 22px;
  box-shadow: 0 3px 0 0 #00030f;
}

.bulk-rates {
  margin-top: 12px;
}

.bulk-rates > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.bulk-rates-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.bulk-rate-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bulk-rate-label {
  flex: 1 1 220px;
  font-weight: 600;
  color: var(--cream);
}

.bulk-rate-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.bulk-rate-field input {
  background: var(--ink-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 16px;
  padding: 8px 10px;
  border-radius: 10px;
  width: 90px;
}

.mode-row {
  display: flex;
}

.cond-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.finish-group {
  /* shares .cond-group styling */
}

.grade-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.grade-select select,
.basis-row select,
.basis-row input {
  background: var(--ink-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: var(--ff);
  font-size: 18px;
  padding: 10px 14px;
  border-radius: var(--radius);
  min-height: 48px;
}

.grade-select select {
  min-width: 160px;
}

/* --- Price basis row --- */
.basis-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.basis-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.basis-row select {
  min-width: 220px;
}

.basis-row input {
  width: 130px;
}

/* --- Rules panel --- */
.rules {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
}

.rules summary {
  cursor: pointer;
  font-family: var(--ff-dis);
  font-weight: 700;
  color: var(--cream);
}

.rules-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.rules-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  gap: 6px;
  font-weight: 700;
}

.rules-grid input {
  background: var(--ink-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 20px;
  padding: 10px 12px;
  border-radius: var(--radius);
  width: 110px;
}

.rules-cond {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.hint {
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 0;
}

/* --- Status line --- */
.status {
  max-width: 1240px;
  margin: 0 auto;
  padding: 4px 20px;
  min-height: 24px;
  color: var(--muted);
  font-weight: 500;
}

.status.error {
  color: var(--danger);
}

/* --- Results --- */
.results {
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 20px;
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 16px;
  align-items: center;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
}

.card img {
  width: 58px;
  border-radius: 8px;
  background: var(--ink-2);
}

.card .thumb-empty {
  width: 58px;
  height: 80px;
  border-radius: 8px;
  background: var(--ink-2);
  border: 1px dashed var(--border);
}

.card.flagged {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft), inset 0 0 0 1px var(--accent);
}

.card-info .name {
  font-family: var(--ff-dis);
  font-size: 20px;
  font-weight: 800;
  color: var(--text-strong);
}

.card-info .meta {
  font-size: 13px;
  color: var(--muted);
}

/* Source comparison chips */
.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 13px;
  font-size: 14px;
}

.chip-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.chip-val {
  font-family: var(--ff-mono);
  font-weight: 700;
}

.chip-val.muted {
  font-weight: 500;
}

.chip-off {
  opacity: 0.6;
}

.chip-ref {
  border-style: dashed;
}

.chip-flag {
  background: rgba(255, 201, 60, 0.16);
  border-color: var(--accent);
  color: var(--accent);
  font-family: var(--ff-dis);
  font-weight: 800;
}

/* Offer column */
.offer {
  display: flex;
  gap: 22px;
  align-items: center;
  text-align: right;
}

.offer .num {
  display: flex;
  flex-direction: column;
  min-width: 92px;
}

.offer .num .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.offer .num .val {
  font-family: var(--ff-mono);
  font-size: 27px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.val.cash {
  color: var(--cash);
}
.val.credit {
  color: var(--credit);
}
.val.shelf {
  color: var(--shelf);
}
.val.basis,
.basis-block .val.basis {
  color: var(--text-strong);
}

.add-btn {
  min-height: 64px;
  align-self: stretch;
  padding: 0 20px;
}

.add-btn:disabled {
  background: var(--ink-2);
  color: var(--muted);
  border-color: var(--border);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* --- Buy list ("The Haul") --- */
.buylist {
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px 20px 0;
}

.buylist-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 12px 0;
}

.buylist-head h2 {
  margin: 0;
  font-family: var(--ff-dis);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.haul-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Smaller variant of the chunky pill for the haul header */
.haul-actions .complete-btn {
  min-height: 44px;
  font-size: 15px;
  padding: 0 18px;
  box-shadow: 0 3px 0 0 #00030f;
}
.haul-actions .complete-btn:hover {
  box-shadow: 0 5px 0 0 #00030f;
}

.clear-btn {
  appearance: none;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--danger);
  font-family: var(--ff-dis);
  font-size: 15px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.clear-btn:hover {
  border-color: var(--danger);
}

.bl-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.bl-name {
  font-family: var(--ff-dis);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-strong);
}

.bl-meta {
  font-size: 13px;
  color: var(--muted);
}

.bl-nums {
  display: flex;
  gap: 18px;
  text-align: right;
}

.bl-nums .val {
  font-family: var(--ff-mono);
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 66px;
}

.rm-btn {
  appearance: none;
  border: 2px solid var(--border);
  background: var(--ink-2);
  color: var(--danger);
  font-size: 16px;
  font-weight: 800;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.rm-btn:hover {
  border-color: var(--danger);
}

/* Buy history */
.history {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 20px 0;
}

.history-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hist-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.hist-when {
  font-weight: 700;
  color: var(--cream);
}

.hist-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.hist-items {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hist-line {
  font-size: 13px;
  padding: 2px 0;
  border-bottom: 1px solid var(--border);
}

.hist-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* --- Sticky totals bar --- */
.totalsbar {
  position: sticky;
  bottom: 0;
  z-index: 25;
  display: flex;
  justify-content: flex-end;
  gap: 30px;
  background: rgba(6, 19, 54, 0.94);
  backdrop-filter: blur(8px);
  border-top: 3px solid var(--accent);
  padding: 14px 24px;
  margin-top: 8px;
}

.totalsbar .tot {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.totalsbar .tot .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}

.totalsbar .tot .val {
  font-family: var(--ff-mono);
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.foot {
  text-align: center;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 0;
  font-size: 13px;
}

/* --- Login page --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 36px 30px;
  text-align: center;
}

.login-logo {
  height: 56px;
  width: auto;
  margin-bottom: 18px;
}

.login-title {
  font-family: var(--ff-dis);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 8px;
  color: var(--accent);
}

.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 15px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form input {
  background: var(--ink-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: var(--ff);
  font-size: 19px;
  padding: 14px 16px;
  border-radius: var(--radius-pill);
  min-height: 54px;
  text-align: center;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 201, 60, 0.18);
}

.login-form .btn-primary {
  width: 100%;
}

.login-msg {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--danger);
  font-weight: 600;
}

/* --- Responsive --- */
@media (max-width: 760px) {
  /* Header: let the 5-game toggle wrap instead of overflowing the screen */
  .topbar {
    padding: 12px 14px;
  }
  .game-toggle {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }
  .game-btn,
  .cond-btn {
    padding: 8px 13px;
    font-size: 15px;
  }
  .cond-title {
    padding: 0 6px;
  }
  /* Control rows: wrap their groups and never exceed the viewport */
  .controls {
    padding: 14px;
  }
  .cond-group,
  .finish-group,
  #conditionToggle,
  #companyToggle {
    flex-wrap: wrap;
  }
  #searchInput {
    font-size: 18px;
    min-height: 52px;
  }
  .basis-row select,
  .grade-select select,
  .bulk-form select {
    min-width: 0;
    width: 100%;
  }
  .basis-row label,
  .bulk-form label {
    flex: 1 1 100%;
  }

  .card {
    grid-template-columns: 48px 1fr;
  }
  .offer {
    grid-column: 1 / -1;
    justify-content: space-between;
    gap: 12px;
  }
  .offer .num {
    min-width: 0;
  }
  .offer .num .val {
    font-size: 22px;
  }
  .add-btn {
    min-height: 52px;
  }
  .totalsbar {
    gap: 18px;
    justify-content: space-between;
  }
  .totalsbar .tot .val {
    font-size: 24px;
  }
  /* Buy-list rows: stack name/prices, pin the remove button to the corner */
  .bl-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    position: relative;
    padding-right: 52px;
  }
  .bl-nums {
    justify-content: flex-start;
    gap: 16px;
  }
  .bl-nums .val {
    min-width: 0;
  }
  .rm-btn {
    position: absolute;
    top: 12px;
    right: 12px;
  }
  /* History rows: let the action buttons wrap under the info */
  .hist-row {
    flex-wrap: wrap;
  }
}
