/* ════════════════════════════════════════════════════════
   Portal Fiscal — Folha de estilos principal
   Inspiração: Design System gov.br (DSGov)
   Temas: Claro (padrão) · Escuro ([data-theme="dark"])
   ════════════════════════════════════════════════════════ */

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── VARIÁVEIS — TEMA CLARO ── */
:root {
  /* identidade gov.br */
  --gov-navy:   #071D41;
  --gov-blue:   #1351B4;
  --gov-yellow: #FFCD07;
  --gov-yellow-dk: #E0B400;

  /* status */
  --c-green:  #168821;
  --c-orange: #C45300;
  --c-red:    #CC0000;
  --c-purple: #7B2D8B;

  /* categorias */
  --federal:   #1351B4;
  --estadual:  #168821;
  --fgts:      #C45300;
  --expirada:  #7B2D8B;
  --cndt:      #00695C;
  --mte:       #4527A0;
  --falencia:  #880E4F;
  --cgu:       #455A64;
  --municipal: #00695C;

  /* superfícies */
  --bg:      #F0F2F5;
  --surface: #FFFFFF;
  --surface2: #E8EDF5;
  --border:  #C5D4E8;
  --border2: #DEE2E6;

  /* texto */
  --text:    #1C1C1C;
  --muted:   #555E6B;
  --subtle:  #8898AA;

  /* efeitos */
  --r:  4px;
  --sh: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --sh2:0 4px 12px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);

  /* layout */
  --header-h: 74px;
  --nav-h:    42px;

  /* tema */
  --theme-icon: '🌙';
}

/* ── VARIÁVEIS — TEMA ESCURO ── */
[data-theme="dark"] {
  --bg:      #0D1117;
  --surface: #161B22;
  --surface2: #21262D;
  --border:  #30363D;
  --border2: #30363D;

  --text:   #E6EDF3;
  --muted:  #8B949E;
  --subtle: #6E7681;

  --sh:  0 1px 3px rgba(0,0,0,.3);
  --sh2: 0 4px 12px rgba(0,0,0,.4);

  --gov-navy: #0D1F3C;

  --theme-icon: '☀️';
}

/* ── NOVO DESIGN — shell (sidebar/topbar) + tabela de certidões ──
   Paleta "Navy Trust" + tipografia Sora/Manrope, portados do protótipo Lovable.
   Escopo: exclusivo do index.html (SPA de Certidões) — não usado pelas demais
   páginas, que continuam com o header/app-nav clássico. ── */
:root {
  --navy-deep:  #0f1b3d;
  --navy:       #1e3a5f;
  --navy-mid:   #3b6fa0;
  --navy-light: #e8edf3;
  --mist:       #f4f7fb;

  --font-display: 'Sora', 'Segoe UI', sans-serif;
  --font-sans:    'Manrope', 'Segoe UI', sans-serif;

  --r-lg: 10px;
}

/* ── BASE ── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans), -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.5;
  transition: background .2s, color .2s;
}

/* .logo-icon: usada pelo mini-cabeçalho (.mod-header) de outras páginas
   (dashboard.php, guias.php, parcelamentos.php, automacao_log.php) — mantida. */
.logo-icon {
  width: 42px; height: 42px;
  background: var(--gov-yellow);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

/* ── APP NAV (usado pelas demais páginas via render_nav()) ── */
.app-nav {
  background: #0D2158;
  border-bottom: 1px solid rgba(255,255,255,.08);
  position: sticky;
  top: var(--header-h);
  z-index: 150;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.app-nav.app-nav--page { top: 0; z-index: 200; }

.app-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: var(--nav-h);
  gap: .25rem;
}

.app-nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  height: 100%;
}
.app-nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  height: 100%;
  padding: 0 .9rem;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  border-top: 2px solid transparent;
  transition: color .12s, border-color .12s, background .12s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.nav-active { color: #fff; border-bottom-color: var(--gov-yellow); }

.app-nav-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-user-name {
  font-size: .78rem;
  color: rgba(255,255,255,.65);
  white-space: nowrap;
}

.nav-badge-admin {
  font-size: .62rem;
  background: var(--gov-yellow);
  color: var(--gov-navy);
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.nav-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,.18);
  flex-shrink: 0;
}

