:root {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #24344d;
  --border-color: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.15);
  --radius: 12px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* Layout Geral */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-info span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Navegação por Abas */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-logout {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--danger);
  color: white;
}

/* Área de Conteúdo */
.main-container {
  max-width: 1400px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Barra de Filtros e Ações */
.toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.filter-item label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.date-range-inputs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.date-sep {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-control, .form-select {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent-primary);
}

.btn {
  background: var(--accent-primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.2s, transform 0.1s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.btn-success {
  background: var(--success);
}
.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
}
.btn-danger:hover {
  background: #dc2626;
}

/* Cards de KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-primary);
}

.kpi-card.success::before { background: var(--success); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.purple::before { background: var(--purple); }

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.kpi-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.diff-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.diff-positive {
  background: var(--success-bg);
  color: var(--success);
}

.diff-negative {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Gráficos e Seções */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

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

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.content-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.content-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Tabelas */
.table-responsive {
  overflow-x: auto;
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-entrada {
  background: var(--success-bg);
  color: var(--success);
}

.badge-saida {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-empresa {
  background: var(--purple-bg);
  color: #c084fc;
}

.badge-pessoal {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Agenda */
.event-card {
  background: var(--bg-main);
  border-left: 4px solid var(--accent-primary);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.event-date {
  font-weight: 700;
  color: var(--accent-primary);
  font-size: 0.85rem;
}

.event-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.event-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Código & Snippets */
pre.code-block {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  color: #38bdf8;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 0.84rem;
  overflow-x: auto;
  line-height: 1.5;
}

.copy-btn {
  float: right;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

/* Alertas & Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  color: var(--text-primary);
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  font-size: 0.88rem;
}

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

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   ORBE FLUTUANTE IA & COMANDO DE VOZ
   ========================================================================== */

/* Botão Flutuante do Orbe no Canto da Tela */
.ai-floating-orb-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-floating-orb-btn {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0;
}

.ai-floating-orb-btn:hover {
  transform: scale(1.08);
}

.ai-floating-orb-btn:active {
  transform: scale(0.95);
}

.orb-halo {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.6) 0%, rgba(168, 85, 247, 0.4) 50%, transparent 70%);
  filter: blur(8px);
  animation: orbHaloPulse 3s infinite ease-in-out;
  pointer-events: none;
}

.orb-core {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #0f172a 0%, #000 100%);
  box-shadow: 0 0 22px rgba(139, 92, 246, 0.7), 0 0 40px rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.electric-orb-core {
  background: #030712 !important;
  box-shadow: 0 0 25px rgba(168, 85, 247, 0.75), 0 0 45px rgba(56, 189, 248, 0.5) !important;
}

.floating-electric-orb-img {
  width: 130%;
  height: 130%;
  object-fit: cover;
  border-radius: 50%;
  mix-blend-mode: screen;
  filter: contrast(1.15) brightness(1.2);
  animation: floatingElectricSpin 16s linear infinite;
  pointer-events: none;
}

@keyframes floatingElectricSpin {
  0% { transform: rotate(0deg) scale(1.02); }
  50% { transform: rotate(180deg) scale(1.12); }
  100% { transform: rotate(360deg) scale(1.02); }
}

.orb-icon {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  animation: orbIconFloat 2.5s infinite ease-in-out;
}

.orb-badge {
  position: absolute;
  right: 76px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #e0f2fe;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.25s ease;
}

.ai-floating-orb-wrapper:hover .orb-badge {
  opacity: 1;
  transform: translateX(0);
}

@keyframes orbHaloPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 0.95; transform: scale(1.15); }
}

@keyframes orbIconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* Modal / Gaveta de Voz do Orbe */
.ai-voice-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 16, 0.65);
  backdrop-filter: blur(10px);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.ai-voice-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.ai-voice-panel {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(56, 189, 248, 0.15);
  overflow: hidden;
  transform: scale(0.94) translateY(15px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-voice-modal-overlay.active .ai-voice-panel {
  transform: scale(1) translateY(0);
}

/* Cabeçalho do Modal */
.ai-voice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
}

.ai-voice-title-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-mini-orb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #a855f7);
  box-shadow: 0 0 10px #38bdf8;
  animation: orbMiniPulse 2s infinite ease-in-out;
}

.ai-voice-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
}

.ai-status-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  margin-top: 2px;
}

.ai-status-tag.status-idle { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.ai-status-tag.status-listening { background: rgba(239, 68, 68, 0.2); color: #f87171; animation: blinkTag 1s infinite; }
.ai-status-tag.status-processing { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
.ai-status-tag.status-speaking { background: rgba(16, 185, 129, 0.2); color: #34d399; }

@keyframes blinkTag {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ai-voice-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1rem;
}

.ai-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.ai-icon-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

/* Palco Central do Orbe */
.ai-orb-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.8rem 1rem 1.2rem;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.6) 0%, transparent 70%);
}

.ai-main-orb {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  user-select: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-main-orb:hover {
  transform: scale(1.05);
}

.ai-main-orb:active {
  transform: scale(0.96);
}

/* Anéis de ondas sonoras ao redor do orbe */
.orb-wave-ring {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s ease;
}

/* Esfera Principal do Orbe */
.orb-sphere {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 50%, #a855f7 100%);
  box-shadow: 0 0 35px rgba(14, 165, 233, 0.6), inset 0 3px 8px rgba(255, 255, 255, 0.5), inset 0 -5px 12px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s ease;
}

.orb-inner-glow {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.8), transparent 60%);
  pointer-events: none;
}

.orb-center-icon {
  color: #ffffff;
  z-index: 2;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
  transition: transform 0.3s;
}

.ai-voice-subtitle {
  margin-top: 1rem;
  font-size: 0.88rem;
  color: #94a3b8;
  font-weight: 500;
  text-align: center;
  min-height: 1.4rem;
  transition: color 0.3s;
}

/* Estados Dinâmicos do Orbe */

/* 1. IDLE (Pronto / Respirando) */
.ai-main-orb.state-idle .orb-sphere {
  animation: orbIdleBreath 3s infinite ease-in-out;
}
@keyframes orbIdleBreath {
  0%, 100% { transform: scale(1); box-shadow: 0 0 25px rgba(14, 165, 233, 0.5); }
  50% { transform: scale(1.05); box-shadow: 0 0 45px rgba(168, 85, 247, 0.7); }
}

/* 2. LISTENING (Ouvindo voz com ondas concêntricas pulsando) */
.ai-main-orb.state-listening .orb-sphere {
  background: linear-gradient(135deg, #ef4444 0%, #ec4899 50%, #8b5cf6 100%);
  box-shadow: 0 0 50px rgba(239, 68, 68, 0.8);
  animation: orbListeningPulse 1s infinite alternate ease-in-out;
}
.ai-main-orb.state-listening .orb-wave-ring {
  border: 2px solid rgba(239, 68, 68, 0.6);
  opacity: 1;
}
.ai-main-orb.state-listening .ring-1 {
  inset: -12px;
  animation: waveRingExpand 1.5s infinite linear;
}
.ai-main-orb.state-listening .ring-2 {
  inset: -24px;
  animation: waveRingExpand 1.5s 0.5s infinite linear;
}
.ai-main-orb.state-listening .ring-3 {
  inset: -36px;
  animation: waveRingExpand 1.5s 1s infinite linear;
}

@keyframes waveRingExpand {
  0% { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes orbListeningPulse {
  0% { transform: scale(0.98); }
  100% { transform: scale(1.08); }
}

/* 3. PROCESSING (Pensando / Consultando) */
.ai-main-orb.state-processing .orb-sphere {
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 50%, #06b6d4 100%);
  box-shadow: 0 0 45px rgba(139, 92, 246, 0.8);
  animation: orbProcessingSpin 2s infinite linear;
}
@keyframes orbProcessingSpin {
  0% { transform: rotate(0deg) scale(1.02); }
  50% { transform: rotate(180deg) scale(0.98); }
  100% { transform: rotate(360deg) scale(1.02); }
}

/* 4. SPEAKING (Falando / Emitindo voz) */
.ai-main-orb.state-speaking .orb-sphere {
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 50%, #3b82f6 100%);
  box-shadow: 0 0 50px rgba(16, 185, 129, 0.8);
  animation: orbSpeakingVoice 0.8s infinite alternate ease-in-out;
}
@keyframes orbSpeakingVoice {
  0% { transform: scale(0.95); box-shadow: 0 0 30px rgba(16, 185, 129, 0.6); }
  100% { transform: scale(1.1); box-shadow: 0 0 60px rgba(6, 182, 212, 0.9); }
}

/* Barra do botão para solicitar digitação de texto */
.ai-text-request-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.85rem 1rem 1.4rem;
  transition: all 0.25s ease;
}

.btn-request-text {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
  padding: 0.6rem 1.4rem;
  border-radius: 22px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.btn-request-text:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.45);
  color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.25);
}

.btn-request-text:active {
  transform: scale(0.97);
}

/* Seção Recolhível de Chat e Mensagens */
.ai-collapsible-chat {
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 14, 28, 0.75);
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  max-height: 480px;
  opacity: 1;
  overflow: hidden;
}

