/* ========================================
   Prices — deal monitor dashboard
   Dark trading-desk look. All colours go through CSS variables so a light
   theme (or a retailer-accent theme) can be dropped in without touching rules.
   ======================================== */

:root {
  --bg:            #0b0e14;
  --bg-raised:     #131824;
  --bg-raised-2:   #1a2130;
  --bg-input:      #0f141e;
  --border:        #232c3d;
  --border-strong: #33405a;

  --text:          #e6ecf5;
  --text-dim:      #8d9bb3;
  --text-faint:    #5d6a80;

  --primary:       #4f8cff;
  --good:          #29d17c;
  --good-dim:      #17603c;
  --warn:          #ffb020;
  --danger:        #ff5c5c;

  --type-price_error: #ff4d6d;
  --type-clearance:   #ffb020;
  --type-restock:     #4f8cff;
  --type-flip:        #29d17c;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 8px 28px rgba(0, 0, 0, .45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(180deg, #10141f 0%, #0d111a 100%);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex; align-items: center; gap: 16px;
  max-width: 1400px; margin: 0 auto;
  padding: 12px 20px;
}

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-size: 20px; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: 2px; }
.brand-sub { font-size: 11px; color: var(--text-faint); letter-spacing: 1px; text-transform: uppercase; }

.dest-chip {
  display: flex; align-items: center; gap: 5px;
  margin-left: auto;
  padding: 5px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap;
}
.dest-chip strong { color: var(--text); }

.monitor-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim);
  font-family: var(--mono);
}

.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 0 rgba(41, 209, 124, .6);
}
.live-dot.is-live {
  background: var(--good);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(41, 209, 124, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(41, 209, 124, 0); }
  100% { box-shadow: 0 0 0 0 rgba(41, 209, 124, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot.is-live { animation: none; }
}

/* ---------- Stat bar ---------- */

.statbar {
  display: flex; gap: 4px;
  max-width: 1400px; margin: 0 auto;
  padding: 0 20px 12px;
  overflow-x: auto;
}

.stat {
  display: flex; flex-direction: column; gap: 1px;
  flex: 1 1 0; min-width: 96px;
  padding: 9px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.stat-value { font-family: var(--mono); font-size: 17px; font-weight: 700; }
.stat-good  { color: var(--good); }
.stat-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .6px; }

/* ---------- Toolbar ---------- */

.toolbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 14, 20, .93);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.toolbar-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 12px 20px;
  display: flex; flex-direction: column; gap: 10px;
}

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
  padding: 6px 13px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 12.5px; font-weight: 550;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.pill:hover { background: var(--bg-raised-2); color: var(--text); }
.pill.is-active {
  background: var(--primary); border-color: var(--primary);
  color: #fff;
}

.control-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 11px;
  font-size: 13px;
  font-family: inherit;
}
.input:focus { outline: none; border-color: var(--primary); }
.input-search { flex: 1 1 240px; min-width: 180px; }
.input-select { cursor: pointer; }

.roi-filter {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap;
}
.roi-filter strong { color: var(--good); font-family: var(--mono); }
.roi-filter input[type=range] { width: 110px; accent-color: var(--good); }

/* ---------- Feed ---------- */

.feed { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* Says which prices are real. Must never be subtle. */
.mode-banner {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 16px;
  border-radius: var(--radius);
  font-size: 12.5px; line-height: 1.5;
  color: var(--text-dim);
}
.mode-banner[hidden] { display: none; }
.mode-banner.is-live { background: rgba(41, 209, 124, .08); border: 1px solid rgba(41, 209, 124, .28); }
.mode-banner.is-demo { background: rgba(255, 176, 32, .08); border: 1px solid rgba(255, 176, 32, .28); }
.mode-banner strong { color: var(--text); }

.mode-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .7px;
  padding: 3px 8px; border-radius: 4px;
  white-space: nowrap;
}
.mode-tag-live { background: var(--good); color: #06251a; }
.mode-tag-demo { background: var(--warn); color: #2a1c00; }

.feed-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.feed-head h1 { font-size: 16px; }
.feed-count { font-size: 12px; color: var(--text-faint); font-family: var(--mono); }

.deal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 12px;
}

.loading, .empty {
  grid-column: 1 / -1;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-faint);
}

/* ---------- Deal card ---------- */

