@font-face { font-family: "Montserrat"; src: url("/fonts/Montserrat-Regular.ttf"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("/fonts/Montserrat-Medium.ttf"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("/fonts/Montserrat-SemiBold.ttf"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("/fonts/Montserrat-Bold.ttf"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("/fonts/Montserrat-ExtraBold.ttf"); font-weight: 800; font-display: swap; }

:root {
  --brand: #585850;
  --brand-2: #7a7a6e;
  --brand-dark: #43433c;
  --gold: #d8c860;
  --gold-deep: #b9a63f;
  --surface: #ffffff;
  --surface-2: #f4f3ee;
  --text: #2c2c28;
  --muted: #6b6b62;
  --border: #e2e0d6;
  --leve: #16a34a;
  --media: #ca8a04;
  --grave: #ea580c;
  --grave_iminente: #dc2626;
  --aceitavel: #16a34a;
  --atencao: #ca8a04;
  --critico: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--surface-2); color: var(--text); padding-bottom: 48px;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10; background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 3px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-icon { width: 38px; height: 38px; flex: none; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 21px; font-weight: 800; color: var(--brand); letter-spacing: -0.3px; }
.brand-sub { font-size: 11px; font-weight: 600; color: var(--muted); }
.tabs { display: flex; gap: 8px; margin-top: 10px; }
.tab {
  flex: 1; padding: 9px; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; color: var(--muted); font-weight: 700; font-size: 14px;
}
.tab.active { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }

.view { display: none; padding: 16px; max-width: 700px; margin: 0 auto; }
.view.active { display: block; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 13px; color: var(--brand); text-transform: uppercase; letter-spacing: .05em; font-weight: 800; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
input[type=text] {
  width: 100%; margin-top: 6px; padding: 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px; font-weight: 400;
}
.busca { width: 100%; padding: 11px; font-size: 15px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }

/* Modos */
.modos { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.modo {
  text-align: left; padding: 14px; border: 2px solid var(--border); border-radius: 12px;
  background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.modo strong { font-size: 15px; }
.modo small { color: var(--muted); font-size: 12px; }
.modo-ico { font-size: 22px; }
.modo.on { border-color: var(--gold-deep); background: #faf8ec; }

/* Classificação da avaliação */
.rotulo { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.clf-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.clf { display: flex; align-items: center; gap: 5px; padding: 9px 13px; border: 2px solid var(--border); border-radius: 10px; background: #fff; font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer; font-family: inherit; }
.clf span { font-size: 16px; }
.clf.on { border-color: var(--gold-deep); background: #faf8ec; color: var(--brand); }

/* Riscos observados */
.ajuda { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.risco-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.risco-add select { padding: 11px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; background: #fff; }
.risco-add input { flex: 1; min-width: 150px; margin: 0; padding: 11px; font-size: 15px; border: 1px solid var(--border); border-radius: 10px; }
.risco-add .mini { padding: 0 14px; font-size: 14px; }
.riscos-lista { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.risco-item { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 9px; padding: 8px 10px; font-size: 13px; }
.risco-item .rtipo { font-weight: 800; font-size: 11px; text-transform: uppercase; color: var(--brand); background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }
.risco-item .rdesc { flex: 1; }
.risco-item .rdel { cursor: pointer; color: var(--grave_iminente); font-weight: 800; border: none; background: none; font-size: 16px; }

/* NR */
.nr-acoes { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mini { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 12px; font-weight: 600; }
.contador { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 700; }
.nr-grupo { margin-bottom: 12px; }
.nr-grupo-titulo { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 6px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 8px 12px; border-radius: 999px; border: 2px solid var(--border);
  background: #fff; font-size: 13px; font-weight: 700; cursor: pointer; user-select: none;
}
.chip.on { color: #fff; border-color: transparent; }

/* Botoes */
.btn-primary, .btn-secondary {
  width: 100%; padding: 16px; border: none; border-radius: 12px; font-size: 16px; font-weight: 800; cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:disabled { background: #b9c6cc; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px dashed var(--muted); }
.preview-wrap { margin-top: 12px; }
.preview-wrap img { width: 100%; border-radius: 10px; }

.laudo-meta { font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* Topbar com usuário */
.topbar-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
#user-chip { font-weight: 700; font-size: 13px; color: var(--brand); }

/* Login */
.login-overlay { position: fixed; inset: 0; z-index: 100; background: var(--surface-2); display: flex; align-items: center; justify-content: center; padding: 20px; padding-top: max(20px, env(safe-area-inset-top)); }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.login-card .btn-primary { margin-top: 8px; }
.login-erro { color: var(--grave_iminente); font-size: 13px; font-weight: 700; min-height: 18px; }

/* Filtros do histórico + selects de formulário */
.filtros { display: flex; flex-wrap: wrap; gap: 8px; }
.filtros .busca { margin-bottom: 10px; }
input[type=password], select { width: 100%; margin-top: 6px; padding: 12px; font-size: 16px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; background: #fff; }
#u-role { font-weight: 400; }

/* Status */
.status { text-align: center; padding: 14px; color: var(--muted); font-weight: 700; }
.status.erro { color: var(--grave_iminente); }
.spinner { display: inline-block; width: 16px; height: 16px; margin-right: 8px; border: 3px solid #cbd5e1; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Resultado */
.resultado h3 { margin: 0 0 4px; }
.badge { display: inline-block; padding: 6px 12px; border-radius: 8px; color: #fff; font-weight: 800; font-size: 13px; margin: 6px 6px 6px 0; }
.risco-baixo, .risco-aceitavel { background: var(--leve); }
.risco-medio, .risco-leve { background: var(--media); }
.risco-alto, .risco-moderado { background: var(--grave); }
.risco-critico, .risco-muito_alto { background: var(--grave_iminente); }

.nc { border-left: 4px solid var(--grave); background: #fff7ed; border-radius: 0 10px 10px 0; padding: 12px; margin: 10px 0; }
.nc .grav { font-size: 12px; font-weight: 800; text-transform: uppercase; }
.nc .grav.leve { color: var(--leve); } .nc .grav.media { color: var(--media); }
.nc .grav.grave { color: var(--grave); } .nc .grav.grave_iminente { color: var(--grave_iminente); }
.nc h4 { margin: 4px 0; } .nc p { margin: 4px 0; font-size: 14px; } .nc .meta { font-size: 12px; color: var(--muted); }
.conforme { color: var(--leve); font-size: 14px; margin: 4px 0; }

.bloco { margin-top: 14px; }
.bloco h4 { margin: 0 0 6px; font-size: 14px; }
.descricao-box { background: var(--surface-2); border-radius: 10px; padding: 12px; font-size: 14px; line-height: 1.5; }
.copy-link { color: var(--brand); font-weight: 700; font-size: 13px; cursor: pointer; }
.carac { width: 100%; border-collapse: collapse; font-size: 13px; }
.carac td { border: 1px solid var(--border); padding: 7px; }
.carac td:first-child { font-weight: 700; color: var(--muted); width: 38%; }
.agente { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }
.agente .tag { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--brand); }

/* Ergonomia */
.chart-wrap { position: relative; height: 280px; margin: 10px 0; }
.fator { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.fator .barra { flex: 1; height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.fator .barra span { display: block; height: 100%; }
.fator .nome { width: 130px; font-weight: 700; }
.fator .val { width: 34px; text-align: right; font-weight: 800; }

.acoes { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.acoes button { flex: 1; min-width: 130px; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: #fff; font-weight: 700; }

/* Historico */
.historico-lista { display: flex; flex-direction: column; gap: 10px; }
.hist-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.hist-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.hist-item .info { flex: 1; } .hist-item .info strong { display: block; } .hist-item .info small { color: var(--muted); }
.tipo-tag { display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase; color: #fff; background: var(--brand); padding: 2px 7px; border-radius: 6px; }
.empty { color: var(--muted); text-align: center; padding: 24px; }
/* Psicossocial */
.amb-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.45); display: flex; justify-content: center; }
.amb-card { background: #fff; width: 100%; max-width: 680px; display: flex; flex-direction: column; height: 100%; }
.amb-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.amb-body { padding: 16px; overflow-y: auto; flex: 1; }
.amb-foot { padding: 12px 16px; border-top: 1px solid var(--border); }
.fator-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.fator-card .fnome { font-weight: 700; font-size: 14px; }
.fator-card .fperg { font-size: 12px; color: var(--muted); margin: 4px 0 8px; line-height: 1.4; }
.simnao { display: flex; gap: 8px; margin-bottom: 8px; }
.simnao button { flex: 1; padding: 9px; border: 2px solid var(--border); border-radius: 8px; background: #fff; font-weight: 800; font-size: 13px; font-family: inherit; cursor: pointer; }
.simnao button.sim-on { border-color: var(--grave_iminente); color: var(--grave_iminente); background: #fff5f5; }
.simnao button.nao-on { border-color: var(--leve); color: var(--leve); background: #f0fdf4; }
.psc-grid { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.psc-grid label { font-size: 11px; font-weight: 700; margin: 0; display: flex; flex-direction: column; gap: 3px; color: var(--muted); }
.psc-grid select { padding: 8px; min-width: 58px; margin: 0; }
.nre-badge { padding: 7px 11px; border-radius: 8px; color: #fff; font-weight: 800; font-size: 12px; white-space: nowrap; }
.amb-item { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.amb-item .info { flex: 1; }
.amb-item .info strong { display: block; }
.amb-item .info small { color: var(--muted); }

.hidden { display: none; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--brand-dark); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 700; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
