/*
 * styles.css — the whole design. No framework.
 *
 * Dark by default, light via prefers-color-scheme, both driven off one token
 * set so nothing is defined in only one theme.
 *
 * Delta band colors are separated by lightness as well as hue, so the red/green
 * pair stays distinguishable for the common forms of color blindness. Every
 * colored cell also shows its number and carries a text tooltip: color is
 * reinforcement here, never the only channel.
 */

/* ── 1. tokens ─────────────────────────────────────────────────────────── */

:root {
  --bg: #0f1115;
  --bg-raised: #161920;
  --bg-inset: #1c2029;
  --border: #262b36;
  --border-strong: #333a48;
  --text: #e6e9ef;
  --text-dim: #98a0b0;
  --text-faint: #6b7383;
  --accent: #5b9dff;
  --accent-dim: #2f4a75;

  /* "deal" is blue: cheaper than market is the outcome worth celebrating.
     Blue sits far from green (fine), yellow (caution) and red (over), so it
     reads as its own state at a glance. It is a sky blue, lighter and cooler
     than --accent, so a deal never looks like a clickable control. */
  --band-deal: #8fd0ff;
  --band-deal-bg: rgba(91, 175, 255, 0.18);
  --band-deal-border: rgba(110, 185, 255, 0.6);
  --band-green: #86c98a;
  --band-green-bg: rgba(134, 201, 138, 0.12);
  --band-yellow: #b08a1e;
  --band-yellow-bg: rgba(176, 138, 30, 0.14);
  --band-red: #f0736a;
  --band-red-bg: rgba(240, 115, 106, 0.15);
  --band-unknown: #6b7383;
  --band-unknown-bg: rgba(107, 115, 131, 0.1);
  /* Table shading: mixed in at 6-60% — darker = more profitable. */
  --shade-green: #2f9e58;

  --ok: #34d399;
  --warn: #e8c05a;
  --err: #f0736a;

  --radius: 8px;
  --radius-sm: 5px;
  --gap: 16px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa;
    --bg-raised: #ffffff;
    --bg-inset: #f0f2f5;
    --border: #e0e4ea;
    --border-strong: #c8cfd9;
    --text: #1a1e26;
    --text-dim: #5a6473;
    --text-faint: #8892a0;
    --accent: #2563eb;
    --accent-dim: #bfd4ff;

    /* On white, the pale sky blue would vanish, so the text goes deep blue
       over a saturated light-blue fill with a mid-blue border. */
    --band-deal: #0b559e;
    --band-deal-bg: rgba(77, 160, 255, 0.28);
    --band-deal-border: rgba(30, 110, 200, 0.7);
    --band-green: #3f7d43;
    --band-green-bg: rgba(63, 125, 67, 0.09);
    --band-yellow: #6b5a12;
    --band-yellow-bg: rgba(140, 120, 40, 0.1);
    --band-red: #c02c22;
    --band-red-bg: rgba(192, 44, 34, 0.1);
    --band-unknown: #8892a0;
    --band-unknown-bg: rgba(136, 146, 160, 0.1);
    --shade-green: #2e8b4f;

    --ok: #047857;
    --warn: #9a6b00;
    --err: #c02c22;
  }
}

/* ── 2. reset + base ───────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 10px; }

/* ── 3. layout ─────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 52px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.brand-mark {
  width: 15px; height: 15px; border-radius: 4px;
  /* Brand mark, not a price indicator: stays gold when deals are blue. */
  background: linear-gradient(135deg, var(--accent), #ffe9a3);
}
.brand-name { white-space: nowrap; }

