/* Dashboard do CamFácil IA. Só variáveis de tokens.css. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tiny { font-size: var(--fs-xs); color: var(--text-3); }
.right { text-align: right; }

.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 14px; height: 14px; }

/* ---------- Estrutura ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--s5);
  padding: var(--s4) var(--s3);
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2); font-weight: 600; font-size: var(--fs-md); letter-spacing: -0.01em; }
.brand img { border-radius: var(--r-sm); }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav button {
  width: 100%; display: flex; align-items: center; gap: var(--s3);
  padding: 7px var(--s2); border: 0; border-radius: var(--r);
  background: none; color: var(--text-3); font: inherit; font-size: var(--fs-md);
  text-align: left; cursor: pointer;
  transition: background-color .12s, color .12s;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.nav button[aria-selected="true"] .ico { color: var(--accent); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s1); padding: var(--s3) var(--s2) 0; border-top: 1px solid var(--line); }
.live { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--text-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 3px var(--c-green-dim); }
.dot.off { background: var(--c-danger); }

main { min-width: 0; padding: var(--s6) var(--s7) var(--s5); display: flex; flex-direction: column; }
.page { max-width: 960px; width: 100%; }

/* ---------- Cabeçalho de página ---------- */
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s5); padding-bottom: var(--s5); border-bottom: 1px solid var(--line); }
.pagehead h1 { margin: 0; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.lede { margin: var(--s2) 0 0; max-width: 68ch; color: var(--text-3); text-wrap: pretty; }

/* ---------- Blocos ---------- */
.block { padding: var(--s5) 0; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.block h2 { margin: 0 0 var(--s3); font-size: var(--fs-md); font-weight: 600; }

/* Linhas chave/valor */
.rows { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; margin: 0; }
.rows dt, .rows dd { padding: 9px 0; border-top: 1px solid var(--line); margin: 0; }
.rows dt { color: var(--text-3); }
.rows dd { color: var(--text); overflow-wrap: anywhere; }
.rows dt:first-of-type, .rows dt:first-of-type + dd { border-top: 0; }
.rows .em { color: var(--accent); font-weight: 600; }

/* Tabelas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th { text-align: left; font-weight: 500; font-size: var(--fs-xs); color: var(--text-3); padding: 9px var(--s4); background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px var(--s4); border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover td { background: var(--surface); }
.table .group td { padding-top: var(--s4); font-size: var(--fs-xs); color: var(--text-3); background: none; }
.table .empty td { color: var(--text-3); padding: var(--s5) var(--s4); text-align: center; }
.table .locked td:not(:last-child) { color: var(--text-3); }
.table th.right, .table td.right { text-align: right; }

/* Estado com ponto */
.state { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--text-2); }
.state .ico { color: var(--text-3); }

/* Chave liga/desliga */
.switch { position: relative; display: inline-block; width: 30px; height: 18px; vertical-align: middle; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--line-strong); transition: background-color .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--c-100); transition: transform .15s cubic-bezier(.2,.8,.2,1); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); background: var(--c-black); }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + span { opacity: .45; }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 32px; padding: 0 var(--s3);
  font: inherit; font-size: var(--fs-md); font-weight: 500; white-space: nowrap;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  cursor: pointer; transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--c-500); }
.btn.primary { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }
.btn.primary:hover { background: var(--c-white); }
.btn.ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 var(--s2); font-size: var(--fs-sm); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn:focus-visible, .nav button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.actions.end { justify-content: flex-end; }

/* Formulário */
.form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4) var(--s3); max-width: 720px; }
.form .span-2 { grid-column: span 2; }
.form .span-4 { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: var(--fs-sm); color: var(--text-2); }
.form input, .form select { width: 100%; min-width: 0; }
input, select {
  height: 34px; padding: 0 var(--s3);
  font: inherit; font-size: var(--fs-md); color: var(--text);
  background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--r);
  accent-color: var(--accent);
  transition: border-color .12s;
}
input::placeholder { color: var(--text-3); }
input:hover, select:hover { border-color: var(--c-500); }
input:focus-visible, select:focus-visible { outline: 0; border-color: var(--focus); box-shadow: 0 0 0 3px var(--c-green-dim); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 6px; padding: 0; }

