:root {
  --bg: #071018;
  --surface: #0d1a24;
  --surface-2: #112431;
  --line: rgba(255,255,255,.10);
  --text: #f7f1e7;
  --muted: #aeb9c2;
  --gold: #d3ad6b;
  --gold-light: #ecd5a7;
  --green: #54c88d;
  --yellow: #e5b759;
  --red: #e17878;
  --blue: #68b2df;
  --shadow: 0 24px 70px rgba(0,0,0,.35);
  --radius: 20px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 7%, rgba(211,173,107,.12), transparent 30%),
    radial-gradient(circle at 90% 1%, rgba(104,178,223,.07), transparent 25%),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.container { width: min(1220px, calc(100% - 36px)); margin: 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.muted { color: var(--muted); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(7,16,24,.82);
  backdrop-filter: blur(16px);
}
.nav {
  min-height: 76px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand.haler-brand { transition: opacity .2s ease, transform .2s ease; }
.brand.haler-brand:hover { opacity: .92; transform: translateY(-1px); }
.brand-logo-frame {
  width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--gold-light), #ffffff 52%, var(--gold));
  box-shadow: 0 10px 30px rgba(211,173,107,.18);
  border: 1px solid rgba(255,255,255,.22);
  overflow: hidden;
}
.brand-logo-img {
  width: 37px; height: 37px;
  object-fit: contain;
  display: block;
}
.brand-text { display: block; }
.brand strong { display: block; letter-spacing: .16em; font-size: 15px; color: var(--text); }
.brand small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; text-transform: uppercase; letter-spacing: .08em; }
.brand-mark {
  width: 43px; height: 43px; display: grid; place-items: center;
  color: #111820; border-radius: 13px; font-weight: 900;
  background: linear-gradient(145deg, var(--gold-light), var(--gold));
  box-shadow: 0 10px 30px rgba(211,173,107,.18);
}
.database-state {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 12px; font-size: 12px;
}
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); }
.database-state.ready .state-dot { background: var(--green); }
.database-state.error .state-dot { background: var(--red); }

.hero { padding: 76px 0 44px; text-align: center; }
.eyebrow, .section-kicker { color: var(--gold-light); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; margin: 0; }
h1 {
  max-width: 950px; margin: 21px auto 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500; font-size: clamp(42px, 6.8vw, 74px);
  line-height: 1; letter-spacing: -.045em;
}
.hero-copy { max-width: 760px; margin: 0 auto; color: var(--muted); line-height: 1.7; font-size: 17px; }
.search-panel {
  max-width: 1080px; margin: 42px auto 0; padding: 21px; text-align: left;
  border: 1px solid var(--line); border-radius: 27px;
  background: linear-gradient(180deg, rgba(17,36,49,.95), rgba(13,26,36,.96));
  box-shadow: var(--shadow);
}
.search-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; }
.search-input-wrap { position: relative; }
.search-input-wrap svg {
  position: absolute; left: 19px; top: 50%; width: 21px; transform: translateY(-50%);
  fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round;
}
.search-input-wrap input {
  width: 100%; min-height: 62px; padding: 0 18px 0 52px;
  color: var(--text); background: rgba(4,11,16,.58);
  border: 1px solid rgba(255,255,255,.12); border-radius: 16px; outline: none;
  font-size: 17px;
}
.search-row > button, .primary-button {
  min-height: 52px; border: 0; border-radius: 14px; padding: 0 24px;
  color: #111820; background: linear-gradient(145deg, var(--gold-light), var(--gold));
  font-weight: 800;
}
.search-row > button { min-width: 160px; }
.search-row > button:disabled { opacity: .55; cursor: wait; }
.filter-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-top: 13px; }
.filter-grid label > span, label > small { display: block; color: var(--muted); font-size: 11px; margin: 0 0 7px 3px; }
select, input, textarea {
  width: 100%; min-height: 47px; padding: 0 12px;
  color: var(--text); background: #09151e;
  border: 1px solid rgba(255,255,255,.11); border-radius: 12px; outline: none;
}
textarea { min-height: 120px; padding-top: 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(211,173,107,.68); box-shadow: 0 0 0 4px rgba(211,173,107,.08); }
.search-help { margin: 14px 3px 0; color: var(--muted); font-size: 12px; }

