:root {
  color-scheme: dark;
  --bg: #f3f7f8;
  --surface: #ffffff;
  --surface-2: #e8f0f2;
  --border: rgba(10, 66, 87, 0.16);
  --text: #123746;
  --muted: #56717b;
  --accent: #008fc5;
  --accent-2: #8bcf55;
  --warning: #f0b45b;
  --danger: #ef7d8b;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(145deg, #f7fbfc 0, var(--bg) 58rem);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 4px solid var(--accent-2);
  display: flex;
  justify-content: space-between;
  padding: 18px clamp(20px, 5vw, 72px);
}
.brand { align-items: center; color: var(--text); display: flex; gap: 12px; text-decoration: none; }
.brand-logo { display: block; height: 42px; object-fit: contain; object-position: left center; width: 170px; }
.auth-logo { display: block; height: auto; margin-bottom: 12px; max-width: 260px; }
.brand-mark {
  align-items: center;
  background: linear-gradient(145deg, #8bcf55, #008fc5);
  border-radius: 12px;
  box-shadow: 0 7px 24px rgba(66, 125, 255, 0.28);
  display: flex;
  font-size: 20px;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  width: 38px;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: 0.01em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.topbar-status { color: var(--muted); font-size: 12px; }
.status-dot { background: var(--accent-2); border-radius: 50%; display: inline-block; height: 7px; margin-right: 7px; width: 7px; }

.content { margin: 0 auto; max-width: 1440px; padding: 54px clamp(20px, 5vw, 72px) 32px; }
.hero { align-items: flex-end; display: flex; gap: 24px; justify-content: space-between; margin-bottom: 28px; }
.eyebrow { color: var(--accent-2); font-size: 10px; font-weight: 750; letter-spacing: 0.18em; margin: 0 0 9px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(30px, 4vw, 48px); letter-spacing: -0.04em; line-height: 1; margin-bottom: 14px; }
h2 { font-size: 18px; letter-spacing: -0.02em; margin-bottom: 0; }
h3 { color: #dce7f7; font-size: 14px; margin-bottom: 13px; }
.hero-copy, .panel-copy { color: var(--muted); line-height: 1.65; margin-bottom: 0; max-width: 620px; }

.button { border: 0; border-radius: 10px; font-size: 12px; font-weight: 700; padding: 11px 15px; transition: 160ms ease; }
.button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.button:disabled { cursor: wait; filter: none; opacity: .65; transform: none; }
.button-primary { background: linear-gradient(135deg, #4a8dff, #5e61db); color: white; width: 100%; }
.button-secondary { background: rgba(93, 142, 231, 0.14); border: 1px solid rgba(111, 159, 238, 0.3); color: #cfe1ff; }
.button-ghost { background: transparent; color: var(--muted); padding: 7px 10px; }

.flash { border: 1px solid rgba(102, 213, 195, 0.3); border-radius: 10px; color: #b9f3e9; margin-bottom: 18px; padding: 12px 15px; }
.flash.error { border-color: rgba(239, 125, 139, 0.4); color: #ffc3ca; }
.hidden { display: none !important; }
.auth-loading { display: none; }
.auth-loading .brand-mark { height: 48px; width: 48px; }
.auth-loading p { font-size: 12px; margin: 0; }

.stats-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.stat-card, .panel { background: linear-gradient(150deg, rgba(18, 31, 51, 0.96), rgba(10, 19, 33, 0.96)); border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-card { border-radius: 14px; min-height: 126px; padding: 20px; }
.stat-label { color: var(--muted); display: block; font-size: 11px; margin-bottom: 15px; }
.stat-card strong { display: block; font-size: 28px; letter-spacing: -0.04em; }
.stat-card small { color: #62738c; display: block; font-size: 11px; margin-top: 7px; }

.workspace-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); margin-bottom: 18px; }
.panel { border-radius: 16px; padding: 24px; }
.panel-heading { align-items: flex-start; display: flex; justify-content: space-between; margin-bottom: 15px; }
.panel-icon { align-items: center; background: rgba(74, 141, 255, 0.13); border: 1px solid rgba(74, 141, 255, 0.25); border-radius: 10px; color: #8eb7ff; display: flex; font-size: 15px; height: 32px; justify-content: center; width: 32px; }
.upload-panel .panel-copy { margin-bottom: 22px; }
.directorate-field { display: block; margin-bottom: 14px; }
.directorate-field > span { color: var(--muted); display: block; font-size: 11px; margin-bottom: 6px; }
.directorate-field select { background: rgba(8, 15, 27, 0.68); border: 1px solid rgba(129, 166, 221, 0.36); border-radius: 8px; color: var(--text); padding: 10px; width: 100%; }
.directorate-field small { color: var(--muted); display: block; font-size: 10px; line-height: 1.4; margin-top: 6px; }
.file-drop { align-items: center; background: rgba(8, 15, 27, 0.45); border: 1px dashed rgba(129, 166, 221, 0.36); border-radius: 12px; display: flex; gap: 13px; margin-bottom: 12px; padding: 16px; }
.file-drop:hover { border-color: var(--accent); }
.file-drop-secondary { margin-top: 10px; }
.file-drop strong, .file-drop small { display: block; }
.file-drop strong { font-size: 12px; margin-bottom: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.file-drop-icon { align-items: center; background: rgba(239, 125, 139, 0.12); border: 1px solid rgba(239, 125, 139, 0.25); border-radius: 8px; color: #ffacb7; display: flex; font-size: 10px; font-weight: 800; height: 34px; justify-content: center; width: 34px; }
input[type="file"] { display: none; }
.form-status { color: var(--muted); font-size: 11px; min-height: 16px; }
.form-status.error { color: var(--danger); }
.upload-hint { color: var(--muted); font-size: 10px; line-height: 1.4; margin: 4px 0 14px; }

.catalog-summary { color: var(--muted); font-size: 13px; line-height: 1.6; min-height: 120px; }
.catalog-summary strong { color: var(--text); }
.catalog-kpis { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); margin: 14px 0 19px; }
.catalog-kpi { background: rgba(7, 13, 24, 0.45); border-radius: 10px; padding: 12px; }
.catalog-kpi strong { display: block; font-size: 18px; }
.catalog-kpi small { color: #71839c; font-size: 10px; }
.catalog-note { align-items: center; border-top: 1px solid var(--border); color: var(--muted); display: flex; font-size: 11px; gap: 8px; line-height: 1.45; padding-top: 15px; }
.note-mark { align-items: center; border: 1px solid rgba(240, 180, 91, 0.45); border-radius: 50%; color: var(--warning); display: inline-flex; font-weight: 800; height: 18px; justify-content: center; width: 18px; }

.upload-progress { background: rgba(7, 13, 24, 0.48); border: 1px solid rgba(74, 141, 255, 0.22); border-radius: 10px; margin-top: 13px; padding: 11px 12px; }
.upload-progress-meta { align-items: center; color: #cfe1ff; display: flex; font-size: 11px; justify-content: space-between; margin-bottom: 8px; }
.upload-progress-meta strong { color: #8eb7ff; font-size: 12px; }
.upload-progress-track { background: rgba(150, 177, 216, 0.15); border-radius: 999px; height: 8px; overflow: hidden; }
.upload-progress-bar { background: linear-gradient(90deg, #4a8dff, #66d5c3); border-radius: inherit; display: block; height: 100%; min-width: 0; transition: width 260ms ease; width: 0%; }
.upload-progress-detail { color: var(--muted); display: block; font-size: 10px; line-height: 1.4; margin-top: 7px; }
.upload-progress.is-complete { border-color: rgba(102, 213, 195, 0.32); }
.upload-progress.is-error { border-color: rgba(239, 125, 139, 0.4); }
.upload-progress.is-error .upload-progress-bar { background: var(--danger); }

.processes-panel { margin-bottom: 18px; }
.stat-card-clickable { cursor: pointer; transition: transform .18s ease, border-color .18s ease; }
.stat-card-clickable:hover, .stat-card-clickable:focus-visible { transform: translateY(-2px); border-color: rgba(74, 141, 255, .65); outline: none; }
.main-nav { display: flex; gap: 12px; align-items: center; margin-left: auto; margin-right: 18px; }
.main-nav a { color: var(--muted); font-size: 12px; text-decoration: none; }
.main-nav a:hover { color: var(--text); }
.user-form { grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; }
@media (max-width: 900px) { .main-nav { order: 3; width: 100%; justify-content: center; margin: 8px 0 0; } }
.matrix-form { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)) auto; gap: 10px; margin-bottom: 16px; }
.matrix-form input { min-width: 0; }
@media (max-width: 1000px) { .matrix-form { grid-template-columns: repeat(2, minmax(140px, 1fr)); } }
@media (max-width: 620px) { .matrix-form { grid-template-columns: 1fr; } }
.compact-panel-copy { font-size: 11px; margin: 7px 0 0; }
.process-table td { padding-bottom: 10px; padding-top: 10px; }
.muted-label { color: var(--muted); font-size: 11px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 720px; width: 100%; }
th { color: #71839d; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; padding: 0 12px 12px; text-align: left; text-transform: uppercase; }
td { border-top: 1px solid rgba(150, 177, 216, 0.1); color: #c9d6e9; font-size: 12px; padding: 14px 12px; }
td:first-child { color: #8db7ff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.table-action { background: rgba(74, 141, 255, 0.12); border: 1px solid rgba(74, 141, 255, 0.24); border-radius: 7px; color: #a9c7ff; font-size: 11px; padding: 6px 9px; }
.state-pill { border-radius: 999px; display: inline-block; font-size: 10px; padding: 5px 8px; }
.state-received { background: rgba(240, 180, 91, 0.12); color: #f2c277; }
.state-complete { background: rgba(102, 213, 195, 0.12); color: #8be6d7; }
.empty-state { color: var(--muted); padding: 34px 12px; text-align: center; }

.detail-panel { margin-bottom: 18px; }
.detail-actions { align-items: center; display: flex; gap: 8px; }
.detail-actions .button { width: auto; }
.detail-summary { display: grid; gap: 10px; grid-template-columns: repeat(5, 1fr); margin-bottom: 25px; }
.detail-kpi { background: rgba(7, 13, 24, 0.46); border-radius: 10px; padding: 12px; }
.detail-kpi span, .detail-kpi strong { display: block; }
.detail-kpi span { color: var(--muted); font-size: 10px; margin-bottom: 6px; }
.detail-kpi strong { font-size: 15px; }
.detail-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.segment-list { display: grid; gap: 8px; max-height: 430px; overflow-y: auto; padding-right: 4px; }
.segment-item { background: rgba(7, 13, 24, 0.42); border: 1px solid rgba(150, 177, 216, 0.1); border-radius: 10px; color: var(--text); padding: 12px; text-align: left; }
.segment-item:hover, .segment-item.active { border-color: rgba(74, 141, 255, 0.55); }
.segment-item strong, .segment-item small { display: block; }
.segment-item strong { font-size: 12px; margin-bottom: 6px; }
.segment-item small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.evidence-box { background: rgba(7, 13, 24, 0.42); border: 1px solid rgba(150, 177, 216, 0.1); border-radius: 12px; min-height: 300px; padding: 15px; }
.evidence-heading { align-items: center; display: flex; justify-content: space-between; }
.evidence-heading h3 { margin-bottom: 0; }
pre { color: #bdcbe0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.65; margin: 18px 0 0; max-height: 360px; overflow: auto; white-space: pre-wrap; }
.review-panel { border-top: 1px solid var(--border); margin-top: 26px; padding-top: 24px; }
.review-form-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.review-form-grid label { display: block; }
.review-form-grid label > span { color: var(--muted); display: block; font-size: 10px; margin-bottom: 6px; }
.review-form-grid input, .review-form-grid textarea { background: rgba(7, 13, 24, 0.62); border: 1px solid rgba(150, 177, 216, 0.18); border-radius: 8px; color: var(--text); padding: 9px 10px; width: 100%; }
.review-form-grid textarea { resize: vertical; }
.review-comment { grid-column: span 3; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.review-actions .button { width: auto; }
.review-history { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 18px; }
.review-history h3 { margin-bottom: 10px; }
.review-history-list { display: grid; gap: 8px; }
.review-history-item { background: rgba(7, 13, 24, 0.42); border: 1px solid rgba(150, 177, 216, 0.1); border-radius: 9px; padding: 10px 12px; }
.review-history-item strong, .review-history-item small, .review-history-item p { display: block; }
.review-history-item strong { font-size: 11px; }
.review-history-item small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.review-history-item p { color: #bdcbe0; font-size: 11px; line-height: 1.5; margin: 7px 0 0; }
.footer { color: #53647d; font-size: 11px; padding: 0 20px 25px; text-align: center; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid, .detail-grid { grid-template-columns: 1fr; }
  .review-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-comment { grid-column: span 2; }
}
@media (max-width: 560px) {
  .content { padding-top: 34px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero .button { width: 100%; }
  .stats-grid, .detail-summary { grid-template-columns: 1fr 1fr; }
  .review-form-grid { grid-template-columns: 1fr; }
  .review-comment { grid-column: span 1; }
  .topbar-status { display: none; }
  .detail-actions { align-items: flex-end; flex-direction: column; }
  .interpretive-alert-item { grid-template-columns: 1fr; }
}
.auth-screen { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card { background: rgba(17, 28, 47, 0.9); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28); max-width: 430px; padding: 30px; width: 100%; }
.auth-brand { align-items: center; display: flex; gap: 12px; margin-bottom: 28px; }
.auth-form { display: grid; gap: 12px; }
.auth-form label { color: var(--muted); display: grid; font-size: 12px; gap: 6px; }
.auth-form input { background: rgba(7, 13, 24, 0.62); border: 1px solid rgba(150, 177, 216, 0.18); border-radius: 8px; color: var(--text); padding: 11px; width: 100%; }
.auth-form .button { width: 100%; }
.ai-assistance { background: rgba(74, 141, 255, 0.08); border: 1px solid rgba(74, 141, 255, 0.24); border-radius: 12px; margin-bottom: 22px; padding: 14px 16px; }
.ai-assistance-heading { align-items: center; display: flex; justify-content: space-between; }
.ai-assistance p, .ai-assistance li { color: #c9d6e9; font-size: 12px; line-height: 1.55; }
.ai-assistance ul { margin: 8px 0 0; padding-left: 20px; }
.ai-assistance small { color: var(--muted); }
.interpretive-alert-panel { background: rgba(74, 141, 255, 0.07); border: 1px solid rgba(74, 141, 255, 0.24); border-radius: 12px; margin-bottom: 22px; padding: 16px; }
.interpretive-alert-list { display: grid; gap: 9px; }
.interpretive-alert-item { align-items: start; background: rgba(7, 13, 24, 0.42); border: 1px solid rgba(150, 177, 216, 0.12); border-radius: 10px; display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr) minmax(170px, .34fr); padding: 12px 14px; }
.interpretive-alert-item strong { color: #cfe1ff; display: block; font-size: 12px; margin-bottom: 5px; }
.interpretive-alert-item p, .interpretive-alert-item small, .interpretive-alert-evidence span { color: var(--muted); display: block; font-size: 10px; line-height: 1.5; margin: 0; }
.interpretive-alert-item small { color: #bdcbe0; margin-top: 6px; }
.interpretive-alert-evidence { display: grid; gap: 6px; }
.interpretive-alert-comment { background: rgba(7, 13, 24, 0.62); border: 1px solid rgba(150, 177, 216, 0.18); border-radius: 8px; color: var(--text); margin-top: 10px; min-height: 48px; padding: 7px; resize: vertical; width: 100%; }
.interpretive-alert-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.interpretive-alert-actions .button { flex: 1 1 120px; font-weight: 700; padding: 8px 7px; }
.finding-validation-panel { background: rgba(246, 184, 73, 0.08); border: 1px solid rgba(246, 184, 73, 0.28); border-radius: 12px; margin-bottom: 22px; padding: 16px; }
.process-feedback-panel { background: rgba(92, 169, 255, 0.07); border: 1px solid rgba(92, 169, 255, 0.25); border-radius: 12px; margin-bottom: 22px; padding: 16px; }
.feedback-form { display: grid; gap: 10px; grid-template-columns: 1fr 1fr 1fr; }
.feedback-form textarea { grid-column: 1 / -1; }
.feedback-form button { justify-self: start; }
.feedback-history { border-top: 1px solid rgba(150, 177, 216, 0.18); margin-top: 14px; padding-top: 10px; }
.feedback-history-item { border-bottom: 1px solid rgba(150, 177, 216, 0.12); padding: 8px 0; }
.feedback-history-item strong, .feedback-history-item small, .feedback-history-item p { display: block; margin: 2px 0; }
.feedback-history-item small { color: var(--muted); }
.finding-validation-table-wrap { margin-top: 14px; }
.finding-validation-table { min-width: 0; table-layout: fixed; width: 100%; }
.finding-validation-table th:nth-child(1) { width: 29%; }
.finding-validation-table th:nth-child(2) { width: 34%; }
.finding-validation-table th:nth-child(3) { width: 18%; }
.finding-validation-table th:nth-child(4) { width: 19%; }
.finding-validation-table th { padding-left: 8px; padding-right: 8px; }
.finding-validation-table td { vertical-align: top; padding: 9px 8px; overflow-wrap: anywhere; }
.finding-validation-item strong { color: #f6d38a; display: block; line-height: 1.4; }
.finding-validation-item small, .finding-validation-evidence span { color: var(--muted); display: block; font-size: 10px; line-height: 1.45; margin-top: 5px; }
.finding-validation-evidence strong { color: #cfe1ff; font-size: 11px; }
.finding-validation-actions { display: grid; gap: 6px; grid-template-columns: 1fr; }
.finding-validation-actions .button { font-weight: 700; padding: 9px 5px; width: 100%; }
.finding-validation-comment { background: rgba(7, 13, 24, 0.62); border: 1px solid rgba(150, 177, 216, 0.18); border-radius: 8px; color: var(--text); min-height: 62px; padding: 8px; resize: vertical; width: 100%; }
.evidence-page-link { background: transparent; border: 0; color: #8eb7ff; cursor: pointer; display: block; font-size: 10px; margin-top: 6px; padding: 0; text-align: left; }
.evidence-page-link:hover { text-decoration: underline; }

/* Superfície institucional EMSERH: cartões claros, hierarquia consistente
   e contraste confortável em todas as páginas. */
:root { color-scheme: light; }
.stat-card, .panel { background: #ffffff; border-color: #d7e5e8; box-shadow: 0 12px 30px rgba(18, 55, 70, 0.10); }
.panel h2, .panel h3, .stat-card strong, .catalog-summary strong { color: #123746; }
.stat-card small, .footer { color: #66828b; }
.button-secondary { background: #eaf5f8; border-color: #b9d7e0; color: #056f99; }
.button-ghost { color: #46717e; }
.directorate-field select, .file-drop, .upload-progress, .catalog-kpi, .segment-item, .evidence-box, .review-history-item, .auth-form input, .review-form-grid input, .review-form-grid textarea, .interpretive-alert-comment, .finding-validation-comment { background: #f7fbfc; border-color: #c8dce2; color: #123746; }
.file-drop:hover, .segment-item:hover { border-color: #008fc5; background: #f0f9fb; }
.upload-progress-meta, .finding-validation-evidence strong, .interpretive-alert-item strong { color: #14556a; }
td { color: #244f5d; border-top-color: #dce8eb; }
.state-complete { background: #edf9f0; color: #2e7d45; }
.interpretive-alert-panel, .process-feedback-panel { background: #f2f9fb; border-color: #c7e0e7; }
.interpretive-alert-item { background: #ffffff; border-color: #d7e5e8; }
.interpretive-alert-item small { color: #52737d; }
.finding-validation-panel { background: #fffaf0; border-color: #ead7a7; }
.finding-validation-item strong { color: #8a5b00; }
.auth-card { background: #ffffff; box-shadow: 0 18px 50px rgba(18, 55, 70, 0.14); }
.finding-validation-comment:focus, .auth-form input:focus, .directorate-field select:focus { border-color: #008fc5; box-shadow: 0 0 0 3px rgba(0, 143, 197, 0.12); outline: none; }
.evidence-page-link { color: #007aa8; }
.process-table td small { color: #6a8790; display: block; font-family: inherit; font-size: 10px; margin-top: 4px; }
.process-table td:first-child { color: #123746; font-family: inherit; font-size: 12px; }
.process-table td:first-child strong { font-weight: 700; }
body { font-family: "Aptos", "Segoe UI", Arial, sans-serif; }
h1, h2, h3, .button, .eyebrow, th { font-family: "Aptos Display", "Aptos", "Segoe UI", Arial, sans-serif; }
.button-primary { background: #006f8f; box-shadow: 0 4px 10px rgba(0, 111, 143, 0.18); }
.button-primary:hover { background: #005b75; }
.finding-validation-panel { background: #f5fafb; border-color: #c8e1e6; }
.finding-validation-item strong { color: #123746; font-family: "Aptos", "Segoe UI", Arial, sans-serif; font-size: 12px; }
.finding-validation-evidence strong { color: #1b6076; }
.finding-validation-item small { color: #69838b; }
.eyebrow { color: #5b9f35; }
.main-nav a:hover { color: #006f8f; }
