/* Pesquisa — design system. Tokens, base, componentes, layout do painel e do questionário. */
@font-face {
  font-family: "Inter Variable";
  src: url(/static/fonts/inter-latin-wght-normal.woff2) format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --font: "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f5f7f6; --surface: #ffffff; --surface-2: #eef2f0; --text: #14201c; --muted: #54655e;
  --line: #dde4e0; --line-strong: #b9c5bf;
  --primary: #0f6e56; --primary-hover: #0b5a46; --primary-soft: #e1f5ee; --on-primary: #ffffff; --primary-text: #085041;
  --ok: #1b6e36; --ok-soft: #e5f4ea; --warn: #7a4a00; --warn-soft: #fcefd2; --danger: #b3261e; --danger-soft: #fbe9e7;
  --focus: #0b5a46;
  --r: 12px; --r-sm: 8px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --surface: #162019; --surface-2: #1d2b24; --text: #e8f0ec; --muted: #9db0a7;
    --line: #26352d; --line-strong: #3a4e44;
    --primary: #3fc79b; --primary-hover: #66d6b3; --primary-soft: #12372d; --on-primary: #04201a; --primary-text: #a6ecd3;
    --ok: #6fd18c; --ok-soft: #143323; --warn: #f2bd62; --warn-soft: #3a2c0d; --danger: #ff8a80; --danger-soft: #3d1b18;
    --focus: #66d6b3;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 1rem/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.125rem; } h3 { font-size: 1rem; }
p { margin: 0 0 var(--s3); }
.muted { color: var(--muted); } .small { font-size: .875rem; } .xs { font-size: .8125rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--primary-text); }
.icon { flex: none; vertical-align: -3px; }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.grow { flex: 1 1 auto; min-width: 0; }

/* Botões */
.btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4);
  border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.sm { min-height: 34px; padding: 0 var(--s3); font-size: .875rem; }
.btn.block { width: 100%; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: not-allowed; }

/* Cartões, selos, avisos */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s5); }
.card.flat { padding: var(--s4); }
.card > h2 { margin-bottom: var(--s3); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 500; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--primary-soft); color: var(--primary-text); } .badge.danger { background: var(--danger-soft); color: var(--danger); }
.notice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: var(--surface-2); font-size: .9375rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); } .notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.danger { background: var(--danger-soft); color: var(--danger); } .notice.info { background: var(--primary-soft); color: var(--primary-text); }

/* Formulários */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.field label { font-weight: 500; font-size: .9375rem; }
.input { font: inherit; width: 100%; min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); }
.input::placeholder { color: var(--muted); }
.hint { font-size: .8125rem; color: var(--muted); }
.err { color: var(--danger); font-weight: 500; font-size: .9375rem; min-height: 1.4em; }
.check { display: flex; gap: var(--s3); align-items: flex-start; cursor: pointer; font-size: .9375rem; margin: var(--s4) 0; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }

/* Indicadores e tabelas */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s4); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4) var(--s5); }
.stat .label { color: var(--muted); font-size: .875rem; display: flex; gap: 6px; align-items: center; }
.stat .value { font-size: 1.875rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.stat .sub { color: var(--muted); font-size: .8125rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: .8125rem; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: var(--surface-2); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875rem; letter-spacing: .02em; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 99px; transition: width .2s ease; }

/* Estados: carregando, vazio */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--r-sm); height: 20px; }
@keyframes sk { to { background-position: -200% 0; } }
.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--muted); }
.empty h3 { color: var(--text); margin: var(--s3) 0 var(--s2); }

