/* Slopbin Data Lab — css/data-lab.css */
/* Light/dark via [data-theme] on <html>; default follows prefers-color-scheme */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --text: #171a26;
  --muted: #5b6172;
  --border: #dfe2ec;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, 0.1);
  --good: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 1px 3px rgba(20, 24, 46, 0.08), 0 8px 24px rgba(20, 24, 46, 0.06);
  --radius: 14px;
}
[data-theme="dark"] {
  --bg: #0d1017;
  --surface: #151a24;
  --surface-2: #1c2331;
  --text: #e8eaf2;
  --muted: #98a0b3;
  --border: #2a3142;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
h1, h2, h3 { line-height: 1.2; }
h2 { font-size: 1.5rem; margin: 0 0 1rem; letter-spacing: -0.01em; }
.subhead { font-size: 1.02rem; margin: 1.4rem 0 0.6rem; }
a { color: var(--accent); }

/* ---------- header / footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 12px; padding: 12px 20px; }
.logo { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.logo span { color: var(--accent); }
.header-tag {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 999px;
}
.header-inner #theme-toggle { margin-left: auto; }
.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; padding: 1.6rem 0; color: var(--muted); font-size: 0.9rem; }
.footer-inner p { margin: 0.25rem 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 0.92rem;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 16px; cursor: pointer; color: var(--text); background: var(--surface);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-secondary { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- hero ---------- */
.hero-section { padding: 3.2rem 0 2rem; text-align: center; }
#hero-title { font-size: clamp(2rem, 5.5vw, 3.2rem); margin: 0 0 0.6rem; letter-spacing: -0.02em; }
.hero-sub { font-size: 1.15rem; color: var(--muted); margin: 0 0 0.4rem; }
.hero-privacy { color: var(--good); font-weight: 600; margin: 0 0 1.6rem; }
.drop-zone {
  max-width: 640px; margin: 0 auto;
  border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); padding: 2.6rem 1.5rem;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.drop-zone.dragover {
  border-color: var(--accent); background: var(--accent-soft);
  transform: scale(1.01);
}
.drop-zone-icon { font-size: 2.2rem; margin-bottom: 0.4rem; }
.drop-zone-title { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.04em; }
.drop-zone-or { color: var(--muted); margin: 0.5rem 0 0.8rem; }
.sample-row { margin-top: 1.1rem; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.sample-note { color: var(--muted); font-size: 0.88rem; }
.privacy-banner {
  margin: 1.6rem auto 0; max-width: 640px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 0.9rem; color: var(--muted);
}

/* ---------- status / progress / errors ---------- */
.status-section { padding: 2rem 0 0; }
.loading-box, .error-box {
  display: flex; gap: 16px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.2rem 1.4rem; margin-bottom: 1.2rem;
}
.error-box { border-color: var(--bad); flex-direction: column; }
.error-title { font-weight: 700; font-size: 1.1rem; color: var(--bad); }
.error-body { margin: 0.4rem 0; }
.error-box .btn { align-self: flex-start; margin-top: 0.5rem; }
.spinner {
  width: 26px; height: 26px; flex: 0 0 26px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-track { width: 260px; max-width: 60vw; height: 6px; background: var(--surface-2); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s; }

/* ---------- dataset banner ---------- */
.dataset-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.4rem; margin-bottom: 1.4rem;
}
.banner-big { font-size: 1.7rem; font-weight: 800; margin-right: 4px; }
.banner-label { opacity: 0.85; margin-right: 18px; font-weight: 600; }
.banner-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dataset-banner .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.45); }
.filter-status { font-weight: 600; font-size: 0.95rem; }

/* ---------- sections & cards ---------- */
.app-section { padding: 1.6rem 0; }
.overview-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem;
}
.overview-card { display: flex; flex-direction: column; gap: 2px; }
.ov-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.ov-value { font-size: 1.7rem; font-weight: 800; }
.overview-card.warn .ov-value { color: var(--warn); }

/* ---------- insights ---------- */
.insights-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.insight {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 0.8rem 1rem; font-size: 0.95rem;
}
.insight.warn { border-left-color: var(--warn); }

