.eco-head {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 max(1.5rem, var(--page-pad, 1rem));
}

.tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0 max(1.5rem, var(--page-pad, 1rem)) 1.25rem;
  max-width: 1040px;
  margin: 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  min-height: 44px;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}
.tab-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
}
.tab:hover,
.tab:active {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text);
}
.tab.active {
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--accent);
  background: var(--accent-dim);
}

.eco-main {
  padding: 0 max(1.5rem, var(--page-pad, 1rem)) calc(3rem + var(--safe-bottom, 0px));
  max-width: 1040px;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 1rem;
}
#search {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: inherit;
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#search:focus {
  border-color: rgba(52, 211, 153, 0.4);
}
.count {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.eco-panel { display: none; }
.eco-panel.active { display: grid; }

.item-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
}

.item-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.15s, transform 0.15s;
}
.item-card[data-market-key] {
  cursor: pointer;
}
.item-card[data-market-key]:hover,
.item-card[data-market-key]:active {
  border-color: rgba(52, 211, 153, 0.35);
  transform: translateY(-1px);
}
.item-card:hover,
.item-card:active {
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.mc-slot {
  background-color: #5a5a62;
  background-image:
    linear-gradient(45deg, #63636b 25%, transparent 25%),
    linear-gradient(-45deg, #63636b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #63636b 75%),
    linear-gradient(-45deg, transparent 75%, #63636b 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.item-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.45);
}
.item-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}

.item-info { min-width: 0; flex: 1; }
.item-name {
  font-weight: 600;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}
.item-name.mc-colored span { font-weight: inherit; }
.item-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-price {
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.trend-up { color: var(--ok); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--muted); }

.empty, .error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

/* iPhone */
@media (max-width: 480px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .count {
    text-align: center;
    padding-bottom: 0.15rem;
  }
  .item-grid { grid-template-columns: 1fr; }
  .item-meta { white-space: normal; }
}

/* iPad */
@media (min-width: 481px) and (max-width: 1024px) {
  .item-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* iPad landscape / desktop */
@media (min-width: 1025px) {
  .item-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--safe-bottom, 0) var(--page-pad, 1rem) 1rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}
.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: 90vh;
  max-height: 90dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 16px 16px 12px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.25rem 1.2rem 1.5rem;
}
.modal-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.modal-head {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1rem;
  padding-right: 2.5rem;
}
.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.modal-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}
.modal-cat {
  margin: 0 0 0.35rem;
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(52, 211, 153, 0.25);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.modal-head h2 {
  margin: 0.2rem 0 0;
  font-size: 1.125rem;
  font-weight: 700;
}
.modal-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.stat {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.stat span {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.9375rem;
}
.modal-chart-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  padding: 0.85rem;
}
.modal-chart-label {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.modal-chart {
  width: 100%;
  min-height: 120px;
}
.modal-chart svg {
  width: 100%;
  height: 120px;
  display: block;
}
.chart-empty {
  margin: 0;
  padding: 1.5rem 0.5rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}
.chart-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.chart-bar {
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}
.chart-bar span {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-bar strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1rem;
}
.chart-bar .bar-track {
  margin-top: 0.55rem;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.chart-bar .bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}
.chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.45rem;
  font-size: 0.6875rem;
  color: var(--muted);
}
.modal-updated {
  margin: 0.85rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding-bottom: 2rem;
  }
  .modal-panel {
    border-radius: 16px;
  }
  .modal-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}