/* Controle segmentado */
.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--field); border: 1px solid var(--line-strong); border-radius: var(--r); }
.seg label { flex-direction: row; position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; padding: 5px var(--s3); border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.seg input:checked + span { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.note { display: flex; align-items: center; gap: var(--s2); margin: var(--s3) 0 0; font-size: var(--fs-sm); color: var(--text-3); }

.result { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s4); max-width: 720px; padding: var(--s2) var(--s2) var(--s2) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.result code { flex: 1; font-size: var(--fs-sm); overflow-wrap: anywhere; color: var(--text); }
.msg { min-height: 1.5em; margin: var(--s3) 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.msg.ok { color: var(--text-2); }
.msg.ok::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: var(--s2); border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.msg.err { color: var(--c-danger); }

/* Resultado do teste */
.measure { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); }
.measure > div { padding: var(--s3) var(--s4); border-left: 1px solid var(--line); }
.measure > div:first-child { border-left: 0; }
.measure dt { font-size: var(--fs-xs); color: var(--text-3); }
.measure dd { margin: 2px 0 0; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
.measure .on { color: var(--accent); }
.hint { margin: var(--s3) 0 0; font-size: var(--fs-sm); color: var(--text-3); max-width: 68ch; }

/* Lista */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list strong { font-weight: 500; }
.list p { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.badge { flex: none; font-size: var(--fs-xs); color: var(--text-2); padding: 2px var(--s2); border: 1px solid var(--line-strong); border-radius: var(--r-pill); }

.foot { margin-top: auto; padding-top: var(--s6); max-width: 960px; font-size: var(--fs-xs); color: var(--text-3); }

/* Diálogo */
dialog { width: min(520px, calc(100vw - 32px)); padding: var(--s5); color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 24px 64px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog h2 { margin: 0 0 var(--s3); font-size: var(--fs-lg); font-weight: 600; }
.disc { margin: 0 0 var(--s5); padding-left: var(--s5); display: flex; flex-direction: column; gap: var(--s2); color: var(--text-2); }

/* ---------- Telas pequenas ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; z-index: 2; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s3) var(--s4); border-right: 0; border-bottom: 1px solid var(--line); }
  .rail nav { order: 3; width: 100%; overflow-x: auto; }
  .nav { flex-direction: row; }
  .nav button { padding: 6px var(--s3); white-space: nowrap; }
  .rail-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .rail-foot .tiny, #live-text { display: none; }
  main { padding: var(--s5) var(--s4); }
  .pagehead { flex-direction: column; }
  .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form .span-2 { grid-column: 1 / -1; }
  .measure { grid-template-columns: 1fr; }
  .measure > div { border-left: 0; border-top: 1px solid var(--line); }
  .measure > div:first-child { border-top: 0; }
  .rows { grid-template-columns: 1fr 1.4fr; }
}

/* ---------- Site do domínio (cfia-api) ---------- */
a { color: var(--text); text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: var(--text-3); }
a.btn { text-decoration: none; }
.btn.wide { width: 100%; height: 40px; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: var(--s5); }
.gate-box { width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; gap: var(--s3); text-align: center; }
.gate-box img { border-radius: 9px; }
.gate-box h1 { margin: var(--s2) 0 0; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; }
.gate-box .lede { margin: 0 0 var(--s3); }
.gate-box .tiny { margin-top: var(--s4); }

.rail-foot .btn { align-self: flex-start; margin-left: calc(var(--s2) * -1); }
#eu-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.steps { margin: 0; padding-left: var(--s5); display: flex; flex-direction: column; gap: var(--s2); color: var(--text-2); max-width: 68ch; }
.steps strong { color: var(--text); font-weight: 500; }

.cell-edit { background: none; border: 1px solid transparent; height: 30px; padding: 0 var(--s2); margin-left: calc(var(--s2) * -1); width: min(240px, 100%); }
.cell-edit:hover { border-color: var(--line-strong); }
.dot-inline { display: inline-block; vertical-align: 1px; margin-right: var(--s2); }
.sprite { position: absolute; width: 0; height: 0; }
.actions.mt { margin-top: var(--s4); }
.doc { max-width: 72ch; margin: 0 auto; padding: var(--s7) var(--s5); }
.doc h1 { font-size: var(--fs-xl); letter-spacing: -0.02em; margin: 0 0 var(--s2); }
.doc h2 { font-size: var(--fs-lg); margin: var(--s6) 0 var(--s2); }
.doc p, .doc li { color: var(--text-2); }
.doc .tiny { margin-bottom: var(--s5); }