/* Toasts e diálogo */
.toasts { position: fixed; right: var(--s4); bottom: var(--s4); display: flex; flex-direction: column; gap: var(--s2); z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-sm); font-size: .9375rem; display: flex; gap: var(--s2); align-items: center; }
.toast.err { background: var(--danger); color: #fff; }
.backdrop { position: fixed; inset: 0; background: rgba(8, 16, 12, .55); display: flex; align-items: center; justify-content: center; padding: var(--s4); z-index: 70; }
.dialog { background: var(--surface); border-radius: var(--r); padding: var(--s5); max-width: 420px; width: 100%; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.dialog .actions { display: flex; gap: var(--s3); margin-top: var(--s5); } .dialog .actions > * { flex: 1; }

/* Gráfico de posição por dimensão (SVG) */
.track-svg { width: 100%; height: auto; display: block; }
.tr-bg { fill: var(--surface-2); } .tr-band { fill: var(--primary); opacity: .22; } .tr-tick { stroke: var(--line-strong); stroke-width: 1; }
.tr-dot { fill: var(--primary); stroke: var(--surface); stroke-width: 3; } .tr-dot.few { fill: var(--muted); }
.tr-lab { fill: var(--muted); font: 400 11px var(--font); }
.dim-row { padding: var(--s3) 0; border-bottom: 1px solid var(--line); } .dim-row:last-child { border-bottom: 0; }

/* Painel administrativo (computador) */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: var(--s5) var(--s3); display: flex; flex-direction: column; gap: var(--s1); position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.125rem; padding: 0 var(--s3) var(--s5); }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px var(--s3); border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 500; font-size: .9375rem; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary-text); }
.sidebar .spacer { flex: 1; }
.user-box { border-top: 1px solid var(--line); padding: var(--s3) var(--s3) 0; font-size: .875rem; }
.main { padding: var(--s6); max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head p { margin: 4px 0 0; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: var(--s2) var(--s3); border-right: 0; border-bottom: 1px solid var(--line); gap: var(--s2); }
  .brand { padding: 0 var(--s2) 0 0; } .brand span:last-child { display: none; }
  .nav-link { white-space: nowrap; } .user-box { border: 0; padding: 0; white-space: nowrap; }
  .main { padding: var(--s4); }
}

/* Questionário (celular primeiro): uma pergunta por tela, sem rolagem sempre que couber. */
.page { max-width: 560px; margin: 0 auto; padding: var(--s4); }
.q-screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 560px; margin: 0 auto; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.q-top { flex: none; }
.q-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: .875rem; color: var(--muted); }
.q-main { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 2px; }
.q-text { font-size: clamp(1.05rem, 4.6vw, 1.3rem); line-height: 1.3; font-weight: 600; margin: 0; }
.q-options { display: flex; flex-direction: column; gap: 8px; gap: clamp(6px, 1.3dvh, 12px); }
.q-opt { font: inherit; font-size: clamp(.95rem, 4vw, 1.05rem); line-height: 1.25; text-align: left; display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; min-height: clamp(46px, 8dvh, 76px); padding: 6px 14px;
  border: 1.5px solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--text); cursor: pointer; }
.q-opt .dot { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); }
.q-opt[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.q-opt[aria-checked="true"] .dot { border-color: var(--primary); background: radial-gradient(var(--primary) 45%, transparent 50%); }
.q-pnr { align-self: center; font: inherit; font-size: .875rem; background: none; border: 0; color: var(--muted); text-decoration: underline; min-height: 44px; padding: 0 12px; cursor: pointer; }
.q-pnr[aria-pressed="true"] { color: var(--primary-text); font-weight: 600; }
.q-foot { flex: none; display: flex; gap: 10px; } .q-foot .btn { flex: 1; min-height: 52px; min-height: clamp(46px, 7dvh, 56px); font-size: 1rem; border-radius: 14px; }
@media (max-height: 700px) {
  .q-screen { gap: 6px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .q-meta { margin-top: 4px; } .q-main { gap: 8px; } .q-pnr { min-height: 36px; }
}
.q-hint { min-height: 1.2em; font-size: .8125rem; color: var(--muted); text-align: center; }
.center { text-align: center; } .thanks { padding: var(--s6) var(--s4); }
.thanks .mark { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text); display: grid; place-items: center; margin: 0 auto var(--s4); }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .progress > div { transition: none; } }
