:root {
  /* Paleta — indigo + slate */
  --bg:          #f8fafc;
  --bg-elev:    #ffffff;
  --surface:    #ffffff;
  --surface-2: #f1f5f9;
  --text:       #0f172a;
  --text-2:     #334155;
  --muted:      #64748b;
  --muted-2:   #94a3b8;
  --border:     #e2e8f0;
  --border-strong: #cbd5e1;

  --primary:        #4f46e5;
  --primary-hover:  #4338ca;
  --primary-soft:   #eef2ff;
  --primary-text:   #fff;

  --danger:         #dc2626;
  --danger-soft:    #fef2f2;

  --risk-low:    #16a34a;
  --risk-low-bg: #dcfce7;
  --risk-mid:    #d97706;
  --risk-mid-bg: #fef3c7;
  --risk-high:   #dc2626;
  --risk-high-bg:#fee2e2;

  --sidebar-bg:   #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-muted:#94a3b8;
  --sidebar-active-bg: rgba(99, 102, 241, 0.18);
  --sidebar-active-text: #c7d2fe;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============ Layout shell ============ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  flex-shrink: 0;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 12px;
}
.sidebar .brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}
.sidebar .brand h1 { margin: 0; font-size: 15px; font-weight: 600; color: #fff; letter-spacing: -0.01em; }
.sidebar .brand small { color: var(--sidebar-muted); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }

.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--sidebar-muted); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.05); color: var(--sidebar-text); }
.sidebar nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.sidebar nav a .ico { font-size: 16px; opacity: 0.9; }

.sidebar .empresa-context {
  padding: 10px 6px 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar .empresa-context label {
  color: var(--sidebar-muted);
  font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 600;
  margin-bottom: 6px; padding-left: 4px;
}
.sidebar .empresa-context select {
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
}
.sidebar .empresa-context select option { color: var(--text); }

.sidebar nav .nav-sep {
  color: var(--sidebar-muted);
  font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 600;
  padding: 14px 12px 6px;
}

.sidebar .foot {
  margin-top: auto;
  color: var(--sidebar-muted);
  font-size: 11px;
  padding: 12px 10px 0;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1180px;
}
.main h1.page-title {
  margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.015em;
}
.main p.page-sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; }

/* container fallback (responder, etc) */
.container { max-width: 1080px; margin: 0 auto; padding: 24px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 32px 24px; }

/* ============ Typography ============ */
h2 { margin: 28px 0 12px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 600; }
h4 { margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.muted { color: var(--muted); }

/* ============ Cards ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.card-pad-sm { padding: 14px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

/* ============ Inputs ============ */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 180px; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=email], input[type=number], input[type=password], textarea, select {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }

/* ============ Buttons ============ */
button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  background: var(--primary); color: var(--primary-text);
  border: 1px solid var(--primary); border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .04s, box-shadow .12s;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: 0.55; cursor: not-allowed; }

button.secondary, .btn.secondary {
  background: #fff; color: var(--text-2); border: 1px solid var(--border-strong);
}
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); color: var(--text); }

button.danger, .btn.danger {
  background: #fff; color: var(--danger); border: 1px solid #fecaca;
}
button.danger:hover, .btn.danger:hover { background: var(--danger-soft); border-color: #fca5a5; }

button.ghost, .btn.ghost { background: transparent; color: var(--muted); border-color: transparent; }
button.ghost:hover { color: var(--text); background: var(--surface-2); }

button.sm, .btn.sm { padding: 5px 10px; font-size: 12.5px; }

/* ============ Tables ============ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th {
  color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--surface-2);
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }
td.actions > * + * { margin-left: 6px; }

/* ============ Tags / pills ============ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  line-height: 1.5;
}
.tag.low   { background: var(--risk-low-bg);  color: var(--risk-low); }
.tag.mid   { background: var(--risk-mid-bg);  color: var(--risk-mid); }
.tag.high  { background: var(--risk-high-bg); color: var(--risk-high); }
.tag.neutral { background: var(--surface-2);  color: var(--muted); }
.tag.info  { background: var(--primary-soft); color: var(--primary); }

/* ============ Flash messages ============ */
.flash {
  padding: 11px 14px; border-radius: var(--radius-sm);
  margin-bottom: 14px; font-size: 14px;
  border: 1px solid transparent;
}
.flash.ok  { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash.err { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }

/* ============ Tabs (legacy — used as full-page sections in admin) ============ */
.tabpanel { display: none; }
.tabpanel.active { display: block; }

/* ============ Responder (página do funcionário) ============ */
.responder-hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}
.responder-hero h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.responder-hero p { margin: 0; opacity: 0.9; font-size: 14px; }
.responder-hero .meta { margin-top: 14px; font-size: 13px; opacity: 0.85; }
.responder-hero .meta strong { font-weight: 600; }

.pergunta {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.pergunta:last-child { border-bottom: none; padding-bottom: 4px; }
.pergunta .num {
  display: inline-block; min-width: 26px; height: 26px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary);
  text-align: center; line-height: 26px; font-size: 12px; font-weight: 600;
  margin-right: 10px;
}
.pergunta .dim {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin-bottom: 4px;
}
.pergunta .texto { font-weight: 500; margin-bottom: 12px; font-size: 15px; color: var(--text); }

.opcoes { display: flex; flex-direction: column; gap: 8px; }
.opcoes label {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px; color: var(--text);
  cursor: pointer; font-weight: 400;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.opcoes label:hover { border-color: var(--primary); background: var(--primary-soft); }
.opcoes input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; flex-shrink: 0; }
.opcoes label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px rgba(79,70,229,0.12);
}