/* ---------- column analysis ---------- */
.section-hint { margin: -0.5rem 0 0.9rem; font-size: 0.88rem; }
.column-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.col-card { cursor: pointer; }
.col-card summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.col-card summary::-webkit-details-marker { display: none; }
.col-card summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.col-name { font-weight: 700; font-size: 1rem; }
.col-type {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 9px;
}
.col-type.t-number { background: rgba(16,185,129,0.14); color: var(--good); }
.col-type.t-date { background: rgba(59,130,246,0.14); color: #3b82f6; }
.col-type.t-boolean { background: rgba(236,72,153,0.14); color: #ec4899; }
.col-mini { color: var(--muted); font-size: 0.85rem; }
.col-detail { margin-top: 0.8rem; border-top: 1px solid var(--border); padding-top: 0.7rem; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.stat-table td { padding: 3px 0; }
.stat-table td:first-child { color: var(--muted); width: 55%; }
.stat-table td:last-child { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.top-values { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-top: 0.5rem; }
.top-values td { padding: 3px 0; border-top: 1px dashed var(--border); }
.top-values td:first-child { overflow-wrap: anywhere; }
.top-values td:last-child { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.outlier-note { font-size: 0.85rem; color: var(--warn); margin: 0.6rem 0 0; font-weight: 600; }

/* ---------- charts ---------- */
.chart-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.chart-card { padding: 0.9rem 1rem 0.6rem; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 0.4rem; }
.chart-title { font-weight: 700; font-size: 0.95rem; }
.chart-btns { display: flex; gap: 6px; }
.chart-body { width: 100%; overflow-x: auto; }
.chart-body svg { display: block; width: 100%; height: auto; }
.chart-body svg text { font-family: inherit; }
svg .tick { fill: var(--muted); font-size: 10px; }
svg .axis-label { fill: var(--text); font-size: 11px; font-weight: 600; }
svg .chart-caption { fill: var(--text); font-size: 12px; font-weight: 700; }
svg .grid { stroke: currentColor; stroke-opacity: 0.12; stroke-width: 1; }
svg .axis-line { stroke: var(--muted); stroke-width: 1; }
svg .legend-text { fill: var(--text); font-size: 10px; }
svg .tip-rect { fill: var(--surface); stroke: var(--border); }
svg .tip-text { fill: var(--text); font-size: 11px; }
svg .chart-empty-text { fill: var(--muted); font-size: 13px; }
.chart-empty { color: var(--muted); font-size: 0.9rem; padding: 1.4rem 0; text-align: center; }
svg .dl-tip { opacity: 0; pointer-events: none; }
svg .dl-tip-on { opacity: 1; }

/* ---------- relationships ---------- */
.rel-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.rel-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem 1rem; }
.rel-pair { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rel-r { font-size: 1.25rem; font-weight: 800; color: var(--accent); }
.rel-r.neg { color: var(--bad); }
.rel-desc { color: var(--muted); font-size: 0.88rem; }
.corr-matrix-wrap { overflow-x: auto; padding-bottom: 6px; }
table.corr { border-collapse: collapse; font-size: 0.85rem; min-width: 420px; }
table.corr th, table.corr td { border: 1px solid var(--border); padding: 6px 10px; text-align: center; font-variant-numeric: tabular-nums; }
table.corr th { background: var(--surface-2); font-weight: 700; }
table.corr th:first-child { text-align: left; }
.corr-cell { cursor: default; }
.corr-diag { background: var(--surface-2); color: var(--muted); }
.corr-legend { margin-top: 8px; font-size: 0.8rem; color: var(--muted); }

/* ---------- builder ---------- */
.builder-layout { display: grid; gap: 16px; grid-template-columns: minmax(300px, 380px) 1fr; align-items: start; }
.builder-fields { display: flex; flex-direction: column; gap: 10px; }
.builder-fields label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; font-size: 0.9rem; }
.vb-select {
  font: inherit; min-width: 55%; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.vb-palette { display: flex; flex-wrap: wrap; gap: 8px; margin: 0.5rem 0 1rem; min-height: 38px; }
.vb-chip {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 12px; font-size: 0.85rem; font-weight: 600; cursor: grab; user-select: none;
}
.vb-chip:active { cursor: grabbing; }
.vb-targets { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.vb-target {
  border: 1.5px dashed var(--border); border-radius: 10px; padding: 8px;
  font-size: 0.8rem; font-weight: 700; color: var(--muted); text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.vb-target.dragover { border-color: var(--accent); background: var(--accent-soft); }
.vb-target .vb-drop { min-height: 30px; margin-top: 4px; display: flex; align-items: center; justify-content: center; }
.vb-drop-filled {
  background: var(--accent-soft); color: var(--accent); border-radius: 7px;
  padding: 3px 8px; font-size: 0.8rem; font-weight: 700; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.vb-target.clearable { cursor: pointer; }
#vb-chart { min-height: 340px; }

/* ---------- quality ---------- */
.quality-card { display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; }
.quality-score { text-align: center; }
.quality-num { font-size: 3rem; font-weight: 800; color: var(--good); }
.quality-den { color: var(--muted); font-weight: 600; }
.quality-label { display: block; font-weight: 700; margin-top: 4px; }
.quality-breakdown { flex: 1; min-width: 280px; }
.qb-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 0.9rem; }
.qb-row .qb-bar { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.qb-row .qb-fill { height: 100%; border-radius: 999px; background: var(--good); }
.qb-row.ded .qb-fill { background: var(--warn); }

/* ---------- outliers / missing ---------- */
.outlier-summary { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.4rem; }
.outlier-group { margin-top: 1rem; }
.outlier-group h4 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.outlier-group p { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.85rem; }
.outlier-values { display: flex; flex-wrap: wrap; gap: 6px; }
.outlier-val {
  background: rgba(217, 119, 6, 0.12); color: var(--warn);
  border-radius: 7px; padding: 3px 9px; font-size: 0.85rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.view-rows-btn { margin: 0.5rem 0 0; font-size: 0.8rem; padding: 4px 10px; }
.missing-layout { display: grid; gap: 16px; grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr); align-items: start; }
.missing-filter-btn { margin-top: 0.8rem; }

/* ---------- filters + table ---------- */
.filter-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; font-weight: 700; }
.filter-panel { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.filter-group { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.filter-group h4 { margin: 0 0 0.5rem; font-size: 0.88rem; }
.filter-group label { display: block; font-size: 0.85rem; color: var(--muted); margin: 4px 0 2px; }
.filter-group input[type="number"], .filter-group input[type="date"], .filter-group input[type="search"] {
  font: inherit; padding: 6px 9px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); width: 100%;
}
.cat-options { display: flex; flex-wrap: wrap; gap: 4px 12px; max-height: 130px; overflow-y: auto; }
.cat-options label { display: inline-flex; align-items: center; gap: 5px; font-size: 0.85rem; color: var(--text); margin: 0; }
.table-card { margin-top: 16px; }
.table-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.search-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; flex: 1; min-width: 260px; }
.search-label input { flex: 1; max-width: 380px; }
.table-wrap { overflow: auto; max-height: 65vh; border: 1px solid var(--border); border-radius: 10px; }
table.dl-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 0.88rem; }
.dl-table th, .dl-table td { padding: 7px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; background: var(--surface); }
.dl-table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  font-weight: 700; cursor: pointer; user-select: none; min-width: 90px;
}
.dl-table th:hover { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.dl-table th .sort-arrow { color: var(--accent); margin-left: 4px; }
.dl-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dl-table td.missing-cell { color: var(--muted); font-style: italic; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.dl-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.pager { display: flex; align-items: center; gap: 6px; }

/* ---------- export ---------- */
.export-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- seo content ---------- */
.seo-section { border-top: 1px solid var(--border); margin-top: 2.5rem; padding: 2.4rem 0 1rem; }
.seo-section article { max-width: 820px; }
.seo-section h2 { font-size: 1.25rem; margin-top: 2rem; }
.seo-section p, .seo-section li { color: var(--muted); }
.faq h3 { font-size: 1rem; margin: 1.2rem 0 0.2rem; }
.faq p { margin: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); border-radius: 10px;
  padding: 10px 18px; font-size: 0.9rem; font-weight: 600; z-index: 90;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); max-width: 90vw; text-align: center;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .builder-layout { grid-template-columns: 1fr; }
  .missing-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .chart-grid { grid-template-columns: 1fr; }
  .column-list { grid-template-columns: 1fr; }
  .insights-list { grid-template-columns: 1fr; }
  .hero-section { padding-top: 2rem; }
  .drop-zone { padding: 1.8rem 1rem; }
  .banner-big { font-size: 1.3rem; }
  .header-tag { display: none; }
  .quality-card { gap: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