.tabs { display: flex; gap: 2px; flex: 1; }
.tab {
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  white-space: nowrap;
}
.tab:hover { background: var(--bg-inset); color: var(--text); text-decoration: none; }
.tab.active { background: var(--accent-dim); color: var(--text); }
.tab-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status { display: flex; gap: 14px; font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.status-item { font-variant-numeric: tabular-nums; }
.status-item.ok { color: var(--ok); }
.status-item.warn { color: var(--warn); }
.status-item.err { color: var(--err); }

.view { padding: 20px; max-width: 1500px; margin: 0 auto; }

.split { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; gap: var(--gap); align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--gap);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-tight { gap: 6px; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ── 4. controls ───────────────────────────────────────────────────────── */

button, .btn {
  font: inherit;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-inset);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { filter: brightness(1.1); }
button.subtle { background: transparent; border-color: transparent; color: var(--text-dim); padding: 4px 8px; }
button.subtle:hover:not(:disabled) { background: var(--bg-inset); color: var(--text); border-color: transparent; }
button.small { padding: 4px 9px; font-size: 12px; }

input, textarea, select {
  font: inherit;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-inset);
  color: var(--text);
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 4px; }

.decklist-input {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  min-height: 340px;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}
.decklist-input::placeholder { color: var(--text-faint); opacity: 1; }

.counter { font-family: var(--mono); font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.counter.warn { color: var(--warn); }
.counter.err { color: var(--err); }

.checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.checkbox input { width: auto; }

.hint { font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.hint code { font-family: var(--mono); color: var(--text-dim); }

/* ── 5. tables ─────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.sort-head {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
}
.sort-head:hover { color: var(--text); }
.sort-head.active { color: var(--accent); }
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-inset); }
.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.card-name { font-weight: 500; }

.pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  white-space: nowrap;
}
.pill.foil { color: var(--accent); border-color: var(--accent-dim); }
.pill.etched { color: var(--band-yellow); border-color: var(--band-yellow); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.err { color: var(--err); border-color: var(--err); }
.pill.warn { color: var(--warn); border-color: var(--warn); }

/* ── 6. delta bands ────────────────────────────────────────────────────── */

.band {
  display: inline-block;
  min-width: 62px;
  text-align: right;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12px;
}
/* Gold gets a border so it never reads as a slightly-brighter yellow. */
.band-deal {
  color: var(--band-deal);
  background: var(--band-deal-bg);
  box-shadow: inset 0 0 0 1px var(--band-deal-border);
}
.band-green { color: var(--band-green); background: var(--band-green-bg); }
.band-yellow { color: var(--band-yellow); background: var(--band-yellow-bg); }
.band-red { color: var(--band-red); background: var(--band-red-bg); }
.band-unknown { color: var(--band-unknown); background: var(--band-unknown-bg); }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--text-faint); }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ── stat tiles ────────────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.tile { background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; }
.tile-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; }
.tile-value { font-family: var(--mono); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
/* The deck-total tile carries the same band scale as an individual card, so
   "is this whole order a good deal" reads the same way one row does. */
.tile.banded { border-width: 1px; border-style: solid; }
.tile.band-deal { background: var(--band-deal-bg); border-color: var(--band-deal-border); }
.tile.band-green { background: var(--band-green-bg); border-color: var(--band-green); }
.tile.band-yellow { background: var(--band-yellow-bg); border-color: var(--band-yellow); }
.tile.band-red { background: var(--band-red-bg); border-color: var(--band-red); }
.tile.band-unknown { background: var(--band-unknown-bg); border-color: var(--border); }
.tile.band-deal .tile-value { color: var(--band-deal); }
.tile.band-green .tile-value { color: var(--band-green); }
.tile.band-yellow .tile-value { color: var(--band-yellow); }
.tile.band-red .tile-value { color: var(--band-red); }

/* ── 7. feedback ───────────────────────────────────────────────────────── */

/* pointer-events:none so the empty space around and between toasts never
   blocks clicks on the page underneath — only an actual toast should. */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 420px; pointer-events: none; }
.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  animation: slide-in 0.16s ease-out;
  pointer-events: auto;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-body { font-size: 12px; color: var(--text-dim); font-family: var(--mono); word-break: break-word; }
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.empty, .loading { padding: 40px 20px; text-align: center; color: var(--text-faint); }
.empty-title { font-size: 15px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }

.error-box {
  background: var(--band-red-bg);
  border: 1px solid var(--band-red);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: var(--gap);
}
.error-code { font-family: var(--mono); font-weight: 600; color: var(--band-red); font-size: 12px; }
.error-message { margin-top: 4px; color: var(--text); }
.error-meta { margin-top: 6px; font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

.warn-box {
  background: var(--band-yellow-bg);
  border: 1px solid var(--band-yellow);
  border-radius: var(--radius);
  padding: 10px 13px;
  margin-bottom: 12px;
  font-size: 13px;
}

.issues { max-height: 190px; overflow-y: auto; }
.issue-line { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.issue-line:last-child { border-bottom: none; }
.issue-num { font-family: var(--mono); color: var(--text-faint); min-width: 34px; }
.issue-text { font-family: var(--mono); color: var(--text); }
.issue-why { color: var(--text-dim); }

.spinner {
  display: inline-block; width: 12px; height: 12px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── share result ──────────────────────────────────────────────────────── */

.share-url {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  word-break: break-all;
}
.qr { background: #fff; padding: 8px; border-radius: var(--radius-sm); display: inline-block; }
.history-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.history-item:last-child { border-bottom: none; }

/* ── sourcing board ────────────────────────────────────────────────────── */

/*
 * One column per source, scrolling horizontally as a group and vertically
 * inside each column. The vertical scroll is per-column on purpose: a 500-card
 * TCGplayer pile must not push a 40-card Journey's End column off the screen,
 * because comparing the piles is the whole reason they're side by side.
 *
 * Columns are a fixed width rather than a fraction of the page — a card line
 * has a natural width, and stretching it to fill a wide screen just moves the
 * price further from the name.
 */
.board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: var(--gap);
  align-items: stretch;
}

.column {
  flex: 0 0 268px;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 220px;
  max-height: 62vh;
}
/* The undecided pile is a holding area, not a destination — dashed to read as
   provisional next to the real sources. */
.column-undecided { border-style: dashed; background: transparent; }
.column-je { border-color: var(--accent-dim); }
.column-owned { opacity: 0.92; }

.column.drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.column-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; padding: 10px 10px 0;
}
.column-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.column-name {
  font-weight: 600; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.column-total {
  padding: 2px 10px 8px;
  font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.column-body { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.column-empty {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 18px 10px; text-align: center; font-size: 12px; color: var(--text-faint);
}

/* One card on the board. */
.bcard {
  position: relative;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 24px 6px 8px;
  cursor: grab;
  font-size: 12px;
}
.bcard:hover { border-color: var(--border-strong); }
.bcard.dragging { opacity: 0.4; cursor: grabbing; }
.bcard-main { display: flex; align-items: center; gap: 5px; min-width: 0; }
/* Tick-to-bundle box: small and quiet until used. */
.bcard-select { width: 13px; height: 13px; margin: 0; flex: none; opacity: 0.45; cursor: pointer; }
.bcard-select:checked, .bcard:hover .bcard-select { opacity: 1; }
.bcard-qty {
  font-family: var(--mono); font-weight: 600; color: var(--text-dim);
  min-width: 16px; text-align: right; font-variant-numeric: tabular-nums;
}
.bcard-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bcard-sub { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11px; }
.bcard-price { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-dim); }
/* Hidden until hover so a column of 500 cards isn't a column of 500 buttons,
   but always present for pointers that can't right-click comfortably. */
.bcard-menu { position: absolute; top: 3px; right: 2px; opacity: 0; padding: 2px 5px; }
.bcard:hover .bcard-menu, .bcard-menu:focus { opacity: 1; }

/* A column whose order has already been sent. Dimmed and green-edged so it
   reads as settled history rather than something still being decided. */
.column-placed { border-color: var(--ok); }
.column-placed .column-body { opacity: 0.72; }
.column-placed-note {
  padding: 4px 10px 6px; font-size: 11px; color: var(--ok);
  border-bottom: 1px solid var(--border);
}

/* Order coverage: assigned copies against required copies. Red until it's
   complete, because "nearly covered" is the state that costs money. */
.coverage {
  height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--bg-inset); border: 1px solid var(--border);
}
.coverage-fill { height: 100%; background: var(--err); transition: width 0.2s ease-out; }
.coverage-fill.ok { background: var(--ok); }

/* ── popup menu ────────────────────────────────────────────────────────── */

.popmenu {
  position: absolute; z-index: 200;
  min-width: 190px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 4px;
  display: flex; flex-direction: column;
}
.popmenu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: none; text-align: left;
  padding: 6px 9px; border-radius: var(--radius-sm); font-size: 13px;
}
.popmenu-item:hover { background: var(--bg-inset); border-color: transparent; }
.popmenu-item.danger { color: var(--err); }

/* ── modal ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: min(460px, 100%);
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.modal-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

.split-body { display: flex; flex-direction: column; gap: 8px; }
.split-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.split-label { display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.split-need { font-weight: 600; }
.split-divider { border-top: 1px solid var(--border); margin: 2px 0; }
.split-status {
  margin-top: 6px; padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.split-status.ok { background: var(--band-green-bg); color: var(--band-green); }
.split-status.bad { background: var(--band-red-bg); color: var(--band-red); }
.split-error {
  margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--band-red-bg); border: 1px solid var(--band-red);
  color: var(--text); font-size: 12px;
}

/* ── commissions ───────────────────────────────────────────────────────── */

.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.range-note { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
tr.reversal td { background: var(--band-red-bg); }
tr.highlight { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--accent-dim); } to { background: transparent; } }
.mono { font-family: var(--mono); font-size: 12px; }
.trunc { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

/* ── order history: packages ───────────────────────────────────────────── */

.fold { border: 1px solid var(--border); border-radius: var(--radius); margin-top: 6px; }
.fold > summary { cursor: pointer; padding: 7px 10px; list-style-position: inside; }
.fold > summary:hover { background: var(--bg-inset); }
.fold[open] > summary { border-bottom: 1px solid var(--border); }
.fold-body { padding: 6px 10px 10px; }
.fold-body > .fold { margin-left: 4px; }
.fold-plain { border: none; }
.fold-plain[open] > summary { border-bottom: none; }

.pkg-table input[type="checkbox"] { width: auto; cursor: pointer; }
.pkg-table input[type="checkbox"]:disabled { cursor: not-allowed; }
.pkg-line { cursor: pointer; }
.pkg-print td { background: var(--bg-inset); font-size: 12px; }
.pkg-print td:nth-child(2) { padding-left: 28px; }
.caret { display: inline-block; width: 1em; color: var(--text-faint); }
.qty-input { width: 52px; padding: 2px 4px; text-align: right; }
.small-select { width: auto; padding: 3px 6px; font-size: 12px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }

.bookmarklet {
  display: inline-block;
  padding: 2px 8px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  cursor: grab;
}

.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search-input { padding: 5px 10px; font-size: 13px; }
.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 4px;
}
.search-results[hidden] { display: none; }
.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}
.search-hit:hover, .search-hit:focus { background: var(--bg-inset); }
.search-more { padding: 6px 8px; }