.deal-card {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  padding: 13px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: inherit; font: inherit;
  transition: transform .12s, border-color .12s, background .12s;
}
.deal-card:hover {
  transform: translateY(-2px);
  background: var(--bg-raised-2);
  border-color: var(--border-strong);
}
.deal-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.deal-card.type-price_error { border-left-color: var(--type-price_error); }
.deal-card.type-clearance   { border-left-color: var(--type-clearance); }
.deal-card.type-restock     { border-left-color: var(--type-restock); }
.deal-card.type-flip        { border-left-color: var(--type-flip); }

/* Newly arrived deals flash once so you can see the monitor working. */
.deal-card.is-new { animation: flash-in .9s ease-out; }
@keyframes flash-in {
  0%   { background: rgba(79, 140, 255, .22); transform: translateY(-6px); }
  100% { background: var(--bg-raised); transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .deal-card.is-new { animation: none; }
}

.card-top { display: flex; align-items: center; gap: 6px; }

.type-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px;
}
.type-badge.type-price_error { background: rgba(255, 77, 109, .16); color: var(--type-price_error); }
.type-badge.type-clearance   { background: rgba(255, 176, 32, .16); color: var(--type-clearance); }
.type-badge.type-restock     { background: rgba(79, 140, 255, .16); color: var(--type-restock); }
.type-badge.type-flip        { background: rgba(41, 209, 124, .16); color: var(--type-flip); }

.retailer-chip {
  font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.deal-age { margin-left: auto; font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

.card-main { display: flex; gap: 10px; align-items: flex-start; }
.thumb {
  flex: 0 0 44px; height: 44px;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.deal-title {
  font-size: 13.5px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.price-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.price-now  { font-family: var(--mono); font-size: 21px; font-weight: 700; }
.price-unit { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; }

.sticker-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: -4px; }
.sticker    { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.price-off  { font-size: 11.5px; font-weight: 700; color: var(--danger); }
.import-add { font-family: var(--mono); font-size: 11px; color: var(--warn); }

/* Lane badges — the "can I actually import this" signal */
.lane-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lane-badge {
  font-size: 10.5px; font-weight: 650;
  padding: 2px 8px; border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.lane-badge.lane-good { background: rgba(41, 209, 124, .12); color: var(--good);   border-color: rgba(41, 209, 124, .25); }
.lane-badge.lane-warn { background: rgba(255, 176, 32, .12); color: var(--warn);   border-color: rgba(255, 176, 32, .25); }
.lane-badge.lane-bad  { background: rgba(255, 92, 92, .12);  color: var(--danger); border-color: rgba(255, 92, 92, .28); }

.dead-flag {
  font-size: 10.5px; font-weight: 650; color: var(--danger);
  text-transform: uppercase; letter-spacing: .4px;
}

.card-foot {
  display: flex; align-items: center; gap: 8px;
  padding-top: 9px; border-top: 1px solid var(--border);
}
.roi-badge {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  color: var(--good);
  background: rgba(41, 209, 124, .12);
  padding: 2px 8px; border-radius: 4px;
}
.roi-badge.is-thin { color: var(--warn); background: rgba(255, 176, 32, .12); }
.roi-badge.is-bad  { color: var(--danger); background: rgba(255, 92, 92, .12); }
.profit-note { font-size: 11.5px; color: var(--text-dim); font-family: var(--mono); }

.conf-wrap { margin-left: auto; display: flex; align-items: center; gap: 5px; }
.conf-bar { width: 40px; height: 4px; background: var(--bg-input); border-radius: 2px; overflow: hidden; }
.conf-fill { height: 100%; background: var(--primary); }
.conf-num { font-size: 10px; color: var(--text-faint); font-family: var(--mono); }

.oos-flag { font-size: 10.5px; color: var(--danger); font-weight: 600; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 6, 11, .78);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  position: relative;
  width: 100%; max-width: 620px;
  max-height: 90vh; overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim); cursor: pointer;
  font-size: 13px; line-height: 1;
}
.modal-close:hover { color: var(--text); background: var(--bg-raised-2); }

.modal-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 4px; padding-right: 30px; }
.modal-title { font-size: 17px; line-height: 1.3; }
.modal-meta { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); margin-top: 3px; }

.section { margin-top: 20px; }
.section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-faint); margin-bottom: 8px;
}

/* Price history sparkline */
.spark-wrap {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}
.spark-wrap svg { display: block; width: 100%; height: auto; }
.spark-legend {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--text-faint); font-family: var(--mono);
  margin-top: 6px;
}

.badge-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Landed cost breakdown ---------- */

.cost-table {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cost-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 7px 12px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
}
.cost-row:last-child { border-bottom: none; }
.cost-row span:last-child { font-family: var(--mono); white-space: nowrap; }
.cost-row.is-muted { color: var(--text-faint); }
.cost-row.is-warn  { color: var(--warn); }
.cost-row.is-total {
  background: var(--bg-raised-2);
  font-weight: 700; font-size: 14px;
  border-top: 1px solid var(--border-strong);
}

