:root {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2e38;
  --text: #e6e8eb;
  --muted: #9aa1ac;
  --accent: #5b9cf6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.emission-status {
  justify-self: center;
  text-align: center;
  white-space: nowrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 20px;
}

.emission-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.emission-counter {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.emission-status.active .emission-title,
.emission-status.active .emission-counter {
  color: #4cd964;
}

header .brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 18px;
}

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

.main-nav {
  display: flex;
  gap: 16px;
}

.main-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.main-nav a:hover {
  color: var(--accent);
}

.search-wrap {
  position: relative;
}

.search-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.search-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-box {
  position: absolute;
  top: 44px;
  right: 0;
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 10px;
  z-index: 20;
}

.search-box input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-results {
  max-height: 360px;
  overflow-y: auto;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.search-result-item img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.search-result-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px;
}

main {
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

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

.category-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.category-card h3 {
  margin: 0 0 8px;
  text-transform: capitalize;
}

.category-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.category-card li a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.8;
}

.category-card li a:hover {
  color: var(--accent);
}

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

.item-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.rarity-section {
  margin-bottom: 28px;
}

.rarity-section h3 {
  font-size: 14px;
  margin: 0 0 10px;
  padding-left: 10px;
  border-left: 4px solid var(--border);
}

.rarity-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.06);
}

.rarity-DEFAULT { color: #f2f2f2; border-color: #f2f2f2; }
.rarity-QUEST_ITEM { color: #e4c661; border-color: #e4c661; }
.rarity-RANK_NEWBIE { color: #4cd964; border-color: #4cd964; }
.rarity-RANK_STALKER { color: #4a9eff; border-color: #4a9eff; }
.rarity-RANK_VETERAN { color: #ff6fb0; border-color: #ff6fb0; }
.rarity-RANK_MASTER { color: #ff4d4d; border-color: #ff4d4d; }
.rarity-RANK_LEGEND { color: #f0d33e; border-color: #f0d33e; }

.rarity-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.rarity-filter button {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  opacity: 0.55;
}

.rarity-filter button.active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.lots-by-quality {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.lots-by-quality .chip {
  font-size: 12px;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.04);
}

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

#price-chart {
  cursor: pointer;
}

.potential-table {
  border-collapse: collapse;
  width: 100%;
  max-width: 600px;
  font-size: 13px;
  margin-top: 8px;
}

.potential-table th,
.potential-table td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  text-align: right;
  white-space: nowrap;
}

.cartridge-table {
  max-width: 900px;
}

.potential-table th:first-child,
.potential-table td:first-child {
  text-align: left;
}

.potential-table thead {
  color: var(--muted);
}

.potential-table tbody tr.baseline {
  color: var(--muted);
}

.potential-table tbody tr.clickable:hover {
  background: var(--panel-hover, rgba(255, 255, 255, 0.05));
}

.chart-controls {
  margin-bottom: 10px;
}

.chart-controls select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
}

.chart-controls button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.chart-controls button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chart-controls button:disabled {
  opacity: 0.5;
  cursor: default;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 10px;
  font-size: 12px;
}

.chart-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text);
  opacity: 1;
}

.chart-legend .legend-item.off {
  opacity: 0.35;
}

.chart-legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.item-card img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.item-card span {
  font-size: 13px;
}

.item-detail {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.item-detail img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}

.summary-row {
  display: flex;
  gap: 24px;
  margin: 16px 0;
}

.stat-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
}

.stat-box .label {
  color: var(--muted);
  font-size: 12px;
}

.stat-box .value {
  font-size: 20px;
  font-weight: 600;
}

canvas {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 100%;
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.breadcrumb a {
  color: var(--muted);
}
