/* =========================================================================
   SECOM · Design System
   Sistema de Gestão de Publicidade — Secretaria de Comunicação do Governo
   do Estado de São Paulo.

   Paleta e tipografia derivadas do Manual de Identidade Visual SP.GOV.BR
   (Secretaria de Gestão e Governo Digital) e da arte oficial do Brasão do
   Estado de São Paulo. Não copia a marca SP.GOV.BR - usa o Brasão oficial
   como identidade e a mesma paleta cromática do Governo do Estado.
   ========================================================================= */

@font-face {
  font-family: 'Rawline';
  src: url("../fonts/rawline-400.95759d6259ec.woff2") format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rawline';
  src: url("../fonts/rawline-600.a5e49cd7c7b3.woff2") format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rawline';
  src: url("../fonts/rawline-700.5e2e4c2ca8f9.woff2") format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Rawline';
  src: url("../fonts/rawline-900.28fd6c428d45.woff2") format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ---- Paleta institucional (Manual SP.GOV.BR, p.6) ---- */
  --sp-vermelho: #FF161F;
  --sp-vermelho-escuro: #C21119;
  --sp-preto: #000000;
  --sp-branco: #FFFFFF;
  --sp-cinza-escuro: #808080;
  --sp-cinza-claro: #BFBFBF;
  --sp-amarelo: #FBB900;
  --sp-azul: #034EA2;
  --sp-verde: #0B9247;

  /* ---- Acento do produto (deriva do vermelho institucional) ---- */
  --acento: var(--sp-vermelho);
  --acento-hover: #E01019;
  --acento-active: var(--sp-vermelho-escuro);
  --acento-fraco: #FFECED;

  /* ---- Semânticas (derivadas da paleta, não são cores novas) ---- */
  --cor-sucesso: var(--sp-verde);
  --cor-sucesso-fundo: #E7F6ED;
  --cor-sucesso-texto: #076536;
  --cor-erro: var(--sp-vermelho-escuro);
  --cor-erro-fundo: #FDECEC;
  --cor-erro-texto: #971018;
  --cor-aviso: var(--sp-amarelo);
  --cor-aviso-fundo: #FFF6DF;
  --cor-aviso-texto: #7A5B00;
  --cor-info: var(--sp-azul);
  --cor-info-fundo: #E8F0FA;
  --cor-info-texto: #023970;

  /* ---- Neutros de interface (escala funcional p/ texto/fundo/borda) ---- */
  --n-0: #FFFFFF;
  --n-50: #F7F7F8;
  --n-100: #EEEEF0;
  --n-200: #E1E2E5;
  --n-300: #CBCCD1;
  --n-400: #A6A8B0;
  --n-500: #7D8089;
  --n-600: #5B5E68;
  --n-700: #40424B;
  --n-800: #292A31;
  --n-900: #17181C;

  /* ---- Superfícies e texto (papéis semânticos) ---- */
  --fundo-pagina: var(--n-50);
  --fundo-superficie: var(--n-0);
  --fundo-superficie-realcada: var(--n-100);
  --texto-primario: var(--n-900);
  --texto-secundario: var(--n-600);
  --texto-terciario: var(--n-500);
  --texto-sobre-acento: #FFFFFF;
  --borda: var(--n-200);
  --borda-forte: var(--n-300);
  --anel-foco: 0 0 0 3px rgba(255, 22, 31, 0.25);

  /* ---- Tipografia ---- */
  --fonte-base: 'Rawline', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --texto-xs: 0.6875rem;   /* 11px */
  --texto-sm: 0.75rem;     /* 12px */
  --texto-base: 0.8125rem; /* 13px */
  --texto-md: 0.875rem;    /* 14px */
  --texto-lg: 1rem;        /* 16px */
  --texto-xl: 1.25rem;     /* 20px */
  --texto-2xl: 1.625rem;   /* 26px */
  --lh-compacta: 1.25;
  --lh-normal: 1.45;

  /* ---- Espaçamento (escala 4px, compacta) ---- */
  --esp-1: 4px;
  --esp-2: 6px;
  --esp-3: 8px;
  --esp-4: 12px;
  --esp-5: 16px;
  --esp-6: 20px;
  --esp-8: 28px;
  --esp-10: 36px;

  /* ---- Raios ---- */
  --raio-sm: 4px;
  --raio-md: 6px;
  --raio-lg: 8px;
  --raio-full: 999px;

  /* ---- Sombras ---- */
  --sombra-sm: 0 1px 2px rgba(23, 24, 28, 0.06), 0 1px 1px rgba(23, 24, 28, 0.04);
  --sombra-md: 0 4px 10px rgba(23, 24, 28, 0.08), 0 1px 3px rgba(23, 24, 28, 0.06);
  --sombra-lg: 0 12px 32px rgba(23, 24, 28, 0.14), 0 2px 6px rgba(23, 24, 28, 0.08);

  /* ---- Densidade de controles (compacta, tipo planilha) ---- */
  --altura-controle: 30px;
  --altura-controle-sm: 25px;
  --altura-controle-lg: 36px;
  --sidebar-largura: 232px;
  --sidebar-largura-recolhida: 60px;

  /* ---- Transições ---- */
  --dur-rapida: 120ms;
  --dur-base: 180ms;
  --curva: cubic-bezier(0.2, 0, 0, 1);
}

