:root {
  --navy: #1a3771;
  --navy-600: #234591;
  --navy-800: #122a58;
  --navy-50: #eaf0fb;
  --bg: #eceef2;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --field: #f1f2f5;
  --border: #d9dce3;
  --text: #1c2433;
  --text-2: #5b6475;
  --title: #1a3771;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 30, 60, .06), 0 2px 8px rgba(16, 30, 60, .05);

  --ok: #1f7a4d;       --ok-bg: #e3f4ea;
  --warn: #8a5a00;     --warn-bg: #fdf1d8;
  --err: #b3261e;      --err-bg: #fbe4e2;
  --info: #1a3771;     --info-bg: #e6edfa;
  --neutral: #4b5565;  --neutral-bg: #eceef2;

  --c-ruim: #b3261e; --c-regular: #b86e00; --c-bom: #2a6fdb; --c-otimo: #1f7a4d;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--title); margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy); color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand img { width: 58px; height: auto; flex: none; }
.brand-name { font-weight: 700; font-size: 1rem; line-height: 1.15; }
.brand-name small { display: block; font-weight: 400; opacity: .7; font-size: .75rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 18px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; color: #dfe6f5; padding: 9px 12px;
  border-radius: 9px; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.nav a.ativo { background: rgba(255, 255, 255, .14); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding: 14px 8px 0; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, .16);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none;
}
.user-chip .nome { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.user-chip .perfil { font-size: .75rem; opacity: .7; }
.sair { color: #dfe6f5; margin-left: auto; display: grid; place-items: center; padding: 6px; border-radius: 8px; }
.sair:hover { background: rgba(255, 255, 255, .1); }
.sair svg { width: 18px; height: 18px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 32px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--text-2); min-width: 0; }
.crumbs a { color: var(--text-2); }
.crumbs .sep { opacity: .5; }
.crumbs .atual { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 28px 32px 48px; max-width: 1180px; width: 100%; }

/* ---------- Componentes ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 24px 26px; }
.card-head { padding: 18px 26px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.content > .card + .card, .content > form.card + .card, .content > .card + form.card { margin-top: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .95rem; padding: 10px 22px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer; background: var(--navy); color: #fff;
  transition: background .15s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { background: var(--navy-600); text-decoration: none; }
.btn:focus-visible, .field:focus-visible, .opcao input:focus-visible + span { outline: 3px solid #9bb6ee; outline-offset: 2px; }
.btn svg { width: 18px; height: 18px; }
.btn-lg { padding: 13px 30px; font-size: 1.02rem; }
.btn-sec { background: var(--surface); color: var(--navy); border-color: var(--border); }
.btn-sec:hover { background: var(--navy-50); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 6px 10px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--err); }
.btn[disabled], .btn.desabilitado { opacity: .45; pointer-events: none; }
.acoes { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; margin-top: 22px; }
.acoes.centro { justify-content: center; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.neutro { color: var(--neutral); background: var(--neutral-bg); }
.badge.processando { color: var(--info); background: var(--info-bg); }
.badge.processando::before { animation: pulsar 1.2s infinite; }
.badge.atencao { color: var(--warn); background: var(--warn-bg); }
.badge.sucesso { color: var(--ok); background: var(--ok-bg); }
.badge.erro { color: var(--err); background: var(--err-bg); }
@keyframes pulsar { 50% { opacity: .25; } }

.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 500; border: 1px solid transparent; }
.flash.sucesso { background: var(--ok-bg); color: var(--ok); }
.flash.erro { background: var(--err-bg); color: var(--err); }
.flash.info { background: var(--info-bg); color: var(--info); }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: 240px 1fr; gap: 16px 22px; align-items: center; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label.rotulo { color: var(--title); font-weight: 500; }
.form-grid .topo { align-self: start; padding-top: 10px; }
.field {
  width: 100%; font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--field);
  border-radius: var(--radius-sm); padding: 11px 14px; transition: border-color .15s, background .15s;
}
.field:hover { border-color: var(--border); }
.field:focus { background: #fff; border-color: var(--navy-600); outline: none; box-shadow: 0 0 0 3px rgba(35, 69, 145, .15); }
textarea.field { resize: vertical; min-height: 84px; line-height: 1.5; }
.form-grid .campo-rotulo { align-self: start; padding-top: 10px; }
.form-grid .full .campo-rotulo, .form-grid .full.campo-rotulo { padding-top: 0; }
.campo-rotulo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag { font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--navy-50); color: var(--navy); }
.tag.editado { background: var(--warn-bg); color: var(--warn); }
.linha-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 38%) 1fr; }
.login-lado { background: var(--navy); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-lado img { width: min(280px, 100%); height: auto; }
.login-lado h2 { color: #fff; font-size: 1.7rem; margin-top: 36px; max-width: 16ch; }
.login-lado p { opacity: .75; max-width: 38ch; }
.login-form { display: grid; place-items: center; padding: 32px 16px; }
.login-form .card { width: min(440px, 100%); }
.login-form h1 { text-align: center; margin-bottom: 22px; }
.login-form label { display: block; color: var(--title); font-weight: 500; margin: 14px 0 6px; }

/* ---------- Home ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { padding: 16px 18px; }
.kpi .v { font-size: 1.7rem; font-weight: 700; color: var(--title); line-height: 1.1; }
.kpi .l { font-size: .85rem; color: var(--text-2); }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filtros .field { width: auto; flex: 1 1 220px; background: var(--surface); border-color: var(--border); }
.filtros select.field { flex: 0 1 230px; }
.grid-obras { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.obra-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; color: var(--text); transition: box-shadow .15s, border-color .15s, transform .15s; }
.obra-card:hover { text-decoration: none; border-color: #b8c4dc; box-shadow: 0 6px 18px rgba(16, 30, 60, .1); transform: translateY(-1px); }
.obra-card h3 { font-size: 1.12rem; font-weight: 600; }
.obra-card .meta { font-size: .85rem; color: var(--text-2); }
.obra-card .rodape { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 8px; font-size: .85rem; }
.obra-card .ver { color: var(--navy-600); font-weight: 600; }
.obra-card.nova { border: 2px dashed #b8c4dc; background: transparent; box-shadow: none; align-items: center; justify-content: center; text-align: center; color: var(--navy); min-height: 150px; }
.obra-card.nova .mais { width: 40px; height: 40px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; }
.vazio { text-align: center; padding: 48px 16px; color: var(--text-2); }

/* ---------- Obra ---------- */
.obra-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.obra-head .meta { color: var(--text-2); font-size: .9rem; margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.obra-head .meta span + span::before { content: "·"; margin-right: 8px; opacity: .6; }
.steps { display: flex; gap: 0; margin-bottom: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; overflow-x: auto; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; color: var(--text-2); font-weight: 500; white-space: nowrap; min-width: max-content; }
.step:hover { text-decoration: none; background: var(--surface-2); }
.step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--neutral-bg); color: var(--neutral); flex: none; }
.step.feito .n { background: var(--ok-bg); color: var(--ok); }
.step.ativo { background: var(--navy-50); color: var(--navy); font-weight: 600; }
.step.ativo .n { background: var(--navy); color: #fff; }
.step.bloq { opacity: .5; pointer-events: none; }
.step.hist { flex: 0; margin-left: auto; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  border: 2px dashed #b8c4dc; border-radius: var(--radius); padding: 40px 20px; background: var(--surface-2);
  color: var(--title); cursor: pointer; transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.sobre { background: var(--navy-50); border-color: var(--navy-600); }
.dropzone .titulo { font-size: 1.35rem; font-weight: 500; display: flex; align-items: center; gap: 12px; }
.dropzone svg { width: 28px; height: 28px; color: var(--text); }
.dropzone input { display: none; }
.selecionados { font-size: .9rem; color: var(--text-2); }

table.tabela { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabela th { text-align: left; font-weight: 600; color: var(--text-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 26px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tabela td { padding: 12px 26px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela .arquivo { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.tabela .arquivo svg { width: 18px; height: 18px; color: var(--navy); flex: none; }
.tabela .num { text-align: right; white-space: nowrap; }
.tabela-wrap { overflow-x: auto; }

.parecer { background: var(--surface-2); border-radius: var(--radius); padding: 22px 26px; color: var(--title); white-space: pre-wrap; line-height: 1.6; }
.resumo-ia { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.pill-grande { font-size: .95rem; padding: 6px 14px; }
.nota { font-size: 2rem; font-weight: 700; color: var(--title); line-height: 1; }
.colunas-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.lista-box h3 { margin-bottom: 8px; font-size: .9rem; }
.lista-box ul { margin: 0; padding-left: 18px; color: var(--text); font-size: .92rem; }
.lista-box li + li { margin-top: 4px; }

.espera { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px 20px; text-align: center; color: var(--text-2); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--navy-50); border-top-color: var(--navy); animation: girar 1s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

.classificar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 22px; }
.opcao { position: relative; }
.opcao input { position: absolute; opacity: 0; }
.opcao span {
  display: flex; justify-content: center; align-items: center; padding: 14px; border-radius: 999px; font-weight: 600; font-size: 1.05rem;
  background: var(--navy); color: #fff; cursor: pointer; border: 3px solid transparent; transition: background .15s, transform .1s;
}
.opcao span:hover { background: var(--navy-600); }
.opcao input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--navy-600); background: var(--navy-800); }
.opcao.sugerida span::after { content: "IA"; font-size: .65rem; margin-left: 8px; background: rgba(255, 255, 255, .2); padding: 1px 6px; border-radius: 6px; }
.resultado-final { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cls { font-weight: 700; padding: 4px 14px; border-radius: 999px; color: #fff; }
.cls.RUIM { background: var(--c-ruim); } .cls.REGULAR { background: var(--c-regular); }
.cls.BOM { background: var(--c-bom); } .cls.OTIMO { background: var(--c-otimo); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 12px 26px; border-bottom: 1px solid var(--border); font-size: .92rem; }
.timeline li:last-child { border-bottom: 0; }
.erro-box { background: var(--err-bg); color: var(--err); border-radius: var(--radius-sm); padding: 14px 18px; }
.erro-box pre { white-space: pre-wrap; font-size: .8rem; margin: 8px 0 0; max-height: 240px; overflow: auto; }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

.menu-mobile { display: none; }

/* ---------- Responsivo ---------- */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .colunas-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .obra-head .meta span:last-child { display: none; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; }
  .brand { padding: 0; } .brand img { width: 44px; } .brand-name { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; }
  .nav-label { display: none; }
  .nav a { padding: 8px 10px; white-space: nowrap; }
  .nav a span { display: none; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .user-chip .nome, .user-chip .perfil, .user-chip .avatar { display: none; }
  .topbar { padding: 0 16px; height: 50px; }
  .content { padding: 20px 16px 40px; }
  .form-grid { grid-template-columns: 1fr; gap: 6px; }
  .form-grid .field { margin-bottom: 10px; }
  .linha-2 { grid-template-columns: 1fr; }
  .classificar { grid-template-columns: repeat(2, 1fr); }
  .login { grid-template-columns: 1fr; }
  .login-lado { padding: 24px 16px; flex-direction: row; align-items: center; gap: 16px; }
  .login-lado img { width: 150px; } .login-lado h2 { margin: 0; font-size: 1.2rem; } .login-lado p { display: none; }
  .card-body { padding: 18px 16px; } .card-head { padding: 14px 16px; }
  .tabela th, .tabela td, .timeline li { padding-left: 16px; padding-right: 16px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .parecer { padding: 16px; }
  .step .rot { display: none; } .step { flex: 0 0 auto; }
}

/* ---------- Tratamento de documentos / seções da avaliação ---------- */
.field-sm { padding: 6px 10px; font-size: .85rem; min-width: 190px; }
.tabela-docs td { vertical-align: top; }
.tabela-docs .trat { min-width: 280px; }
.resumo-doc { font-size: .85rem; color: var(--text); margin-top: 6px; line-height: 1.45; }
.secoes { overflow: hidden; }
.secoes details { border-bottom: 1px solid var(--border); }
.secoes details:last-child { border-bottom: 0; }
.secoes summary {
  cursor: pointer; list-style: none; padding: 16px 26px; display: flex; align-items: center; gap: 10px;
  font-weight: 650; color: var(--title); font-size: 1.02rem;
}
.secoes summary::-webkit-details-marker { display: none; }
.secoes summary::before { content: "▸"; color: var(--text-2); transition: transform .15s; }
.secoes details[open] > summary::before { transform: rotate(90deg); }
.secoes summary:hover { background: var(--surface-2); }
.secoes .cont { font-size: .75rem; font-weight: 600; color: var(--text-2); background: var(--neutral-bg); padding: 1px 8px; border-radius: 999px; }
.secoes .tabela { font-size: .86rem; }
.secoes .lista { padding: 0 26px 18px; margin: 0; }
.secoes ul.lista, .secoes ol.lista { padding-left: 46px; }
.secoes .lista li + li { margin-top: 4px; }
.secoes .colunas-3.lista { padding: 4px 26px 18px; }
@media (max-width: 820px) {
  .secoes summary { padding: 14px 16px; }
  .secoes .lista, .secoes .colunas-3.lista { padding-left: 16px; padding-right: 16px; }
  .secoes ul.lista, .secoes ol.lista { padding-left: 34px; }
}
