:root {
  --bg: #0b0d10;
  --panel: #12161b;
  --text: #e7edf3;
  --muted: #9aa6b2;
  --border: #242c35;
  --accent: #7dd3fc;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

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

/* badge links: keep badge look, but clearly clickable */
a.badge { color: var(--muted); }
a.badge:hover { text-decoration: underline; cursor: pointer; }

/* SKU badge links (search/store -> link page) */
a.skuLink { color: var(--muted); }
a.skuLink:hover { text-decoration: underline; cursor: pointer; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
}

/* header becomes 2 rows */
.header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.headerRow1 {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.headerRow2 {
  width: 100%;
}

.headerButtons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* disabled button styling */
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}


.h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.input {
  width: 100%;
  padding: 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1318;
  color: var(--text);
  outline: none;
}

.input:focus { border-color: #37566b; }

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

.item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #0f1318;
  cursor: pointer;
  min-height: 92px; /* keep results uniform */
}

.item:hover { border-color: #2f3a46; }

.itemRow {
  display: flex;
  gap: 12px;
  align-items: center; /* keep thumb centered; don't stretch */
  min-height: 68px;
}

.thumbBox {
  width: 64px;
  height: 64px;          /* fixed thumb height */
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b0d10;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumbPlaceholder {
  width: 100%;
  height: 100%;
  background: #0b0d10;
}

.itemBody {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.itemTop {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.itemName {
  font-weight: 700;
  font-size: 14px;
  min-width: 0;
  white-space: nowrap;      /* lock to one line */
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badgeGood {
  color: rgba(20,110,40,0.95);
  background: rgba(20,110,40,0.10);
  border-color: rgba(20,110,40,0.25);
}

.badgeNeutral {
  color: var(--muted);
  background: rgba(255,255,255,0.02);
}

.badgeBad {
  color: rgba(160,40,40,0.95);
  background: rgba(160,40,40,0.12);
  border-color: rgba(160,40,40,0.25);
}

.badgeBest {
  color: rgba(210, 170, 60, 0.95);
  background: rgba(210, 170, 60, 0.12);
  border-color: rgba(210, 170, 60, 0.26);
}

.metaRow {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;      /* keep single row (desktop) */
  align-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
}

.price {
  font-weight: 700;
  color: var(--text);
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.btn {
  border: 1px solid var(--border);
  background: #0f1318;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 10px;
  cursor: pointer;
}

.btn:hover { border-color: #2f3a46; }

.btnWide {
  padding-left: 14px;
  padding-right: 14px;
  min-width: 120px;
  text-align: center;
}

.btnSm {
  padding: 10px 12px;
  color: var(--muted);
}

.btnSm:hover {
  color: var(--text);
}

.links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}

.small {
  color: var(--muted);
  font-size: 12px;
}

/* small subtle inline selects */
.selectSmall {
  border: 1px solid var(--border);
  background: #0f1318;
  color: var(--muted);
  border-radius: 999px;

  /* custom arrow (puts it a bit left from the edge) */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa6b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;

  padding: 6px 28px 6px 10px; /* right padding reserves room for arrow */
  font-size: 12px;
  line-height: 1;
  outline: none;
}


.selectSmall:hover {
  border-color: #2f3a46;
  color: var(--text);
  cursor: pointer;
}

.selectSmall:focus {
  border-color: #37566b;
  outline: 1px solid #37566b;
  color: var(--text);
}

/* --- Store selector (top of search page) --- */
.storeBarWrap {
  margin-top: 12px; /* slightly more gap from the top text */
}

.storeBar{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  width:100%;
  justify-content: space-between; /* spread each row to fill */
}

.storeBtn {
  border: 1px solid var(--border);
  background: #0f1318;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.storeBreak {
  flex-basis: 100%;
  width: 0;
  height: 0;
}

/* let mobile wrap naturally */
@media (max-width: 640px) {
  .storeBreak { display: none; }
}

.storeBtn:hover {
  border-color: #2f3a46;
  color: var(--text);
  text-decoration: none;
}

.storeBtnActive {
  border-color: #37566b;
  outline: 1px solid #37566b;
  color: var(--text);
}

/* Detail view sizing */
.detailCard {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detailHeader {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.detailThumbBox {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b0d10;
  flex: 0 0 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detailThumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detailHeaderText {
  flex: 1;
  min-width: 0;
}

/* Chart fills most of viewport, but stays usable on mobile */
.chartBox {
  width: 100%;
  height: min(72vh, 720px);
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0f1318;
  padding: 10px;
}

@media (max-width: 640px) {
  .container { padding: 14px; }
  .thumbBox { width: 56px; height: 56px; flex: 0 0 56px; }
  .item { min-height: 0; }        /* allow natural height on small screens */
  .metaRow { flex-wrap: wrap; }   /* wrapping is fine on mobile */

  .detailThumbBox { width: 84px; height: 84px; flex: 0 0 84px; }

  .chartBox {
    height: 58vh;
    min-height: 260px;
    padding: 8px;
  }
}

.chartBox canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- SKU linker additions --- */
.pinnedItem {
  outline: 2px solid #37566b;
  border-color: #37566b;
}

.linkBar {
  margin-top: 12px;
  position: sticky;
  bottom: 0;
}

/* Stats page only */
.statsHeaderLeft {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.statsTitleStack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* --- Store page: two-column results (new; isolated to store page) --- */
.storeGrid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.storeCol {
  min-width: 0;
}

.storeColHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 10px 2px;
}

.storeColList {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 640px) {
  .storeGrid {
    grid-template-columns: 1fr; /* stack columns */
  }
}

.badgeExclusive {
  color: rgba(20, 140, 140, 0.95);
  background: rgba(20, 140, 140, 0.12);
  border-color: rgba(20, 140, 140, 0.28);
}

.badgeLastStock {
  color: rgba(200, 120, 20, 0.95);
  background: rgba(200, 120, 20, 0.12);
  border-color: rgba(200, 120, 20, 0.28);
}

/* Prevent layout width shift when scrollbar appears/disappears */
html { overflow-y: scroll; }

/* Prevent long status text from forcing header wrap */
#statsStatus{
  max-width: 52ch;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Stats dual range slider: custom track + fill (no native progress) --- */
.rangeDual {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: 18px;
}

.rangeDual .rangeTrack,
.rangeDual .rangeFill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  border-radius: 999px;
}

.rangeDual .rangeTrack {
  left: 0;
  right: 0;
  background: var(--border);
}

.rangeDual .rangeFill {
  left: 0;
  right: 0;
  background: #37566b; /* matches your focus outline color */
}

/* Hide native track/progress; keep thumbs clickable */
.rangeDual input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.rangeDual input[type="range"]::-webkit-slider-runnable-track { background: transparent; }
.rangeDual input[type="range"]::-webkit-slider-thumb { pointer-events: all; }

.rangeDual input[type="range"]::-moz-range-track { background: transparent; }
.rangeDual input[type="range"]::-moz-range-progress { background: transparent; }
.rangeDual input[type="range"]::-moz-range-thumb { pointer-events: all; }


/* Stats page: make chart fill remaining viewport height */
.containerFull{
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.cardFill{
  flex: 1 1 auto;
  min-height: 320px; /* safety */
  display: flex;
}

.chartFill{
  flex: 1 1 auto;
  min-height: 0; /* IMPORTANT so flex children can actually shrink/grow */
}

.chartFill canvas{
  width: 100% !important;
  height: 100% !important;
}