details.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 2px var(--accent); }
  100% { box-shadow: 0 0 0 2px transparent; }
}

/* Package headline: "Seller | 13" bold, order number lighter beside it. */
.pkg-title { font-size: 14px; }
.pkg-sep { color: var(--text-faint); font-weight: 400; }
.pkg-number { font-size: 12px; color: var(--text-faint); font-family: var(--mono); }
.arrived-btn { margin-left: 8px; padding: 1px 8px; }
button.prompt { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

/* Fixed layout so expanding a card's printings never reflows the columns. */
.pkg-table { table-layout: fixed; min-width: 640px; }
.pkg-table td { overflow-wrap: anywhere; }
.pkg-col-check { width: 34px; }
.pkg-col-qty { width: 72px; }
.pkg-col-recv { width: 104px; }
.pkg-col-money { width: 82px; }
.pkg-col-band { width: 96px; }

/* Dropping a file anywhere on Order History. */
.dropzone {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 4px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}
.dropzone:hover { border-color: var(--accent); color: var(--text); }
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 17, 21, 0.72);
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }
.drop-overlay > div {
  padding: 28px 40px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 16px;
}

/* A confirm button for something that cannot be casually repeated. */
button.primary.danger { background: var(--err); border-color: var(--err); }

/* ── books ─────────────────────────────────────────────────────────────── */

