:root {
  --ink: #171d17;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --border: #dfe3dc;
  --primary: #023c54;
  --primary-dark: #012b3d;
  --primary-light: #e5f1f5;
  --primary-border: #bdd8e3;
  --accent-gold: #a9803f;
  --muted: #667066;
  --danger: #a3403a;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}
.auth-overlay { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(23,29,23,.55); padding: 20px; }
.auth-page { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; background:linear-gradient(135deg,#e5f1f5,var(--bg)); }
.auth-overlay.d-none { display: none !important; }.auth-card { width:100%; max-width:380px; background:var(--surface); padding:28px; border-radius:12px; box-shadow:0 16px 48px rgba(0,0,0,.24); }.auth-links { display:flex; justify-content:space-between; margin-top:12px; }.auth-links button { border:0; background:none; color:var(--primary); padding:0; font-size:12px; }.user-menu { display:flex; align-items:center; gap:8px; margin-left:auto; }.plan-badge { background:var(--primary-light); color:var(--primary-dark); border-radius:999px; padding:3px 8px; font-size:11px; font-weight:600; }

/* ===== Sidebar de filtros ===== */
.filters-panel {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

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

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.brand-mark-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title { font-weight: 600; font-size: 15px; line-height: 1.2; }
.brand-subtitle { font-size: 12px; color: var(--muted); }

.filters-form { padding: 18px 20px 28px; }

.filter-group { margin-bottom: 14px; }

.filter-group-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filter-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}

.filter-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.filters-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(2, 60, 84, 0.15);
}

/* ===== Área principal ===== */
.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.content-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.results-summary { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 220px; }
.results-count { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--primary-dark); }
.results-label { font-size: 13px; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.sort-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 28px;
  margin-top: 14px;
}
.active-filters:empty { margin-top: 0; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  padding: 3px 6px 3px 12px;
  font-size: 12px;
}

/* Disabled state for filters based on plan restrictions */
.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.disabled input,
.disabled select {
  background-color: #f8f9fa !important;
}

.form-text.text-muted {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
}
.filter-chip button {
  border: none;
  background: transparent;
  color: var(--primary-dark);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
}
.filter-chip button:hover { background: #d3e7ee; }

.table-wrapper {
  flex: 1;
  overflow: auto;
  padding: 20px 28px;
}

.results-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13.5px;
}

.results-table thead th {
  background: #fbfbfa;
  font-size: 11.5px;
  text-transform: none;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  white-space: nowrap;
}

.results-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef0ec;
  vertical-align: middle;
}

.results-table tbody tr:last-child td { border-bottom: none; }
.results-table tbody tr { cursor: pointer; }
.results-table tbody tr:hover { background: #f8faf7; }

.cnpj-mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); }

.razao-social { font-weight: 600; color: var(--ink); }
.nome-fantasia { font-size: 12px; color: var(--muted); }

.badge-situacao {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-situacao.ativa { background: var(--primary-light); color: var(--primary-dark); }
.badge-situacao.suspensa { background: #fbf1de; color: #8a6416; }
.badge-situacao.baixada { background: #f5e6e5; color: #954c47; }
.badge-situacao.inapta { background: #f5e6e5; color: #954c47; }
.badge-situacao.nula { background: #eceeec; color: var(--muted); }
.badge-situacao.default { background: #eceeec; color: var(--muted); }

.cnae-descricao { font-size: 12px; color: var(--muted); max-width: 260px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty-state, .loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
}
.empty-state i { font-size: 32px; margin-bottom: 10px; }

.content-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.page-size-info { font-size: 12px; color: var(--muted); }

.pagination .page-link { color: var(--primary-dark); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1030;
  display: none;
}
.overlay.show { display: block; }

/* Modal de detalhe */
.detail-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 18px 0 8px;
}
.detail-section-title:first-child { margin-top: 0; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.detail-field-label { font-size: 11.5px; color: var(--muted); }
.detail-field-value { font-size: 13.5px; font-weight: 500; }
.detail-field-value.mono { font-family: var(--font-mono); }

.socio-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

@media (max-width: 991.98px) {
  .filters-panel {
    position: fixed;
    left: 0; top: 0;
    z-index: 1040;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 24px rgba(0,0,0,0.2);
  }
  .filters-panel.show { transform: translateX(0); }
  .detail-grid { grid-template-columns: 1fr; }
}


/* ===== Caixa de Diálogo Chat IA ===== */
.ai-chat-box {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-chat-input-wrapper {
  display: flex;
  align-items: center;
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 6px 8px 6px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease-in-out;
}

.ai-chat-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(2, 60, 84, 0.15);
}

.ai-chat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.15rem;
  margin-right: 10px;
}

.ai-chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--ink);
  font-family: var(--font-ui);
}

.ai-chat-input::placeholder {
  color: #94a3b8;
  font-size: 0.88rem;
}

.ai-chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}

.ai-chat-send-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.ai-chat-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-chat-send-btn .bi-arrow-up {
  font-size: 1.1rem;
  font-weight: bold;
}

/* Sugestões de prompts rápidos */
.ai-prompt-suggestions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-left: 6px;
}

.suggestion-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.prompt-chip {
  background: #eef6f8;
  border: 1px solid #d4e5eb;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.75rem;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}

.prompt-chip:hover {
  background: #dceef3;
  border-color: var(--primary);
  color: var(--primary-dark);
}

.natural-search-avisos {
  margin-top: 4px;
}
