:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6eaf1;
  --border-strong: #d3d9e3;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8290a6;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-weak: #eef3ff;
  --red: #c81e1e;
  --red-bg: #fef1f1;
  --amber: #b45309;
  --amber-bg: #fff7e8;
  --green: #047857;
  --green-bg: #e9f8f1;
  --blue: #1d4ed8;
  --blue-bg: #eef3ff;
  --gray-bg: #f0f3f8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.16);
  color-scheme: light;
}

/* modo noturno (botão no menu lateral; a escolha fica salva no navegador) */
:root[data-tema='escuro'] {
  --bg: #0b1120;
  --surface: #121a2b;
  --surface-2: #172036;
  --border: #233049;
  --border-strong: #31405e;
  --text: #e5ebf5;
  --text-2: #b3bfd3;
  --muted: #7d8ba3;
  --primary: #5b8cff;
  --primary-hover: #7aa2ff;
  --primary-weak: #1a2747;
  --red: #f87171;
  --red-bg: #3a1618;
  --amber: #fbbf24;
  --amber-bg: #3a2a0e;
  --green: #34d399;
  --green-bg: #0f2e24;
  --blue: #7aa2ff;
  --blue-bg: #18264a;
  --gray-bg: #1c2740;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}
:root[data-tema='escuro'] mark { background: #a16207; color: #fff7d6; }
:root[data-tema='escuro'] .toast { background: #1e293b; border: 1px solid var(--border-strong); }
:root[data-tema='escuro'] .logo, :root[data-tema='escuro'] .btn.primario { box-shadow: none; }

.tema-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text-2); font: inherit; font-weight: 550; cursor: pointer;
}
.tema-btn:hover { background: var(--surface-2); color: var(--text); }
.tema-btn .ic { color: var(--muted); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: Inter, 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.005em; }
code { font-family: Consolas, monospace; font-size: 12.5px; background: var(--gray-bg); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.t-critico { color: var(--red); }
.t-atencao { color: var(--amber); }
.t-info { color: var(--blue); }
.nowrap { white-space: nowrap; }
.centro { text-align: center; }

.ic { width: 18px; height: 18px; fill: currentColor; flex: none; vertical-align: -4px; }
.ic-sm { width: 12px; height: 12px; margin-left: 3px; vertical-align: -1px; opacity: 0.6; }

/* ------------------------------------------------------------------ estrutura */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  gap: 22px;
}
.marca { display: flex; align-items: center; gap: 11px; color: var(--text); padding: 2px 8px; text-decoration: none !important; }
.marca strong { display: block; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.marca small { display: block; font-size: 12px; color: var(--muted); }
.logo {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 14px; box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
}
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 550; text-decoration: none; position: relative;
}
#nav a .ic { color: var(--muted); }
#nav a:hover { background: var(--surface-2); color: var(--text); }
#nav a.ativo { background: var(--primary-weak); color: var(--primary); font-weight: 650; }
#nav a.ativo .ic { color: var(--primary); }
#nav a.ativo::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
#nav .badge { margin-left: auto; }
.badge {
  min-width: 22px; padding: 0 7px; height: 20px; border-radius: 10px; font-size: 11.5px; font-weight: 700;
  display: inline-grid; place-items: center; background: var(--gray-bg); color: var(--text-2);
}
.badge:empty { display: none; }
.badge.critico { background: var(--red); color: #fff; }

.sei-box {
  margin-top: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 6px; font-size: 12.5px;
}
.sei-box small { display: block; color: var(--muted); }
.sei-box small.erro { color: var(--red); }
.sei-status { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 650; }
.ponto { width: 9px; height: 9px; border-radius: 50%; background: #a3aec0; flex: none; }
.ponto.ok { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.ponto.atencao { background: #f59e0b; }
.ponto.critico { background: #ef4444; }
.sei-acoes { display: flex; gap: 6px; margin-top: 4px; }
.sei-acoes .btn { flex: 1; justify-content: center; }
.sei-prog { display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.giro { width: 12px; height: 12px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: giro 0.8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }

main { min-width: 0; outline: none; }
.pagina { padding: 32px 36px 56px; max-width: 1400px; display: flex; flex-direction: column; gap: 20px; }
.pagina.estreita { max-width: 920px; }
.cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cab .sub { margin: 4px 0 0; color: var(--text-2); }
.cab-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; margin-top: 8px; }
.voltar { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-weight: 500; margin-bottom: -8px; width: fit-content; }

/* ------------------------------------------------------------------ botões */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 10px; transition: background 0.15s, border-color 0.15s;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primario { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(29, 78, 216, 0.22); }
.btn.primario:hover { background: var(--primary-hover); }
.btn.perigo { background: var(--red); border-color: var(--red); color: #fff; }
.btn.perigo-texto { color: var(--red); border-color: transparent; background: transparent; }
.btn.perigo-texto:hover { background: var(--red-bg); }
.btn.pequeno { height: 30px; padding: 0 10px; font-size: 13px; }
.btn .ic { width: 16px; height: 16px; }
.btn-icone {
  border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
  display: inline-grid; place-items: center; font-size: 20px;
}
.btn-icone:hover { background: var(--gray-bg); color: var(--text); }
.link-discreto { color: var(--text-2); font-size: 13px; }

/* ------------------------------------------------------------------ avisos */
.aviso {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid; background: var(--surface);
}
.aviso > .ic { width: 22px; height: 22px; }
.aviso div { flex: 1; }
.aviso p { margin: 2px 0 0; color: var(--text-2); }
.aviso.info { border-color: color-mix(in srgb, var(--blue) 35%, transparent); background: var(--blue-bg); }
.aviso.info > .ic { color: var(--blue); }
.aviso.atencao { border-color: color-mix(in srgb, var(--amber) 35%, transparent); background: var(--amber-bg); }
.aviso.atencao > .ic { color: var(--amber); }
.aviso.critico { border-color: color-mix(in srgb, var(--red) 35%, transparent); background: var(--red-bg); }
.aviso.critico > .ic { color: var(--red); }

/* ------------------------------------------------------------------ KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 3px; color: var(--text); text-decoration: none !important; position: relative; overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.kpi:hover { border-color: var(--border-strong); box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08); transform: translateY(-1px); }
.kpi::before { content: ''; position: absolute; right: 20px; top: 22px; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.kpi.critico::before { background: var(--red); box-shadow: 0 0 0 4px var(--red-bg); }
.kpi.atencao::before { background: #f59e0b; box-shadow: 0 0 0 4px var(--amber-bg); }
.kpi.info::before { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-bg); }
.kpi-valor { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.kpi.critico .kpi-valor { color: var(--red); }
.kpi.atencao .kpi-valor { color: var(--amber); }
.kpi.info .kpi-valor { color: var(--blue); }
.kpi-rotulo { font-weight: 650; margin-top: 4px; }
.kpi-sub { color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ cartões */
.cartao { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.cartao.sem-padding { padding: 0; overflow: hidden; }
.cartao.rolavel { overflow-x: auto; }
.cartao-cab { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 14px; }
.cartao-cab h2 { margin-right: auto; }
.cartao-pe { border-top: 1px solid var(--border); margin: 14px -20px -18px; padding: 10px 20px; font-size: 13px; }
.grade-painel { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grade-detalhe { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.coluna { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.lista-atencao { display: flex; flex-direction: column; gap: 6px; }
.atencao-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 0; border-radius: 8px; background: var(--surface-2);
  color: var(--text); text-decoration: none !important; border: 1px solid transparent;
}
.atencao-item:hover { border-color: var(--border-strong); }
.atencao-item .barra { width: 4px; align-self: stretch; border-radius: 0 3px 3px 0; background: var(--amber); flex: none; }
.atencao-item.critico .barra { background: var(--red); }
.atencao-txt { flex: 1; min-width: 0; }
.atencao-txt strong { display: block; font-weight: 600; }
.atencao-txt small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lista-venc { display: flex; flex-direction: column; }
.venc { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.venc:last-child { border-bottom: 0; }
.venc:hover .venc-txt span { color: var(--primary); }
.venc-data { width: 48px; text-align: center; border-radius: 8px; padding: 4px 0; background: var(--gray-bg); flex: none; line-height: 1.15; }
.venc-data b { display: block; font-size: 17px; }
.venc-data small { font-size: 11px; text-transform: uppercase; color: var(--text-2); }
.venc-data.vencido, .venc-data.critico { background: var(--red-bg); color: var(--red); }
.venc-data.atencao { background: var(--amber-bg); color: var(--amber); }
.venc-txt { flex: 1; min-width: 0; }
.venc-txt small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.venc-txt span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.venc-quando { font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.venc-quando.vencido, .venc-quando.critico { color: var(--red); }
.venc-quando.atencao { color: var(--amber); }

/* movimentações */
.lista-mov { display: flex; flex-direction: column; }
.mov { display: grid; grid-template-columns: 74px minmax(0, 1fr) 150px; gap: 14px; padding: 10px 6px; border-bottom: 1px solid var(--border); align-items: start; }
.mov:last-child { border-bottom: 0; }
.mov.nova { background: var(--blue-bg); border-radius: 6px; cursor: pointer; }
.mov-hora { font-weight: 600; font-size: 13px; }
.mov-hora small, .mov-unidade small { display: block; color: var(--muted); font-weight: 400; }
.mov-corpo { min-width: 0; }
.mov-desc { display: block; }
.mov-corpo small { display: block; color: var(--muted); margin-top: 2px; }
.mov-unidade { font-size: 13px; font-weight: 550; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.lista-mov.compacta .mov { grid-template-columns: 64px minmax(0, 1fr) 110px; }
.ponto-novo { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-right: 7px; vertical-align: 1px; }
.ponto-novo.vermelho { background: var(--red); }
.dia-mov .cartao-cab h2::first-letter { text-transform: uppercase; }

/* ------------------------------------------------------------------ chips */
.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600;
  background: var(--gray-bg); color: var(--text-2); white-space: nowrap;
}
.chip.vencido, .chip.critico { background: var(--red-bg); color: var(--red); }
.chip.atencao { background: var(--amber-bg); color: var(--amber); }
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.info { background: var(--blue-bg); color: var(--blue); }
.chip.sem_dado { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); }
.chip.neutro { background: var(--gray-bg); color: var(--text-2); }
.chip.papel-titular { background: var(--primary-weak); color: var(--primary); }
.chip.papel-subst { background: var(--gray-bg); color: var(--text-2); }
.chip.critico-borda { background: transparent; border: 1px solid var(--red); color: var(--red); margin-top: 4px; }
.chip.mini { height: 18px; font-size: 11px; padding: 0 6px; }

/* ------------------------------------------------------------------ tabelas */
.tabela { width: 100%; border-collapse: collapse; }
.tabela th {
  text-align: left; font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
.tabela td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tabela tr:last-child td { border-bottom: 0; }
.tabela td small { display: block; color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.tabela td small.muted { color: var(--muted); }
.tabela tr.clicavel { cursor: pointer; }
.tabela tr.clicavel:hover td { background: var(--surface-2); }
.tabela tr.apagada td { opacity: 0.62; }
.tabela.compacta td, .tabela.compacta th { padding: 8px 10px; }
.col-titulo { min-width: 240px; }
.col-titulo strong { font-weight: 620; }
.col-mov { max-width: 300px; }
.truncar { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prazo-cel small { display: block; }
.tabela-form td { vertical-align: middle; }
.tabela-form input, .tabela-form select {
  height: 32px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 8px; font: inherit; background: var(--surface); color: var(--text);
  transition: background 0.3s, border-color 0.3s;
}
.tabela-form input.curto { width: 110px; }
.tabela-form input.salvo { border-color: var(--green); background: var(--green-bg); }

/* filtros */
.barra-filtros { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.abas { display: flex; gap: 2px; background: var(--gray-bg); padding: 3px; border-radius: 9px; }
.aba {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font: inherit; font-weight: 550; color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.aba.ativa { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.contador { font-size: 11.5px; background: var(--border); color: var(--text-2); border-radius: 9px; padding: 0 6px; min-width: 18px; text-align: center; }
.contador.critico { background: var(--red); color: #fff; }
.contador.info { background: var(--blue); color: #fff; }
input[type='search'] {
  margin-left: auto; height: 36px; min-width: 260px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 12px;
  font: inherit; background: var(--surface); color: var(--text);
}
.check-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); cursor: pointer; user-select: none; }

/* ------------------------------------------------------------------ detalhe do contrato */
.alertas { display: flex; flex-direction: column; gap: 6px; }
.alerta { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; font-weight: 550; }
.alerta.critico { background: var(--red-bg); color: var(--red); }
.alerta.atencao { background: var(--amber-bg); color: var(--amber); }
.alerta.info { background: var(--blue-bg); color: var(--blue); font-weight: 500; }
.prazos { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.prazo-bloco {
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--border-strong); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow);
}
.prazo-bloco.vencido, .prazo-bloco.critico { border-top-color: var(--red); }
.prazo-bloco.atencao { border-top-color: var(--amber); }
.prazo-bloco.ok { border-top-color: var(--green); }
.prazo-titulo { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.prazo-data { font-size: 20px; font-weight: 650; }
.prazo-bloco.sem_dado .prazo-data { color: var(--muted); font-size: 16px; font-weight: 500; }
.prazo-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prazo-info small { color: var(--muted); }
.dados { display: flex; flex-direction: column; }
.dado { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.dado:last-child { border-bottom: 0; }
.dado > span { color: var(--muted); font-size: 13px; }
.lista-simples { display: flex; flex-direction: column; }
.linha-simples { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.linha-simples:last-child { border-bottom: 0; }
.linha-simples > span { flex: 1; min-width: 0; }
.linha-simples small { display: block; color: var(--text-2); font-size: 12.5px; }
.linha-simples.apagada { opacity: 0.6; }
a.linha-simples:hover > span { color: var(--primary); }

/* ------------------------------------------------------------------ modal e formulários */
#modal-root .modal-fundo {
  position: fixed; inset: 0; background: rgba(9, 15, 25, 0.5); display: grid; place-items: center; padding: 20px; z-index: 50;
  animation: surgir 0.12s ease-out;
}
@keyframes surgir { from { opacity: 0; } }
.modal { width: 100%; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal h2 { font-size: 17px; }
.modal-corpo { padding: 18px 20px; overflow-y: auto; }
.modal-corpo p { margin: 0; }
.modal > footer { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); }
.espaco { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .largo { grid-column: 1 / -1; }
.form-secao { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.form-secao:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.campo { display: flex; flex-direction: column; gap: 5px; }
.campo label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.campo input, .campo select, .campo textarea {
  height: 38px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 11px; font: inherit; background: var(--surface); color: var(--text); width: 100%;
}
.campo textarea { height: auto; padding: 9px 11px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus, input[type='search']:focus, .tabela-form input:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); outline-offset: 0; border-color: var(--primary);
}
.campo small, .check small { color: var(--muted); font-size: 12px; }
.campo .invalido { border-color: var(--red); }
.check { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; padding-top: 4px; cursor: pointer; }
.check input { margin-top: 3px; }
.check small { flex-basis: 100%; padding-left: 22px; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 11px; cursor: pointer; transition: background 0.15s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }

.linha-botoes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.rodape-form { display: flex; justify-content: flex-end; }
#form-config { display: flex; flex-direction: column; gap: 18px; }
.nota { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.cartao .nota:last-child { margin-bottom: 0; margin-top: 12px; }
.explica { margin-top: 14px; color: var(--text-2); }
.explica summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.explica ul { margin: 10px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

.vazio { text-align: center; padding: 26px 16px; color: var(--text-2); }
.vazio p { margin: 0; font-weight: 600; }
.vazio small { display: block; margin-top: 4px; color: var(--muted); }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: 420px; }
.toast {
  padding: 12px 16px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); font-weight: 500;
  border-left: 4px solid #34c472; transition: opacity 0.35s, transform 0.35s;
}
.toast.erro { border-left-color: #f2685e; }
.toast.info { border-left-color: #6aa4f5; }
.toast.saindo { opacity: 0; transform: translateY(8px); }

a.sei-link { font-weight: 600; white-space: nowrap; }

/* ------------------------------------------------------------------ detalhe da solicitação */
.det { display: flex; flex-direction: column; gap: 16px; }
.det-titulo { font-size: 20px; font-weight: 650; margin: 8px 0 4px; line-height: 1.3; }
.det-proc { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; color: var(--text-2); font-size: 13px; }
.det-proc-nome { color: var(--muted); }
.det-fatos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.det-fatos > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; min-width: 0; }
.det-fatos span { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.det-fatos b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.det-fatos small { display: block; color: var(--text-2); font-size: 12.5px; }
.det-secao { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.det-secao > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.det-secao h4 { margin: 0; font-size: 14px; }
.det-secao.destaque { border-color: color-mix(in srgb, var(--blue) 40%, var(--border)); background: color-mix(in srgb, var(--blue-bg) 45%, var(--surface)); }
.det-explica { margin: 0 0 8px; color: var(--text-2); font-size: 13px; }
.det-grade { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.det-obs { margin: 0; color: var(--text-2); }
.doc-pedido { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.doc-cab { display: flex; gap: 10px; align-items: flex-start; }
.doc-cab > .ic { color: var(--blue); margin-top: 2px; }
.doc-cab small { display: block; color: var(--text-2); margin-top: 2px; }
.doc-assunto { font-weight: 600; }
.doc-assunto span { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-right: 8px; font-weight: 650; }
.doc-trecho { margin: 0; padding: 10px 14px; border-left: 3px solid var(--blue); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--text); line-height: 1.55; }
mark { background: #ffe58a; color: #1d2939; border-radius: 3px; padding: 0 2px; }
.doc-completo summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 13px; }
.doc-texto { margin-top: 8px; max-height: 340px; overflow-y: auto; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.aviso-mini { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-top: 10px; }
.aviso-mini .ic { width: 16px; height: 16px; margin-top: 1px; }
.aviso-mini ul { margin: 6px 0 0; padding-left: 18px; }
.aviso-mini.info { background: var(--blue-bg); color: var(--text); }
.aviso-mini.info .ic { color: var(--blue); }
.aviso-mini.atencao { background: var(--amber-bg); color: var(--text); }
.aviso-mini.atencao .ic { color: var(--amber); }
.aviso-mini.critico { background: var(--red-bg); color: var(--red); }
.aviso-mini.ok { background: var(--green-bg); color: var(--text); }
.aviso-mini.ok .ic { color: var(--green); }
.lista-docs { display: flex; flex-direction: column; }
.doc-linha { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.doc-linha:last-child { border-bottom: 0; }
.doc-linha.cita .doc-nome { font-weight: 600; }
.doc-nome { min-width: 0; }
.doc-meta { grid-column: 1; color: var(--muted); font-size: 12px; }
.doc-linha > span:nth-child(3) { grid-column: 2; grid-row: 1; }

/* ------------------------------------------------------------------ buscar no SEI (cadastro de contrato) */
.busca-sei { background: var(--primary-weak); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.busca-sei > label { font-size: 13px; font-weight: 650; color: var(--primary); }
.busca-sei > small { color: var(--text-2); font-size: 12px; }
.busca-sei-linha { display: flex; gap: 8px; }
.busca-sei-linha input { flex: 1; height: 38px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 11px; font: inherit; background: var(--surface); color: var(--text); min-width: 0; }
.busca-sei-res:empty { display: none; }
.busca-sei-res .aviso-mini { margin-top: 2px; }
.campo input.auto, .campo textarea.auto { border-color: var(--blue); background: var(--blue-bg); }
.giro.escuro { border-color: var(--border-strong); border-top-color: var(--primary); display: inline-block; vertical-align: -2px; }

/* pedidos do SEI no contrato */
.lista-pedidos { display: flex; flex-direction: column; gap: 10px; }
.pedido { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.pedido-cab b { display: block; }
.pedido-cab small { color: var(--muted); font-size: 12px; }
.pedido-trecho { margin: 2px 0 4px; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 860px) {
  .det-fatos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .det-grade { grid-template-columns: minmax(0, 1fr); }
  .busca-sei-linha { flex-direction: column; }
}

/* ------------------------------------------------------------------ telas menores */
@media (max-width: 1180px) {
  .grade-painel, .grade-detalhe { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: column; padding: 12px 16px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--border); }
  #nav a.ativo::before { display: none; }
  #nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  #nav a { white-space: nowrap; padding: 7px 10px; }
  .sei-box { display: none; }
  .pagina { padding: 18px 16px 40px; }
  .mov, .lista-mov.compacta .mov { grid-template-columns: 60px minmax(0, 1fr); }
  .mov-unidade { grid-column: 2; text-align: left; }
  input[type='search'] { margin-left: 0; min-width: 0; width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .dado { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------------ ART */
.art-botoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.art-analise.critico { border-left: 4px solid var(--red); }
.art-analise.ok { border-left: 4px solid var(--green); }
.art-analise.atencao { border-left: 4px solid var(--amber); }
.art-fatos { margin: 0 0 6px; color: var(--text-2); }
.art-msg { margin: 0 0 6px; font-weight: 550; }
.art-analise .alerta { margin-top: 6px; }
.art-grupo { margin-bottom: 12px; }
.art-campo { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 7px 0; border-bottom: 1px solid var(--border); }
.art-campo:last-child { border-bottom: 0; }
.art-rotulo { color: var(--muted); font-size: 13px; }
.art-valor { font-weight: 550; word-break: break-word; }
.art-valor small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.ordem-sel { height: 36px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; font: inherit; background: var(--surface); color: var(--text); }
@media (max-width: 860px) { .art-campo { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ painel simplificado */
.grade-painel.tres { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lista-prazos { display: flex; flex-direction: column; }
.linha-prazo { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.linha-prazo:last-child { border-bottom: 0; }
a.linha-prazo:hover .lp-txt b { color: var(--primary); }
.lp-txt { flex: 1; min-width: 0; }
.lp-txt b { display: block; font-weight: 600; }
.lp-txt small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.lp-data { text-align: right; white-space: nowrap; font-size: 13px; font-weight: 600; }
.lp-data small { display: block; font-weight: 600; }
.lp-data small.vencido, .lp-data small.critico { color: var(--red); }
.lp-data small.atencao { color: var(--amber); }
@media (max-width: 1180px) { .grade-painel.tres { grid-template-columns: minmax(0, 1fr); } }

/* Controle de obras: processo e portaria copiáveis */
.copiavel { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 2px 6px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer; white-space: nowrap; }
.copiavel:hover { border-color: var(--primary); color: var(--primary); }
.copiavel .ic { width: 13px; height: 13px; opacity: 0.6; }
.copiavel.ok { border-color: var(--green); color: var(--green); }

/* minuta de resposta */
.minuta-orientacao { display: flex; gap: 8px; }
.minuta-orientacao input { flex: 1; min-width: 0; height: 36px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 11px; font: inherit; background: var(--surface); color: var(--text); }
.minuta-topo { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; }
.minuta-texto { width: 100%; border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 12px; font: inherit; font-size: 13.5px; line-height: 1.55; background: var(--surface); color: var(--text); resize: vertical; }
@media (max-width: 860px) { .minuta-orientacao { flex-direction: column; } }

/* marca Fiscaliza+ */
.logo b { color: #bfdbfe; font-weight: 800; }
.marca-mais { color: var(--primary); font-weight: 800; }
.marca strong { letter-spacing: 0.01em; }

/* botão do modo noturno: fica no pé do menu, acima da caixa do SEI */
.sidebar .tema-btn { margin-top: auto; }
.tema-btn + .sei-box { margin-top: 0; }
@media (max-width: 860px) {
  .sidebar .tema-btn { margin-top: 0; width: auto; align-self: flex-start; padding: 6px 10px; font-size: 13px; }
}