.books-move td { color: var(--text-dim); }
.books-total td { font-weight: 600; border-top: 1px solid var(--border-strong); }
.books-attention { border-color: var(--warn); }
/* Label-over-input fields, as many to a row as fit. */
.books-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 12px; }
.modal:has(.books-form) { width: min(620px, 100%); }
.modal:has(.copies-table) { width: min(820px, 100%); }
.modal .books-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.books-form select { width: 100%; }
.books-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.books-inline input { width: auto; flex: 1 1 130px; }
.books-preview { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-inset); font-family: var(--mono); }
.books-canceled td { opacity: 0.5; text-decoration: line-through; }
.books-sub td { font-size: 12px; }
.books-steps { margin: 0 0 10px; padding-left: 20px; line-height: 1.7; }
button.danger-text { color: var(--err); border-color: transparent; background: transparent; }

/* ── sub-tabs (Order Builder pages, Books sections) ─────────────────────── */

.subtabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 0 0 var(--gap); }
.subtab {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
}
.subtab:hover { background: var(--bg-inset); color: var(--text); text-decoration: none; }
.subtab.active { background: var(--accent-dim); color: var(--text); }
.app-subnav { padding: 12px 20px 0; max-width: 1500px; margin: 0 auto; }
.app-subnav .subtabs { margin: 0; }
.app-subnav[hidden] { display: none; }

/* ── sortable / shaded tables (table.js) ───────────────────────────────── */

.th-inner { display: inline-flex; align-items: center; gap: 4px; }
th.num .th-inner { flex-direction: row-reverse; }
.shade-toggle {
  all: unset;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  color: var(--text-faint);
  opacity: 0.55;
}
.shade-toggle:hover { opacity: 1; color: var(--text); }
.shade-toggle.on { opacity: 1; color: var(--shade-green); }

/* Header refresh button for the price feed. */
.status-refresh {
  all: unset;
  cursor: pointer;
  margin-left: -8px;
  padding: 0 4px;
  color: var(--text-faint);
  font-size: 13px;
}
.status-refresh:hover { color: var(--text); }
.status-refresh:disabled { cursor: progress; opacity: 0.5; }

/* Inbox: refunds and replacements read from order emails, awaiting review. */
.inbox-list { display: flex; flex-direction: column; gap: 8px; }
.inbox-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--band-green, var(--border-strong));
  border-radius: var(--radius);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
/* Couldn't tell which card for sure: worth a look before accepting. */
.inbox-item.check { border-left-color: var(--band-yellow, var(--warn)); }
.inbox-note { font-style: italic; color: var(--text-dim, inherit); }
.inbox-issue { color: var(--warn); }
.inbox-done { padding: 3px 0; }
button.reconnect-idle { opacity: 0.55; }
button.reconnect-idle:hover:not(:disabled) { opacity: 1; }

/* ── feedback ──────────────────────────────────────────────────────────── */

/* Bottom-left, because toasts own the bottom-right corner. */
.feedback-fab {
  position: fixed; left: 18px; bottom: 18px; z-index: 250;
  border-radius: 999px; padding: 7px 14px;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  display: inline-flex; align-items: center; gap: 6px;
}
.feedback-panel {
  position: fixed; left: 18px; bottom: 62px; z-index: 250;
  width: min(380px, calc(100vw - 36px)); max-height: min(70vh, 640px);
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.feedback-panel[hidden] { display: none; }
.feedback-head { display: flex; align-items: center; gap: 8px; }
.feedback-input { width: 100%; min-height: 90px; resize: vertical; }
.feedback-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.feedback-note { border-top: 1px solid var(--border); padding-top: 6px; }
.feedback-note.done .feedback-text { color: var(--text-dim); text-decoration: line-through; }
.feedback-text { white-space: pre-wrap; font-size: 13px; margin-bottom: 2px; }
.feedback-file { font-size: 11px; word-break: break-all; }

/* ── collection and the dig list ───────────────────────────────────────── */

.dig-card { border-top: 1px solid var(--border); padding: 10px 0; }
.dig-card.done { opacity: 0.65; }
.dig-copies td, .dig-copies th { padding-top: 3px; padding-bottom: 3px; }
.dig-pricier { color: var(--warn); }
