/* =============================================================================
   BASE — Tokens de sistema + reset + shell + componentes globais
   =============================================================================
   Carregar DEPOIS de theme.css. Consome --empresa-* definidos lá.
   Pivot Fase 6: extraído do <style> inline de novo.html, 37 classes órfãs
   removidas (sobras das Fases 2–5 após migração pra fragments BEM-escopados).
   ========================================================================== */

:root {
  /* Sistema base (neutros, identidade do produto, nunca mudam por empresa) */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-hover: #eff1f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #059669;
  --success-soft: #d1fae5;
  --warning: #b45309;
  --warning-soft: #fef3c7;

  /* Medidas */
  --sidebar-w: 260px;
  --header-h: 56px;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);
}

/* =============================================================================
   RESET
   ========================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[x-cloak] { display: none !important; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a { color: inherit; text-decoration: none; }

/* =============================================================================
   BOOT SCREEN
   ========================================================================== */

.boot-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 9999;
}

.boot-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--empresa-simples);
  border-radius: 50%;
  animation: boot-spin 0.8s linear infinite;
}

@keyframes boot-spin {
  to { transform: rotate(360deg); }
}

/* =============================================================================
   TELA DE LOGIN
   ========================================================================== */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(40, 65, 147, 0.06), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 40px 32px 32px;
}

.login-welcome {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
  margin: 0 0 32px;
}

.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-field input:focus {
  outline: none;
  border-color: var(--empresa-simples);
  box-shadow: 0 0 0 3px rgba(40, 65, 147, 0.12);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  background: var(--empresa-simples);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary:hover { background: #1e3173; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg {
  padding: 10px 12px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

.success-msg {
  padding: 10px 12px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

/* =============================================================================
   SHELL
   ========================================================================== */

.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.shell-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  padding: 0 16px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hamburger {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.hamburger:hover { background: var(--surface-2); }

.shell-brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.shell-brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--empresa-primary);
  transition: background 0.2s;
}

.shell-header-spacer {
  flex: 1;
}

.shell-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 20px;
  margin-left: 4px;
  border-left: 1px solid var(--border);
}

.shell-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--empresa-simples);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.shell-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.shell-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.shell-user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.shell-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* =============================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 10px 24px;
}

.sidebar-section {
  margin-bottom: 2px;
}

/* Titulo de grupo NAO-clicavel: apenas separa as secoes da sidebar (jul/2026). */
.sidebar-section-title {
  padding: 15px 12px 5px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.65;
  user-select: none;
  pointer-events: none;
}
/* O primeiro titulo (logo abaixo do Inicio) dispensa o espaco extra no topo. */
.sidebar-section:first-child .sidebar-section-title { padding-top: 6px; }

/* Menu LIMPO (jul/2026): folhas e sub-grupos ficam SEM icone (visual limpo).
   Escopado por .sistema-simples (gancho no <aside>). Desde ago/2026 a CORUJA usa o
   MESMO gancho (adaptacao do menu ao padrao da Simples) -> so' Config/Asta nao mudam. */
.sidebar.sistema-simples .sidebar-link > i,
.sidebar.sistema-simples .sidebar-link > svg,
.sidebar.sistema-simples .subgroup-icon {
  display: none;
}

/* Item folha (sem filhos) */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
  padding-left: 9px;
}

.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-link.active {
  background: var(--empresa-surface);
  color: var(--empresa-accent);
  border-left-color: var(--empresa-accent);
}

.sidebar-link i[data-lucide] {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.sidebar-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Grupo com filhos */
.sidebar-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  transition: background 0.12s;
  text-align: left;
}

.sidebar-group-header:hover { background: var(--surface-hover); }

.sidebar-group-header .group-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--empresa-accent);
}

