:root {
  color-scheme: light;
  --bg: #0b1020;
  --bg-2: #111827;
  --panel: rgba(17, 24, 39, 0.78);
  --panel-solid: #111827;
  --panel-soft: #182234;
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --border: rgba(148, 163, 184, 0.18);
  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f87171;
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.35);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.25), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(34, 197, 94, 0.12), transparent 28%),
    linear-gradient(180deg, #050816 0%, #0b1020 100%);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.25rem;
  max-width: 1680px;
  margin: 0 auto;
  padding: 1.25rem;
  transition: grid-template-columns 0.18s ease;
}

html.sidebar-collapsed .app-shell,
body.sidebar-collapsed .app-shell {
  grid-template-columns: 88px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 1.25rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: calc(100vh - 2.5rem);
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.92), rgba(15, 23, 42, 0.8));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

html.sidebar-collapsed .sidebar,
body.sidebar-collapsed .sidebar {
  padding: 1rem 0.6rem;
}

html.sidebar-collapsed .sidebar-copy,
body.sidebar-collapsed .sidebar-copy,
html.sidebar-collapsed .sidebar-card,
body.sidebar-collapsed .sidebar-card,
html.sidebar-collapsed .shop-list,
body.sidebar-collapsed .shop-list,
html.sidebar-collapsed .quick-searches,
body.sidebar-collapsed .quick-searches,
html.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .brand-copy {
  display: none;
}

html.sidebar-collapsed .sidebar-header,
body.sidebar-collapsed .sidebar-header {
  flex-direction: column;
  align-items: center;
}

html.sidebar-collapsed .brand,
body.sidebar-collapsed .brand {
  justify-content: center;
}

html.sidebar-collapsed .brand-mark,
body.sidebar-collapsed .brand-mark {
  width: 2.5rem;
  height: 2.5rem;
}

html.sidebar-collapsed .sidebar-toggle,
body.sidebar-collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
}

.brand-copy { min-width: 0; }

.sidebar-toggle {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.88);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.sidebar-toggle:hover {
  background: rgba(59, 130, 246, 0.22);
}

.brand { display: flex; gap: 0.9rem; align-items: center; }
.brand-mark {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  color: white;
  box-shadow: 0 10px 30px rgba(59, 130, 246, 0.32);
}
.brand h1, .panel h2, .panel h3, p { margin: 0; }
.eyebrow {
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.sidebar-copy { color: var(--muted); line-height: 1.6; }
.sidebar-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.55);
}
.sidebar-card h2 { font-size: 1rem; margin-bottom: 0.8rem; }
.quick-searches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}
.quick-searches button,
.tag,
.row-button,
.secondary-button,
.drawer-tab {
  border: 1px solid rgba(96, 165, 250, 0.24);
  background: rgba(59, 130, 246, 0.14);
  color: var(--text);
  border-radius: 999px;
  padding: 0.65rem 0.85rem;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.quick-searches button:hover,
.row-button:hover,
.secondary-button:hover,
.drawer-tab:hover {
  transform: translateY(-1px);
  background: rgba(59, 130, 246, 0.26);
  border-color: rgba(96, 165, 250, 0.42);
}
.drawer-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: rgba(96, 165, 250, 0.45);
  color: white;
}
.shop-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.shop-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.92rem;
}
.shop-pill::before {
  content: '';
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.panel {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(30, 41, 59, 0.9));
}
.hero h2 {
  font-size: clamp(1.5rem, 2vw, 2.4rem);
  line-height: 1.1;
  max-width: 20ch;
}
.hero-copy { color: var(--muted); margin-top: 0.65rem; line-height: 1.6; }
.hero-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 0.75rem;
}
.metric {
  min-width: 140px;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
}
.metric span {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
}
.metric label { color: var(--muted); font-size: 0.85rem; }

.search-form {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 260px auto;
  gap: 1rem;
  align-items: end;
}
label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.92rem;
  color: var(--muted);
}
input, select {
  width: 100%;
  padding: 0.92rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: var(--muted-2); }
input:focus, select:focus {
  border-color: rgba(96, 165, 250, 0.7);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}
button#search-button {
  border: 1px solid rgba(96, 165, 250, 0.3);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  padding: 0.95rem 1.2rem;
  border-radius: 16px;
  font-weight: 800;
  min-width: 120px;
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.24);
}
button#search-button:hover { filter: brightness(1.05); }
button#search-button:disabled,
.row-button:disabled,
.secondary-button:disabled {
  opacity: 0.65;
  cursor: wait;
}
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}
.status {
  color: var(--muted);
  min-height: 1.25rem;
}
.status.error { color: var(--danger); }
.status.success { color: var(--success); }
.result-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.9rem;
}
.tag.success { border-color: rgba(34, 197, 94, 0.25); background: rgba(34, 197, 94, 0.12); }
.tag.warning { border-color: rgba(245, 158, 11, 0.25); background: rgba(245, 158, 11, 0.12); }
.tag.neutral { border-color: rgba(96, 165, 250, 0.25); background: rgba(59, 130, 246, 0.12); }

