:root {
  color-scheme: light dark;
  --accent: #2f6f4f;
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --badge-good: #2f6f4f;
  --badge-drop: #1a7f37;
  --badge-rise: #b3261e;
}

* { box-sizing: border-box; }

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

.topbar {
  padding: 16px 24px;
  background: var(--card-bg);
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  font-size: 20px;
  margin: 0;
  flex: 1 1 auto;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

button, select {
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #d0d0d0;
  background: white;
  cursor: pointer;
}

#refreshBtn {
  background: var(--accent);
  color: white;
  border: none;
}

#refreshBtn:disabled {
  opacity: 0.6;
  cursor: wait;
}

#statusLine {
  width: 100%;
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 20px 24px;
}

.card {
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
  background: #ddd;
}

.card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-price {
  font-size: 18px;
  font-weight: 600;
}

.card-meta {
  font-size: 13px;
  color: var(--muted);
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  color: white;
}

.badge-recommended { background: var(--badge-good); }
.badge-drop { background: var(--badge-drop); }
.badge-rise { background: var(--badge-rise); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.detail-panel {
  background: var(--card-bg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 10px;
  padding: 24px;
  position: relative;
}

.detail-panel .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
}

.detail-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px 0;
}

.detail-gallery img {
  height: 160px;
  border-radius: 6px;
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.lightbox.hidden {
  display: none;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-close {
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  font-size: 32px;
  line-height: 1;
}

.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-nav.hidden { display: none; }

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border-radius: 999px;
}

.detail-phone {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  text-decoration: none;
}