.border-delta {
  margin-top: 8px; padding: 9px 12px;
  background: rgba(255, 176, 32, .07);
  border: 1px solid rgba(255, 176, 32, .2);
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-dim);
}
.border-delta strong { color: var(--warn); font-family: var(--mono); }

.lane-notes {
  margin: 8px 0 0; padding-left: 16px;
  font-size: 11.5px; color: var(--text-faint); line-height: 1.5;
}
.lane-notes li { margin-bottom: 3px; }

/* ---------- Cross-border comparison ---------- */

.xb-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.xb-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 18px 58px;
  gap: 10px; align-items: center;
  width: 100%;
  padding: 8px 11px;
  background: var(--bg-input);
  border: none; border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  color: var(--text); font: inherit; font-size: 12.5px;
  text-align: left; cursor: pointer;
}
.xb-row:last-child { border-bottom: none; }
.xb-row:hover:not(.is-head) { background: var(--bg-raised-2); }
.xb-row.is-head {
  background: var(--bg-raised-2);
  color: var(--text-faint); font-size: 10px;
  text-transform: uppercase; letter-spacing: .6px;
  cursor: default; padding: 6px 11px;
}
.xb-row.is-best    { border-left-color: var(--good); }
.xb-row.is-current { background: rgba(79, 140, 255, .07); border-left-color: var(--primary); }
.xb-row.is-dead    { opacity: .55; }

.xb-src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xb-sticker, .xb-landed, .xb-roi { font-family: var(--mono); white-space: nowrap; }
.xb-sticker { color: var(--text-faint); font-size: 11.5px; }
.xb-landed  { font-weight: 700; }
.xb-roi     { text-align: right; font-weight: 650; }
.xb-roi.is-good { color: var(--good); }
.xb-roi.is-bad  { color: var(--danger); }
.xb-lane { text-align: center; }

.xb-tag {
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  padding: 1px 5px; border-radius: 3px;
  background: rgba(79, 140, 255, .18); color: var(--primary);
}
.xb-tag-best { background: rgba(41, 209, 124, .18); color: var(--good); }

.xb-hint {
  margin-top: 8px; padding: 9px 12px;
  background: rgba(41, 209, 124, .07);
  border: 1px solid rgba(41, 209, 124, .22);
  border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--good);
}
.xb-foot { margin-top: 6px; font-size: 10.5px; color: var(--text-faint); }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.kv {
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.kv-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; }
.kv-value { font-family: var(--mono); font-size: 15px; font-weight: 650; }

/* Profit calculator */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.calc-field { display: flex; flex-direction: column; gap: 3px; }
.calc-field label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; }
.calc-field input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono); font-size: 14px;
  padding: 6px 9px; width: 100%;
}
.calc-field input:focus { outline: none; border-color: var(--primary); }

.calc-out {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.calc-out .kv { flex: 1 1 100px; background: none; border: none; padding: 0; }
.calc-out .kv-value.is-good { color: var(--good); }
.calc-out .kv-value.is-bad  { color: var(--danger); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(1.12); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--bg-raised-2); color: var(--text); border-color: var(--border-strong); }
.btn-ghost     { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-ghost.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.chip-count {
  display: inline-block; min-width: 18px;
  padding: 0 5px; border-radius: 9px;
  background: var(--bg-input);
  font-family: var(--mono); font-size: 11px;
  text-align: center;
}

.modal-actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 140px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--bg-raised-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.toast[hidden] { display: none; }

/* ---------- Footer ---------- */

.site-foot {
  max-width: 1400px; margin: 0 auto;
  padding: 30px 20px 40px;
  color: var(--text-faint); font-size: 11.5px;
  border-top: 1px solid var(--border);
}
.site-foot p { margin: 0 0 8px; max-width: 900px; line-height: 1.6; }
.site-foot p:last-child { margin-bottom: 0; }
.site-foot strong { color: var(--text-dim); }

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 10px; }
  .dest-chip { margin-left: 0; order: 2; }
  .monitor-status { order: 3; width: 100%; margin-left: 0; }
  .xb-row { grid-template-columns: minmax(0, 1fr) auto 16px 52px; }
  .xb-row .xb-sticker { display: none; }
  .statbar .stat { min-width: 86px; }
  .deal-grid { grid-template-columns: 1fr; }
  .roi-filter { width: 100%; }
  .roi-filter input[type=range] { flex: 1; width: auto; }
}