.results-section { padding: 36px 0 86px; }
.results-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 19px; }
.results-header h2 {
  margin: 7px 0 5px; font-family: Georgia, "Times New Roman", serif;
  font-weight: 500; font-size: 34px;
}
.results-header p:last-child { margin: 0; color: var(--muted); }
.clear-button, .secondary-button {
  min-height: 42px; padding: 0 14px; color: var(--text);
  border: 1px solid var(--line); border-radius: 11px; background: transparent;
}
.table-shell {
  overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(13,26,36,.86); box-shadow: 0 18px 45px rgba(0,0,0,.18);
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1040px; }
th {
  padding: 13px 15px; color: var(--gold-light); background: rgba(211,173,107,.08);
  border-bottom: 1px solid var(--line); text-align: left; text-transform: uppercase;
  letter-spacing: .06em; font-size: 10px;
}
td { padding: 17px 15px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 13px; line-height: 1.45; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.process-link { color: var(--gold-light); text-decoration: none; font-weight: 700; }
.process-link:hover { text-decoration: underline; }
.mark-name { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 18px; }
.presentation { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.status-badge { display: inline-flex; align-items: flex-start; gap: 7px; max-width: 260px; }
.status-badge::before { content: ""; flex: 0 0 auto; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: currentColor; }
.status-registro { color: var(--green); }
.status-exame { color: var(--yellow); }
.status-arquivado { color: var(--blue); }
.status-indeferido { color: var(--red); }
.cards { display: none; gap: 13px; }
.result-card { padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: rgba(13,26,36,.88); }
.result-card h3 { margin: 0 0 5px; font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 500; }
.result-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 0; }
.result-card dt { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.result-card dd { margin: 4px 0 0; font-size: 13px; }
.empty-state { padding: 56px 25px; text-align: center; border: 1px dashed rgba(255,255,255,.15); border-radius: var(--radius); background: rgba(13,26,36,.42); }
.empty-state strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 25px; font-weight: 500; }
.empty-state p { color: var(--muted); margin: 8px 0 0; }
.notice { padding: 14px 16px; margin: 0 0 16px; border-radius: 13px; line-height: 1.5; }
.notice.error { color: #ffc2c2; border: 1px solid rgba(225,120,120,.25); background: rgba(225,120,120,.08); }
.notice.success { color: #b9f6d3; border: 1px solid rgba(84,200,141,.25); background: rgba(84,200,141,.08); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 20px; }
.pagination button { min-height: 41px; padding: 0 14px; color: var(--text); border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.pagination button:disabled { opacity: .35; cursor: not-allowed; }
.pagination span { color: var(--muted); font-size: 13px; }
.legal-note { margin-top: 36px; padding: 20px; color: var(--muted); border-left: 3px solid var(--gold); background: rgba(211,173,107,.055); line-height: 1.6; }
.legal-note strong { color: var(--text); }
.legal-note p { margin: 5px 0 0; }

/* Instalação e administração */
.install-body, .admin-body { background: var(--bg); }
.install-wrap { width: min(900px, calc(100% - 28px)); margin: 45px auto; }
.install-card, .admin-card {
  padding: 28px; border: 1px solid var(--line); border-radius: 24px;
  background: rgba(13,26,36,.94); box-shadow: var(--shadow);
}
.install-card h1 { margin: 9px 0 8px; font-size: 48px; text-align: left; }
.install-card h2, .admin-card h2 { margin: 28px 0 12px; font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
.requirements { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0; }
.requirements > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.requirements .ok { color: #b9f6d3; }
.requirements .fail { color: #ffc2c2; }
.requirements small { display: block; color: var(--muted); margin-top: 4px; }
.install-form label, .admin-form label { display: block; color: var(--muted); font-size: 12px; margin-top: 12px; }
.install-form input, .admin-form input, .admin-form select { margin-top: 6px; }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.primary-button { margin-top: 20px; }
.admin-layout { min-height: 100vh; display: grid; grid-template-columns: 245px minmax(0,1fr); }
.admin-sidebar { padding: 25px 18px; border-right: 1px solid var(--line); background: #08141d; }
.admin-sidebar .brand { margin-bottom: 28px; }
.admin-nav { display: grid; gap: 7px; }
.admin-nav a { padding: 11px 12px; color: var(--muted); text-decoration: none; border-radius: 10px; }
.admin-nav a:hover, .admin-nav a.active { color: var(--text); background: rgba(255,255,255,.055); }
.admin-main { padding: 32px; min-width: 0; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.admin-head h1 { margin: 0; font-size: 42px; text-align: left; }
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.stat-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.stat-card span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.stat-card strong { display: block; margin-top: 8px; font-family: Georgia, "Times New Roman", serif; font-size: 28px; font-weight: 500; }
.admin-section { margin-top: 24px; }
.admin-table { min-width: 800px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.progress { height: 12px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-light)); transition: width .2s; }
.code-box { padding: 14px; overflow-wrap: anywhere; color: var(--gold-light); border: 1px solid var(--line); border-radius: 11px; background: #061018; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.login-wrap { width: min(470px, calc(100% - 26px)); margin: 10vh auto; }

@media (max-width: 950px) {
  .filter-grid, .stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-nav { grid-template-columns: repeat(4,1fr); }
}
@media (max-width: 700px) {
  .container { width: min(100% - 22px, 1220px); }
  .hero { padding-top: 53px; }
  .search-panel { padding: 14px; border-radius: 20px; }
  .search-row, .filter-grid, .form-grid.two, .requirements, .stats-grid { grid-template-columns: 1fr; }
  .search-row > button { min-height: 54px; }
  .results-header, .admin-head { align-items: flex-start; flex-direction: column; }
  .table-shell { display: none !important; }
  .cards[hidden] { display: none; }
  .cards:not([hidden]) { display: grid; }
  .admin-main { padding: 21px 12px; }
  .admin-nav { grid-template-columns: 1fr 1fr; }
}


/* Central de ajuda contextual */
.section-title-row,
.help-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-title-row h2,
.help-title-row h2 {
  margin-top: 0;
  margin-bottom: 0;
}

.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 13px;
  color: var(--gold-light);
  border: 1px solid rgba(211,173,107,.28);
  border-radius: 999px;
  background: rgba(211,173,107,.07);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  transition: .2s ease;
}

.help-button:hover,
.help-button:focus-visible {
  color: #111820;
  background: var(--gold-light);
  transform: translateY(-1px);
  outline: none;
}

.help-button--compact {
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
}

.help-button__icon {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
}

.admin-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.help-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 17px;
  color: #111820;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--gold-light), var(--gold));
  box-shadow: 0 14px 42px rgba(0,0,0,.38);
  font-weight: 900;
}

.help-fab > span:first-child {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid rgba(17,24,32,.5);
  border-radius: 50%;
}

.help-fab:hover,
.help-fab:focus-visible {
  transform: translateY(-2px);
  outline: 3px solid rgba(236,213,167,.2);
}

body.help-open {
  overflow: hidden;
}

.help-modal[hidden] {
  display: none;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 18px;
}

.help-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1,7,11,.82);
  backdrop-filter: blur(8px);
}

.help-modal__dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(17,36,49,.98), rgba(10,23,32,.99));
  box-shadow: 0 30px 90px rgba(0,0,0,.56);
}

.help-modal__header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 23px 24px 19px;
  border-bottom: 1px solid var(--line);
  background: rgba(13,27,38,.96);
  backdrop-filter: blur(12px);
}

.help-modal__eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 10px;
}

.help-modal__header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(27px, 5vw, 38px);
  font-weight: 500;
  line-height: 1.08;
}

