:root {
  --ink: #0b1930;
  --ink-2: #122748;
  --paper: #eef2f8;
  --paper-dim: #dde6f2;
  --line: #24406f;
  --line-light: #c7d2e0;
  --accent: #4f8cff;
  --accent-dim: #1a2f52;
  --sage: #4fae7d;
  --sage-dim: #1c3a2c;
  --brick: #d1584a;
  --brick-dim: #4a2420;
  --text-hi: #eef2f8;
  --text-mid: #9fb0c9;
  --text-low: #64748f;
  --radius: 4px;
}

* { box-sizing: border-box; }

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

body {
  background: var(--ink);
  color: var(--text-hi);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 24px;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.brand-mark span { color: var(--accent); }
.brand-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  color: var(--text-low);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 20px;
}
.route {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-mid);
  text-align: right;
  line-height: 1.5;
}
.route b { color: var(--accent); font-weight: 600; }

.tabnav { display: flex; gap: 0.5rem; margin-bottom: 20px; }
.tab-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-mid);
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  padding: 8px 20px;
  border-radius: 20px;
  cursor: pointer;
}
.tab-btn.active { background: var(--accent); color: #0b1930; border-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-head { padding: 18px 20px 14px; }
.panel-head h2 {
  font-family: 'Archivo', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mid);
  margin: 0;
}
.panel-body { padding: 0 20px 4px; }
.panel-footer {
  padding: 10px 20px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-low);
}

.field-block { margin-bottom: 18px; }
.field-label {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mid);
  margin-bottom: 8px;
}

.cat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-hi);
  background: transparent;
}
.cat-item:hover { border-color: var(--accent); }
.cat-item.selected { background: var(--accent-dim); border-color: var(--accent); }
.cat-item.disabled {
  cursor: not-allowed;
  color: var(--text-low);
  opacity: 0.6;
}
.cat-item .cat-note { margin-left: auto; font-family: 'IBM Plex Mono', monospace; font-size: 0.66rem; color: var(--text-low); }

.search-row { display: flex; gap: 0.6rem; }
.search-row input[type="text"] {
  flex: 1;
  min-width: 200px;
}

input, select, .search-btn, .ghost-btn, .more-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
}
input, select {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--text-hi);
}
input::placeholder { color: var(--text-low); }

.search-btn {
  background: var(--accent);
  color: #0b1930;
  border: none;
  font-weight: 700;
  padding: 0.55rem 1.3rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.search-btn:hover { filter: brightness(1.08); }
.ghost-btn {
  background: none;
  border: 1px dashed var(--line);
  color: var(--text-low);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
}
.ghost-btn:hover { color: var(--accent); border-color: var(--accent); }

button {
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  background: var(--ink);
  color: var(--text-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 0.8rem;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.status-line { color: var(--text-mid); font-size: 0.88rem; margin: 4px 0 16px; }
.status-line b { color: var(--accent); }

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  align-items: start;
}

.card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-light);
}
.card.rejected { opacity: 0.55; }
.card-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 12px 14px 10px;
  color: #1c2531;
  line-height: 1.35;
  border-bottom: 1px solid var(--line-light);
}

.price-check-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.66rem;
  padding: 7px 14px;
  line-height: 1.4;
  border-bottom: 1px solid var(--line-light);
}
.price-check-badge.verified { background: var(--sage-dim); color: #b9d4ae; }
.price-check-badge.unverified { background: #2a3547; color: #a9b7cb; }

.badges { padding: 8px 14px 0; }
.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  margin: 0 0.3rem 0.3rem 0;
  font-family: 'IBM Plex Mono', monospace;
}
.badge.reject { background: #f3d9d5; color: #a13a2c; }
.badge.score { background: #dbe6fb; color: #24548c; }

.compare { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; }
.side { padding: 14px; text-align: center; }
.side a { display: block; position: relative; }
.side img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  background: #ddd7c6;
  margin-bottom: 10px;
  display: block;
}
.side-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8a93a6;
  margin-bottom: 4px;
}
.side-price {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 1.2rem;
  color: #1c2531;
}
.side.ebay .side-price { color: var(--brick); }
.side.amazon .side-price { color: var(--sage); }
.side-sub { font-family: 'IBM Plex Mono', monospace; font-size: 0.66rem; color: #8a93a6; margin-top: 2px; }
.side-pending {
  aspect-ratio: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(135deg, #e3e8f0, #e3e8f0 8px, #d8e0eb 8px, #d8e0eb 16px);
  border: 1px dashed var(--line-light);
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-low);
  text-align: center;
  line-height: 1.5;
  padding: 8px;
}
.side-pending span { font-size: 0.62rem; opacity: 0.75; }

.gauge-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 8px;
  border-left: 1px dashed var(--line-light);
  border-right: 1px dashed var(--line-light);
  background: var(--paper-dim);
}
.gauge-arrow { font-size: 1.1rem; color: #8a93a6; }

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #e2e8f2;
  border-top: 1px solid var(--line-light);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
}
.gap-pill { font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.gap-pill.good { background: var(--sage-dim); color: #b9d4ae; }
.gap-pill.great { background: var(--accent); color: #0b1930; }
.gap-pill.poor { background: var(--brick-dim); color: #e8b8a8; }
.meta-tags { color: #6b7690; }

.more-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #dbe2ee;
  border-top: 1px solid var(--line-light);
}
.more-btn {
  background: none;
  border: none;
  color: #4a5570;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 2px 0;
}
.more-btn:hover:not(:disabled) { color: #1c2531; }
.more-btn .chev { display: inline-block; transition: transform 0.15s; margin-left: 3px; }
.more-btn.open .chev { transform: rotate(180deg); }

.detail { display: none; background: #16294a; color: var(--text-hi); padding: 16px; }
.detail.open { display: block; }
.detail h4 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mid);
  margin: 0 0 10px;
}
.detail-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.76rem;
  padding: 5px 0;
  border-bottom: 1px dashed #2f3a5a;
}
.detail-line span:first-child { color: var(--text-mid); }
.detail-note { font-size: 0.72rem; color: var(--text-low); margin-top: 10px; line-height: 1.5; }

.ledger-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ledger-form input, .ledger-form select { flex: 1; min-width: 140px; }

.ledger-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.import-label {
  display: inline-flex;
  align-items: center;
  background: none;
  border: 1px dashed var(--line);
  color: var(--text-low);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
}
.import-label:hover { color: var(--accent); border-color: var(--accent); }

.ledger-summary {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-mid);
}
.ledger-summary strong { display: block; font-size: 1.2rem; color: var(--text-hi); }

.ledger-table { width: 100%; border-collapse: collapse; }
.ledger-table th, .ledger-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem;
  text-align: left;
  font-size: 0.85rem;
}
.ledger-table th { color: var(--text-mid); font-weight: 600; }

.hint { color: var(--text-mid); font-size: 0.85rem; line-height: 1.5; }

.usage-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'IBM Plex Mono', monospace;
  margin-bottom: 8px;
}
.usage-stat .count { font-size: 1.4rem; font-weight: 600; color: var(--text-hi); }
.usage-track { height: 10px; border-radius: 5px; background: var(--ink); overflow: hidden; margin-bottom: 12px; }
.usage-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.usage-fill.capped { background: var(--brick); }
.usage-limit-msg {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: #e8b8a8;
  background: var(--brick-dim);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-top: 4px;
}