/* ============ KPI grid ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; color: var(--text); }

/* ============ Bars / distribution ============ */
.bar-row { display: flex; align-items: center; gap: 12px; margin: 6px 0; font-size: 13px; }
.bar-row .label { width: 200px; color: var(--text-2); }
.bar-row .bar   { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-row .bar > div { height: 100%; border-radius: 999px; transition: width .4s ease; }
.bar-row .val   { width: 110px; text-align: right; color: var(--muted); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

.dist {
  display: flex; height: 10px; border-radius: 999px;
  overflow: hidden; background: var(--surface-2);
}
.dist > div { height: 100%; transition: width .4s ease; }
.dist .seg-low  { background: var(--risk-low); }
.dist .seg-mid  { background: var(--risk-mid); }
.dist .seg-high { background: var(--risk-high); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; vertical-align: middle; margin-right: 6px; }

/* ============ Editor de perguntas (admin) ============ */
.pergunta-edit {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--surface-2);
}
.pergunta-edit .head {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 10px;
}
.pergunta-edit .head .num {
  width: 28px; height: 28px;
  background: var(--primary); color: #fff;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.pergunta-edit .grid {
  display: grid; gap: 10px;
  grid-template-columns: 2fr 1fr 100px;
}
.pergunta-edit .opcoes-edit {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px; margin-top: 10px;
}
.pergunta-edit .opcao-row {
  display: grid; grid-template-columns: 1fr 100px auto;
  gap: 8px; align-items: center; margin: 4px 0;
}

/* ============ Misc ============ */
details summary { cursor: pointer; user-select: none; }
details summary::marker { color: var(--muted); }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ============ Radio pills (modo exibicao) ============ */
.radio-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; margin: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.radio-pill:hover { border-color: var(--primary); }
.radio-pill input { accent-color: var(--primary); }
.radio-pill:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============ Banner padrão (editor) ============ */
.pergunta-edit.readonly {
  opacity: 0.7;
}
.pergunta-edit.readonly input,
.pergunta-edit.readonly select { background: #f8fafc; cursor: not-allowed; }

/* ============ Modal ============ */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 50;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  width: 100%; max-width: 900px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.modal-head button.ghost { font-size: 16px; padding: 4px 10px; }
.modal-card input[readonly] {
  background: var(--surface-2); color: var(--text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============ Wizard (responder) ============ */
.wizard-progress {
  height: 6px; background: rgba(255,255,255,0.18);
  border-radius: 999px; overflow: hidden; margin-top: 18px;
}
.wizard-progress > div { height: 100%; background: #fff; transition: width .25s ease; }
.wizard-counter { font-size: 12px; margin-top: 8px; opacity: 0.9; }
.wizard-nav {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ============ Checkbox anônimo ============ */
.anon-box {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 16px;
}
.anon-box input { margin-top: 3px; accent-color: var(--primary); }
.anon-box label { margin: 0; font-size: 13.5px; color: var(--text-2); font-weight: 500; cursor: pointer; }
.anon-box .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Responsive */
@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; padding: 16px; flex-direction: row; align-items: center; gap: 6px; overflow-x: auto; }
  .sidebar .brand { border: none; padding: 0 12px 0 0; margin: 0; border-right: 1px solid rgba(255,255,255,0.08); }
  .sidebar nav { display: flex; gap: 4px; }
  .sidebar nav a { padding: 6px 10px; }
  .sidebar .foot { display: none; }
  .main { padding: 20px 16px; max-width: 100%; }
}
