/* shadcn-inspired design tokens + component utilities */
:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.75rem;
  --success: 142 76% 36%;
  --warning: 38 92% 50%;
  --chart-1: 221 83% 53%;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 3.9%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 3.9%;
    --popover-foreground: 0 0% 98%;
    --primary: 0 0% 98%;
    --primary-foreground: 240 5.9% 10%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 240 4.9% 83.9%;
    --success: 142 70% 45%;
    --warning: 38 92% 50%;
  }
}

html.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 240 10% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
  --success: 142 70% 45%;
  --warning: 38 92% 50%;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  font-family: var(--font-sans);
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "rlig" 1, "calt" 1;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }
:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
code {
  font-size: 0.875em;
  background: hsl(var(--muted));
  padding: 0.125rem 0.375rem;
  border-radius: calc(var(--radius) - 4px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1rem;
}
@media (min-width: 640px) { .container { padding: 0 1.5rem; } }

/* Header / nav */
.site-header {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.site-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem 0;
  max-width: 1120px; margin: 0 auto; padding-left: 1rem; padding-right: 1rem;
}
@media (min-width: 640px) {
  .site-header-inner { padding-left: 1.5rem; padding-right: 1.5rem; }
}
.brand {
  font-weight: 600; font-size: 0.95rem; letter-spacing: -0.01em;
  display: flex; flex-direction: column; gap: 0.1rem;
  text-decoration: none !important;
}
.brand span.muted { font-size: 0.7rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.nav-links { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }

/* Typography helpers */
.muted { color: hsl(var(--muted-foreground)); }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.tracking-tight { letter-spacing: -0.025em; }
.leading-tight { line-height: 1.25; }

.page-hero { padding: 2rem 0 1.5rem; }
.page-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700; letter-spacing: -0.025em; line-height: 1.2;
  margin-bottom: 0.5rem;
}
.page-hero p { color: hsl(var(--muted-foreground)); max-width: 40rem; font-size: 1rem; }

.section { margin: 1.75rem 0; }
.section-title {
  font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}
.section-desc { color: hsl(var(--muted-foreground)); font-size: 0.875rem; margin-bottom: 1rem; }

/* Card */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header { padding: 1.25rem 1.25rem 0.5rem; }
.card-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.card-description { color: hsl(var(--muted-foreground)); font-size: 0.875rem; margin-top: 0.25rem; }
.card-content { padding: 1rem 1.25rem 1.25rem; }
.card-footer { padding: 0 1.25rem 1.25rem; display: flex; align-items: center; gap: 0.5rem; }
a.card-link {
  display: block; text-decoration: none !important; color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
a.card-link:hover {
  border-color: hsl(var(--foreground) / 0.25);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.cards-grid {
  display: grid; gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .cards-grid { grid-template-columns: 1fr 1fr; } }

.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 860px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-2.plot-row { grid-template-columns: 1.05fr 0.95fr; }
}

/* Badge */
.badge {
  display: inline-flex; align-items: center;
  border-radius: 9999px; border: 1px solid transparent;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem; font-weight: 600; line-height: 1.25rem;
  white-space: nowrap;
}
.badge-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-outline { background: transparent; color: hsl(var(--foreground)); border-color: hsl(var(--border)); }
.badge-success {
  background: hsl(var(--success) / 0.12);
  color: hsl(var(--success));
  border-color: hsl(var(--success) / 0.25);
}
.badge-info {
  background: hsl(221 83% 53% / 0.12);
  color: hsl(221 83% 45%);
  border-color: hsl(221 83% 53% / 0.25);
}
.badge-warning {
  background: hsl(var(--warning) / 0.12);
  color: hsl(38 80% 35%);
  border-color: hsl(var(--warning) / 0.3);
}
@media (prefers-color-scheme: dark) {
  .badge-info { color: hsl(213 94% 68%); }
  .badge-warning { color: hsl(48 96% 53%); }
}
html.dark .badge-info { color: hsl(213 94% 68%); }
html.dark .badge-warning { color: hsl(48 96% 53%); }

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  white-space: nowrap; border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem; font-weight: 500; font-family: inherit;
  height: 2.25rem; padding: 0 1rem;
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  text-decoration: none !important;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-default { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-default:hover { opacity: 0.9; }
.btn-outline {
  background: transparent; border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}
.btn-outline:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.btn-ghost:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover { opacity: 0.85; }
.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.8125rem; border-radius: calc(var(--radius) - 4px); }
.btn-xs { height: 1.75rem; padding: 0 0.625rem; font-size: 0.75rem; border-radius: calc(var(--radius) - 4px); }

/* Input / select */
.input, .select {
  display: flex; width: 100%; height: 2.5rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem; font-family: inherit;
  color: hsl(var(--foreground));
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus, .select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}
.select { appearance: none; cursor: pointer; width: auto; min-width: 8rem; }
.label {
  display: block; font-size: 0.8rem; font-weight: 500;
  color: hsl(var(--muted-foreground)); margin-bottom: 0.35rem;
}

/* Table */
.table-wrap {
  width: 100%; overflow-x: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}
table.data {
  width: 100%; border-collapse: collapse; font-size: 0.875rem;
  min-width: 520px;
}
table.data th, table.data td {
  padding: 0.65rem 0.85rem; text-align: left;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: top;
}
table.data th {
  font-size: 0.75rem; font-weight: 500;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.5);
  white-space: nowrap; user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: hsl(var(--foreground)); }
table.data th.sorted { color: hsl(var(--foreground)); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr[data-id] { cursor: pointer; }
table.data tbody tr[data-id]:hover,
table.data tbody tr[data-id].selected { background: hsl(var(--muted) / 0.6); }
.num { font-variant-numeric: tabular-nums; }

/* Separator */
.separator {
  height: 1px; width: 100%;
  background: hsl(var(--border));
  margin: 1.5rem 0;
}

/* Status pill */
.status-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; font-weight: 500;
  padding: 0.15rem 0.55rem; border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}
.status-ok { color: hsl(var(--success)); border-color: hsl(var(--success) / 0.35); background: hsl(var(--success) / 0.08); }
.status-dot { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; }

/* Alert / disclaimer */
.alert {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.4);
}
.alert strong { color: hsl(var(--foreground)); font-weight: 600; }
.alert-warning {
  border-color: hsl(var(--warning) / 0.35);
  background: hsl(var(--warning) / 0.08);
}