.sidebar-group-header .group-label {
  flex: 1;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Marca-texto vermelho no item de menu (ex.: Gestão Carteiras com vencidos nas
   carteiras separadas). Faixa que não cobre a altura toda -> efeito highlighter. */
.group-label .gc-marca {
  background: linear-gradient(transparent 15%, #fca5a5 15%, #fca5a5 90%, transparent 90%);
  color: #7f1d1d;
  font-weight: 800;
  padding: 0 3px;
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.sidebar-group-header .group-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-dim);
  transition: transform 0.15s;
}

.sidebar-group-header.open .group-chevron { transform: rotate(90deg); }

.sidebar-group-children {
  padding-left: 20px;
  margin-top: 2px;
  margin-bottom: 6px;
  border-left: 1px solid var(--border);
  margin-left: 17px;
}

.sidebar-group-children .sidebar-link {
  padding: 7px 10px;
  font-size: 13px;
  padding-left: 7px;
}

/* Sub-grupo expansivel (nivel 3 do sidebar).
   Vive dentro de .sidebar-group-children. Header parece um link mas com chevron;
   o clique nao navega, apenas abre/fecha o sub-grupo. Os filhos do sub-grupo
   sao renderizados como .sidebar-link com indent extra. */
.sidebar-subsection {
  margin-bottom: 2px;
}

.sidebar-subgroup-header {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 7px 10px;
  padding-left: 7px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  text-align: left;
}

.sidebar-subgroup-header:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar-subgroup-header i.subgroup-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.sidebar-subgroup-header .subgroup-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-subgroup-header .subgroup-chevron {
  width: 13px;
  height: 13px;
  color: var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.sidebar-subgroup-header.open .subgroup-chevron { transform: rotate(90deg); }

.sidebar-subgroup-children {
  padding-left: 16px;
  margin-top: 2px;
  margin-bottom: 4px;
}

.sidebar-subgroup-children .sidebar-link {
  padding: 6px 10px;
  padding-left: 7px;
  font-size: 12.5px;
}

/* =============================================================================
   SIDEBAR — ACORDEAO (layout limpo; jul/2026)
   Cada grupo (SISTEMA_SECOES na Simples; nós tipo:'grupo' no menu curado da
   Coruja) vira um header clicavel so' com titulo em destaque (sem icones);
   clique expande/recolhe as paginas. Escopado em .sistema-simples — gancho que
   desde ago/2026 tambem e' aplicado na CORUJA (ver <aside> no novo.html);
   Asta/Config seguem no layout antigo.
   ========================================================================== */

.sidebar.sistema-simples { padding: 14px 12px 28px; }

/* --- Header do grupo (nivel 1) --- */
.sidebar.sistema-simples .sidebar-group-header {
  gap: 11px;
  padding: 8px 10px;
  margin-top: 4px;
  border-radius: 11px;
  transition: background 0.15s ease;
}
.sidebar.sistema-simples .sidebar-group-header:hover { background: var(--surface-hover); }

/* Sem icones no menu principal (Roberto, jul/2026): grupos so' com titulo. */
.sidebar.sistema-simples .group-icon { display: none; }

.sidebar.sistema-simples .sidebar-group-header .group-label {
  flex: 1;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}
.sidebar.sistema-simples .sidebar-group-header .group-chevron { color: var(--text-dim); }

/* Estado ABERTO: destaque de marca (chama atencao) */
.sidebar.sistema-simples .sidebar-group-header.open { background: var(--empresa-surface); }
.sidebar.sistema-simples .sidebar-group-header.open .group-label { color: var(--empresa-accent); }
.sidebar.sistema-simples .sidebar-group-header.open .group-chevron { color: var(--empresa-accent); }

/* Dot vermelho de alerta no header (ex.: vencidos em Gestao Carteiras) */
.group-alert {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
  flex-shrink: 0;
}

/* --- Container das paginas: trilho de marca --- */
.sidebar.sistema-simples .sidebar-group-children {
  margin-left: 5px;
  margin-top: 3px;
  margin-bottom: 8px;
  padding-left: 10px;
  border-left: 2px solid var(--empresa-surface);
}

/* --- Paginas (folhas) dentro do grupo: sem bullet, encostadas a esquerda --- */
.sidebar.sistema-simples .sidebar-group-children .sidebar-link {
  padding: 7px 8px;
  border-radius: 8px;
  border-left: none;
  font-size: 13px;
  color: var(--text-muted);
}
.sidebar.sistema-simples .sidebar-group-children .sidebar-link:hover { background: var(--surface-hover); color: var(--text); }
.sidebar.sistema-simples .sidebar-group-children .sidebar-link.active {
  background: var(--empresa-surface);
  color: var(--empresa-accent);
  font-weight: 600;
}

/* --- Subgrupo (nivel 2: Gestao Carteiras, Distribuicao da Cobranca) --- */
.sidebar.sistema-simples .sidebar-subgroup-header {
  border-radius: 8px;
  font-weight: 600;
  color: var(--text-muted);
  padding-left: 8px;
}
.sidebar.sistema-simples .sidebar-subgroup-header.open { color: var(--empresa-accent); }
/* Nivel 3 (paginas dentro do subgrupo): recuo menor pra caber o nome */
.sidebar.sistema-simples .sidebar-subgroup-children { padding-left: 8px; }
.sidebar.sistema-simples .sidebar-subgroup-children .sidebar-link { padding-left: 8px; }

/* =============================================================================
   CONTENT
   ========================================================================== */

.content {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 40px;
  overflow-y: auto;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  color: var(--text);
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-body { padding: 24px; }

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* =============================================================================
   TELA MEU PERFIL
   ========================================================================== */

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  max-width: 680px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.profile-row:last-child { border-bottom: none; }

.profile-row .label {
  color: var(--text-muted);
  font-weight: 500;
}

.profile-row .value {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* =============================================================================
   TELA EM CONSTRU\u00c7\u00c3O (fallback)
   ========================================================================== */

.em-construcao {
  max-width: 500px;
  margin: 80px auto;
  text-align: center;
  padding: 40px;
}

.em-construcao-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--empresa-surface);
  color: var(--empresa-accent);
  border-radius: 50%;
  margin-bottom: 20px;
}

.em-construcao-icon i[data-lucide] { width: 28px; height: 28px; }

.em-construcao h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
}

.em-construcao p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

/* =============================================================================
   RESPONSIVO (shell)
   ========================================================================== */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 90;
}