.help-modal__close {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-size: 26px;
  line-height: 1;
}

.help-modal__close:hover,
.help-modal__close:focus-visible {
  color: #111820;
  background: var(--gold-light);
  outline: none;
}

.help-modal__content {
  padding: 24px;
}

.help-modal__intro {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.help-modal__block + .help-modal__block,
.help-modal__tip + .help-modal__block,
.help-modal__warning + .help-modal__block {
  margin-top: 22px;
}

.help-modal__block h3 {
  margin: 0 0 12px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 500;
}

.help-modal__steps {
  margin: 0;
  padding-left: 25px;
  color: var(--muted);
}

.help-modal__steps li {
  padding: 5px 0 5px 7px;
  line-height: 1.55;
}

.help-modal__steps li::marker {
  color: var(--gold-light);
  font-weight: 900;
}

.help-modal__sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.help-modal__sections article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.025);
}

.help-modal__sections strong {
  display: block;
  color: var(--gold-light);
  margin-bottom: 5px;
}

.help-modal__sections p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.help-modal__tip,
.help-modal__warning {
  margin-top: 22px;
  padding: 16px 17px;
  border-radius: 14px;
  line-height: 1.55;
}

.help-modal__tip {
  color: #c9f5dc;
  border: 1px solid rgba(84,200,141,.24);
  background: rgba(84,200,141,.07);
}