.nav-btn {
  height: 28px;
  padding: 0 .75rem;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.85);
  border-radius: var(--r);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.nav-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.nav-btn--green { background: rgba(46,125,50,.7); border-color: rgba(46,125,50,.5); }
.nav-btn--green:hover { background: rgba(46,125,50,1); }

.nav-logout {
  height: 28px;
  padding: 0 .75rem;
  background: rgba(198,40,40,.65);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
  white-space: nowrap;
}
.nav-logout:hover { background: #c62828; }

/* pesquisa */
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.search-ic {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: .85rem;
  color: var(--muted);
}
.search-input {
  width: 100%;
  height: 34px;
  padding: 0 2rem 0 2.2rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: .85rem;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s, background .2s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus {
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(59,111,160,.15);
  background: var(--surface);
}
.search-clear {
  position: absolute;
  right: .5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: .8rem;
  padding: .2rem .3rem;
  border-radius: 2px;
  line-height: 1;
  transition: background .12s;
}
.search-clear:hover { background: var(--surface2); }

/* botão de tema (topbar) */
.theme-btn {
  width: 32px; height: 32px;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: .95rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
  flex-shrink: 0;
}
.theme-btn:hover { border-color: var(--navy-mid); color: var(--navy-mid); }

/* ══════════════════════════════════════════════════════════
   SHELL — sidebar + topbar + KPIs + toolbar (chips/select) + tabela
   ══════════════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; }

/* sidebar */
.app-sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--navy-deep);
  color: rgba(255,255,255,.92);
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  border-radius: var(--r);
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .85rem;
}
.sidebar-brand-title { font-family: var(--font-display); font-weight: 600; font-size: .88rem; line-height: 1.25; }
.sidebar-brand-sub   { font-size: .68rem; color: rgba(255,255,255,.55); }

.sidebar-nav { flex: 1; padding: 1rem .7rem; }
.sidebar-nav-label {
  padding: 0 .5rem .5rem;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.4);
  font-weight: 600;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  height: 38px;
  padding: 0 .7rem;
  margin-bottom: 2px;
  border-radius: var(--r);
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .84rem;
  transition: background .12s, color .12s;
}
.sidebar-link span:first-of-type { flex: 1; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link-active { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.sidebar-link-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--navy-light); flex-shrink: 0; }
.sidebar-badge-admin {
  font-size: .58rem;
  background: var(--navy-light);
  color: var(--navy-deep);
  padding: 1px 5px;
  border-radius: 10px;
  font-weight: 700;
  vertical-align: middle;
}