.ai-collapsible-chat.collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  border-top: none !important;
  pointer-events: none !important;
}

/* Barra de Ferramentas do Chat */
.ai-chat-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 1.25rem;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-chat-toolbar-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-collapse-chat {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.btn-collapse-chat:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}

/* Histórico de Mensagens */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 280px;
  min-height: 140px;
  background: rgba(10, 15, 29, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: fadeInMsg 0.25s ease-out;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg.user {
  align-self: flex-end;
}

.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-msg.bot {
  align-self: flex-start;
}

.ai-msg.bot .ai-msg-bubble {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.ai-msg-bubble {
  padding: 0.7rem 0.95rem;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

.ai-msg-bubble strong {
  color: #38bdf8;
}

/* Barra de Entrada */
.ai-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  background: rgba(15, 23, 42, 0.9);
}

.btn-mic-input {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-mic-input:hover {
  background: rgba(56, 189, 248, 0.3);
  transform: scale(1.05);
}

.btn-mic-input.active {
  background: #ef4444;
  color: #fff;
  animation: blinkMic 0.8s infinite;
}

@keyframes blinkMic {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(239, 68, 68, 0.6); }
  50% { transform: scale(1.1); box-shadow: 0 0 20px rgba(239, 68, 68, 0.9); }
}

.ai-input-bar input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  color: #f8fafc;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.ai-input-bar input:focus {
  border-color: #38bdf8;
  background: rgba(255, 255, 255, 0.09);
}

.btn-send-input {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-send-input:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(14, 165, 233, 0.5);
}

/* ==========================================================================
   RESPONSIVIDADE COMPLETA PARA DISPOSITIVOS MÓVEIS (SMARTPHONES E TABLETS)
   ========================================================================== */

@media (max-width: 768px) {
  /* Cabeçalho do App no Celular */
  .app-header {
    padding: 0.65rem 0.85rem;
  }

  .header-container {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.65rem 0.5rem;
  }

  .brand {
    grid-column: 1 / 2;
    gap: 0.55rem;
    min-width: 0;
  }

  .brand-icon {
    width: 36px;
    height: 36px;
    font-size: 1.15rem;
    flex-shrink: 0;
  }

  .brand-info h1 {
    font-size: 0.98rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-info span {
    font-size: 0.68rem;
    display: block;
  }

  .user-menu {
    grid-column: 2 / 3;
    justify-self: end;
    gap: 0.35rem;
  }

  #userGreeting {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.5rem !important;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
  }

  .btn-logout {
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
  }

  /* Abas de Navegação em Linha com Rolagem Suave no Toque */
  .nav-tabs {
    grid-column: 1 / -1;
    width: 100%;
    padding: 0.25rem;
    gap: 0.35rem;
  }

  .nav-tab {
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
  }

  /* Espaçamento Principal do Conteúdo e Safe Area */
  .main-container {
    padding: 0 0.85rem;
    margin: 1rem auto;
    padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  /* Barras de Filtros e Ações */
  .toolbar {
    padding: 0.85rem;
    margin-bottom: 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .filter-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    width: 100%;
  }

  .filter-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    width: 100%;
  }

  .filter-item label {
    font-size: 0.76rem;
    color: var(--text-secondary);
  }

  .filter-item .form-control,
  .filter-item .form-select {
    width: 100%;
    font-size: 0.85rem;
    padding: 0.5rem 0.7rem;
  }

  .filter-search {
    min-width: 100% !important;
  }

  .date-range-inputs {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    width: 100%;
  }

  .date-range-inputs .form-control {
    flex: 1;
    min-width: 0;
  }

  .toolbar-actions {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }

  .toolbar-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 0.55rem;
    font-size: 0.85rem;
  }

  /* Cards de Indicadores KPIs */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-bottom: 1rem;
  }

  .kpi-card {
    padding: 0.85rem 0.95rem;
  }

  .kpi-title {
    font-size: 0.72rem;
  }

  .kpi-value {
    font-size: 1.25rem;
    margin-bottom: 0.2rem;
  }

  .kpi-sub {
    font-size: 0.68rem;
  }

  /* Gráficos e Seções */
  .content-card {
    padding: 0.95rem;
    margin-bottom: 1rem;
  }

  .content-card-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
  }

  .content-card-title {
    font-size: 0.92rem;
  }

  .chart-container {
    height: 220px;
  }

  /* Tabelas com rolagem lateral suave */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid var(--border-color);
  }

  .data-table th,
  .data-table td {
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
  }

  /* Botão Flutuante do Orbe IA no Mobile */
  .ai-floating-orb-wrapper {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    gap: 0.4rem;
  }

  .ai-floating-orb-btn {
    width: 58px;
    height: 58px;
  }

  .orb-core {
    width: 48px;
    height: 48px;
  }

  .orb-icon {
    font-size: 1.35rem;
  }

  .orb-badge {
    display: none !important;
  }

  /* Modal do Assistente Orion no Mobile (Estilo Bottom Sheet Moderno) */
  .ai-voice-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .ai-voice-panel {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 88vh;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  }

  .ai-voice-header {
    padding: 0.75rem 1rem;
  }

  .ai-orb-stage {
    padding: 1rem 1rem 0.6rem;
  }

  .ai-orb-3d-canvas {
    width: 180px !important;
    height: 180px !important;
  }

  .ai-voice-subtitle {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    min-height: 1.2rem;
  }

  .ai-text-request-bar {
    padding: 0.4rem 1rem 0.75rem;
  }

  .btn-request-text {
    padding: 0.45rem 1.1rem;
    font-size: 0.82rem;
  }

  .ai-chat-messages {
    max-height: 160px;
    min-height: 90px;
    padding: 0.65rem 0.85rem;
    gap: 0.5rem;
  }

  .ai-msg-bubble {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
  }

  .ai-input-bar {
    padding: 0.6rem 0.85rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
  }

  .ai-input-bar input {
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
  }

  .btn-mic-input,
  .btn-send-input {
    width: 38px;
    height: 38px;
  }

  .ai-settings-drawer.open {
    max-height: 320px;
    padding: 0.85rem 1rem;
  }

  .ai-settings-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
}