.help-modal__warning {
  color: #ffe2ad;
  border: 1px solid rgba(229,183,89,.26);
  background: rgba(229,183,89,.07);
}

.help-modal__tip strong,
.help-modal__warning strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
}

.help-modal__tip ul {
  margin: 0;
  padding-left: 20px;
}

.help-modal__tip li + li {
  margin-top: 5px;
}

.help-modal__warning p {
  margin: 0;
}

.help-modal__related {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.help-related-button {
  min-height: 39px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.035);
  font-size: 12px;
}

.help-related-button:hover,
.help-related-button:focus-visible {
  color: var(--gold-light);
  border-color: rgba(211,173,107,.4);
  outline: none;
}

@media (max-width: 700px) {
  .help-fab {
    right: 13px;
    bottom: 13px;
  }

  .help-fab > span:last-child {
    display: none;
  }

  .help-fab {
    width: 49px;
    padding: 0;
    justify-content: center;
  }

  .help-modal {
    padding: 8px;
  }

  .help-modal__dialog {
    max-height: 94vh;
    border-radius: 18px;
  }

  .help-modal__header,
  .help-modal__content {
    padding: 18px;
  }

  .help-modal__sections {
    grid-template-columns: 1fr;
  }

  .section-title-row {
    align-items: flex-start;
  }

  .admin-head-actions {
    width: 100%;
    justify-content: flex-start;
  }
}


/* Atualização automática de RPIs */
.check-option {
  display: flex !important;
  align-items: flex-start;
  gap: 12px;
  min-height: 78px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
}

.check-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--gold);
}

.check-option span {
  display: grid;
  gap: 5px;
}

.check-option strong {
  color: var(--text);
}

.check-option small {
  color: var(--muted);
  line-height: 1.45;
}

.stat-card-small {
  font-size: clamp(15px, 2.5vw, 21px) !important;
  line-height: 1.25;
}

.code-box {
  overflow: auto;
  margin: 12px 0;
  padding: 14px 16px;
  border: 1px solid rgba(211,173,107,.22);
  border-radius: 13px;
  background: rgba(0,0,0,.22);
  color: var(--gold-light);
  white-space: pre-wrap;
  word-break: break-all;
}