@media (max-width: 720px) {
  .hamburger { display: inline-flex; }
  .shell-user-info { display: none; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  .content { padding: 16px; }
  .page-title { font-size: 18px; }
}

/* =============================================================================
   CRUD / GESTAO (FUND 1-C) — resíduos em uso após migração das telas pra
   fragments BEM. O que sobrou aqui é consumido pela ASTA CCB e afins.
   ========================================================================== */

.crud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.crud-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.crud-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-new {
  background: var(--empresa-primary);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.btn-new:hover { filter: brightness(0.92); }
.btn-new i[data-lucide] { width: 16px; height: 16px; }

.crud-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.crud-empty i[data-lucide] {
  width: 32px;
  height: 32px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.crud-empty p { margin: 0; }

/* =============================================================================
   TOASTS
   ========================================================================== */

.toasts {
  position: fixed;
  top: calc(var(--header-h) + 16px);
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 300px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--empresa-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  cursor: pointer;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }

.toast i[data-lucide] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.toast.toast-success i[data-lucide] { color: var(--success); }
.toast.toast-error i[data-lucide] { color: var(--danger); }

/* =============================================================================
   ASTA — CONTRATOS CCB (ASTA 1-A)
   ========================================================================== */

/* Wrap da tela aplica tokens da Asta no escopo local */
.ccb-wrap {
  --empresa-primary: var(--empresa-asta);
  --empresa-surface: #e6efff;
  --empresa-accent: var(--empresa-asta);
}

.ccb-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.ccb-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.ccb-filter.flex-grow { flex: 1; min-width: 240px; }

.ccb-filter label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ccb-filter input,
.ccb-filter select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  height: 36px;
}

.ccb-filter input:focus,
.ccb-filter select:focus {
  outline: 2px solid var(--empresa-primary);
  outline-offset: -1px;
  border-color: var(--empresa-primary);
}

.ccb-filters-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-left: auto;
}

.btn-filter-clear {
  padding: 8px 12px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.btn-filter-clear:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Status pills (status de parcela) */
.ccb-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ccb-status-paga       { background: var(--success-soft); color: var(--success); }
.ccb-status-vencida    { background: var(--danger-soft);  color: var(--danger);  }
.ccb-status-a_vencer   { background: #e6efff;             color: #0048cc;        }
.ccb-status-renegociada { background: var(--surface-2); color: var(--text-muted); }

/* Chips de filtro de status (multi-select) */
.ccb-status-chips {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ccb-status-chip {
  padding: 6px 12px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.ccb-status-chip:hover { background: var(--surface-hover); }

.ccb-status-chip.active {
  border-color: var(--empresa-primary);
  color: var(--empresa-primary);
  background: var(--empresa-surface);
  font-weight: 600;
}

/* Botoes de export */
.ccb-export-group { display: inline-flex; gap: 8px; }

.btn-export {
  padding: 8px 12px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.btn-export i[data-lucide] { width: 16px; height: 16px; }
.btn-export-excel { background: var(--success); }
.btn-export-excel:hover:not(:disabled) { background: #047857; }
.btn-export-pdf   { background: var(--danger); }
.btn-export-pdf:hover:not(:disabled)   { background: #b91c1c; }
.btn-export:disabled { opacity: 0.4; cursor: not-allowed; }

/* Paginacao */
.ccb-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.ccb-pagination-left { color: var(--text-muted); font-size: 13px; }

.ccb-pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-page {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.btn-page:hover:not(:disabled) { background: var(--surface-hover); }
.btn-page:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-page.active {
  background: var(--empresa-primary);
  border-color: var(--empresa-primary);
  color: #fff;
}

.ccb-pagination-per-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
}

.ccb-pagination-per-page select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  height: 28px;
}

/* Wrap da tabela CCB sem bordas do rodape (pagination anexa embaixo) */
.ccb-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  overflow-x: auto;
}

.ccb-table-wrap + .ccb-pagination { margin-bottom: 16px; }

.ccb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ccb-table th {
  background: var(--surface-2);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.ccb-table th.sort-active { color: var(--empresa-primary); }
.ccb-table th .sort-arrow { margin-left: 4px; opacity: 0.8; }

.ccb-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.ccb-table tbody tr:hover { background: var(--surface-hover); }
.ccb-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.ccb-table a.row-link {
  color: var(--empresa-primary);
  font-weight: 600;
  text-decoration: none;
}

.ccb-table a.row-link:hover { text-decoration: underline; }

/* Linha de parcela vencida: fundo avermelhado suave. */
.ccb-table tbody tr.tr-vencida:not(:hover) { background: rgba(220, 38, 38, 0.06); }
.ccb-table tbody tr.tr-vencida:hover       { background: rgba(220, 38, 38, 0.10); }

/* Celula clicavel (nome devedor, avalista sim, tipo veiculo) */
.ccb-table .cell-clickable {
  color: var(--empresa-primary);
  cursor: pointer;
  text-decoration: none;
}

.ccb-table .cell-clickable:hover { text-decoration: underline; }

/* Celula do valor pago (sempre editavel) */
.ccb-table td.cell-pago {
  text-align: right;
  font-variant-numeric: tabular-nums;
  cursor: text;
  min-width: 110px;
}

.ccb-table td.cell-pago:hover .pago-view { background: var(--surface-hover); }

.ccb-table td.cell-pago .pago-view {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  min-width: 90px;
  text-align: right;
}

.ccb-table td.cell-pago .pago-view.empty { color: var(--text-muted); font-style: italic; }

.ccb-table td.cell-pago input.pago-input {
  width: 100px;
  padding: 4px 8px;
  border: 1px solid var(--empresa-primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  outline: none;
}

.ccb-table td.cell-pago input.pago-input:focus {
  box-shadow: 0 0 0 2px var(--empresa-surface);
}

/* Placeholder "em construcao" pra telas ASTA sem impl ainda.
   NOTA: sobrescreve .em-construcao global (cascata). Comportamento preservado
   da versão pre-Fase 6 — se precisar scopear, refatorar em fase posterior. */
.em-construcao {
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.em-construcao i[data-lucide] {
  width: 32px;
  height: 32px;
  opacity: 0.5;
  margin-bottom: 12px;
}

/* =============================================================================
   ASTA 1-B — Modal de Detalhe do Contrato
   ========================================================================== */

.ccb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.ccb-modal {
  --empresa-primary: var(--empresa-asta);
  --empresa-surface: #e6efff;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ccb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.ccb-modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ccb-modal-title .ccb-badge-num {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  padding: 2px 8px;
  background: var(--empresa-surface);
  color: var(--empresa-primary);
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.ccb-modal-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
}

.ccb-modal-close:hover { background: var(--surface-hover); color: var(--text); }
.ccb-modal-close i[data-lucide] { width: 18px; height: 18px; }

/* Abas */
.ccb-modal-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 20px;
}

.ccb-modal-tab {
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.ccb-modal-tab:hover:not(:disabled):not(.active) {
  color: var(--text);
  background: var(--surface-hover);
}

.ccb-modal-tab.active {
  color: var(--empresa-primary);
  border-bottom-color: var(--empresa-primary);
}

.ccb-modal-tab:disabled {
  color: var(--text-muted);
  opacity: 0.5;
  cursor: not-allowed;
}

.ccb-modal-tab i[data-lucide] { width: 14px; height: 14px; }

/* Corpo (scroll) */
.ccb-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  background: var(--surface);
}

.ccb-modal-body .loading {
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
}

/* Grid de campos readonly e editaveis */
.ccb-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 20px;
}

.ccb-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ccb-field.col-full { grid-column: 1 / -1; }

.ccb-field label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ccb-field .value-readonly {
  font-size: 14px;
  color: var(--text);
  padding: 6px 0;
  word-break: break-word;
}

.ccb-field .value-readonly.empty { color: var(--text-muted); font-style: italic; }

/* Campos editaveis inline (igual estilo planilha) */
.ccb-field.editable .value-editable {
  font-size: 14px;
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px dashed transparent;
  cursor: text;
  min-height: 32px;
  display: inline-block;
}

.ccb-field.editable .value-editable:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}

.ccb-field.editable .value-editable.empty { color: var(--text-muted); font-style: italic; }

.ccb-field.editable input.field-input {
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--empresa-primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
}

.ccb-field.editable input.field-input:focus {
  box-shadow: 0 0 0 2px var(--empresa-surface);
}

/* Avalista ausente - mensagem no corpo */
.ccb-no-avalista {
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
}

.ccb-no-avalista i[data-lucide] {
  width: 28px; height: 28px;
  opacity: 0.5;
  margin-bottom: 10px;
}

/* Rodape com Baixar pacote + Excluir */
.ccb-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.btn-modal {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-modal i[data-lucide] { width: 16px; height: 16px; }
.btn-modal:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-modal-primary {
  background: var(--empresa-primary);
  color: #fff;
  border-color: var(--empresa-primary);
}

.btn-modal-primary:hover:not(:disabled) { filter: brightness(0.92); }

.btn-modal-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-modal-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-modal-neutral {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-modal-neutral:hover:not(:disabled) { background: var(--surface-hover); }

/* Modal de confirmacao de exclusao (mais enxuto) */
.ccb-confirm {
  --empresa-primary: var(--empresa-asta);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
}

.ccb-confirm-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.ccb-confirm-header i[data-lucide] {
  width: 20px; height: 20px;
  color: var(--danger);
}

.ccb-confirm-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.ccb-confirm-body {
  padding: 18px 20px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.55;
}

.ccb-confirm-body .destaque {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-weight: 700;
  background: var(--empresa-surface);
  color: var(--empresa-primary);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.ccb-confirm-body ul {
  margin: 12px 0 0 18px;
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.ccb-confirm-body ul li { margin-bottom: 4px; }

.ccb-confirm-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* Responsivo: em telas estreitas os campos viram 1 coluna */
@media (max-width: 640px) {
  .ccb-fields { grid-template-columns: 1fr; }
  .ccb-modal { max-width: 100%; }
}

/* =============================================================================
   TELA INICIAL — Escolha de sistema (4 botoes), jun/2026
   ========================================================================== */

.home-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(40, 65, 147, 0.06), transparent 60%),
    var(--bg);
}

.home-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 36px 32px 32px;
}

.home-welcome {
  text-align: center;
  margin-bottom: 28px;
}

.home-welcome h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 8px;
}

.home-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.home-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  min-height: 116px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.home-btn:hover {
  border-color: var(--empresa-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.home-btn i[data-lucide],
.home-btn svg {
  width: 26px;
  height: 26px;
  color: var(--empresa-primary);
}

.home-btn span {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.home-btn--off {
  cursor: not-allowed;
  opacity: 0.55;
  background: var(--bg);
}

.home-btn--off:hover {
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}

.home-btn--off i[data-lucide],
.home-btn--off svg {
  color: var(--text-dim);
}

/* Cadeado do botao congelado: vem por ultimo pra ganhar do seletor generico
   de icone (mesma especificidade, ordem decide). */
.home-btn i.home-btn__lock,
.home-btn svg.home-btn__lock {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 15px;
  height: 15px;
  color: var(--text-dim);
}

@media (max-width: 560px) {
  .home-grid { grid-template-columns: 1fr; }
}

/* Botao "Trocar de sistema" no header do shell */
.shell-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.shell-switch:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.shell-switch i[data-lucide],
.shell-switch svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 640px) {
  .shell-switch__label { display: none; }
}
