body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background-color: #f9fafb;
  color: #111827;
}

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: #1e293b;
  color: #fff;
  width: 220px;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  box-shadow: 2px 0 6px rgba(0,0,0,0.15);
}

.sidebar h2 {
  margin: 0 0 2rem 0;
  font-size: 1.4rem;
  text-align: center;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar button {
  background: none;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #fff;
  padding: 0.7rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s ease;
}

.sidebar button:hover {
  background: #334155;
}

.sidebar button.active {
  background: #3b82f6;
  border-color: #3b82f6;
}

/* Main layout */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Topbar */
.topbar {
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-size: 1.25rem;
  margin: 0;
  color: #1e293b;
}

.topbar form {
  display: flex;
  gap: 0.5rem;
}

input[type="text"] {
  padding: 0.6rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  width: 300px;
  font-size: 1rem;
}

button {
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: #2563eb;
}

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  background-color: #f9fafb;
  padding: 1.5rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* Listing Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.listing-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  transition: transform 0.15s ease;
}

.listing-card:hover {
  transform: translateY(-3px);
}

.listing-card img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background-color: #f1f5f9;
  display: block;
  padding: 10px;
}

.card-content {
  padding: 1rem;
}

.card-content h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  color: #111827;
}

.shipping, .total, .category, .seller {
  font-size: 0.9rem;
  color: #4b5563;
  margin-bottom: 0.4rem;
}

.identifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
  margin-bottom: 0.8rem;
}

.identifiers span {
  background: #f3f4f6;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: #374151;
}

.price {
  color: #16a34a;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.condition {
  font-size: 0.9rem;
  color: #6b7280;
  margin-bottom: 0.75rem;
}

a {
  text-decoration: none;
  color: #2563eb;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

#priceChart {
  width: 100%;
  height: 400px;
  box-sizing: border-box;
  background: white;
  border-radius: 10px;
  padding: 1rem;
  border: 1px solid #e2e8f0;
}

/* 3D Flip Effect for Reference Cards */
.listing-card.reference {
  perspective: 800px;
}

.listing-card.reference .image-flip {
  position: relative;
  width: 100%;
  height: 240px;
  transform-style: preserve-3d;
  transition: transform 0.7s ease;
  cursor: pointer;
}

.listing-card.reference:hover .image-flip {
  transform: rotateY(180deg);
}

.listing-card.reference .image-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.listing-card.reference .image-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f9fafb;
}

.listing-card.reference .image-face.back {
  transform: rotateY(180deg);
  box-shadow: inset 0 0 12px rgba(0,0,0,0.2);
}

.listing-card.reference .card-content {
  text-align: center;
  padding: 10px 0px 0px;
  background: white;
  border-top: 1px solid #e2e8f0;
}

.series-section {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.series-header {
  background: #3b82f6;
  color: #fff;
  padding: 0.75rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.series-header:hover {
  background: #2563eb;
}

.series-cards {
  display: none;
  padding: 1rem;
}

.series-section.open .series-cards {
  display: grid;
}

.series-section.open .series-header::after {
  content: " ▲";
}

.series-section .series-header::after {
  content: " ▼";
  float: right;
  font-weight: normal;
  opacity: 0.8;
}