@media (max-width: 480px) {
  .header-container {
    gap: 0.5rem 0.35rem;
  }

  .brand-info h1 {
    font-size: 0.9rem;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   CONFIGURAÇÕES DE VOZ, ESTILOS 3D E MODO TELA CHEIA
   ========================================================================== */

/* Gaveta de Configurações */
.ai-settings-drawer {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(10, 15, 30, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 1.4rem;
}

.ai-settings-drawer.open {
  max-height: 260px;
  opacity: 1;
  padding: 1rem 1.4rem;
}

.ai-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 500px) {
  .ai-settings-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

.ai-setting-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 0.35rem;
}

.ai-form-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #f8fafc;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  outline: none;
}

.ai-form-select option {
  background: #0f172a;
  color: #f8fafc;
}

.ai-range-slider {
  flex: 1;
  accent-color: #38bdf8;
  height: 6px;
  cursor: pointer;
}

.ai-rate-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  padding: 0.1rem 0.45rem;
  border-radius: 8px;
}

.ai-theme-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ai-theme-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 0.3rem 0.65rem;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-theme-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.ai-theme-chip.active {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #38bdf8;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* Canvas 3D do Orbe */
.ai-orb-3d-canvas {
  width: 240px;
  height: 240px;
  display: block;
  filter: drop-shadow(0 0 25px rgba(56, 189, 248, 0.35));
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-orb-3d-canvas:hover {
  transform: scale(1.04);
}

.ai-orb-3d-canvas:active {
  transform: scale(0.97);
}

.orb-3d-interaction-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

/* Modo Tela Cheia Imersivo */
.ai-voice-panel.fullscreen-mode {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  background: radial-gradient(circle at center, #0b1329 0%, #030712 100%) !important;
}

.ai-voice-panel.fullscreen-mode .ai-orb-stage {
  flex: 1;
  padding: 2rem 1rem;
}

.ai-voice-panel.fullscreen-mode .ai-orb-3d-canvas {
  width: 340px !important;
  height: 340px !important;
}

.ai-voice-panel.fullscreen-mode .ai-voice-subtitle {
  font-size: 1.15rem;
  margin-top: 1.5rem;
  max-width: 700px;
}

.ai-voice-panel.fullscreen-mode .ai-chat-messages {
  max-height: 200px;
}

/* Toggle Switch Estilo iOS / Moderno */
.ai-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.ai-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ai-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 24px;
}

.ai-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.ai-switch input:checked + .ai-slider {
  background-color: #10b981;
}

.ai-switch input:checked + .ai-slider:before {
  transform: translateX(20px);
}

.ai-floating-orb-wrapper.wake-listening .orb-halo {
  background: radial-gradient(circle, rgba(16, 185, 129, 0.7) 0%, rgba(56, 189, 248, 0.5) 50%, transparent 70%);
  animation: wakeGlow 2s infinite ease-in-out !important;
}

@keyframes wakeGlow {
  0%, 100% { transform: scale(1); opacity: 0.7; filter: blur(10px); }
  50% { transform: scale(1.25); opacity: 1; filter: blur(16px); }
}

/* Ajustes de layout quando a caixa de texto está recolhida */
.ai-voice-panel.chat-collapsed {
  min-height: 480px;
}

.ai-voice-panel.chat-collapsed .ai-orb-stage {
  padding: 3rem 1.5rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ai-voice-panel.fullscreen-mode.chat-collapsed .ai-orb-stage {
  padding: 5rem 1.5rem 2.5rem;
  flex: 1;
}

.ai-voice-panel.fullscreen-mode.chat-collapsed .ai-orb-3d-canvas {
  width: 400px !important;
  height: 400px !important;
}