[data-tema="escuro"] {
  --fundo-pagina: #101114;
  --fundo-superficie: #17181C;
  --fundo-superficie-realcada: #202127;
  --texto-primario: #F2F2F4;
  --texto-secundario: #B6B8C0;
  --texto-terciario: #868999;
  --borda: #2C2E35;
  --borda-forte: #3C3E47;
  --acento-fraco: #3A1417;
}

/* ============================= Reset ================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--fonte-base);
  font-size: var(--texto-md);
  line-height: var(--lh-normal);
  color: var(--texto-primario);
  background: var(--fundo-pagina);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--esp-1); font-weight: 700; line-height: var(--lh-compacta); color: var(--texto-primario); }
h1 { font-size: var(--texto-xl); }
h2 { font-size: var(--texto-lg); }
h3 { font-size: var(--texto-md); font-weight: 600; }
h4 { font-size: var(--texto-base); font-weight: 600; }
p { margin: 0 0 var(--esp-2); color: var(--texto-secundario); }
a { color: var(--acento); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: var(--texto-sm); color: var(--texto-terciario); }
hr { border: none; border-top: 1px solid var(--borda); margin: var(--esp-4) 0; }
:focus-visible { outline: none; box-shadow: var(--anel-foco); border-radius: var(--raio-sm); }

/* ============================= Layout ================================= */
.container { max-width: 1480px; margin: 0 auto; padding: 0 var(--esp-5); }
.grid { display: grid; gap: var(--esp-3); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.pilha { display: flex; flex-direction: column; gap: var(--esp-2); }
.linha { display: flex; align-items: center; gap: var(--esp-2); flex-wrap: wrap; }
.espaco-entre { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-2); }

/* ---- Cabeçalho de página (título + ações) ---- */
.pagina-cabecalho { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-3); margin-bottom: var(--esp-4); }
.pagina-cabecalho h1 { margin-bottom: 2px; }
.pagina-cabecalho .acoes { display: flex; gap: var(--esp-2); flex: 0 0 auto; }

/* ---- Barra de ações: busca + filtros + ação primária numa linha ---- */
.barra-acoes {
  display: flex; align-items: center; gap: var(--esp-2); flex-wrap: wrap;
  padding: var(--esp-3); margin-bottom: var(--esp-3);
  background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-lg);
}
.barra-acoes .busca { flex: 1 1 220px; min-width: 160px; }
.barra-acoes .entrada, .barra-acoes select.entrada { height: var(--altura-controle-sm); font-size: var(--texto-sm); width: auto; }
.barra-acoes .separador-v { width: 1px; align-self: stretch; background: var(--borda); margin: 0 2px; }
.barra-acoes .espacador { flex: 1; }

