/* N&K Lab: demo 03 */
#val-live { min-height: calc(2 * 1.55em); }
.val-table tr[hidden]{display:none!important}
.val-table tr[data-changed]{background:var(--cyan-soft);box-shadow:inset 3px 0 var(--cyan)}
.before-value{display:block;color:var(--muted);font-size:12px}
.val-filter{display:none;border:0;padding:0;margin:0 0 12px;gap:8px}
.val-filter legend{font-size:12px;color:var(--muted)}
.val-filter label{display:inline-flex;align-items:center;min-height:44px;padding:8px;border:1px solid var(--line);border-radius:var(--r-sm)}
/* rules above, table at full width (no squeezed columns) */
.val-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-top: 1rem; }
.val-side, .val-main { min-width: 0; padding: 1rem; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.val-side h2, .val-main h2 { margin-bottom: .6rem; }

/* rules: fixed list, the state is text (aplicada / próxima / pendente) */
.val-rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .4rem; counter-reset: r; }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .5rem; padding: .5rem .6rem; border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 6px; counter-increment: r; }
.rule-name { font-size: .875rem; font-weight: 600; }
.rule-name::before { content: counter(r) ". "; color: var(--muted); }
.rule-state { font-family: var(--mono); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.rule-impact { grid-column: 1 / -1; font-size: .75rem; color: var(--muted); }
.rule.is-on { border-left-color: var(--cyan); }
.rule.is-on .rule-state { color: var(--cyan); }
.rule.is-next { border-color: var(--muted); border-left-color: var(--muted); }
.rule.is-next .rule-state { color: var(--text); }

.val-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-bottom: .8rem; }
.val-totals div { padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 6px; }
.val-totals dt { font-size: .75rem; color: var(--muted); }
.val-totals dd { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.val-totals .t-rej dd { color: var(--warn); }
.val-totals dd.sub { font-size: .75rem; font-weight: 400; color: var(--muted); white-space: nowrap; }

/* table: fixed rows (three lines) and space reserved for the 12 rows before the script fills them,
   so neither the first render nor applying a rule moves the page */
.val-table-wrap { overflow-x: auto; font-size: .8125rem; min-height: calc(12 * (2.7em + 1rem + 1px) + 2.6em); }
.val-table { width: 100%; border-collapse: collapse; font-size: 1em; }
.val-table th, .val-table td { padding: .35rem .4rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: break-word; }
/* short codes never break mid-word: #, código, CEP, data, limite, situação */
.val-table th:first-child, .val-table td:nth-child(2), .val-table td:nth-child(5), .val-table td:nth-child(6), .val-table td:nth-child(7), .val-table thead th, .val-table .tag { white-space: nowrap; }
.val-table td:nth-child(4) { overflow-wrap: normal; }
.val-table tbody tr { height: calc(2 * 1.35em + 1rem); }
.val-table th, .val-table td { line-height: 1.35; }
.val-table thead th { font-family: var(--mono); font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.val-table tbody th { color: var(--muted); font-weight: 600; }
.val-table td.is-fixed .val { color: var(--cyan); font-weight: 600; }
.val-table td.is-fixed .val::after { content: " ✓"; content: " ✓" / ""; }
.status-cell .why { display: block; font-size: .75rem; color: var(--warn); }
.tag { display: inline-block; padding: .05rem .4rem; border: 1px solid var(--line); border-radius: 3px; font-size: .75rem; font-weight: 600; }
.tag-ok { color: var(--text); }
.tag-wait { color: var(--muted); border-style: dashed; }
.tag-fix { border-color: var(--cyan); color: var(--cyan); }
.tag-rej { border-color: var(--warn); color: var(--warn); }

.val-indicator { margin-top: 1rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.val-indicator h2 { font-size: 1.0625rem; }
.val-indicator dl { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .6rem; }
.val-indicator dt { font-size: .8125rem; color: var(--muted); }
.val-indicator dd { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; min-height: 1.6em; }
.val-indicator.is-done dd + dd, .val-indicator.is-done #ind-depois { color: var(--cyan); }
.val-why { margin-top: .6rem; font-size: .875rem; color: var(--muted); }
.val-why b { color: var(--text); }

@media (max-width: 720px) {
  .val-filter{display:flex;flex-wrap:wrap}
  .val-controls .actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
  #val-originals{grid-column:1/-1}
  #val-live { min-height: calc(4 * 1.55em); }
  .val-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .val-indicator dl { grid-template-columns: 1fr; }
  .val-side, .val-main { padding: .75rem .6rem; }
  /* table becomes cards; column names come from data-label */
  .val-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .val-table, .val-table tbody, .val-table tr, .val-table th, .val-table td { display: block; }
  .val-table tbody tr { height: auto; margin-bottom: .5rem; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; }
  .val-table tbody th { border: 0; padding: 0 0 .2rem; }
  .val-table tbody th::before { content: "Cadastro "; }
  .val-table td { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .5rem; border: 0; padding: .1rem 0; }
  .val-table td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; }
  .val-table td.status-cell { min-height: 2.6em; }
  .status-cell .tag { justify-self: start; }
  .status-cell .why { grid-column: 2; }
}
@media (prefers-reduced-motion: no-preference) {
  .rule, .val-table td, .val-totals dd { transition: color .25s var(--ease), border-color .25s var(--ease); }
}
.val-table thead th{font-size:12px}
