/* ============================================================
   Murilo Lympius — simulador.css
   Estilos do laboratório de dados. Reusa os tokens de style.css.
   ============================================================ */

.lab-hero { padding-top: clamp(40px, 5vw, 64px); padding-bottom: clamp(32px, 4vw, 48px); position: relative; }
.lab-hero::before {
  content: "";
  position: absolute; inset: -140px 0 auto 0; height: 420px;
  background: radial-gradient(ellipse 70% 100% at 22% 0%, rgba(242,163,60,0.07), transparent 65%);
  pointer-events: none;
}
.lab-hero .wrap { position: relative; }
.lab-title { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -0.03em; margin-bottom: 18px; max-width: 18ch; }
.lab-lead { color: var(--text-2); font-size: clamp(1rem, 1.4vw, 1.12rem); line-height: 1.68; max-width: 70ch; }
.lab-disclaimer { color: var(--text-3); font-size: 0.86rem; margin-top: 12px; max-width: 70ch; }

.lab-sec { padding-block: clamp(48px, 6vw, 80px); border-top: 1px solid var(--border); }

/* ---------- Controles ---------- */
.controls {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  display: grid; gap: 18px;
}
.ctl-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ctl-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px 22px; align-items: end; }
.ctl { display: grid; gap: 8px; }
.ctl-k {
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.04em;
  color: var(--text-3); display: flex; justify-content: space-between; gap: 8px;
}
.ctl-k output { color: var(--accent); font-weight: 600; white-space: nowrap; }
.ctl input[type="range"] { width: 100%; accent-color: var(--accent); }
.ctl-check { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-2); cursor: pointer; padding-bottom: 4px; }
.ctl-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.kpi {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 14px 16px; min-width: 0;
}
.kpi-hl { border-color: var(--accent-line); background: var(--accent-soft); }
.kpi-l { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.kpi-v { font-family: var(--font-display); font-size: clamp(1.1rem, 1.9vw, 1.45rem); font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-d { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-3); }

/* ---------- Pipeline ---------- */
.pipe { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; counter-reset: none; }
.pipe li { position: relative; }
.pipe li:not(:last-child)::after {
  content: ""; position: absolute; top: 50%; right: -9px; width: 8px; height: 1px;
  background: var(--border-2);
}
.stage {
  width: 100%; height: 100%; text-align: left; cursor: pointer;
  display: grid; gap: 4px; align-content: start;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 12px 14px; font: inherit;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.stage:hover { border-color: var(--border-2); transform: translateY(-2px); }
.stage.on { border-color: var(--accent); background: var(--surface-2); }
.stage-n { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-3); }
.stage-k { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--teal); }
.stage[data-layer="Bronze"] .stage-k { color: #D08A5B; }
.stage[data-layer="Ouro"] .stage-k, .stage[data-layer="Gold"] .stage-k { color: var(--accent); }
.stage[data-layer="Fonte"] .stage-k, .stage[data-layer="Source"] .stage-k { color: var(--text-3); }
.stage-name { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; line-height: 1.2; }
.stage-c { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-2); font-variant-numeric: tabular-nums; margin-top: 4px; }

.stage.flash { animation: stageflash 0.7s var(--ease); }
@keyframes stageflash {
  0%   { box-shadow: 0 0 0 0 rgba(242,163,60,0); }
  25%  { box-shadow: 0 0 0 2px rgba(242,163,60,0.55); border-color: var(--accent); }
  100% { box-shadow: 0 0 0 0 rgba(242,163,60,0); }
}

.stage-panel {
  margin-top: 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden;
}
.stage-info { padding: 22px; display: grid; gap: 10px; align-content: start; border-right: 1px solid var(--border); }
.stage-kicker { color: var(--accent); }
.stage-info h3 { font-size: 1.25rem; }
.stage-info p { color: var(--text-2); font-size: 0.92rem; }