/* Footer */
.site-footer {
  margin-top: 3rem; padding: 1.5rem 0 2.5rem;
  border-top: 1px solid hsl(var(--border));
  font-size: 0.8rem; color: hsl(var(--muted-foreground));
}

/* Y/N helpers */
.yn-y { color: hsl(var(--success)); font-weight: 600; }
.yn-n { color: hsl(var(--destructive)); font-weight: 600; }
.yn-u { color: hsl(var(--warning)); font-weight: 600; }

/* Investigation-specific */
.search-wrap { position: relative; margin-bottom: 0.85rem; }
.search-input { height: 2.75rem; font-size: 1rem; padding-left: 2.6rem; }
.search-icon {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  width: 1rem; height: 1rem; color: hsl(var(--muted-foreground)); pointer-events: none;
}
.suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: hsl(var(--popover)); color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  max-height: 280px; overflow-y: auto; box-shadow: var(--shadow-md); z-index: 40;
  display: none;
}
.suggestions.open { display: block; }
.sug-item {
  display: block; width: 100%; text-align: left;
  padding: 0.65rem 0.9rem; border: 0; background: transparent;
  color: inherit; font: inherit; cursor: pointer;
  border-bottom: 1px solid hsl(var(--border));
}
.sug-item:last-child { border-bottom: 0; }
.sug-item:hover, .sug-item[aria-selected="true"] { background: hsl(var(--accent)); }
.sug-item .meta { color: hsl(var(--muted-foreground)); font-size: 0.8rem; margin-left: 0.5rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.25rem; }
.chip {
  appearance: none; border: 1px solid hsl(var(--border));
  background: hsl(var(--background)); color: hsl(var(--muted-foreground));
  font: inherit; font-size: 0.8rem; padding: 0.3rem 0.7rem;
  border-radius: 9999px; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover, .chip.active {
  border-color: hsl(var(--foreground) / 0.3);
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}

.flavor-hero.empty {
  display: flex; align-items: center; justify-content: center;
  min-height: 180px; color: hsl(var(--muted-foreground)); text-align: center;
  font-size: 0.95rem;
}
.flavor-name { font-size: clamp(1.25rem, 2.5vw, 1.6rem); font-weight: 650; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
.score-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem 1.1rem; margin-bottom: 0.75rem; }
.score-big { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.score-big span { font-size: 0.95rem; color: hsl(var(--muted-foreground)); font-weight: 500; }
.rank-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: hsl(var(--secondary)); border: 1px solid hsl(var(--border));
  padding: 0.25rem 0.65rem; border-radius: 9999px; font-size: 0.85rem;
  color: hsl(var(--secondary-foreground));
}
.flag-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.flag {
  font-size: 0.7rem; font-weight: 600; padding: 0.2rem 0.55rem;
  border-radius: 9999px; border: 1px solid hsl(var(--border));
  background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground));
}
.flag.art-color { background: hsl(330 70% 50% / 0.1); color: hsl(330 55% 40%); border-color: hsl(330 70% 50% / 0.25); }
.flag.art-flavor { background: hsl(270 60% 50% / 0.1); color: hsl(270 45% 40%); border-color: hsl(270 60% 50% / 0.25); }
.flag.seed-oil { background: hsl(var(--warning) / 0.1); color: hsl(38 80% 35%); border-color: hsl(var(--warning) / 0.3); }
.flag.clean { background: hsl(var(--success) / 0.1); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.25); }
.flag.incomplete { color: hsl(var(--muted-foreground)); }