/* content column */
.app-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* topbar */
.app-topbar {
  height: 56px;
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.app-topbar-crumb { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--muted); }
.crumb-sep { opacity: .5; }
.crumb-current { color: var(--text); font-weight: 600; }
.app-topbar-right { display: flex; align-items: center; gap: .75rem; }
.sync-status { display: flex; align-items: center; gap: .4rem; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-green); flex-shrink: 0; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; }
.topbar-user { display: flex; align-items: center; gap: .55rem; }
.topbar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.topbar-user-info { line-height: 1.25; }
.topbar-user-name { font-size: .78rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.topbar-user-role { font-size: .66rem; color: var(--muted); }
.topbar-logout-form { margin: 0; }
.topbar-logout {
  width: 30px; height: 30px;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.topbar-logout:hover { border-color: #c62828; color: #c62828; }

/* KPIs */
.kpi-section { padding: 1.5rem 1.75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.kpi-section-hdr { margin-bottom: 1.25rem; max-width: 640px; }
.kpi-eyebrow {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: .4rem;
}
.kpi-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.kpi-sub { font-size: .82rem; color: var(--muted); margin-top: .35rem; line-height: 1.5; }
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: .75rem; }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: .85rem .9rem;
  transition: border-color .12s;
}
.kpi-card:hover { border-color: var(--navy-mid); }
.kpi-ic { font-size: 1rem; }
.kpi-value { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; color: var(--text); margin-top: .5rem; }
.kpi-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-top: .1rem; }
.kpi-success .kpi-value { color: #2e7d46; }
.kpi-warning .kpi-value { color: #b8860b; }
.kpi-danger  .kpi-value { color: #b3261e; }

/* toolbar (busca / selects / chips) */
.cnd-toolbar { padding: 1rem 1.75rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.cnd-toolbar-row { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; margin-bottom: .75rem; }
.cnd-toolbar-row .search-wrap { flex: 1; min-width: 260px; max-width: 480px; }

.cnd-select {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  height: 34px;
  padding: 0 .5rem 0 .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  cursor: pointer;
}
.cnd-select span {
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.cnd-select select {
  border: none;
  background: transparent;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.chip-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.chip-row:first-of-type { margin-top: 0; }
.chip-row-label {
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
  width: 62px;
  flex-shrink: 0;
}
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  height: 30px;
  padding: 0 .75rem;
  border-radius: 999px;
  border: none;
  background: var(--mist);
  font-size: .74rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}
[data-theme="dark"] .chip { background: var(--surface2); }
.chip:hover { background: var(--border); }
.chip.active { background: var(--navy); color: #fff; }

.chip.federal.active   { background: var(--federal);  }
.chip.estadual.active  { background: var(--estadual); }
.chip.fgts.active      { background: var(--fgts);     }
.chip.cndt.active      { background: var(--cndt);     }
.chip.mte.active       { background: var(--mte);      }
.chip.falencia.active  { background: var(--falencia); }
.chip.cgu.active       { background: var(--cgu);      }
.chip.municipal.active { background: var(--municipal);}
.chip.expirada.active  { background: var(--expirada); }
.chip.neg.active       { background: var(--c-green);  }
.chip.warn.active      { background: var(--c-orange); }
.chip.pos.active       { background: var(--c-red);    }

/* cartão da tabela */
.cnd-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.cnd-table-card .results-bar { padding: .75rem 1rem; margin-bottom: 0; border-bottom: 1px solid var(--border); }
.table-scroll { overflow-x: auto; }

.cnd-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.cnd-table thead tr {
  text-align: left;
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--mist);
}
[data-theme="dark"] .cnd-table thead tr { background: var(--surface2); }
.cnd-table th { padding: .6rem .9rem; font-weight: 600; }
.cnd-table td { padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cnd-table tbody tr:last-child td { border-bottom: none; }
.cnd-table tbody tr:hover { background: var(--mist); }
[data-theme="dark"] .cnd-table tbody tr:hover { background: var(--surface2); }
.cnd-table tbody tr.row-selected { background: rgba(59,111,160,.1); }
.cnd-table tbody tr.row-expiring td:first-child { box-shadow: inset 3px 0 0 var(--c-orange); }

.col-right { text-align: right; }
.col-mono { font-family: 'Courier New', monospace; color: var(--muted); }
.col-check, .col-actions { width: 1%; white-space: nowrap; }
.col-empresa { min-width: 220px; }
.row-validade { color: var(--text); font-weight: 600; }

.row-check-wrap { display: inline-flex; cursor: pointer; }
.row-check { width: 14px; height: 14px; cursor: pointer; accent-color: var(--navy-mid); }

.row-razao { font-weight: 700; color: var(--text); line-height: 1.3; }
.row-sem-cadastro { font-style: italic; font-weight: 400; color: var(--muted); }
.row-sub { font-size: .72rem; color: var(--muted); margin-top: 1px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  height: 24px;
  padding: 0 .55rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.cat-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 .5rem;
  border-radius: var(--r);
  border: 1px solid;
  background: var(--mist);
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
}
[data-theme="dark"] .cat-badge { background: var(--surface2); }

.restam-danger  { color: #b3261e; font-weight: 600; }
.restam-warning { color: #b8860b; font-weight: 600; }
.restam-muted   { color: var(--muted); }

.row-actions { display: flex; align-items: center; gap: .15rem; justify-content: flex-end; }
.row-act {
  width: 28px; height: 28px;
  border-radius: var(--r);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: background .12s;
}
.row-act:hover { background: var(--mist); }
[data-theme="dark"] .row-act:hover { background: var(--surface2); }
.row-act-del:hover { background: rgba(179,38,30,.12); }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .app-sidebar { display: none; }
}

/* ── MAIN ── */
.main {
  flex: 1;
  width: 100%;
  padding: 1.5rem 1.75rem 2rem;
}

/* estados */
.state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 280px; text-align: center;
  color: var(--muted); gap: .75rem;
}
.state-ic { font-size: 2.75rem; }
.state h3 { font-size: 1rem; color: var(--text); font-weight: 600; }
.state p  { font-size: .85rem; }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--navy-mid);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-retry {
  margin-top: .5rem;
  height: 34px;
  padding: 0 1.25rem;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  font-weight: 600;
  font-size: .85rem;
  transition: background .12s;
}
.btn-retry:hover { background: var(--navy-deep); }

/* barra de resultados */
.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .875rem;
  gap: .75rem;
  flex-wrap: wrap;
}
.results-info { font-size: .8rem; color: var(--muted); }

.nro { font-style: normal; color: var(--subtle); }

/* badges — usados pela visão por empresa (renderEmpresas, CND-10) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  padding: .12rem .5rem;
  border-radius: 2px;
  font-size: .62rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .02em;
}
.badge-uf      { background: #546E7A; }
.badge-grupo   { background: #6A1B9A; }
.badge-gray    { background: #78909C; }
.badge-valid   { background: var(--c-green); }
.badge-expired { background: var(--c-red); }
.badge-warning { background: var(--c-orange); }

/* botões de ação do modal (openModal / detalhe de empresa) */
.btn-view, .btn-dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  height: 28px;
  padding: 0 .8rem;
  border-radius: var(--r);
  font-size: .74rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all .12s;
  border: 1.5px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-view {
  background: var(--surface2);
  color: var(--gov-blue);
  border-color: var(--border);
}
.btn-view:hover { border-color: var(--gov-blue); background: var(--border); }
[data-theme="dark"] .btn-view { color: #79B8FF; }

.btn-dl {
  background: var(--gov-blue);
  color: #fff;
  border-color: var(--gov-blue);
  margin-left: auto;
}
.btn-dl:hover { background: var(--gov-navy); border-color: var(--gov-navy); }

.btn-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  height: 28px;
  padding: 0 .8rem;
  border-radius: var(--r);
  font-size: .74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  border: 1.5px solid #c62828;
  background: transparent;
  color: #c62828;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-del:hover:not(:disabled) { background: #c62828; color: #fff; }
.btn-del:disabled { opacity: .5; cursor: default; }
[data-theme="dark"] .btn-del { border-color: #ef5350; color: #ef5350; }
[data-theme="dark"] .btn-del:hover:not(:disabled) { background: #ef5350; color: #fff; }

/* ações da barra de resultados (flag "mais recente" + selecionar todos) */
.results-actions {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.chk-mais-recente {
  height: 28px;
  padding: 0 .85rem;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .77rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  user-select: none;
}
.chk-mais-recente:hover { border-color: var(--navy-mid); color: var(--navy-mid); }
.chk-mais-recente input {
  width: 14px; height: 14px;
  cursor: pointer;
  accent-color: var(--navy-mid);
}

/* botão selecionar todos */
.btn-sel-all {
  height: 28px;
  padding: 0 .85rem;
  border-radius: var(--r);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .77rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  user-select: none;
}
.btn-sel-all:hover { border-color: var(--navy-mid); color: var(--navy-mid); }

/* CND-P08: botão CSV na results-bar */
.btn-csv {
  height: 28px;
  padding: 0 .85rem;
  border-radius: var(--r);
  border: 1.5px solid #2e7d32;
  background: var(--surface);
  color: #2e7d32;
  font-size: .77rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.btn-csv:hover { background: #2e7d32; color: #fff; }

/* barra flutuante de download */
.dl-bar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: .65rem;
  background: var(--navy-deep);
  color: #fff;
  padding: .55rem 1.1rem;
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 300;
  white-space: nowrap;
  animation: dlBarIn .18s ease;
  border-bottom: 3px solid var(--navy-mid);
}
@keyframes dlBarIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.dl-count { font-size: .83rem; font-weight: 700; }

.dl-btn-clear {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.8);
  border-radius: var(--r);
  height: 26px;
  padding: 0 .7rem;
  font-size: .77rem;
  cursor: pointer;
  transition: background .12s;
  display: inline-flex; align-items: center;
}
.dl-btn-clear:hover { background: rgba(255,255,255,.2); }

.dl-btn-download {
  background: var(--navy-light);
  color: var(--navy-deep);
  border: none;
  border-radius: var(--r);
  height: 26px;
  padding: 0 .9rem;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s;
  display: inline-flex; align-items: center; gap: .35rem;
}
.dl-btn-download:hover { background: #fff; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(7,29,65,.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.7); }

.modal-box {
  background: var(--surface);
  border-radius: var(--r);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  border-top: 4px solid var(--gov-blue);
  transition: background .2s;
}
.modal-close {
  position: absolute;
  right: .875rem; top: .875rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
  z-index: 10;
  color: var(--muted);
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-status-banner {
  padding: .65rem 1.5rem;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.modal-title {
  padding: .875rem 1.5rem .35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.modal-table { width: 100%; border-collapse: collapse; }
.modal-table th,
.modal-table td {
  padding: .55rem 1.5rem;
  font-size: .83rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  color: var(--text);
}
.modal-table th {
  width: 36%;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface2);
}
.modal-table tr:last-child th,
.modal-table tr:last-child td { border-bottom: none; }

.modal-actions {
  display: flex;
  gap: .65rem;
  padding: .875rem 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

/* ── FOOTER ── */
.footer {
  background: var(--navy-deep);
  color: rgba(255,255,255,.45);
  border-top: 3px solid var(--navy-mid);
  text-align: center;
  padding: .75rem 1.5rem;
  font-size: .73rem;
}
.footer strong { color: rgba(255,255,255,.75); }

/* ── UTILITÁRIOS ── */
.hidden { display: none !important; }

/* ── RESPONSIVO ── */
@media (max-width: 768px) {
  .cnd-toolbar-row { flex-direction: column; align-items: stretch; }
  .cnd-toolbar-row .search-wrap { max-width: 100%; }
}
@media (max-width: 580px) {
  .dl-bar {
    left: 1rem; right: 1rem;
    transform: none;
    border-radius: var(--r);
  }
  @keyframes dlBarIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ── Visão por Empresa (CND-10) ─────────────────────────────────────────────── */
.empresa-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: .5rem 0;
}
.empresa-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .12s;
}
.empresa-row:hover {
  border-color: var(--gov-blue);
  box-shadow: 0 2px 8px var(--shadow);
  transform: translateX(2px);
}
.emp-row-left  { flex: 1; min-width: 0; }
.emp-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; flex-shrink: 0; }
.emp-row-nome  { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-row-cnpj  { font-size: .75rem; font-family: monospace; color: var(--muted); margin-top: 1px; }
.emp-row-meta  { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .35rem; }
.emp-dots      { font-size: 1.1rem; letter-spacing: .2em; white-space: nowrap; }
.emp-dot-absent { color: var(--border) !important; }
.emp-dots-label { font-size: .7rem; color: var(--muted); text-align: right; }
.emp-worst     { font-size: .78rem; font-weight: 600; }

/* Tabela de categorias no modal de empresa */
.emp-cat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  margin-top: .5rem;
}
.emp-cat-table thead tr {
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  text-align: left;
}
.emp-cat-table th,
.emp-cat-table td { padding: .45rem .6rem; }
.emp-cat-table tbody tr { border-bottom: 1px solid var(--border); }
.emp-cat-table tbody tr:last-child { border-bottom: none; }
.emp-cat-absent td { opacity: .5; }
.emp-cat-link {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  text-decoration: none;
  background: var(--surface2);
  font-size: .85rem;
  margin-right: 2px;
  transition: background .15s;
}
.emp-cat-link:hover { background: var(--border); }
.emp-cat-del {
  background: none;
  border: 1px solid #c62828;
  color: #c62828;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .8rem;
  cursor: pointer;
}
.emp-cat-del:hover { background: #c62828; color: #fff; }

/* Header do modal de empresa */
.emp-modal-header { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.emp-modal-nome   { font-size: 1.05rem; font-weight: 700; }
.emp-modal-sub    { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.emp-modal-cnpj   { font-family: monospace; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.emp-modal-socios { margin-top: 10px; font-size: .82rem; line-height: 1.7; }
.emp-modal-hist-hdr { margin: 16px 0 6px; font-size: .85rem; color: var(--muted); font-weight: 600; }

@media (max-width: 600px) {
  .empresa-row { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .emp-row-right { align-items: flex-start; }
}