.code-box { background: var(--bg-2); min-width: 0; display: flex; flex-direction: column; }
.code-head { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.code-head .mono:first-child { color: var(--accent); }
.code-file { text-transform: none; letter-spacing: 0; }
.code-box pre { margin: 0; padding: 16px; overflow-x: auto; font-size: 0.76rem; line-height: 1.65; }
.code-box code { background: none; border: 0; padding: 0; color: var(--text-2); font-size: inherit; white-space: pre; }
.c-com { color: var(--text-3); font-style: italic; }
.c-str { color: #9BD69B; }
.c-fn  { color: var(--teal); }
.c-kw  { color: var(--accent-2); }

/* ---------- Tabelas ---------- */
.stream-wrap { margin-top: 28px; }
.stream-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.stream-head h3 { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.stream-head .note { color: var(--text-3); font-size: 0.82rem; }

.tbl-scroll {
  overflow: auto; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); max-height: 420px;
  scrollbar-color: var(--border-2) transparent; scrollbar-width: thin;
}
.code-box pre { scrollbar-color: var(--border-2) transparent; scrollbar-width: thin; }
.tbl-scroll.tall { max-height: 520px; }
.tbl { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.tbl th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-3); font-weight: 500; text-align: left;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 7px 12px; border-bottom: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr[tabindex] { cursor: pointer; }
.tbl tbody tr[tabindex]:hover td { background: var(--surface-2); color: var(--text); }
.tbl tr.sel td { background: var(--accent-soft); color: var(--text); }
.tbl tr.sel td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.tbl tr.hit td { background: var(--teal-soft); color: var(--text); }
.tbl tr.hit td:first-child { box-shadow: inset 2px 0 0 var(--teal); }
.tbl tr.new td { animation: rownew 1.2s var(--ease); }
@keyframes rownew { from { background: rgba(242,163,60,0.22); } to { background: transparent; } }
.tbl .null { color: var(--text-3); font-style: italic; }
.neg { color: #E8857A !important; }

/* ---------- Raio-X ---------- */
.xray-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; color: var(--accent); }
.xray-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.xraw {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 16px; position: sticky; top: 80px;
}
.xraw h3 { color: #D08A5B; margin-bottom: 10px; font-size: 0.7rem; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.72rem; }
.kv:first-of-type { border-top: 0; }
.kv-k { color: var(--text-3); }
.kv-v { color: var(--text); text-align: right; word-break: break-all; }

.xsteps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.xstep {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.xstep-h { display: flex; align-items: center; gap: 10px; }
.xstep-n {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--accent); font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600;
}
.xstep h4 { font-size: 0.92rem; }
.xstep-b { display: grid; gap: 6px; flex: 1; }
.xl { display: grid; gap: 1px; font-family: var(--font-mono); font-size: 0.72rem; line-height: 1.45; }
.xl-k { color: var(--text-3); }
.xl-v { color: var(--text); }
.xl-v b { color: var(--accent-2); font-weight: 600; }
.xl-s { color: var(--teal); font-size: 0.66rem; }
.xl-s::before { content: "↳ "; color: var(--text-3); }
.xstep-code { display: block; font-size: 0.66rem; color: var(--text-3); white-space: normal; word-break: break-word; }

/* ---------- Bases ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab, .chipbtn {
  font-family: var(--font-mono); font-size: 0.72rem; cursor: pointer;
  background: var(--surface); color: var(--text-3);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 13px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.tab:hover, .chipbtn:hover { color: var(--text); border-color: var(--border-2); }
.tab[aria-selected="true"], .chipbtn[aria-pressed="true"] { color: #0A0E14; background: var(--accent); border-color: var(--accent); }
.base-desc { color: var(--text-2); font-size: 0.9rem; margin-bottom: 12px; max-width: 80ch; }

/* ---------- Clientes ---------- */
.cli-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cli-detail {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 18px; display: grid; gap: 12px; position: sticky; top: 80px;
}
.cli-k { color: var(--accent); }
.cli-detail h3 { font-family: var(--font-mono); font-size: 1.1rem; }
.cli-detail h4 { color: var(--text-3); margin-top: 6px; }
.mini { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mini div { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: grid; gap: 2px; min-width: 0; }
.mini span { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.mini b { font-family: var(--font-mono); font-size: 0.86rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.cli-tx { display: grid; gap: 4px; }
.cli-tx button {
  width: 100%; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 10px; cursor: pointer; color: var(--text-2);
  font-family: var(--font-mono); font-size: 0.68rem; text-align: left;
}
.cli-tx button:hover { border-color: var(--accent-line); color: var(--text); }
.cli-tx b { color: var(--text); font-weight: 600; }

/* ---------- Segmentos / barras ---------- */
.seg-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.seg-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 18px; }
.chart-card h3 { font-size: 0.95rem; margin-bottom: 14px; }
.chart-card h3.mt { margin-top: 22px; }

.barlist { display: grid; gap: 6px; }
.bar-row {
  display: grid; grid-template-columns: 110px minmax(0, 1fr) 92px; align-items: center; gap: 10px;
  padding: 3px 0; cursor: default;
}
.bar-row:hover .bar { filter: brightness(1.15); }
.bar-row:hover .bar-l { color: var(--text); }
.bar-l { font-size: 0.8rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { position: relative; height: 14px; }
.bar { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 0 4px 4px 0; transition: width 0.35s var(--ease), left 0.35s var(--ease); }
.bar.neg { background: var(--text-3); border-radius: 4px 0 0 4px; }
.bar-zero { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--border-2); }
.bar-v { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.tip {
  position: fixed; z-index: 300; pointer-events: none;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 7px; padding: 7px 10px; font-family: var(--font-mono); font-size: 0.72rem;
  max-width: 320px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

/* ---------- CTA Spark ---------- */
.spark-cta {
  display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--accent-line); border-radius: var(--r);
  padding: clamp(22px, 3vw, 32px);
}
.spark-cta h2 { font-size: clamp(1.3rem, 2.6vw, 1.8rem); }
.spark-cta .note { color: var(--text-2); margin-top: 10px; max-width: 64ch; font-size: 0.95rem; }

/* ============================================================
   Responsivo
   ============================================================ */
@media (max-width: 1100px) {
  .ctl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pipe { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pipe li:nth-child(4)::after { display: none; }
  .xsteps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .stage-panel, .xray-grid, .cli-grid, .seg-grid { grid-template-columns: 1fr; }
  .stage-info { border-right: 0; border-bottom: 1px solid var(--border); }
  .xraw, .cli-detail { position: static; }
}

@media (max-width: 1000px) {
  .hdr .nav a:not(.nav-hl) { display: none; }
}

@media (max-width: 600px) {
  .ctl-grid { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .pipe { grid-template-columns: 1fr 1fr; }
  .pipe li::after { display: none; }
  .xsteps { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 84px minmax(0, 1fr) 76px; gap: 8px; }
  .ctl-row .btn { flex: 1 1 40%; }
}
