:root {
  color-scheme: dark;
  --bg: #09111c;
  --bg-soft: #101b29;
  --card: rgba(15, 23, 38, 0.96);
  --card-soft: #152235;
  --text: #ebf2fa;
  --muted: #9fb0c6;
  --line: rgba(137, 157, 186, 0.22);
  --gold: #d7b24b;
  --green: #52c17a;
  --red: #ef6461;
  --blue: #6fc7ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(111, 199, 255, 0.12), transparent 24%),
    radial-gradient(circle at bottom left, rgba(215, 178, 75, 0.1), transparent 26%),
    linear-gradient(140deg, #08101a 0%, #0d1624 55%, #09111c 100%);
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--gold); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(9, 17, 28, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.03em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--gold), #f0d88b);
  color: #161207;
}

.nav {
  display: flex;
  gap: 18px;
  flex: 1;
  flex-wrap: wrap;
}

.nav a { color: var(--text); font-size: 0.93rem; }

.identity { text-align: right; }
.identity strong, .identity span { display: block; }
.identity span { color: var(--gold); font-size: 0.78rem; }

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 60px;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 24px;
}

h1, h2, h3, p, pre { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin-bottom: 8px; }
h2 { font-size: 1.15rem; }

.eyebrow {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}

.muted { color: var(--muted); }

.card {
  background: linear-gradient(145deg, rgba(18, 29, 44, 0.98), rgba(12, 20, 31, 0.98));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat span, .stat strong { display: block; }
.stat span { color: var(--muted); font-size: 0.86rem; }
.stat strong { margin-top: 12px; font-size: 1.8rem; }

.yellow { color: var(--gold); }
.green { color: var(--green); }
.red { color: var(--red); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  background: var(--gold);
  color: #111827;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.button:hover { color: #111827; filter: brightness(1.08); }
.button.secondary { background: #32465f; color: var(--text); }
.button.success { background: var(--green); color: #0b2716; }
.button.small { padding: 7px 10px; font-size: 0.78rem; }
.button.full { width: 100%; }

.form-stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }

label {
  display: grid;
  gap: 7px;
  color: #d0d9e6;
  font-size: 0.9rem;
  font-weight: 650;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(123, 146, 176, 0.34);
  border-radius: 10px;
  padding: 11px 12px;
  background: #09111c;
  color: var(--text);
  font: inherit;
}

textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(215, 178, 75, 0.35);
  border-color: var(--gold);
}

.auth-shell { min-height: 72vh; display: grid; place-items: center; }
.auth-card { width: min(430px, 100%); }

.notice, .notice-panel {
  margin-top: 18px;
  padding: 13px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.warning, .notice-panel {
  border: 1px solid rgba(215, 178, 75, 0.35);
  background: rgba(215, 178, 75, 0.09);
}

.flash {
  margin-bottom: 16px;
  padding: 13px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.flash.success { background: rgba(82, 193, 122, 0.12); color: #c9f4d5; }
.flash.error { background: rgba(239, 100, 97, 0.12); color: #ffd0ce; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: #32465f;
  font-size: 0.75rem;
  font-weight: 800;
}

.badge.aprovada { color: #c9f4d5; background: rgba(82, 193, 122, 0.15); }
.badge.rejeitada { color: #ffd0ce; background: rgba(239, 100, 97, 0.15); }
.badge.pendente, .badge.parcial { color: #f3df9d; background: rgba(215, 178, 75, 0.13); }
.badge.large { padding: 9px 14px; }

.inline-form { display: flex; align-items: center; gap: 8px; }
.form-page { display: grid; place-items: start center; }
.form-card { width: min(620px, 100%); }
.form-card.wide { width: 100%; }
.actions { display: flex; gap: 10px; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
  gap: 20px;
}

.stack { display: grid; gap: 20px; align-content: start; }

.details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.details div {
  padding: 12px;
  background: rgba(9, 17, 28, 0.7);
  border-radius: 10px;
}

dt { color: var(--muted); font-size: 0.75rem; }
dd { margin: 4px 0 0; font-weight: 750; }

.analysis-text {
  white-space: pre-wrap;
  line-height: 1.65;
  color: #dbeafe;
}

.analysis-image {
  width: 100%;
  max-height: 650px;
  object-fit: contain;
  margin-top: 20px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #020617;
}

.leon-card { border-color: rgba(215, 178, 75, 0.28); }

.score {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.score strong { color: var(--gold); font-size: 1.7rem; }
.review-card, .password-alert { margin-top: 20px; }
.password-alert { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.password-form { flex-wrap: wrap; justify-content: end; }
.password-form input { width: 175px; }
.empty, .centered { text-align: center; }

.audit-heading-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audit-safety {
  margin-bottom: 22px;
  border-color: rgba(82, 193, 122, 0.35);
  background: rgba(82, 193, 122, 0.08);
}

.audit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.7fr);
  gap: 20px;
  margin-bottom: 20px;
}

.audit-findings {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.audit-finding {
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  background: rgba(9, 17, 28, 0.58);
}

.audit-finding h3 { margin-bottom: 0; }
.audit-finding p { margin: 10px 0 0; line-height: 1.5; }
.audit-finding.severity-critico,
.audit-finding.severity-alto { border-left-color: var(--red); }
.audit-finding.severity-medio { border-left-color: var(--gold); }
.audit-finding.severity-info { border-left-color: var(--green); }

.correction {
  padding: 11px 12px;
  border-radius: 9px;
  background: rgba(111, 199, 255, 0.08);
}

.compact-list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.reason-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.reason-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 9px;
  background: rgba(9, 17, 28, 0.65);
}

.reason-list span { overflow-wrap: anywhere; }
.reason-list strong { color: var(--gold); }

.health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.event-list { display: grid; gap: 10px; margin-top: 18px; }
.event {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 17, 28, 0.65);
}
.event strong { margin-right: 10px; }
.event span { color: var(--muted); font-size: 0.82rem; }
.event p { margin: 8px 0 0; color: #d0d9e6; }
.event.critico { border-color: rgba(239, 100, 97, 0.5); }
.event.atencao { border-color: rgba(215, 178, 75, 0.4); }

.log-box {
  margin: 0;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(7, 13, 22, 0.88);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  color: #d7e4f5;
  font: 0.86rem/1.55 "Consolas", "Courier New", monospace;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(111, 199, 255, 0.12);
}

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .identity { margin-left: auto; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: 1fr; }
  .audit-layout { grid-template-columns: 1fr; }
  .password-alert { align-items: stretch; flex-direction: column; }
  .password-form { justify-content: start; }
}

@media (max-width: 620px) {
  .container { width: min(100% - 20px, 1180px); margin-top: 20px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .details { grid-template-columns: 1fr; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .audit-heading-actions { align-items: stretch; flex-direction: column; }
  .password-form input { width: 100%; }
}