.panel-header, .section-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}
.summary-text {
  color: var(--muted);
  font-size: 0.92rem;
}
.table-wrap { overflow: auto; }
table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
}
th, td {
  padding: 0.9rem 0.8rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
tbody tr:hover { background: rgba(59, 130, 246, 0.05); }
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}
.shop-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.18);
  font-size: 0.85rem;
}
.price-pill {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.18);
  color: #c7f9d4;
}
.row-button {
  width: 100%;
  border: 1px solid rgba(96, 165, 250, 0.22);
  background: rgba(59, 130, 246, 0.16);
  padding: 0.72rem 0.85rem;
  border-radius: 14px;
  font-weight: 700;
}
.secondary-button {
  border-radius: 14px;
  padding: 0.72rem 0.95rem;
  background: rgba(15, 23, 42, 0.55);
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}
.drawer.open { display: block; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(6px);
}
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(720px, 100vw);
  height: 100%;
  overflow: auto;
  padding: 1.25rem;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.98));
  box-shadow: -24px 0 70px rgba(2, 6, 23, 0.45);
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.drawer-header h2 { font-size: 1.35rem; }
.drawer-close {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
}
.drawer-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.drawer-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem;
  margin-bottom: 1rem;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.14);
}
.drawer-tab {
  flex: 1;
  border-radius: 14px;
  background: transparent;
  padding: 0.75rem 0.9rem;
  font-weight: 700;
}
.drawer-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: rgba(96, 165, 250, 0.45);
  color: white;
}
.drawer-section {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}
.drawer-section.active { display: flex; }
.drawer-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.drawer-card {
  padding: 0.9rem;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.62);
}
.drawer-card label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.4rem;
}
.drawer-card strong {
  display: block;
  font-size: 1rem;
  line-height: 1.35;
}
.drawer-card .small { margin-top: 0.35rem; }
.drawer-empty { margin-top: 0.5rem; }
.drawer-raw {
  white-space: pre-wrap;
  background: rgba(2, 6, 23, 0.92);
  color: #dbeafe;
  border-radius: 18px;
  padding: 1rem;
  overflow: auto;
  min-height: 280px;
  border: 1px solid rgba(96, 165, 250, 0.16);
}
.drawer-raw.empty {
  background: rgba(15, 23, 42, 0.5);
  color: var(--muted);
  border: 1px dashed rgba(148, 163, 184, 0.2);
}
.loading {
  position: relative;
  overflow: hidden;
}
.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.15s infinite;
}
.hidden { display: none !important; }
@keyframes shimmer {
  100% { transform: translateX(100%); }
}

@media (max-width: 1200px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: auto; }
  html.sidebar-collapsed .app-shell,
  body.sidebar-collapsed .app-shell { grid-template-columns: 1fr; }
  html.sidebar-collapsed .sidebar,
  body.sidebar-collapsed .sidebar { padding: 1.25rem; }
  html.sidebar-collapsed .sidebar-copy,
  body.sidebar-collapsed .sidebar-copy,
  html.sidebar-collapsed .sidebar-card,
  body.sidebar-collapsed .sidebar-card,
  html.sidebar-collapsed .shop-list,
  body.sidebar-collapsed .shop-list,
  html.sidebar-collapsed .quick-searches,
  body.sidebar-collapsed .quick-searches,
  html.sidebar-collapsed .brand-copy,
  body.sidebar-collapsed .brand-copy { display: block; }
  html.sidebar-collapsed .sidebar-header,
  body.sidebar-collapsed .sidebar-header { flex-direction: row; align-items: start; }
  html.sidebar-collapsed .brand,
  body.sidebar-collapsed .brand { justify-content: flex-start; }
  html.sidebar-collapsed .sidebar-toggle,
  body.sidebar-collapsed .sidebar-toggle { transform: none; }
}
@media (max-width: 860px) {
  .hero, .panel-header, .status-row, .drawer-header { align-items: start; flex-direction: column; }
  .search-form { grid-template-columns: 1fr; }
  .hero-meta { grid-template-columns: 1fr 1fr; width: 100%; }
  .drawer-cards { grid-template-columns: 1fr; }
  .drawer-tabs { flex-wrap: wrap; }
}
@media (max-width: 520px) {
  .app-shell { padding: 0.75rem; }
  .panel, .sidebar { border-radius: 20px; }
  .hero-meta { grid-template-columns: 1fr; }
  .drawer-panel { width: 100vw; }
}
