:root {
  --ink: #172033;
  --muted: #667085;
  --line: #dfe5ec;
  --surface: #ffffff;
  --canvas: #f5f7fa;
  --blue: #0b5ed7;
  --blue-dark: #073b8c;
  --cyan: #0891b2;
  --green: #087f5b;
  --amber: #b45309;
  --red: #b42318;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
body { margin: 0; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
button, input, select, textarea { font: inherit; }

.app-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-brand { display: flex; align-items: center; gap: 10px; min-width: 220px; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; background: var(--blue); color: #fff; font-weight: 800; border-radius: 4px; }
.app-brand strong, .app-brand small, .user-menu small { display: block; }
.app-brand small, .user-menu small { color: var(--muted); font-size: 11px; }
.app-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.app-nav a { color: #344054; font-size: 14px; font-weight: 600; padding: 9px 10px; border-radius: 4px; }
.app-nav a:hover { background: #eef4ff; color: var(--blue); }
.user-menu { display: flex; align-items: center; gap: 12px; text-align: right; font-size: 13px; }
.nav-toggle { display: none; background: transparent; border: 0; font-size: 24px; }

.app-main { max-width: 1380px; margin: 0 auto; padding: 28px 24px 56px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: 0; }
.page-head p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid var(--blue);
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.button:hover { background: var(--blue-dark); color: #fff; }
.button.secondary { background: #fff; color: #344054; border-color: #cfd7e3; }
.button.secondary:hover { background: #f2f4f7; color: var(--ink); }
.button.danger { background: var(--red); border-color: var(--red); }
.button.small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 18px; font-size: 18px; letter-spacing: 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); padding: 18px; border-radius: var(--radius); }
.stat strong { display: block; font-size: 28px; margin-top: 6px; }
.stat span { color: var(--muted); font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: #344054; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd7e3;
  border-radius: 5px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}
.field textarea { min-height: 100px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid rgba(11,94,215,.14); border-color: var(--blue); }
.help { font-size: 12px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #edf0f4; vertical-align: top; }
th { background: #f8fafc; color: #475467; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.inline-form { display: inline-flex; gap: 6px; margin: 0; }
.criterion-row { display: grid; grid-template-columns: minmax(240px, 1fr) 110px 90px 90px 80px; gap: 8px; align-items: center; }
.criterion-row input { width: 100%; min-height: 36px; border: 1px solid #cfd7e3; border-radius: 5px; padding: 7px 9px; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; background: #eef2f6; color: #475467; }
.badge.active, .badge.valid, .badge.completed, .badge.approved, .badge.conforme, .badge.sent { background: #dcfae6; color: #067647; }
.badge.pending, .badge.scheduled, .badge.awaiting_board, .badge.awaiting_documents, .badge.parcial { background: #fef0c7; color: #93370d; }
.badge.rejected, .badge.suspended, .badge.revoked, .badge.expired, .badge.reevaluation_required, .badge.nao_conforme, .badge.failed { background: #fee4e2; color: #b42318; }
.badge.in_progress, .badge.sending { background: #dbeafe; color: #1d4ed8; }
.badge.disabled { background: #eef2f6; color: #475467; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: #475467; font-weight: 700; font-size: 13px; white-space: nowrap; }
.tabs a.active { color: var(--blue); border-bottom: 2px solid var(--blue); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef3f8; }
.auth-panel { width: min(520px, 100%); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 34px; }
.auth-panel h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: 0; }
.auth-panel > p { color: var(--muted); margin: 0 0 24px; }
.auth-links { display: flex; justify-content: space-between; gap: 16px; margin-top: 18px; font-size: 13px; }

.flash-stack { position: fixed; top: 82px; right: 18px; z-index: 60; width: min(420px, calc(100vw - 36px)); }
.flash { padding: 13px 15px; margin-bottom: 8px; background: #eef4ff; border: 1px solid #b2ccff; border-radius: 5px; color: #1849a9; box-shadow: 0 8px 24px rgba(16,24,40,.12); }
.flash.success { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.flash.error { background: #fef3f2; border-color: #fecdca; color: #b42318; }
.flash.warning { background: #fffaeb; border-color: #fedf89; color: #93370d; }

.empty { padding: 36px; text-align: center; color: var(--muted); }
.score { font-size: 28px; font-weight: 800; }
.score small { font-size: 13px; color: var(--muted); }
.progress { height: 8px; background: #e8edf3; overflow: hidden; border-radius: 999px; }
.progress span { display: block; height: 100%; background: var(--blue); }
.question { padding: 18px 0; border-bottom: 1px solid var(--line); }
.question:last-child { border-bottom: 0; }
.options { display: grid; gap: 8px; margin-top: 12px; }
.option { display: flex; gap: 9px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 4px; }
.timeline { display: grid; gap: 10px; }
.timeline-item { border-left: 3px solid #cbd5e1; padding: 6px 0 6px 14px; }
.timeline-item strong { display: block; }
.muted { color: var(--muted); }
.danger-text { color: var(--red); }
.success-text { color: var(--green); }
.nowrap { white-space: nowrap; }

@media (max-width: 1050px) {
  .app-header { flex-wrap: wrap; gap: 10px; }
  .nav-toggle { display: block; margin-left: auto; }
  .app-nav { display: none; flex-basis: 100%; order: 4; flex-direction: column; align-items: stretch; }
  .app-nav.open { display: flex; }
  .user-menu { margin-left: auto; }
  .stats, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .app-header { padding: 10px 14px; }
  .app-brand { min-width: 0; }
  .user-menu span { display: none; }
  .app-main { padding: 20px 14px 44px; }
  .page-head { flex-direction: column; }
  .grid.two, .grid.three, .grid.four, .stats { grid-template-columns: 1fr; }
  .auth-panel { padding: 24px; }
  .auth-links { flex-direction: column; }
  .criterion-row { grid-template-columns: 1fr; }
}
