:root {
  --ink: #17233c;
  --muted: #667085;
  --line: #e3e8f1;
  --soft: #f5f7fb;
  --blue: #28559a;
  --blue-2: #3e73c4;
  --navy: #173464;
  --green: #167c5a;
  --amber: #b16a06;
  --red: #b42318;
  --violet: #6b55b6;
  --shadow: 0 16px 40px rgba(23, 52, 100, .12);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--soft); }
body { margin: 0; color: var(--ink); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 6px; color: var(--blue-2); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.muted { color: var(--muted); }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(480px, 1.12fr) minmax(440px, .88fr); background: #fff; }
.login-art { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 54px 7vw; color: #fff; background: radial-gradient(circle at 80% 17%, rgba(88, 151, 231, .48), transparent 26%), linear-gradient(145deg, #112b56 0%, #235492 58%, #3776bc 100%); }
.login-art::after { content: ""; position: absolute; right: -120px; bottom: -160px; width: 510px; height: 510px; border: 80px solid rgba(255,255,255,.055); border-radius: 50%; }
.login-grid { position: absolute; inset: 0; opacity: .09; background-image: linear-gradient(rgba(255,255,255,.55) 1px, transparent 1px), linear-gradient(90deg,rgba(255,255,255,.55) 1px, transparent 1px); background-size: 48px 48px; mask-image: linear-gradient(140deg, transparent 10%, #000 76%); }
.login-brand, .login-copy, .privacy-note { position: relative; z-index: 1; }
.login-brand { display: flex; align-items: center; gap: 20px; font-size: 16px; letter-spacing: .18em; }
.login-brand img { width: 160px; height: auto; padding: 8px 10px; border-radius: 8px; background: #fff; }
.login-brand span { border-left: 1px solid rgba(255,255,255,.45); padding-left: 20px; font-weight: 800; }
.login-copy { max-width: 680px; margin: auto 0; }
.login-copy p { margin: 0 0 20px; font-size: 12px; font-weight: 800; letter-spacing: .18em; opacity: .78; }
.login-copy h1 { margin: 0 0 24px; font-size: clamp(40px, 4.2vw, 68px); line-height: 1.03; letter-spacing: -.045em; }
.login-copy > span { display: block; max-width: 560px; font-size: 18px; line-height: 1.65; color: rgba(255,255,255,.82); }
.privacy-note { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.76); font-size: 12px; }
.privacy-note i, .engine-badge i { width: 8px; height: 8px; border-radius: 50%; background: #4de3a7; box-shadow: 0 0 0 5px rgba(77,227,167,.13); }
.login-card { align-self: center; width: min(470px, calc(100% - 64px)); margin: auto; padding: 48px; border: 1px solid #e5eaf2; border-radius: 20px; background: #fff; box-shadow: 0 26px 70px rgba(22,44,84,.13); }
.login-card h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.03em; }
.login-card > .muted { margin: 0 0 30px; }
.login-card label, .settings-card label { display: grid; gap: 7px; margin: 0 0 18px; color: #344054; font-size: 12px; font-weight: 700; }
.login-card input, .login-card select, .settings-card input, .settings-card select, .settings-card textarea, #access-search { width: 100%; border: 1px solid #cfd7e6; border-radius: 9px; background: #fff; color: var(--ink); outline: none; transition: .2s; }
.login-card input, .login-card select, .settings-card input, .settings-card select, #access-search { min-height: 46px; padding: 10px 13px; }
.login-card select { min-height: 96px; padding: 5px; }
.login-card select option { padding: 7px 9px; border-radius: 5px; }
.login-card input:focus, .login-card select:focus, .settings-card input:focus, .settings-card select:focus, .settings-card textarea:focus, #access-search:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(62,115,196,.13); }
.login-card small { color: var(--muted); font-weight: 500; }
.password-field { position: relative; }
.password-field input { padding-right: 74px; }
.password-field button { position: absolute; right: 8px; top: 7px; height: 32px; padding: 0 8px; border: 0; background: transparent; color: var(--blue); font-size: 12px; font-weight: 700; }
.primary, .secondary, .link-button { border-radius: 8px; font-weight: 750; transition: .18s; }
.primary { min-height: 42px; padding: 0 18px; border: 1px solid var(--blue); background: var(--blue); color: #fff; box-shadow: 0 6px 14px rgba(40,85,154,.16); }
.primary:hover:not(:disabled) { background: #214a89; transform: translateY(-1px); }
.primary:disabled { border-color: #cbd3df; background: #d7dde7; box-shadow: none; cursor: not-allowed; }
.primary.full { width: 100%; min-height: 48px; margin-top: 6px; }
.secondary { min-height: 38px; padding: 0 14px; border: 1px solid #cfd7e4; background: #fff; color: #344054; }
.secondary:hover { border-color: #9eabc0; background: #f8fafc; }
.link-button { border: 0; background: transparent; color: var(--blue); }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-weight: 650; }
.login-help { display: block; margin-top: 10px; text-align: center; line-height: 1.5; }
.mobile-brand { display: none; }

.app-shell { min-height: 100vh; background: var(--soft); }
.topbar { position: sticky; top: 0; z-index: 20; height: 74px; display: grid; grid-template-columns: minmax(270px, .7fr) minmax(460px, 1.4fr) minmax(270px, .7fr); align-items: center; padding: 0 34px; border-bottom: 1px solid #dce3ee; background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: 95px; height: auto; }
.brand > i { width: 1px; height: 30px; background: #d2d9e5; }
.brand div { display: grid; }
.brand b { color: var(--navy); font-size: 13px; letter-spacing: .08em; }
.brand span { color: var(--muted); font-size: 11px; }
.topbar nav { justify-self: center; display: flex; align-items: stretch; height: 100%; gap: 22px; }
.topbar nav button { position: relative; border: 0; background: transparent; color: #5b6678; font-size: 13px; font-weight: 700; }
.topbar nav button::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.topbar nav button.active { color: var(--blue); }
.topbar nav button.active::after { background: var(--blue); }
.user-menu { justify-self: end; display: flex; align-items: center; gap: 14px; }
.user-menu div { display: grid; text-align: right; }
.user-menu b { font-size: 12px; }
.user-menu span { color: var(--muted); font-size: 11px; }
.user-menu button { min-height: 34px; padding: 0 12px; border: 1px solid #d6dde8; border-radius: 7px; background: #fff; color: #475467; font-weight: 700; }
main { width: min(1600px, calc(100% - 64px)); margin: 0 auto; padding: 36px 0 72px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { margin: 0 0 5px; font-size: 28px; letter-spacing: -.035em; }
.page-heading > div > span { color: var(--muted); }
.engine-badge { display: flex; align-items: center; gap: 13px; padding: 11px 16px; border: 1px solid #cae6db; border-radius: 12px; background: #f2fbf7; color: #126247; }
.engine-badge span { display: grid; }
.engine-badge small { color: #4c7f6d; }
.summary-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.summary-card { display: flex; align-items: center; gap: 14px; min-height: 112px; padding: 19px; border: 1px solid var(--line); border-radius: 13px; background: #fff; text-align: left; box-shadow: 0 2px 8px rgba(28,49,87,.04); transition: .18s; }
.summary-card:hover, .summary-card.active { border-color: #9eb9df; box-shadow: 0 8px 24px rgba(28,74,139,.1); transform: translateY(-1px); }
.summary-icon { flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; font-size: 18px; font-weight: 900; }
.summary-icon.blue { color: var(--blue); background: #eaf1fb; }
.summary-icon.gray { color: #667085; background: #eef1f5; }
.summary-icon.amber { color: var(--amber); background: #fff4df; }
.summary-icon.green { color: var(--green); background: #e8f8f1; }
.summary-icon.red { color: var(--red); background: #feeeee; }
.summary-card div { display: grid; }
.summary-card small { color: var(--muted); font-weight: 700; }
.summary-card b { font-size: 27px; line-height: 1.18; }
.summary-card em { color: #8a94a5; font-size: 10px; font-style: normal; }
.filter-panel, .records-panel, .admin-card { border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 3px 12px rgba(23,52,100,.045); }
.filter-panel { margin-bottom: 20px; padding: 20px 22px; }
.filter-title, .records-toolbar, .card-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.filter-title h2, .records-toolbar h2, .card-head h2 { margin: 0; font-size: 17px; }
.filters { display: grid; grid-template-columns: 1fr 1fr 1.15fr .9fr 1.3fr 1.3fr 1.4fr auto; align-items: end; gap: 12px; margin-top: 16px; }
.filters label { display: grid; gap: 5px; color: #596579; font-size: 11px; font-weight: 700; }
.filters input, .filters select { width: 100%; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid #d2d9e5; border-radius: 7px; background: #fff; color: var(--ink); outline: none; }
.filters input:focus, .filters select:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(62,115,196,.11); }
.records-panel { overflow: hidden; }
.records-toolbar { min-height: 71px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.records-toolbar > div { display: grid; }
.records-toolbar span { color: var(--muted); font-size: 11px; }
.toolbar-actions { display: flex !important; grid-auto-flow: column; align-items: center; gap: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 13px; border-bottom: 1px solid var(--line); background: #f9fafc; color: #667085; font-size: 10px; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px; border-bottom: 1px solid #edf0f5; color: #344054; vertical-align: middle; }
tbody tr { transition: .15s; }
tbody tr:hover { background: #f9fbfe; }
.records-table td:nth-child(4) { min-width: 190px; }
.records-table td:nth-child(6) { min-width: 220px; max-width: 350px; }
.records-table td:nth-child(7) { min-width: 130px; }
.cell-main { display: grid; }
.cell-main b { color: var(--ink); font-size: 12px; }
.cell-main small { color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.nao_analisado { color: #667085; background: #eef1f5; }
.status.na_fila, .status.processando { color: #9b5b05; background: #fff4df; }
.status.aprovado, .status.aprovado_manual { color: #11704f; background: #e9f8f1; }
.status.pendencia, .status.revisao, .status.sem_documento, .status.reprovado_manual, .status.erro { color: #a52a20; background: #fdeeed; }
.open-detail { min-height: 34px; padding: 0 11px; border: 1px solid #cfd8e7; border-radius: 7px; background: #fff; color: var(--blue); font-weight: 750; }
.open-detail:disabled { color: #98a2b3; cursor: not-allowed; }
.progress { width: 92px; height: 5px; overflow: hidden; border-radius: 99px; background: #eadbc4; }
.progress i { display: block; height: 100%; background: var(--amber); transition: width .3s; }
.empty-state { display: grid; place-items: center; padding: 65px 20px; color: var(--muted); text-align: center; }
.empty-state span { width: 54px; height: 54px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 50%; background: #eef3fa; color: var(--blue); font-size: 28px; }
.empty-state b { color: #344054; font-size: 15px; }
.empty-state p { margin: 4px 0 0; }
.limit-note { margin: 0; padding: 10px 20px; border-top: 1px solid #f2d7ac; background: #fff8eb; color: #8b550a; font-size: 11px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(340px, .7fr); gap: 20px; }
.admin-card { padding: 22px; }
.card-head { margin-bottom: 20px; }
#access-search-form { display: flex; gap: 8px; }
#access-search { width: 240px; min-height: 38px; }
.access-list { display: grid; gap: 8px; max-height: 650px; overflow-y: auto; }
.access-row { display: grid; grid-template-columns: minmax(220px, 1fr) 130px 110px; align-items: center; gap: 12px; padding: 12px; border: 1px solid #e6eaf1; border-radius: 9px; }
.access-row > div { display: grid; }
.access-row small { color: var(--muted); }
.access-row select { height: 36px; border: 1px solid #ccd5e2; border-radius: 7px; }
.switch { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: #596579; font-size: 11px; font-weight: 700; }
.switch input { width: 18px; height: 18px; accent-color: var(--blue); }
.settings-card textarea { padding: 10px 12px; resize: vertical; }
.label-title { display: block; margin-bottom: 9px; color: #344054; font-size: 12px; font-weight: 700; }
.field-options { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 20px; }
.field-options label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px; border: 1px solid #e5eaf1; border-radius: 7px; color: #475467; font-size: 11px; }
.field-options input { flex: 0 0 16px; width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--blue); }
.audit-table td { font-size: 12px; }
.audit-table td:last-child { max-width: 520px; color: var(--muted); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(10,24,45,.44); backdrop-filter: blur(2px); }
.detail-drawer { position: fixed; z-index: 41; top: 0; right: 0; width: min(720px, 94vw); height: 100vh; transform: translateX(102%); background: #f7f9fc; box-shadow: -24px 0 70px rgba(10,24,45,.23); transition: transform .25s ease; }
.detail-drawer.open { transform: translateX(0); }
.detail-drawer > header { min-height: 102px; display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 22px 26px; border-bottom: 1px solid var(--line); background: #fff; }
.detail-drawer h2 { margin: 0 0 4px; font-size: 22px; }
.detail-drawer header span { color: var(--muted); }
.detail-drawer header > button { width: 38px; height: 38px; border: 1px solid #d7dee9; border-radius: 50%; background: #fff; color: #596579; font-size: 23px; }
.drawer-content { height: calc(100vh - 102px); overflow-y: auto; padding: 22px 26px 50px; }
.detail-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.detail-summary article { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.detail-summary small { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.detail-summary b { font-size: 13px; }
.detail-section { margin-bottom: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.detail-section > h3 { margin: 0 0 3px; font-size: 15px; }
.detail-section > p { margin: 0 0 14px; color: var(--muted); font-size: 11px; }
.field-result { display: grid; grid-template-columns: 1fr 110px; gap: 14px; padding: 13px 0; border-top: 1px solid #edf0f5; }
.field-result:first-of-type { border-top: 0; }
.field-result > div { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 18px; }
.field-result h4 { grid-column: 1 / -1; margin: 0; font-size: 12px; }
.field-result p { margin: 0; }
.field-result small { display: block; color: var(--muted); font-size: 9px; letter-spacing: .04em; text-transform: uppercase; }
.field-result em { grid-column: 1 / -1; color: #7b8596; font-size: 10px; font-style: normal; }
.field-state { align-self: center; justify-self: end; padding: 6px 8px; border-radius: 999px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.field-state.conforme { color: var(--green); background: #e7f7ef; }
.field-state.divergente, .field-state.nao_localizado, .field-state.cadastro_ausente { color: var(--red); background: #fdeeed; }
.field-state.revisao { color: var(--amber); background: #fff3df; }
.document-list { display: grid; gap: 8px; }
.document-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 11px; border: 1px solid #e5eaf1; border-radius: 8px; }
.document-item > div { display: grid; }
.document-item small { color: var(--muted); }
.document-view-button { padding: 7px 10px; border: 1px solid #c7d5e8; border-radius: 7px; background: #fff; color: var(--blue); font-size: 11px; font-weight: 750; cursor: pointer; }
.document-view-button:hover { border-color: var(--blue); background: #f2f7ff; }
.document-error { color: var(--red) !important; }
.document-viewer { position: fixed; z-index: 65; left: 50%; top: 50%; display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(820px, calc(100vw - 32px)); height: min(720px, calc(100vh - 32px)); min-width: 360px; min-height: 280px; overflow: hidden; resize: both; border: 1px solid #bec9d8; border-radius: 12px; background: #fff; box-shadow: 0 24px 80px rgba(10,24,45,.34); }
.document-viewer.hidden { display: none; }
.document-viewer-handle { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); background: #fff; cursor: move; user-select: none; touch-action: none; }
.document-viewer.dragging .document-viewer-handle { cursor: grabbing; }
.document-viewer-handle .eyebrow { margin-bottom: 2px; }
.document-viewer-handle h2 { max-width: min(560px, 60vw); margin: 0; overflow: hidden; color: var(--navy); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.document-viewer-actions { display: flex; align-items: center; gap: 7px; }
.document-viewer-actions a, .document-viewer-actions button { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 1px solid #d7dee9; border-radius: 8px; background: #fff; color: #4d5b70; font-size: 20px; line-height: 1; text-decoration: none; cursor: pointer; }
.document-viewer-actions a:hover, .document-viewer-actions button:hover { border-color: var(--blue); color: var(--blue); }
.document-viewer-body { min-width: 0; min-height: 0; background: #e9edf3; }
.document-viewer-frame { width: 100%; height: 100%; display: block; border: 0; background: #fff; }
.document-viewer-resize-hint { position: absolute; right: 3px; bottom: 1px; color: #7d899a; font-size: 18px; line-height: 1; pointer-events: none; }
.review-box { display: grid; gap: 10px; }
.review-box textarea { width: 100%; min-height: 82px; padding: 10px; border: 1px solid #ccd5e2; border-radius: 8px; resize: vertical; }
.review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.approve-button, .reject-button { min-height: 41px; border-radius: 8px; font-weight: 800; }
.approve-button { border: 1px solid #167c5a; background: #167c5a; color: #fff; }
.reject-button { border: 1px solid #d49a95; background: #fff; color: var(--red); }

.busy-overlay { position: fixed; z-index: 80; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(246,248,252,.77); backdrop-filter: blur(2px); color: var(--navy); }
.busy-overlay i { width: 34px; height: 34px; border: 3px solid #d7e0ed; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 20px); max-width: min(560px, calc(100vw - 32px)); padding: 11px 16px; border-radius: 9px; background: #17233c; color: #fff; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: #8f251f; }

@media (max-width: 1250px) {
  .filters { grid-template-columns: repeat(4, 1fr); }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .topbar { grid-template-columns: 250px 1fr 250px; padding: 0 22px; }
}
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; background: linear-gradient(145deg, #edf3fb, #fff); }
  .login-art { display: none; }
  .login-card { width: min(520px, calc(100% - 32px)); padding: 34px 28px; }
  .mobile-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; color: var(--navy); letter-spacing: .08em; }
  .mobile-brand img { width: 112px; }
  .topbar { height: auto; min-height: 68px; grid-template-columns: 1fr auto; padding: 12px 16px; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; height: 42px; justify-self: start; }
  .brand span { display: none; }
  .user-menu div { display: none; }
  main { width: calc(100% - 28px); padding-top: 24px; }
  .page-heading { align-items: flex-start; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .document-viewer { min-width: 280px; min-height: 240px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { min-height: 86px; }
  .filters { grid-template-columns: 1fr; }
  .page-heading { display: grid; }
  .engine-badge { justify-self: start; }
  .records-toolbar { display: grid; }
  .toolbar-actions { justify-content: space-between; }
  .detail-summary { grid-template-columns: 1fr; }
  .field-result { grid-template-columns: 1fr; }
  .field-state { justify-self: start; }
  .field-result > div { grid-template-columns: 1fr; }
  .field-result h4, .field-result em { grid-column: auto; }
  .access-row { grid-template-columns: 1fr; }
  .switch { justify-content: flex-start; }
}