/* ============================= Botões ================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--esp-2);
  height: var(--altura-controle); padding: 0 var(--esp-4);
  font-family: var(--fonte-base); font-size: var(--texto-base); font-weight: 600;
  border-radius: var(--raio-md); border: 1px solid transparent; cursor: pointer;
  transition: background var(--dur-rapida) var(--curva), border-color var(--dur-rapida) var(--curva), transform var(--dur-rapida) var(--curva);
  white-space: nowrap; line-height: 1;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-sm { height: var(--altura-controle-sm); padding: 0 var(--esp-3); font-size: var(--texto-sm); }
.btn-lg { height: var(--altura-controle-lg); padding: 0 var(--esp-5); font-size: var(--texto-lg); }
.btn-primario { background: var(--acento); color: var(--texto-sobre-acento); }
.btn-primario:hover { background: var(--acento-hover); }
.btn-primario:active { background: var(--acento-active); }
.btn-secundario { background: var(--fundo-superficie-realcada); color: var(--texto-primario); border-color: var(--borda); }
.btn-secundario:hover { background: var(--n-200); }
.btn-contorno { background: transparent; color: var(--texto-primario); border-color: var(--borda-forte); }
.btn-contorno:hover { background: var(--fundo-superficie-realcada); }
.btn-fantasma { background: transparent; color: var(--texto-secundario); }
.btn-fantasma:hover { background: var(--fundo-superficie-realcada); color: var(--texto-primario); }
.btn-perigo { background: var(--cor-erro); color: #fff; }
.btn-perigo:hover { background: #7f0d13; }
.btn-icone { width: var(--altura-controle); padding: 0; flex: 0 0 auto; }

/* ============================= Campos ================================= */
.campo { display: flex; flex-direction: column; gap: var(--esp-1); }
.campo label { font-size: var(--texto-sm); font-weight: 600; color: var(--texto-secundario); }
.campo .dica { font-size: var(--texto-xs); color: var(--texto-terciario); }
.campo .erro-texto { font-size: var(--texto-xs); color: var(--cor-erro); }

.entrada, select.entrada, textarea.entrada {
  height: var(--altura-controle); width: 100%;
  padding: 0 var(--esp-3);
  font-family: var(--fonte-base); font-size: var(--texto-base); color: var(--texto-primario);
  background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-md);
  transition: border-color var(--dur-rapida) var(--curva), box-shadow var(--dur-rapida) var(--curva);
}
textarea.entrada { height: auto; min-height: 80px; padding: var(--esp-2) var(--esp-3); resize: vertical; }
.entrada::placeholder { color: var(--texto-terciario); }
.entrada:hover { border-color: var(--borda-forte); }
.entrada:focus { outline: none; border-color: var(--acento); box-shadow: var(--anel-foco); }
.entrada.campo-erro { border-color: var(--cor-erro); }
.entrada:disabled { background: var(--fundo-superficie-realcada); color: var(--texto-terciario); cursor: not-allowed; }

select.entrada {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235B5E68' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--esp-3) center; padding-right: var(--esp-8);
}
/* ---- Lista suspensa de seleção múltipla (checkboxes num painel flutuante) ---- */
.dropdown-multi { position: relative; }
.dropdown-multi-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  cursor: pointer; text-align: left; color: var(--texto-primario);
}
.dropdown-multi-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-multi-toggle svg { flex: 0 0 auto; margin-left: var(--esp-2); color: var(--texto-terciario); transition: transform var(--dur-rapida) var(--curva); }
.dropdown-multi.aberto .dropdown-multi-toggle svg { transform: rotate(180deg); }
.dropdown-multi.aberto .dropdown-multi-toggle { border-color: var(--acento); box-shadow: var(--anel-foco); }
.dropdown-multi-painel {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-md);
  box-shadow: var(--sombra-md); padding: var(--esp-2); max-height: 220px; overflow-y: auto;
}
.dropdown-multi.aberto .dropdown-multi-painel { display: block; }
.dropdown-multi-opcao { padding: 4px 6px; border-radius: var(--raio-sm); }
.dropdown-multi-opcao:hover { background: var(--fundo-superficie-realcada); }
.dropdown-multi-opcao label { display: flex; align-items: center; gap: 6px; font-size: var(--texto-sm); font-weight: 400; cursor: pointer; margin: 0; }
.dropdown-multi-opcao input[type="checkbox"] { accent-color: var(--acento); margin: 0; flex: 0 0 auto; }

