/* ============================================================
   Dashboard — Mozilla Bug Reports Quality Analysis
   Dark BI theme — vanilla CSS
   ============================================================ */

:root {
  --bg-0: #0d1117;
  --bg-1: #161b22;
  --bg-2: #21262d;
  --bg-3: #2d333b;
  --border: #30363d;
  --text-0: #e6edf3;
  --text-1: #8b949e;
  --text-2: #6e7681;
  --accent: #58a6ff;
  --accent-g: #3fb950;
  --accent-y: #d29922;
  --accent-r: #f85149;
  --accent-p: #bc8cff;
  --badge-ok-bg: #1a3a2a;
  --badge-ok-fg: #3fb950;
  --badge-warn-bg: #3a2a0a;
  --badge-warn-fg: #d29922;
  --badge-err-bg: #3a1010;
  --badge-err-fg: #f85149;
  --badge-neu-bg: #1e2433;
  --badge-neu-fg: #8b949e;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  background: var(--bg-0);
  color: var(--text-0);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Header ---- */
.header {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 1.5rem 0.5rem;
}

.header-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-0);
}

.header-sub {
  font-size: 0.78rem;
  color: var(--text-1);
}

/* ---- Tabs nav ---- */
.tabs-nav {
  display: flex;
  gap: 0;
  padding: 0 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-1);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.6rem 1rem;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--text-0); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- Main & panes ---- */
.main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- Section headings ---- */
.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-0);
  margin-bottom: 0.75rem;
}

.section-sub {
  font-size: 0.82rem;
  color: var(--text-1);
  margin-bottom: 1.25rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ---- KPI grid ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: center;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.kpi-label {
  font-size: 0.73rem;
  color: var(--text-1);
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Pipeline timeline ---- */
.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.pipeline-step {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  position: relative;
}

.step-num {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.step-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-0);
  margin-bottom: 0.2rem;
}

.step-folder {
  font-size: 0.7rem;
  color: var(--accent-g);
  font-family: "Cascadia Code", "Consolas", monospace;
}

.step-desc {
  font-size: 0.73rem;
  color: var(--text-1);
  margin-top: 0.4rem;
  line-height: 1.4;
}

/* ---- Dataset cards ---- */
.datasets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.dataset-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.dataset-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-0);
  margin-bottom: 0.4rem;
}

.dataset-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.meta-chip {
  font-size: 0.72rem;
  background: var(--bg-3);
  color: var(--text-1);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}

.meta-chip span { color: var(--accent); font-weight: 600; }

.dataset-desc {
  font-size: 0.78rem;
  color: var(--text-1);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.dataset-pk, .dataset-join {
  font-size: 0.72rem;
  color: var(--text-2);
  padding: 0.15rem 0;
}

.dataset-pk::before { content: "PK: "; color: var(--text-1); }
.dataset-join::before { content: "JOIN: "; color: var(--text-1); }

/* ---- Gallery ---- */
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--text-1);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.filter-btn:hover { background: var(--bg-3); color: var(--text-0); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.gallery-item {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.gallery-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.gallery-item img {
  width: 100%;
  display: block;
  background: var(--bg-2);
}

.gallery-caption {
  font-size: 0.7rem;
  color: var(--text-1);
  padding: 0.4rem 0.6rem 0.5rem;
  line-height: 1.4;
}

/* ---- Chart containers ---- */
.chart-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-0);
  margin-bottom: 0.25rem;
}

.chart-sub {
  font-size: 0.75rem;
  color: var(--text-1);
  margin-bottom: 0.75rem;
}

.chart-plot { width: 100%; min-height: 320px; }

/* ---- Info cards ---- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.info-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.info-card-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 0.2rem;
}

.info-card-value {
  font-size: 0.85rem;
  color: var(--text-0);
  line-height: 1.5;
}

/* ---- Badges / veredictos ---- */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  letter-spacing: 0.04em;
}

.badge-ok   { background: var(--badge-ok-bg);   color: var(--badge-ok-fg);   }
.badge-warn { background: var(--badge-warn-bg);  color: var(--badge-warn-fg); }
.badge-err  { background: var(--badge-err-bg);   color: var(--badge-err-fg);  }
.badge-neu  { background: var(--badge-neu-bg);   color: var(--badge-neu-fg);  }

/* ---- Hypothesis sections ---- */
.hypothesis-block {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.75rem;
}

.hyp-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.hyp-id {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
}

.hyp-title { font-size: 0.95rem; font-weight: 600; color: var(--text-0); }

.hyp-chain {
  font-size: 0.78rem;
  color: var(--text-1);
  font-family: "Cascadia Code", "Consolas", monospace;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: var(--bg-2);
  border-radius: 4px;
  border-left: 3px solid var(--accent);
}

.hyp-detail {
  font-size: 0.8rem;
  color: var(--text-1);
  margin-top: 0.4rem;
  margin-bottom: 1rem;
}

.hyp-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.hyp-png img {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.hyp-png-caption {
  font-size: 0.68rem;
  color: var(--text-2);
  text-align: center;
  margin-top: 0.25rem;
}

/* ---- Tables ---- */
.data-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.data-table th {
  background: var(--bg-2);
  color: var(--text-1);
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--bg-3);
  color: var(--text-0);
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-2); }

.td-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Summary table ---- */
.summary-table-wrap {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

/* ---- Decisions list ---- */
.decisions-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.decisions-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--bg-3);
  font-size: 0.82rem;
  color: var(--text-0);
}

.decisions-list li:last-child { border-bottom: none; }

.decisions-list li::before {
  content: "→";
  color: var(--accent-g);
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* ---- Modal ---- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
}

.modal.open { display: flex; align-items: center; justify-content: center; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
}

.modal-content {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  z-index: 1;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-1);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.modal-close:hover { color: var(--text-0); }

.modal-img {
  display: block;
  max-width: 80vw;
  max-height: 75vh;
  border-radius: 4px;
}

.modal-caption {
  font-size: 0.75rem;
  color: var(--text-1);
  text-align: center;
  margin-top: 0.5rem;
  max-width: 80vw;
}

/* ---- Framing cards (modelado) ---- */
.framing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.framing-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.framing-q {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.framing-a {
  font-size: 0.82rem;
  color: var(--text-0);
  line-height: 1.5;
}

/* ---- Outlier dataset chips ---- */
.outlier-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dataset-chip {
  font-size: 0.72rem;
  background: var(--bg-3);
  color: var(--text-1);
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-weight: 600;
}

/* ---- Loading placeholder ---- */
.loading {
  color: var(--text-2);
  font-size: 0.82rem;
  padding: 2rem;
  text-align: center;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .hyp-charts-row { grid-template-columns: 1fr; }
  .header-top { flex-direction: column; gap: 0.25rem; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .main { padding: 1rem; }
}
