@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg:        #0c0c0f;
  --surface:   #14141c;
  --border:    #22222e;
  --text:      #d0d0d8;
  --muted:     #6b6b80;
  --green:     #4ade80;
  --red:       #f87171;
  --gold:      #f5a623;
  --amber:     #f59e0b;
  --blue:      #60a5fa;
  --radius:    6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}

header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.3px;
  text-decoration: none;
}
header h1 a {
  color: inherit;
  text-decoration: none;
}

.header-left { display: flex; align-items: center; gap: 24px; }

nav { display: flex; gap: 4px; flex-shrink: 0; }
.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--border); }
.nav-link.active { color: var(--gold); background: rgba(245,166,35,0.1); }

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

input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius);
  width: 220px;
  outline: none;
  font-family: inherit;
  font-size: 13px;
}
input[type="text"]:focus { border-color: var(--blue); }

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

.refresh-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.refresh-btn:hover:not(:disabled) {
  background: #334155;
  color: #e2e8f0;
}
.refresh-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */
main { max-width: 1200px; margin: 0 auto; padding: 20px 24px; }

/* ── Search results ──────────────────────────────────────────────────────── */
.search-results {
  position: absolute;
  top: 56px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 280px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.search-result-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--border); }
.alch-value { color: var(--muted); font-size: 12px; }

/* ── Item panel ──────────────────────────────────────────────────────────── */
.item-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px 20px;
  margin-bottom: 24px;
  position: relative;
  box-shadow: 0 4px 32px rgba(0,0,0,0.5);
}

.item-panel-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.item-panel-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.item-icon-lg {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.item-panel-title {
  min-width: 0;
}
.item-panel-title h2 { font-size: 1.05rem; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.item-meta { display: flex; gap: 12px; color: var(--muted); font-size: 12px; margin-top: 3px; flex-wrap: wrap; }
.item-meta strong { color: var(--text); }
.item-membership { color: var(--blue); }

.item-panel-prices {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  flex-shrink: 0;
}
.item-price-pair { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.price-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.price-value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-buy  { color: var(--green); }
.price-sell { color: var(--red); }
.price-arrow { color: var(--muted); font-size: 14px; }

.close-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.close-btn:hover { color: var(--text); background: var(--border); }

/* Chart toolbar: mode buttons + live badge */
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.chart-modes { display: flex; gap: 6px; }

.chart-live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--green);
  opacity: 0.85;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse-dot 1.6s ease-in-out infinite;
}

#chart-container { width: 100%; height: 420px; }

.chart-modes button, .kind-filters button, .sort-filters button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.chart-modes button.active, .kind-filters button.active, .sort-filters button.active {
  border-color: var(--blue);
  color: var(--blue);
  background: rgba(96,165,250,0.08);
}
.chart-modes button:hover, .kind-filters button:hover, .sort-filters button:hover {
  color: var(--text);
  background: var(--border);
}

.chart-note { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ── Count badges ────────────────────────────────────────────────────────── */
.count-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: var(--border);
  color: var(--muted);
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Section header + two-row controls ──────────────────────────────────── */
.section-header {
  margin-bottom: 16px;
}
.section-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.section-header h2 { font-size: 1rem; font-weight: 600; }

.section-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kind-filters { display: flex; gap: 6px; }
.sort-filters { display: flex; gap: 6px; border-left: 1px solid var(--border); padding-left: 10px; }

.profit-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.profit-filter strong { color: var(--text); font-weight: 600; }
.profit-filter input[type="range"] { width: 100px; accent-color: var(--blue); cursor: pointer; }

/* ── Budget filter ───────────────────────────────────────────────────────── */
.budget-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
  font-size: 12px;
  color: var(--muted);
}
.budget-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  width: 72px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.budget-input:focus { border-color: var(--blue); }
.budget-fractions { display: flex; gap: 3px; }
.budget-fractions button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.4;
  transition: color 0.15s, border-color 0.15s;
}
.budget-fractions button.active { border-color: var(--blue); color: var(--blue); }
.budget-fractions button:disabled { opacity: 0.35; cursor: not-allowed; }
.budget-fractions button:not(:disabled):hover { color: var(--text); }

.per-trade-pill {
  background: rgba(245,166,35,0.12);
  border: 1px solid rgba(245,166,35,0.28);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ── States ──────────────────────────────────────────────────────────────── */
.loading { color: var(--muted); padding: 20px 0; }
.empty   { color: var(--muted); padding: 20px 0; }

/* ── Skeleton shimmer ────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton-line {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skeleton-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Opportunity cards ───────────────────────────────────────────────────── */
.opp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.opp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.opp-card:hover {
  border-color: rgba(96,165,250,0.6);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}
.opp-card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.opp-card.flip       { border-left: 3px solid var(--green); }
.opp-card.alch_floor { border-left: 3px solid var(--amber); }
.opp-card.crash      { border-left: 3px solid var(--red); }

/* Card header: icon + badge left, primary metric right */
.opp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.opp-card-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
  border-radius: 3px;
}

/* Kind badge pills */
.kind-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
}
.kind-badge.kind-flip {
  background: rgba(74,222,128,0.12);
  color: var(--green);
}
.kind-badge.kind-alch_floor {
  background: rgba(245,158,11,0.12);
  color: var(--amber);
}
.kind-badge.kind-crash {
  background: rgba(248,113,113,0.12);
  color: var(--red);
}

/* Primary metric — large number top right */
.opp-primary-metric {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Item name */
.opp-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}

/* Card body */
.opp-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 2px;
}

.opp-stats-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.opp-profit-per {
  color: var(--green);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.opp-margin { color: var(--muted); font-size: 12px; }

/* Budget projection row */
.opp-projected {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  padding: 4px 8px;
  background: rgba(96,165,250,0.07);
  border: 1px solid rgba(96,165,250,0.18);
  border-radius: 4px;
}
.opp-projected-qty    { color: var(--muted); }
.opp-projected-profit { color: var(--green); font-weight: 600; }

/* Capital required + limit */
.opp-capital-row {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.opp-capital-row strong { color: var(--text); }
.opp-sep { color: var(--muted); }

/* Buy/sell prices */
.opp-prices {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.opp-prices strong { color: var(--text); font-variant-numeric: tabular-nums; }
.opp-prices .arrow { color: var(--muted); }

/* Volume */
.opp-volume-row { font-size: 12px; color: var(--muted); }
.opp-volume-row strong { color: var(--text); }

/* Timestamp */
.opp-time {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  margin-top: 2px;
}