/* Fallback p/ formulários Django renderizados com {{ form.as_p }} (sem classes manuais) */
main form p { display: flex; flex-direction: column; gap: var(--esp-1); margin: 0 0 var(--esp-3); max-width: 480px; }
main form p label { font-size: var(--texto-sm); font-weight: 600; color: var(--texto-secundario); }
main form input[type="text"], main form input[type="email"], main form input[type="password"],
main form input[type="date"], main form input[type="datetime-local"], main form input[type="number"],
main form input[type="search"], main form input[type="tel"], main form input[type="url"],
main form select, main form textarea {
  height: var(--altura-controle); width: 100%; padding: 0 var(--esp-3);
  font-family: var(--fonte-base); font-size: var(--texto-base); color: var(--texto-primario);
  background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-md);
  transition: border-color var(--dur-rapida) var(--curva), box-shadow var(--dur-rapida) var(--curva);
}
main form textarea { height: auto; min-height: 70px; padding: var(--esp-2) var(--esp-3); resize: vertical; }
input[type="file"].entrada, main form input[type="file"] {
  height: auto; padding: var(--esp-2) var(--esp-3);
  font-family: var(--fonte-base); font-size: var(--texto-base);
  background: var(--fundo-superficie); border: 1px dashed var(--borda-forte); border-radius: var(--raio-md);
}
input[type="file"]::file-selector-button {
  height: var(--altura-controle-sm); margin-right: var(--esp-3); padding: 0 var(--esp-3);
  font-family: var(--fonte-base); font-size: var(--texto-sm); font-weight: 600;
  background: var(--fundo-superficie-realcada); color: var(--texto-primario); border: 1px solid var(--borda); border-radius: var(--raio-md); cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--n-200); }
main form input:focus, main form select:focus, main form textarea:focus { outline: none; border-color: var(--acento); box-shadow: var(--anel-foco); }
main form ul.errorlist { list-style: none; margin: 2px 0 0; padding: 0; color: var(--cor-erro); font-size: var(--texto-xs); }

.grupo-entrada { display: flex; align-items: stretch; }
.grupo-entrada .entrada { border-radius: 0; }
.grupo-entrada .entrada:first-child { border-top-left-radius: var(--raio-md); border-bottom-left-radius: var(--raio-md); }
.grupo-entrada .entrada:last-child { border-top-right-radius: var(--raio-md); border-bottom-right-radius: var(--raio-md); }
.grupo-entrada .btn { border-radius: 0; border-top-right-radius: var(--raio-md); border-bottom-right-radius: var(--raio-md); border-left: none; }

.busca { position: relative; }
.busca .entrada { padding-left: var(--esp-8); }
.busca svg { position: absolute; left: var(--esp-3); top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--texto-terciario); }

/* checkbox / radio */
.opcao { display: inline-flex; align-items: center; gap: var(--esp-2); font-size: var(--texto-base); color: var(--texto-primario); cursor: pointer; user-select: none; }
.opcao input[type="checkbox"], .opcao input[type="radio"] {
  appearance: none; width: 18px; height: 18px; flex: 0 0 auto;
  border: 1.5px solid var(--borda-forte); background: var(--fundo-superficie);
  display: inline-grid; place-content: center; cursor: pointer;
  transition: background var(--dur-rapida) var(--curva), border-color var(--dur-rapida) var(--curva);
}
.opcao input[type="checkbox"] { border-radius: 5px; }
.opcao input[type="radio"] { border-radius: 50%; }
.opcao input[type="checkbox"]::before {
  content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform var(--dur-rapida) var(--curva);
  box-shadow: inset 1em 1em var(--texto-sobre-acento);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.opcao input[type="radio"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; transform: scale(0); transition: transform var(--dur-rapida) var(--curva); box-shadow: inset 1em 1em var(--texto-sobre-acento); }
.opcao input:checked { background: var(--acento); border-color: var(--acento); }
.opcao input:checked::before { transform: scale(1); }
.opcao input:focus-visible { box-shadow: var(--anel-foco); }

/* toggle / switch */
.alternador { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; }
.alternador input { opacity: 0; width: 0; height: 0; }
.alternador .trilho { position: absolute; inset: 0; background: var(--n-300); border-radius: var(--raio-full); cursor: pointer; transition: background var(--dur-base) var(--curva); }
.alternador .trilho::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform var(--dur-base) var(--curva); box-shadow: var(--sombra-sm); }
.alternador input:checked + .trilho { background: var(--acento); }
.alternador input:checked + .trilho::before { transform: translateX(16px); }

/* ============================= Cards =================================== */
.cartao {
  background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-lg);
  padding: var(--esp-3) var(--esp-4); box-shadow: var(--sombra-sm);
}
.cartao-cabecalho { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--esp-2); gap: var(--esp-2); }
.cartao-titulo { font-size: var(--texto-base); font-weight: 700; margin: 0; }

