:root {
  --navy: #0d1f36;
  --navy-2: #172d49;
  --gold: #c99a3d;
  --gold-light: #f3e5c4;
  --ink: #172333;
  --muted: #647287;
  --line: #dce3eb;
  --surface: #ffffff;
  --canvas: #f3f6f9;
  --green: #13845d;
  --blue: #3976b9;
  --amber: #b97513;
  --red: #bf4747;
  --shadow: 0 12px 32px rgba(13, 31, 54, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 14px/1.5 "DM Sans", Arial, sans-serif; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 20; min-height: 72px; display: flex; align-items: stretch; color: #fff; background: var(--navy); box-shadow: 0 6px 18px rgba(9, 25, 43, .18); }
.brand { min-width: 255px; padding: 0 24px; display: flex; align-items: center; gap: 12px; border-right: 1px solid rgba(255,255,255,.1); }
.brand-icon { width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.72); color: var(--gold); font: 800 14px/1 "Manrope"; letter-spacing: .05em; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy b { font: 700 15px "Manrope"; }
.brand-copy small { margin-top: 4px; color: #9db0c7; font-size: 9px; letter-spacing: .22em; }
.nav { display: flex; align-items: stretch; flex: 1; overflow-x: auto; }
.nav button { position: relative; min-width: 132px; padding: 0 18px; color: #aebed1; border: 0; background: transparent; font-size: 13px; font-weight: 600; }
.nav button span { margin-right: 7px; color: #8398af; }
.nav button:hover, .nav button.active { color: #fff; background: rgba(255,255,255,.045); }
.nav button.active::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: 0; height: 3px; background: var(--gold); }
.user { padding: 0 22px; display: flex; align-items: center; gap: 12px; border-left: 1px solid rgba(255,255,255,.1); color: #b7c4d3; font-size: 12px; white-space: nowrap; }
.icon-button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid rgba(255,255,255,.18); background: transparent; color: inherit; font-size: 20px; }

main { max-width: 1480px; margin: auto; padding: 34px 38px 70px; }
.view { display: none; }
.view.active { display: block; animation: appear .24s ease; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }
.hero { min-height: 116px; margin-bottom: 26px; display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; border-bottom: 1px solid var(--line); padding-bottom: 24px; }
.kicker { margin-bottom: 7px; color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: "Manrope", sans-serif; line-height: 1.2; }
h1 { color: var(--navy); font-size: clamp(29px, 3vw, 42px); letter-spacing: -.04em; }
h2 { color: var(--navy); font-size: 18px; }
.hero p { max-width: 700px; margin: 9px 0 0; color: var(--muted); font-size: 15px; }
.actions, .run-controls { display: flex; align-items: center; gap: 10px; }
.btn { min-height: 40px; padding: 9px 16px; border: 1px solid var(--line); border-radius: 6px; color: var(--navy); background: #fff; font-weight: 700; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #aab6c4; transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-gold { color: #fff; border-color: var(--gold); background: var(--gold); }
.btn-dark { color: #fff; border-color: var(--navy); background: var(--navy); }
.btn-compact { min-height: 34px; padding: 6px 12px; font-size: 12px; }

.grid-kpi { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { position: relative; min-height: 128px; padding: 19px 20px; overflow: hidden; border: 1px solid var(--line); border-top: 3px solid var(--navy); border-radius: 7px; background: var(--surface); box-shadow: 0 4px 14px rgba(13,31,54,.04); }
.kpi::after { content: ""; position: absolute; right: -18px; bottom: -30px; width: 82px; height: 82px; border: 14px solid rgba(13,31,54,.035); border-radius: 50%; }
.kpi small, .section-heading small, .edition-visual small, .monitor-footer small, .table-title small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.kpi strong { display: block; margin: 8px 0 1px; color: var(--navy); font: 800 32px "Manrope"; }
.kpi > span { color: #8b97a5; font-size: 11px; }
.kpi.gold { border-top-color: var(--gold); } .kpi.blue { border-top-color: var(--blue); } .kpi.amber { border-top-color: var(--amber); } .kpi.green { border-top-color: var(--green); }

.card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.dashboard-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 18px; margin: 18px 0; }
.monitor-card, .scope-card, .settings-card { padding: 22px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.section-heading h2 { margin-top: 4px; }
.status-badge, .badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 9px; border-radius: 20px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.status-badge.neutral { color: var(--muted); background: #edf1f5; }
.status-badge.success, .badge.relevante, .badge.concluido { color: #08714d; background: #dcf3e9; }
.badge.novo { color: #2b67a4; background: #e1edf9; }
.badge.em_analise { color: #a26000; background: #fff0d4; }
.badge.arquivado, .badge.sem_edicao { color: #637083; background: #edf1f5; }
.badge.erro { color: #a92d35; background: #fbe2e3; }
.badge.processando { color: #7a5b00; background: #fff1bd; }
.edition-visual { display: flex; align-items: center; gap: 18px; padding: 24px 0; }
.document-mark { width: 72px; height: 86px; flex: 0 0 auto; display: flex; flex-direction: column; justify-content: center; align-items: center; border: 1px solid var(--line); background: #f8fafc; color: var(--navy); font: 800 22px "Manrope"; box-shadow: 5px 5px 0 var(--gold-light); }
.document-mark span { font-size: 12px; letter-spacing: .2em; }
.edition-visual strong { display: block; margin: 5px 0; color: var(--navy); font: 700 18px "Manrope"; }
.edition-visual p, .scope-card p, .settings-card p { margin: 4px 0 0; color: var(--muted); }
.monitor-footer { display: grid; grid-template-columns: 1fr 1fr; padding-top: 16px; border-top: 1px solid var(--line); }
.monitor-footer > div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.monitor-footer b { display: block; margin-top: 5px; color: var(--navy); font-size: 13px; }
.keyword-cloud { display: flex; flex-wrap: wrap; gap: 9px; padding: 22px 0 16px; }
.keyword { padding: 7px 10px; border: 1px solid #e1d1ae; border-radius: 4px; color: #72571e; background: #fbf6eb; font-size: 11px; font-weight: 700; }

.table-card { overflow: hidden; margin-top: 18px; }
.table-toolbar { min-height: 70px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.table-title { display: flex; align-items: center; gap: 12px; }
.table-title b { display: block; margin-top: 2px; color: var(--navy); }
.table-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 6px; color: var(--gold); background: var(--navy); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 14px; color: #718094; background: #f7f9fb; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px; border-bottom: 1px solid #e8edf2; vertical-align: top; color: #46566a; }
tbody tr:hover { background: #fbfcfd; }
.title-cell { min-width: 285px; }
.title-cell b { display: block; margin-bottom: 4px; color: var(--navy); font-size: 13px; line-height: 1.35; }
.title-cell small, td small { color: var(--muted); }
.type-label { display: inline-block; margin-bottom: 5px; color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.chips { min-width: 160px; display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 3px 7px; border-radius: 3px; color: #4b6079; background: #eaf0f5; font-size: 9px; font-weight: 700; white-space: nowrap; }
.open-row { color: var(--gold); border: 0; background: transparent; font-size: 20px; }
.empty-row { padding: 35px; color: var(--muted); text-align: center; }
.pagination { padding: 13px 18px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.pagination div { display: flex; gap: 8px; }

.filters-card { padding: 18px; box-shadow: none; }
.filters-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.filters-head h2 { font-size: 15px; }
.text-button { border: 0; color: var(--gold); background: transparent; font-weight: 700; }
.filters-grid { display: grid; grid-template-columns: 2fr repeat(5, minmax(125px, 1fr)) auto; gap: 12px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label { color: #617087; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
input, select, textarea { width: 100%; min-height: 40px; padding: 9px 11px; color: var(--ink); border: 1px solid #ccd5df; border-radius: 5px; outline: none; background: #fff; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,154,61,.12); }
textarea { resize: vertical; }
.run-controls input { width: 170px; }

.source-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.source-card { padding: 20px; box-shadow: none; }
.source-top { display: flex; justify-content: space-between; gap: 12px; }
.source-card h2 { margin: 4px 0 8px; font-size: 16px; }
.source-card p { min-height: 62px; margin: 0 0 18px; color: var(--muted); }
.source-meta { padding-top: 13px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.source-meta a { color: var(--gold); font-weight: 700; text-decoration: none; }
.planned { opacity: .78; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card .field { max-width: 310px; margin: 22px 0 12px; }
.settings-card > .btn { margin-top: 18px; }
.check-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 20px 0; }
.check-item { padding: 10px 12px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 5px; color: #526177; }
.check-item::before { content: "✓"; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 10px; font-weight: 800; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4,15,27,.7); backdrop-filter: blur(3px); }
.modal-card { position: relative; width: min(930px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; border-radius: 9px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal-head { padding: 24px 26px 20px; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { max-width: 760px; font-size: 21px; }
.modal-head p { margin: 6px 0 0; color: var(--muted); }
.modal-head .icon-button { color: var(--muted); border-color: var(--line); }
.modal-meta { padding: 13px 26px; display: flex; flex-wrap: wrap; gap: 8px; background: #f6f8fa; }
.modal-actions { padding: 18px 26px 0; display: flex; gap: 9px; }
.publication-content { margin: 18px 26px; padding: 22px; color: #35465a; border: 1px solid var(--line); background: #fbfcfd; white-space: pre-wrap; font-family: Georgia, serif; line-height: 1.75; }
.review-form { padding: 20px 26px 26px; display: grid; grid-template-columns: 180px 1fr auto; gap: 13px; align-items: end; border-top: 1px solid var(--line); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 70; max-width: 430px; padding: 13px 17px; color: #fff; border-radius: 6px; background: var(--navy); box-shadow: var(--shadow); }
.progress-panel { position: fixed; right: 24px; bottom: 24px; z-index: 65; width: min(460px, calc(100vw - 32px)); padding: 18px; color: #fff; border: 1px solid rgba(255,255,255,.14); border-radius: 9px; background: var(--navy); box-shadow: 0 22px 55px rgba(5,18,32,.32); }
.progress-panel.complete { background: #0c5f46; }
.progress-panel.error { background: #852d36; }
.progress-head { display: grid; grid-template-columns: 38px 1fr auto; gap: 11px; align-items: center; }
.progress-symbol { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--gold-light); background: rgba(255,255,255,.1); font-size: 20px; animation: spin 1.4s linear infinite; }
.progress-panel.complete .progress-symbol, .progress-panel.error .progress-symbol { animation: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-head small { display: block; color: #9fb0c5; font-size: 9px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.progress-head b { display: block; margin-top: 2px; font-family: "Manrope", sans-serif; }
.progress-head strong { color: #fff; font: 800 17px "Manrope", sans-serif; }
.progress-track { height: 8px; margin-top: 15px; overflow: hidden; border-radius: 8px; background: rgba(255,255,255,.13); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--gold); transition: width .45s ease; }
.progress-panel.complete .progress-track span { background: #65d6a8; }
.progress-panel.error .progress-track span { background: #ffadb4; }
.progress-panel > p { min-height: 21px; margin: 10px 0; color: #d6e0eb; font-size: 12px; }
.progress-steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.progress-steps span { position: relative; padding-top: 10px; color: #70869e; font-size: 8px; font-weight: 800; text-align: center; text-transform: uppercase; }
.progress-steps span::before { content: ""; position: absolute; top: 0; left: calc(50% - 3px); width: 6px; height: 6px; border-radius: 50%; background: #516880; }
.progress-steps span.active { color: #f3dfb7; }
.progress-steps span.active::before { background: var(--gold); box-shadow: 0 0 0 4px rgba(201,154,61,.15); }
.progress-steps span.done { color: #b8c5d4; }
.progress-steps span.done::before { background: #79c5a5; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: #e9eef3; }
.login-shell { width: min(1040px, 100%); min-height: 610px; padding: 0; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border-radius: 10px; background: #fff; box-shadow: 0 28px 80px rgba(13,31,54,.2); }
.login-brand-panel { position: relative; padding: 48px; display: flex; flex-direction: column; color: #fff; background: var(--navy); overflow: hidden; }
.login-brand-panel::after { content: ""; position: absolute; width: 430px; height: 430px; right: -220px; bottom: -180px; border: 60px solid rgba(201,154,61,.13); border-radius: 50%; }
.login-brand { min-width: 0; padding: 0; border: 0; }
.login-message { margin: auto 0; max-width: 430px; position: relative; z-index: 1; }
.login-message h1 { color: #fff; font-size: 38px; }
.login-message p { color: #aebed1; font-size: 16px; }
.login-security { position: relative; z-index: 1; color: #8fa2b9; font-size: 11px; }
.login-security span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #49c68e; }
.login-form-panel { display: grid; place-items: center; padding: 55px; }
.login-form { width: 100%; max-width: 340px; display: grid; gap: 18px; }
.login-form h2 { margin-bottom: 7px; font-size: 27px; }
.login-form p { margin: 0; color: var(--muted); }
.login-form label { display: grid; gap: 7px; color: #536177; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.login-button { width: 100%; margin-top: 4px; }
.form-error { padding: 10px; color: #9f2931; border: 1px solid #f1c6c8; border-radius: 5px; background: #fff1f1; }

@media (max-width: 1100px) {
  .user span { display: none; }
  .grid-kpi { grid-template-columns: repeat(3, 1fr); }
  .filters-grid { grid-template-columns: repeat(3, 1fr); }
  .search-wide { grid-column: span 2; }
  .source-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
  .topbar { position: static; display: block; }
  .brand { height: 68px; border: 0; }
  .nav { min-height: 58px; border-top: 1px solid rgba(255,255,255,.1); }
  .nav button { min-width: 126px; }
  .user { position: absolute; right: 8px; top: 15px; padding: 0; border: 0; }
  main { padding: 24px 16px 50px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .grid-kpi { grid-template-columns: 1fr 1fr; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .source-grid { grid-template-columns: 1fr; }
  .review-form { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 360px; padding: 34px; }
  .login-form-panel { padding: 38px 26px; }
}
@media (max-width: 520px) {
  .grid-kpi, .filters-grid, .check-list { grid-template-columns: 1fr; }
  .search-wide { grid-column: auto; }
  .actions, .run-controls { width: 100%; flex-wrap: wrap; }
  .actions .btn { flex: 1; }
  .monitor-footer { grid-template-columns: 1fr; gap: 14px; }
  .monitor-footer > div + div { padding: 14px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .modal { padding: 8px; }
  .modal-card { max-height: calc(100vh - 16px); }
  .modal-actions { flex-direction: column; }
  .progress-panel { right: 16px; bottom: 16px; }
  .progress-steps span { font-size: 7px; }
}

/* Conferência das palavras-chave e exclusões */
.legend-card { padding: 16px 20px; }
.legend-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; }
.legend-grid small { color: var(--muted); }
.page-chip { display: inline-block; padding: 3px 8px; border-radius: 3px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.page-chip.com_correspondencia { color: #1c6b3c; background: #e2f4e8; }
.page-chip.sem_correspondencia { color: #7a5c00; background: #fdf3d8; }
.page-chip.excluida_por_regra { color: #6d4a86; background: #f0e8f7; }
.page-chip.falha_de_leitura { color: #8c2f2f; background: #fbe7e7; }
.detail-card { margin-top: 18px; padding: 22px; }
.detail-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.config-used { padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: #f8fafc; margin-bottom: 16px; }
.config-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 10px; }
.config-grid small { display: block; color: var(--muted); margin-bottom: 2px; }
.config-grid span { font-size: 12px; }
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.page-cell { display: flex; flex-direction: column; gap: 2px; padding: 10px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 6px; text-decoration: none; color: var(--navy); background: #fff; }
.page-cell b { font-size: 14px; }
.page-cell small { font-size: 10px; color: var(--muted); }
.page-cell:hover { transform: translateY(-1px); border-color: #aab6c4; }
.page-cell.com_correspondencia { border-left-color: #2f9e5f; }
.page-cell.sem_correspondencia { border-left-color: #d9a11c; }
.page-cell.excluida_por_regra { border-left-color: #8e63ad; }
.page-cell.falha_de_leitura { border-left-color: #c04a4a; }
.editor-list { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 12px; }
.editor-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.editor-row input[type="text"] { flex: 1; min-height: 34px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; font: inherit; }
.editor-row.inactive { opacity: .55; background: #f7f8fa; }
.editor-row .editor-value { flex: 1; font-size: 13px; }
.editor-add { display: flex; gap: 8px; margin-bottom: 12px; }
.editor-add input { flex: 1; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.settings-hint { color: var(--muted); }
.suggestion-list { margin-bottom: 8px; }
.suggestion-list small { color: var(--muted); }
.suggestion { margin-left: 4px; padding: 2px 8px; border: 1px dashed var(--line); border-radius: 3px; background: #fff; color: var(--navy); font-size: 11px; cursor: pointer; }
.suggestion:hover { border-style: solid; }
.text-button { border: 0; background: none; color: var(--navy); font-weight: 700; cursor: pointer; }
.text-button.danger { color: #a33; }
@media (max-width: 780px) {
  .config-grid { grid-template-columns: 1fr; }
  .legend-grid { grid-template-columns: 1fr; gap: 4px; }
}