.dim-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.dim-row { display: grid; grid-template-columns: 7rem 1fr 2.2rem; gap: 0.5rem; align-items: center; }
.dim-label { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.dim-track { height: 8px; border-radius: 9999px; background: hsl(var(--muted)); overflow: hidden; }
.dim-fill {
  height: 100%; border-radius: 9999px;
  background: hsl(var(--foreground));
  width: 0; transition: width 0.4s ease;
}
.dim-fill.null {
  background: repeating-linear-gradient(90deg, hsl(var(--muted-foreground) / 0.25) 0 4px, transparent 4px 8px);
  width: 100% !important; opacity: 0.5;
}
.dim-val { font-size: 0.75rem; text-align: right; color: hsl(var(--muted-foreground)); font-variant-numeric: tabular-nums; }

.plot-wrap { position: relative; width: 100%; aspect-ratio: 1.35 / 1; min-height: 260px; }
#scatter { width: 100%; height: 100%; display: block; touch-action: manipulation; }
.plot-hint { margin-top: 0.5rem; font-size: 0.8rem; color: hsl(var(--muted-foreground)); }

.leaderboard { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-bottom: 0.5rem; }
@media (min-width: 700px) { .leaderboard { grid-template-columns: 1fr 1fr; } }
.lb-list { list-style: none; display: flex; flex-direction: column; gap: 0.3rem; }
.lb-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.4rem 0.5rem; border-radius: calc(var(--radius) - 4px);
  cursor: pointer; border: 1px solid transparent; background: hsl(var(--muted) / 0.4);
  font: inherit; color: inherit; text-align: left;
}
.lb-item:hover, .lb-item:focus-visible {
  border-color: hsl(var(--border)); background: hsl(var(--accent));
}
.lb-rank {
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.7rem; font-weight: 700;
  background: hsl(var(--secondary)); color: hsl(var(--foreground));
}
.lb-item.bottom .lb-rank { background: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); }
.lb-name { flex: 1; font-size: 0.875rem; }
.lb-score { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.875rem; }

.table-tools {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem;
  margin-bottom: 0.65rem; align-items: center;
}
.table-tools .label { margin: 0; }
.table-tools .input { width: auto; min-width: 10rem; height: 2.25rem; }

.chain-grid {
  display: grid; gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 1.5rem;
}
.chain-pct { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; margin: 0.35rem 0; }
.chain-pct span { font-size: 0.95rem; color: hsl(var(--muted-foreground)); font-weight: 500; }
.pct-bar { height: 6px; border-radius: 9999px; background: hsl(var(--muted)); margin: 0.55rem 0 0.4rem; overflow: hidden; }
.pct-fill { height: 100%; border-radius: 9999px; background: hsl(var(--foreground)); }

.dim-legend { display: grid; gap: 0.5rem; margin: 1rem 0; grid-template-columns: 1fr; }
@media (min-width: 560px) { .dim-legend { grid-template-columns: 1fr 1fr; } }
.dim-legend dt { font-weight: 600; font-size: 0.875rem; }
.dim-legend dd { color: hsl(var(--muted-foreground)); font-size: 0.8rem; margin: 0 0 0.4rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.main { padding-bottom: 2rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 0.75rem; font-size: 0.8rem; color: hsl(var(--muted-foreground)); }