.kpi { background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-lg); padding: var(--esp-3) var(--esp-4); }
.kpi .rotulo { font-size: var(--texto-sm); color: var(--texto-secundario); font-weight: 600; display: flex; align-items: center; gap: var(--esp-1); }
.kpi .valor { font-size: 1.5rem; font-weight: 700; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .variacao { font-size: var(--texto-xs); font-weight: 600; margin-top: var(--esp-1); display: inline-flex; align-items: center; gap: 2px; }
.kpi .variacao.positiva { color: var(--cor-sucesso-texto); }
.kpi .variacao.negativa { color: var(--cor-erro-texto); }
.kpi .variacao.neutra { color: var(--texto-terciario); }
.kpi-sucesso { border-left: 3px solid var(--cor-sucesso); }
.kpi-aviso { border-left: 3px solid var(--cor-aviso); }
.kpi-erro { border-left: 3px solid var(--cor-erro); }
.kpi-info { border-left: 3px solid var(--cor-info); }

/* ============================= Badges ================================== */
.selo {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 var(--esp-2);
  font-size: var(--texto-xs); font-weight: 700; border-radius: var(--raio-full); line-height: 1;
  white-space: nowrap;
}
.selo-neutro { background: var(--n-100); color: var(--n-700); }
.selo-sucesso { background: var(--cor-sucesso-fundo); color: var(--cor-sucesso-texto); }
.selo-erro { background: var(--cor-erro-fundo); color: var(--cor-erro-texto); }
.selo-aviso { background: var(--cor-aviso-fundo); color: var(--cor-aviso-texto); }
.selo-info { background: var(--cor-info-fundo); color: var(--cor-info-texto); }
.selo-ponto::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.selo-ambiente {
  display: inline-flex; align-items: center; height: 16px; padding: 0 6px; margin-left: 6px;
  font-size: 9px; font-weight: 800; letter-spacing: 0.04em; border-radius: var(--raio-full); line-height: 1;
  vertical-align: middle; white-space: nowrap;
}
.selo-ambiente-homologacao { background: var(--cor-aviso-fundo); color: var(--cor-aviso-texto); }
.selo-ambiente-desenvolvimento { background: var(--cor-info-fundo); color: var(--cor-info-texto); }

/* ============================= Alertas ================================== */
.alerta { display: flex; gap: var(--esp-3); padding: var(--esp-3) var(--esp-4); border-radius: var(--raio-md); border: 1px solid; font-size: var(--texto-base); }
.alerta-titulo { font-weight: 700; margin-bottom: 2px; }
.alerta svg { flex: 0 0 auto; margin-top: 1px; }
.alerta-info { background: var(--cor-info-fundo); border-color: #C6DCF3; color: var(--cor-info-texto); }
.alerta-sucesso { background: var(--cor-sucesso-fundo); border-color: #C3E9D2; color: var(--cor-sucesso-texto); }
.alerta-aviso { background: var(--cor-aviso-fundo); border-color: #F5E3AD; color: var(--cor-aviso-texto); }
.alerta-erro { background: var(--cor-erro-fundo); border-color: #F3C6C8; color: var(--cor-erro-texto); }

/* ============================= Toasts =================================== */
.toasts { position: fixed; top: var(--esp-4); right: var(--esp-4); display: flex; flex-direction: column; gap: var(--esp-2); z-index: 900; width: min(360px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: var(--esp-2); background: var(--n-900); color: #fff;
  padding: var(--esp-3); border-radius: var(--raio-md); box-shadow: var(--sombra-lg); font-size: var(--texto-base);
  animation: entrar-toast var(--dur-base) var(--curva);
}
.toast-sucesso { background: #0B3B22; }
.toast-erro { background: #4A0E12; }
@keyframes entrar-toast { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ============================= Tabelas =================================== */
.tabela-wrap { overflow-x: auto; border: 1px solid var(--borda); border-radius: var(--raio-lg); background: var(--fundo-superficie); }
table.tabela { width: 100%; border-collapse: collapse; font-size: var(--texto-base); }
table.tabela thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--fundo-superficie-realcada); color: var(--texto-secundario);
  font-size: var(--texto-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  text-align: center; padding: 6px var(--esp-3); border-bottom: 1px solid var(--borda); white-space: nowrap;
}
table.tabela thead th a { color: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: 100%; }
table.tabela thead th a:hover { color: var(--texto-primario); text-decoration: none; }
table.tabela tbody td { padding: 5px var(--esp-3); border-bottom: 1px solid var(--borda); color: var(--texto-primario); vertical-align: middle; line-height: 1.3; text-align: center; }
table.tabela.tabela-compacta tbody td, table.tabela.tabela-compacta thead th { padding-top: 3px; padding-bottom: 3px; }
table.tabela tbody tr:last-child td { border-bottom: none; }
table.tabela tbody tr:nth-child(even) { background: var(--fundo-pagina); }
table.tabela tbody tr:hover { background: var(--acento-fraco); }
table.tabela tbody tr.selecionada { background: #FFE1E3; }
table.tabela tbody tr.linha-com-erro { background: var(--cor-erro-fundo); }
table.tabela tbody tr.linha-com-erro:hover { background: #FBD9DA; }
table.tabela .col-numerica { font-variant-numeric: tabular-nums; }
table.tabela .col-acoes { white-space: nowrap; }
table.tabela tbody td > .linha, table.tabela tbody td > .selo { margin-left: auto; margin-right: auto; }

/* ============================= Paginação ================================= */
.paginacao { display: flex; align-items: center; justify-content: space-between; gap: var(--esp-3); padding: var(--esp-3) 0; flex-wrap: wrap; }
.paginacao .paginas { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.paginacao a, .paginacao span.pagina-atual {
  display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px;
  border-radius: var(--raio-sm); font-size: var(--texto-sm); font-weight: 600; color: var(--texto-secundario); padding: 0 6px;
}
.paginacao a:hover { background: var(--fundo-superficie-realcada); text-decoration: none; color: var(--texto-primario); }
.paginacao span.pagina-atual { background: var(--acento); color: #fff; }

/* ============================= Breadcrumbs ================================ */
.trilha { display: flex; align-items: center; gap: 6px; font-size: var(--texto-sm); color: var(--texto-terciario); margin-bottom: var(--esp-4); flex-wrap: wrap; }
.trilha a { color: var(--texto-secundario); }
.trilha .separador { color: var(--n-300); }
.trilha .atual { color: var(--texto-primario); font-weight: 600; }

/* ============================= Abas (tabs) ================================ */
.abas { display: flex; gap: var(--esp-1); border-bottom: 1px solid var(--borda); margin-bottom: var(--esp-4); }
.abas a { padding: var(--esp-2) var(--esp-3); font-size: var(--texto-base); font-weight: 600; color: var(--texto-secundario); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.abas a:hover { color: var(--texto-primario); text-decoration: none; }
.abas a.ativa { color: var(--acento); border-bottom-color: var(--acento); }

/* ============================= Filtros ================================ */
.barra-filtros { display: flex; align-items: center; gap: var(--esp-2); flex-wrap: wrap; padding: var(--esp-3); background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-lg); }
.barra-filtros .entrada, .barra-filtros select.entrada { height: var(--altura-controle-sm); font-size: var(--texto-sm); width: auto; }

/* ============================= Modais ================================== */
.modal-fundo { position: fixed; inset: 0; background: rgba(17, 18, 21, 0.5); display: flex; align-items: center; justify-content: center; padding: var(--esp-4); z-index: 950; }
.modal { background: var(--fundo-superficie); border-radius: var(--raio-lg); box-shadow: var(--sombra-lg); width: 100%; max-width: 480px; }
.modal-cabecalho { display: flex; align-items: center; justify-content: space-between; padding: var(--esp-4); border-bottom: 1px solid var(--borda); }
.modal-corpo { padding: var(--esp-4); color: var(--texto-secundario); }
.modal-rodape { display: flex; justify-content: flex-end; gap: var(--esp-2); padding: var(--esp-4); border-top: 1px solid var(--borda); }

/* ============================= App shell / Sidebar ========================= */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: var(--sidebar-largura); flex: 0 0 var(--sidebar-largura);
  background: var(--n-900); color: #fff;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
  transition: width var(--dur-base) var(--curva), flex-basis var(--dur-base) var(--curva);
}
.sidebar.recolhida { width: var(--sidebar-largura-recolhida); flex-basis: var(--sidebar-largura-recolhida); }

.sidebar-marca { display: flex; align-items: center; gap: var(--esp-2); padding: var(--esp-3); border-bottom: 1px solid rgba(255,255,255,0.1); min-height: 56px; }
.sidebar-marca .chip-brasao { width: 32px; height: 32px; border-radius: var(--raio-sm); background: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.sidebar-marca .chip-brasao img { width: 22px; display: block; }
.sidebar-marca .texto { overflow: hidden; white-space: nowrap; opacity: 1; transition: opacity var(--dur-rapida) var(--curva); }
.sidebar.recolhida .sidebar-marca .texto { opacity: 0; width: 0; }
.sidebar-marca .nome { font-weight: 700; font-size: var(--texto-base); line-height: 1.15; color: #fff; }
.sidebar-marca .versao { color: rgba(255,255,255,0.4); font-size: 10px; }

.sidebar-toggle {
  position: absolute; top: var(--esp-3); right: -11px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--n-700); border: 1px solid rgba(255,255,255,0.15); color: #fff; cursor: pointer;
  display: grid; place-items: center; z-index: 5;
}
.sidebar-toggle:hover { background: var(--acento); }
.sidebar-toggle svg { transition: transform var(--dur-base) var(--curva); }
.sidebar.recolhida .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-nav { flex: 1; padding: var(--esp-2) 6px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: var(--esp-2); padding: 8px var(--esp-2); border-radius: var(--raio-sm);
  font-size: var(--texto-base); font-weight: 600; color: rgba(255,255,255,0.62); margin-bottom: 1px; white-space: nowrap; overflow: hidden;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar-nav a.ativa { background: var(--acento); color: #fff; }
.sidebar-nav a svg { flex: 0 0 auto; width: 17px; height: 17px; }
.sidebar-nav a .rotulo { transition: opacity var(--dur-rapida) var(--curva); }
.sidebar.recolhida .sidebar-nav a .rotulo { opacity: 0; width: 0; }
.sidebar.recolhida .sidebar-nav a { justify-content: center; }

.sidebar-rodape { display: flex; align-items: center; gap: var(--esp-2); padding: var(--esp-3); border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-rodape .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--acento); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; flex: 0 0 auto; }
.sidebar-rodape .texto { overflow: hidden; white-space: nowrap; }
.sidebar.recolhida .sidebar-rodape .texto { display: none; }
.sidebar-rodape .u-nome { color: #fff; font-size: var(--texto-sm); font-weight: 600; }
.tema-toggle {
  width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.7);
  display: grid; place-items: center; cursor: pointer;
}
.tema-toggle:hover { background: rgba(255,255,255,0.16); color: #fff; }
.tema-toggle .icone-lua { display: none; }
[data-tema="escuro"] .tema-toggle .icone-sol { display: none; }
[data-tema="escuro"] .tema-toggle .icone-lua { display: block; }
.sidebar.recolhida .tema-toggle { display: none; }

.sidebar-rodape .u-sair {
  color: rgba(255,255,255,0.45); font-size: var(--texto-xs);
  background: none; border: none; padding: 0; font-family: inherit; cursor: pointer;
}
.sidebar-rodape .u-sair:hover { color: #fff; text-decoration: underline; }

.conteudo-principal { flex: 1; min-width: 0; }
.conteudo-principal main { padding: var(--esp-4) var(--esp-5) var(--esp-8); max-width: 1480px; margin: 0 auto; }

/* ============================= Checklist de documentos ===================== */
.documento-card { border: 1px solid var(--borda); border-radius: var(--raio-lg); padding: var(--esp-3) var(--esp-4); margin-bottom: var(--esp-3); background: var(--fundo-superficie); }
.documento-card.obrigatorio { border-left: 3px solid var(--acento); }
.documento-card .cartao-cabecalho { margin-bottom: var(--esp-2); }
.campo-situacao { display: flex; gap: var(--esp-2); margin: 0 0 var(--esp-2); padding: 0; border: none; }
.campo-situacao label {
  display: inline-flex; align-items: center; gap: 6px; height: var(--altura-controle-sm); padding: 0 var(--esp-3);
  border: 1px solid var(--borda-forte); border-radius: var(--raio-full); font-size: var(--texto-sm); font-weight: 600;
  color: var(--texto-secundario); cursor: pointer; transition: all var(--dur-rapida) var(--curva);
}
.campo-situacao input[type="radio"] { accent-color: var(--acento); margin: 0; }
.campo-situacao label:has(input:checked) { border-color: var(--acento); background: var(--acento-fraco); color: var(--acento); }
.bloco-inconsistencia { padding: var(--esp-3); margin-top: var(--esp-2); background: var(--cor-erro-fundo); border-radius: var(--raio-md); }
.bloco-inconsistencia label { display: block; font-size: var(--texto-sm); font-weight: 600; color: var(--texto-secundario); margin-bottom: var(--esp-1); }
.bloco-inconsistencia ul { list-style: none; margin: 0 0 var(--esp-2); padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bloco-inconsistencia ul label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; color: var(--texto-primario); margin: 0; }
.bloco-inconsistencia textarea { width: 100%; margin-top: 4px; }

/* ============================= Divulgador (details/summary) =============== */
details.divulgador { border: 1px solid var(--borda); border-radius: var(--raio-lg); background: var(--fundo-superficie); margin-bottom: var(--esp-4); }
details.divulgador summary { list-style: none; cursor: pointer; padding: var(--esp-3) var(--esp-4); font-size: var(--texto-base); font-weight: 600; color: var(--texto-primario); display: flex; align-items: center; gap: var(--esp-2); }
details.divulgador summary::-webkit-details-marker { display: none; }
details.divulgador summary::before { content: ""; width: 0; height: 0; border-left: 5px solid var(--texto-terciario); border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform var(--dur-rapida) var(--curva); }
details.divulgador[open] summary::before { transform: rotate(90deg); }
details.divulgador .divulgador-corpo { padding: 0 var(--esp-4) var(--esp-4); }

/* ============================= Compat. (telas ainda não migradas) ========= */
main article {
  background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-lg);
  padding: var(--esp-4); box-shadow: var(--sombra-sm); margin-bottom: var(--esp-4);
}
main article > header { font-weight: 700; margin: calc(var(--esp-4) * -1) calc(var(--esp-4) * -1) var(--esp-3); padding: var(--esp-3) var(--esp-4); border-bottom: 1px solid var(--borda); background: var(--fundo-superficie-realcada); border-radius: var(--raio-lg) var(--raio-lg) 0 0; }
main [role="button"], main button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--esp-2);
  height: var(--altura-controle); padding: 0 var(--esp-4);
  font-family: var(--fonte-base); font-size: var(--texto-base); font-weight: 600;
  border-radius: var(--raio-md); border: 1px solid transparent; cursor: pointer;
  background: var(--acento); color: var(--texto-sobre-acento); text-decoration: none; line-height: 1;
}
main [role="button"]:hover, main button:hover { background: var(--acento-hover); text-decoration: none; }
main [role="button"].secondary { background: var(--fundo-superficie-realcada); color: var(--texto-primario); border-color: var(--borda); }
main [role="button"].secondary:hover { background: var(--n-200); }
main [role="button"].outline { background: transparent; color: var(--acento); border-color: var(--acento); }
main [role="button"].outline:hover { background: var(--acento-fraco); }
main table:not(.tabela) { width: 100%; border-collapse: collapse; font-size: var(--texto-base); background: var(--fundo-superficie); border: 1px solid var(--borda); border-radius: var(--raio-lg); overflow: hidden; }
main table:not(.tabela) th { background: var(--fundo-superficie-realcada); color: var(--texto-secundario); font-size: var(--texto-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; text-align: left; padding: 6px var(--esp-3); border-bottom: 1px solid var(--borda); }
main table:not(.tabela) td { padding: 5px var(--esp-3); border-bottom: 1px solid var(--borda); }
main table:not(.tabela) tr:last-child td { border-bottom: none; }
main .badge { display: inline-flex; align-items: center; height: 22px; padding: 0 var(--esp-2); font-size: var(--texto-xs); font-weight: 700; border-radius: var(--raio-full); }
main .badge-apta { background: var(--cor-sucesso-fundo); color: var(--cor-sucesso-texto); }
main .badge-inapta { background: var(--cor-erro-fundo); color: var(--cor-erro-texto); }
main .badge-em-analise { background: var(--cor-aviso-fundo); color: var(--cor-aviso-texto); }

/* ============================= Utilitários ================================ */
.texto-secundario { color: var(--texto-secundario); }
.texto-terciario { color: var(--texto-terciario); }
.texto-numerico { font-variant-numeric: tabular-nums; }
.somente-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
