/* ==========================================================================
   AGENTS ELITE IA PRO — PREMIUM DESIGN SYSTEM v2.0
   Direção de Arte: Diretor de Criação (Awwwards, FWA, CSSDA)
   Filosofia: Minimalismo funcional, microinterações de alto valor,
   glassmorphism sofisticado, tipografia com propósito.
   ========================================================================== */

/* --- IMPORTAÇÃO DE FONTES --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Georgia:ital@0;1&display=swap');

/* ==========================================================================
   1. FUNDAÇÃO — Variáveis e Reset Refinado
   ========================================================================== */
:root {
  /* Paleta Premium — Deep Navy + Indigo Metálico + Dourado */
  --premium-bg-primary: #080c18;
  --premium-bg-secondary: #0d1225;
  --premium-bg-tertiary: #111827;
  --premium-bg-card: rgba(17, 24, 39, 0.7);
  --premium-bg-glass: rgba(13, 18, 37, 0.6);
  --premium-bg-elevated: rgba(30, 41, 59, 0.4);

  --premium-border-default: rgba(55, 65, 81, 0.25);
  --premium-border-light: rgba(99, 102, 241, 0.2);
  --premium-border-accent: rgba(99, 102, 241, 0.4);

  --premium-text-primary: #f1f5f9;
  --premium-text-secondary: #94a3b8;
  --premium-text-tertiary: #64748b;
  --premium-text-muted: #475569;

  --premium-accent-primary: #6366f1;
  --premium-accent-secondary: #4f46e5;
  --premium-accent-glow: rgba(99, 102, 241, 0.25);
  --premium-accent-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --premium-accent-gradient-hover: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);

  --premium-gold: #f59e0b;
  --premium-gold-light: #fbbf24;
  --premium-gold-subtle: rgba(245, 158, 11, 0.12);

  --premium-success: #10b981;
  --premium-success-subtle: rgba(16, 185, 129, 0.12);
  --premium-warning: #f59e0b;
  --premium-error: #ef4444;
  --premium-error-subtle: rgba(239, 68, 68, 0.12);

  --premium-radius-sm: 6px;
  --premium-radius-md: 10px;
  --premium-radius-lg: 16px;
  --premium-radius-xl: 20px;
  --premium-radius-full: 9999px;

  --premium-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --premium-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
  --premium-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
  --premium-shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
  --premium-shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --premium-shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(99, 102, 241, 0.1);

  --premium-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --premium-transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --premium-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --premium-font-serif: Georgia, 'Times New Roman', serif;
}

/* --- Tipografia global refinada --- */
body {
  font-family: var(--premium-font-sans);
  background: var(--premium-bg-primary) !important;
  color: var(--premium-text-primary) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* App shell header only — never style nested panel headers */
.app-header {
  background: rgba(8, 12, 24, 0.75) !important;
  backdrop-filter: blur(24px) saturate(1.4) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.4) !important;
  border-bottom: 1px solid var(--premium-border-default) !important;
  height: 52px !important;
  padding: 0 24px !important;
  position: relative;
  z-index: 10;
  overflow: hidden;
}

/* Brilho sutil no topo do header */
.app-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.3), transparent);
}

/* ==========================================================================
   3. SIDEBAR — Gradiente sutil + refinamentos
   ========================================================================== */
aside, .sidebar {
  background: linear-gradient(180deg, rgba(13, 18, 37, 0.95) 0%, rgba(8, 12, 24, 0.98) 100%) !important;
  border-right: 1px solid var(--premium-border-default) !important;
  backdrop-filter: blur(8px) !important;
  position: relative;
}

/* Separador decorativo no topo do sidebar */
aside::before, .sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--premium-accent-primary), transparent);
  opacity: 0.3;
}

/* Logo/crown refinado */
aside .fa-crown, .sidebar .fa-crown {
  filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.3));
}

/* ==========================================================================
   4. BOTÕES PREMIUM — Gradientes + brilho
   ========================================================================== */
button:not(.tab-btn):not(.conv-item):not(.skill-card):not(.toast button),
.btn-premium {
  background: var(--premium-accent-gradient) !important;
  border: none !important;
  color: white !important;
  font-weight: 600 !important;
  border-radius: var(--premium-radius-md) !important;
  transition: var(--premium-transition) !important;
  position: relative;
  overflow: hidden;
}

button:not(.tab-btn):not(.conv-item):not(.skill-card):not(.toast button):hover,
.btn-premium:hover {
  background: var(--premium-accent-gradient-hover) !important;
  transform: translateY(-1px);
  box-shadow: var(--premium-shadow-glow) !important;
}

/* Brilho no hover */
button:not(.tab-btn):not(.conv-item):not(.skill-card):not(.toast button)::after,
.btn-premium::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

button:not(.tab-btn):not(.conv-item):not(.skill-card):not(.toast button):hover::after,
.btn-premium:hover::after {
  opacity: 1;
}

/* Botão outline premium */
.btn-outline-premium {
  background: transparent !important;
  border: 1px solid var(--premium-border-light) !important;
  color: var(--premium-text-secondary) !important;
  backdrop-filter: blur(4px);
}

.btn-outline-premium:hover {
  border-color: var(--premium-accent-primary) !important;
  color: var(--premium-accent-primary) !important;
  background: rgba(99, 102, 241, 0.06) !important;
}

/* ==========================================================================
   5. CARDS — Glassmorphism com elevado refinamento
   ========================================================================== */
.card-premium, [class*="card"]:not(.skill-card):not(.conv-item) {
  background: var(--premium-bg-glass) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid var(--premium-border-default) !important;
  border-radius: var(--premium-radius-lg) !important;
  box-shadow: var(--premium-shadow-card) !important;
  transition: var(--premium-transition) !important;
}

.card-premium:hover, [class*="card"]:not(.skill-card):not(.conv-item):hover {
  transform: translateY(-3px);
  border-color: var(--premium-border-light) !important;
  box-shadow: var(--premium-shadow-elevated) !important;
}

/* ==========================================================================
   6. INPUTS — Com glow refinado
   ========================================================================== */
input, select, textarea, .form-input, .form-select {
  background: rgba(3, 7, 18, 0.7) !important;
  border: 1px solid var(--premium-border-default) !important;
  border-radius: var(--premium-radius-md) !important;
  color: var(--premium-text-primary) !important;
  font-size: 13px !important;
  transition: var(--premium-transition) !important;
  backdrop-filter: blur(4px);
}

input:focus, select:focus, textarea:focus, .form-input:focus, .form-select:focus {
  border-color: var(--premium-accent-primary) !important;
  box-shadow: 0 0 0 3px var(--premium-accent-glow) !important;
  outline: none !important;
}

input::placeholder, textarea::placeholder, .form-input::placeholder {
  color: var(--premium-text-tertiary) !important;
  font-weight: 300;
}

/* ==========================================================================
   7. ABAS (Tabs) — Refinamento visual
   ========================================================================== */
.tab-btn {
  transition: var(--premium-transition) !important;
  border-radius: var(--premium-radius-md) !important;
  font-weight: 500 !important;
  position: relative;
}

.tab-btn:not(.active):hover {
  background: rgba(99, 102, 241, 0.06) !important;
  color: var(--premium-text-primary) !important;
}

.tab-btn.active {
  background: rgba(99, 102, 241, 0.1) !important;
  color: var(--premium-accent-primary) !important;
  font-weight: 600 !important;
}

/* Indicador de aba ativa */
.tab-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--premium-accent-gradient);
  border-radius: 0 3px 3px 0;
}

/* ==========================================================================
   8. MENSAGENS DE CHAT — Glassmorphism premium
   ========================================================================== */
.msg-hermes {
  background: rgba(99, 102, 241, 0.08) !important;
  border: 1px solid rgba(99, 102, 241, 0.12) !important;
  backdrop-filter: blur(8px) !important;
  border-radius: var(--premium-radius-lg) !important;
  border-bottom-left-radius: 4px !important;
}

.msg-user {
  background: rgba(31, 41, 55, 0.6) !important;
  border: 1px solid rgba(55, 65, 81, 0.2) !important;
  backdrop-filter: blur(4px) !important;
  border-radius: var(--premium-radius-lg) !important;
  border-bottom-right-radius: 4px !important;
}

/* Input de chat */
.chat-input, .input-area input, .input-area textarea {
  background: rgba(3, 7, 18, 0.8) !important;
  border: 1px solid var(--premium-border-default) !important;
  border-radius: var(--premium-radius-xl) !important;
  backdrop-filter: blur(8px) !important;
}

.chat-input:focus, .input-area input:focus, .input-area textarea:focus {
  border-color: var(--premium-accent-primary) !important;
  box-shadow: 0 0 0 2px var(--premium-accent-glow) !important;
}

/* ==========================================================================
   9. SCROLLBAR PREMIUM
   ========================================================================== */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--premium-text-muted);
  border-radius: var(--premium-radius-full);
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--premium-text-tertiary);
}

/* ==========================================================================
   10. TYPOGRAPHY — Headings com serifa
   ========================================================================== */
h1, h2, h3, h4, h5, .heading-premium {
  font-family: var(--premium-font-serif) !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
}

h1, h2 {
  font-size: 1.5rem !important;
  line-height: 1.2 !important;
}

h3 {
  font-size: 1.125rem !important;
  line-height: 1.3 !important;
}

/* Serifa só pros títulos principais, subtítulos continuam sans-serif */
.subheading-premium {
  font-family: var(--premium-font-sans) !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em !important;
}

/* ==========================================================================
   11. TOAST / NOTIFICAÇÕES
   ========================================================================== */
.toast {
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  border: 1px solid var(--premium-border-default) !important;
  border-radius: var(--premium-radius-lg) !important;
  box-shadow: var(--premium-shadow-lg) !important;
}

/* ==========================================================================
   12. MODAL — Refinado
   ========================================================================== */
.modal-overlay, [class*="modal-overlay"] {
  background: rgba(0, 0, 0, 0.6) !important;
  backdrop-filter: blur(8px) !important;
}

.modal-content, [class*="modal-content"] {
  background: var(--premium-bg-secondary) !important;
  border: 1px solid var(--premium-border-default) !important;
  border-radius: var(--premium-radius-xl) !important;
  box-shadow: var(--premium-shadow-lg) !important;
}

/* ==========================================================================
   13. BRIDGE STATUS — Indicador de conexão
   ========================================================================== */
#bridge-status, [id*="status"] {
  padding: 12px 16px !important;
  border-top: 1px solid var(--premium-border-default) !important;
  background: rgba(0, 0, 0, 0.2) !important;
}

/* ==========================================================================
   14. MISC — Tags, badges, separadores
   ========================================================================== */
.badge-premium, .tag-premium, [class*="badge"], [class*="tag"] {
  background: var(--premium-accent-glow) !important;
  border: 1px solid var(--premium-border-light) !important;
  color: var(--premium-accent-primary) !important;
  border-radius: var(--premium-radius-full) !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  padding: 2px 10px !important;
  letter-spacing: 0.02em !important;
}

hr, [class*="separator"], .border-t {
  border-color: var(--premium-border-default) !important;
}

/* ==========================================================================
   15. GSAP / MICROINTERAÇÕES — Hover refinado em links
   ========================================================================== */
a {
  transition: var(--premium-transition) !important;
}

a:hover {
  color: var(--premium-accent-primary) !important;
}

/* ==========================================================================
   16. ANIMAÇÕES — Timing refinado
   ========================================================================== */
.anim-fade {
  animation: premiumFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

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

.anim-modal {
  animation: premiumSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes premiumSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.anim-slide {
  animation: premiumSlideIn 0.25s ease-out both;
}

@keyframes premiumSlideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Glow pulse para status dot */
.pulse-dot {
  animation: premiumPulse 2s ease-in-out infinite;
}

@keyframes premiumPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  50% { opacity: 0.4; box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
}

/* ==========================================================================
   17. LOGIN PAGE — Luxo absoluto
   ========================================================================== */
body.login-page {
  background: var(--premium-bg-primary) !important;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Gradiente ambiente animado */
body.login-page::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(245, 158, 11, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.04) 0%, transparent 40%);
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.login-card {
  background: rgba(13, 18, 37, 0.7);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid rgba(55, 65, 81, 0.2);
  border-radius: 20px;
  padding: 40px 32px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(99, 102, 241, 0.05);
}

.login-icon {
  width: 56px;
  height: 56px;
  background: var(--premium-accent-gradient);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
}

.login-icon i {
  font-size: 22px;
  color: white;
}

.login-title {
  font-family: var(--premium-font-serif) !important;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--premium-text-primary);
  text-align: center;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 12px;
  color: var(--premium-text-tertiary);
  text-align: center;
  margin-bottom: 28px;
  letter-spacing: 0.03em;
}

.login-input {
  background: rgba(3, 7, 18, 0.6) !important;
  border: 1px solid rgba(55, 65, 81, 0.2) !important;
  border-radius: 12px !important;
  padding: 12px 16px !important;
  font-size: 14px !important;
  color: var(--premium-text-primary) !important;
  width: 100% !important;
  transition: var(--premium-transition) !important;
  backdrop-filter: blur(4px) !important;
}

.login-input:focus {
  border-color: var(--premium-accent-primary) !important;
  box-shadow: 0 0 0 3px var(--premium-accent-glow) !important;
}

.login-input::placeholder {
  color: var(--premium-text-muted) !important;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--premium-accent-gradient);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--premium-transition);
  position: relative;
  overflow: hidden;
}

.login-btn:hover {
  background: var(--premium-accent-gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  color: var(--premium-error);
  font-size: 12px;
  text-align: center;
  margin-top: 12px;
  display: none;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 10px;
  color: var(--premium-text-muted);
  letter-spacing: 0.04em;
}

/* ==========================================================================
   18. SKILL CARDS — refinamento
   ========================================================================== */
.skill-card {
  transition: var(--premium-transition) !important;
  border-radius: var(--premium-radius-md) !important;
}

.skill-card:hover {
  border-color: var(--premium-border-accent) !important;
  background: rgba(99, 102, 241, 0.04) !important;
}

.skill-card.active {
  border-color: var(--premium-accent-primary) !important;
  background: rgba(99, 102, 241, 0.06) !important;
}

/* ==========================================================================
   19. CONVERSATION ITEMS
   ========================================================================== */
.conv-item {
  transition: var(--premium-transition) !important;
  border-radius: var(--premium-radius-sm) !important;
}

.conv-item:hover {
  background: rgba(99, 102, 241, 0.04) !important;
}

.conv-item.active {
  background: rgba(99, 102, 241, 0.08) !important;
  border-left: 2px solid var(--premium-accent-primary) !important;
}

/* ==========================================================================
   20. TYPOGRAPHY HELPERS
   ========================================================================== */
.text-premium-muted { color: var(--premium-text-muted) !important; }
.text-premium-secondary { color: var(--premium-text-secondary) !important; }
.text-premium-accent { color: var(--premium-accent-primary) !important; }
.text-premium-gold { color: var(--premium-gold) !important; }
.bg-premium-accent-subtle { background: rgba(99, 102, 241, 0.06) !important; }
.border-premium-accent { border-color: var(--premium-accent-primary) !important; }
.border-premium-subtle { border-color: var(--premium-border-default) !important; }

/* ==========================================================================
   21. RESPONSIVIDADE — Design System Adaptável (Mobile-First)
   ========================================================================== */

/* --- Sidebar Drawer (Mobile) --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 40;
}

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

@media (max-width: 1023px) {
  aside, .sidebar, .sidebar-drawer {
    position: fixed !important;
    top: 0;
    left: -100%;
    width: 280px !important;
    max-width: 80vw !important;
    height: 100vh !important;
    z-index: 50;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-right: 1px solid var(--premium-border-default) !important;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.4);
  }

  .sidebar.open, .sidebar-drawer.open, aside.open {
    left: 0 !important;
  }

  /* Hamburger button */
  .hamburger-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid var(--premium-border-light);
    border-radius: var(--premium-radius-md);
    color: var(--premium-text-secondary);
    cursor: pointer;
    transition: var(--premium-transition);
    flex-shrink: 0;
  }

  .hamburger-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--premium-accent-primary);
    border-color: var(--premium-border-accent);
  }

  /* Main content full width when sidebar is drawer */
  body.sidebar-drawer-active .app-layout > .flex-1,
  body.sidebar-drawer-active .main-area,
  body.sidebar-drawer-active main:not(.login-page) {
    margin-left: 0 !important;
    width: 100% !important;
  }
}

@media (min-width: 1024px) {
  .hamburger-btn {
    display: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
}

/* --- Mobile: Tablet (640-1023px) --- */
@media (max-width: 1023px) {
  /* Grids: força 2 colunas no máximo */
  .grid-cols-1.lg\:grid-cols-2,
  .grid-cols-1.lg\:grid-cols-2.xl\:grid-cols-3,
  [class*="grid-cols-1"][class*="lg:grid-cols-"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Modal: full-width mobile */
  .modal-content, [class*="modal-content"],
  #agent-modal > div:first-child,
  #personality-modal > div:first-child,
  #kb-modal > div:first-child,
  #product-modal > div:first-child,
  #lead-modal > div:first-child,
  #move-lead-modal > div:first-child,
  #doc-link-modal > div:first-child,
  #kb-link-modal > div:first-child,
  #pers-link-modal > div:first-child,
  #doc-view-modal > div:first-child,
  #drive-config-modal > div:first-child,
  #rename-modal > div:first-child {
    max-width: 95vw !important;
    margin: 0 auto;
  }

  /* Modal grid: single column on tablet */
  #agent-modal .grid.grid-cols-2,
  #personality-modal .grid.grid-cols-2,
  #product-modal .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
  }

  /* Pipeline Kanban horizontal scroll */
  #pipeline-kanban {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  #pipeline-kanban > div {
    min-width: 260px !important;
    flex-shrink: 0;
  }

  /* Chat: sidebar full width */
  #tab-chat > .flex.gap-4 {
    flex-direction: column !important;
  }

  #tab-chat > .flex.gap-4 > div:first-child {
    width: 100% !important;
    max-height: 180px;
  }

  /* Chat messages full width on mobile */
  .msg-hermes, .msg-user,
  [class*="msg-"]:not(.msg-hermes .msg- *) {
    max-width: 90% !important;
  }

  /* WhatsApp: full width elements */
  #tab-whatsapp .max-w-2xl {
    max-width: 100% !important;
  }

  /* Analytics chart responsive */
  #analytics-chart {
    height: 180px !important;
  }

  /* Header padding reduzido */
  .app-header {
    padding: 0 12px !important;
  }

  /* Main padding reduzido */
  main:not(.login-page) {
    padding: 16px !important;
  }

  /* Filters empilhados */
  #tab-agendamentos > .flex.justify-between,
  #tab-documentos > .flex.justify-between:first-child,
  #tab-vendas > .flex.items-center.justify-between {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  #tab-agendamentos > .flex.justify-between > div:first-child,
  #tab-documentos > .flex.justify-between:first-child > div:first-child {
    margin-bottom: 0 !important;
  }

  /* Filter selects empilhados */
  #tab-agendamentos .flex.gap-2,
  #tab-documentos .flex.gap-3,
  #tab-vendas .flex.gap-3.mb-4 {
    flex-wrap: wrap !important;
  }

  #tab-agendamentos .flex.gap-2 select,
  #tab-documentos .flex.gap-3 select,
  #tab-documentos .flex.gap-3 input,
  #tab-vendas .flex.gap-3.mb-4 select,
  #tab-vendas .flex.gap-3.mb-4 input {
    width: 100% !important;
    flex: 1 1 auto;
  }

  /* KPI grid: 2 columns on tablet */
  #analytics-kpis {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* Agendamentos header empilhado */
  #tab-agendamentos > .flex.justify-between {
    flex-direction: column !important;
    gap: 12px !important;
  }

  /* Espaçamento do header mobile */
  #tab-agendamentos > .flex.justify-between .flex.gap-2 {
    width: 100% !important;
  }

  /* Tabelas com scroll horizontal */
  .overflow-x-auto table {
    min-width: 500px;
  }

  /* Toast centralizado */
  .toast {
    right: 16px !important;
    left: 16px !important;
    bottom: 16px !important;
    max-width: none !important;
  }

  /* Vendas subtabs wrap */
  #tab-vendas .flex.gap-2.mb-5 {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  #tab-vendas .flex.gap-2.mb-5 button {
    flex: 1 1 auto;
    text-align: center;
    font-size: 11px !important;
    padding: 8px 12px !important;
  }

  /* Modal padding reduzido */
  #agent-modal .p-6,
  #personality-modal .p-6,
  #kb-modal .p-6,
  #product-modal .p-6 {
    padding: 16px !important;
  }

  /* Modal section sticky fix */
  #agent-modal .sticky,
  #personality-modal .sticky,
  #product-modal .sticky {
    padding: 16px !important;
  }

  /* Product modal header flexível */
  #tab-vendas .flex.items-center.justify-between.mb-4 {
    flex-direction: column !important;
    gap: 10px !important;
    align-items: stretch !important;
  }

  /* Sub-navigation vendas */
  #tab-vendas .flex.gap-2.mb-5.border-b {
    gap: 6px !important;
  }

  #tab-vendas .flex.gap-2.mb-5.border-b button {
    padding: 8px 14px !important;
    font-size: 11px !important;
  }

  /* Table wrapper auto-scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
  }

  /* Agendamentos action buttons */
  #tab-agendamentos .flex.items-start.justify-between.mb-3 {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  #tab-agendamentos .flex.items-start.justify-between.mb-3 > div:last-child {
    width: 100% !important;
    display: flex !important;
    gap: 6px !important;
  }

  #tab-agendamentos .flex.items-start.justify-between.mb-3 > div:last-child button {
    flex: 1 !important;
    font-size: 10px !important;
    padding: 6px 10px !important;
  }
}

/* --- Mobile: Smartphone (< 640px) --- */
@media (max-width: 639px) {
  /* Grid: single column */
  .grid-cols-1.lg\:grid-cols-2,
  .grid-cols-1.lg\:grid-cols-2.xl\:grid-cols-3,
  [class*="grid-cols-1"][class*="lg:grid-cols-"],
  #agents-grid,
  #products-grid,
  #knowledge-bases-grid,
  #personalities-grid,
  #analytics-kpis {
    grid-template-columns: 1fr !important;
  }

  #analytics-kpis {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Header: reduce font size */
  .app-header h2 {
    font-size: 10px !important;
  }

  /* Main padding minimal */
  main:not(.login-page) {
    padding: 12px !important;
  }

  /* Buttons compactos */
  button:not(.tab-btn):not(.conv-item):not(.skill-card):not(.toast button):not(.hamburger-btn) {
    font-size: 11px !important;
    padding: 8px 14px !important;
  }

  /* Chat web full height */
  #tab-chat > .flex.gap-4 {
    height: calc(100vh - 8rem) !important;
  }

  #tab-chat .h-\[calc\(100vh-10rem\)\] {
    height: auto !important;
  }

  /* Chat messages max-width */
  .msg-hermes, .msg-user {
    max-width: 95% !important;
  }

  /* Modals full screen */
  #agent-modal,
  #personality-modal,
  #product-modal,
  #kb-modal,
  #lead-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  #agent-modal > div,
  #personality-modal > div,
  #product-modal > div,
  #lead-modal > div {
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 90vh !important;
    margin-top: auto;
  }

  /* Modal animation for bottom sheet */
  #agent-modal > div,
  #personality-modal > div,
  #product-modal > div,
  #lead-modal > div {
    animation: premiumSlideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  /* Login: padding extra small */
  .login-card {
    padding: 24px 16px !important;
  }

  .login-container {
    padding: 16px !important;
  }

  /* Toast full width */
  .toast {
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    font-size: 12px !important;
    padding: 12px 16px !important;
  }
}

/* --- Tablet Portrait (640-1023px) fix para sidebar drawer --- */
@media (min-width: 640px) and (max-width: 1023px) {
  aside, .sidebar, .sidebar-drawer {
    width: 240px !important;
  }
}

/* --- Small Desktop (1024-1279px) --- */
@media (min-width: 1024px) and (max-width: 1279px) {
  .xl\:grid-cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  #agents-grid.xl\:grid-cols-3,
  #products-grid.xl\:grid-cols-3,
  #knowledge-bases-grid.xl\:grid-cols-3,
  #personalities-grid.xl\:grid-cols-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  main:not(.login-page) {
    padding: 20px !important;
  }
}

/* ==========================================================================
   22. CLIENT OPS — Conversas (inbox) + Pedidos (kitchen board)
   Premium product surfaces for paying clients only
   ========================================================================== */

.ops-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100vh - 8.5rem);
}

.ops-panel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.ops-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--premium-gold-light);
  margin-bottom: 6px;
}

.ops-title {
  font-family: var(--premium-font-serif);
  font-size: 1.65rem;
  font-weight: 500;
  color: var(--premium-text-primary);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.ops-subtitle {
  margin-top: 6px;
  font-size: 12px;
  color: var(--premium-text-tertiary);
  max-width: 52ch;
  line-height: 1.5;
}

.ops-subtitle em {
  color: var(--premium-text-secondary);
  font-style: normal;
  font-weight: 500;
}

.ops-panel__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ops-search {
  position: relative;
  min-width: min(280px, 70vw);
}

.ops-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--premium-text-muted);
  font-size: 12px;
  pointer-events: none;
}

.ops-search input {
  width: 100%;
  background: rgba(8, 12, 24, 0.85);
  border: 1px solid var(--premium-border-default);
  border-radius: 12px;
  color: var(--premium-text-primary);
  font-size: 13px;
  padding: 11px 14px 11px 34px;
  outline: none;
  transition: var(--premium-transition);
}

.ops-search input:focus {
  border-color: var(--premium-border-accent);
  box-shadow: 0 0 0 3px var(--premium-accent-glow);
}

.ops-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--premium-transition);
}

.ops-btn--ghost {
  background: rgba(13, 18, 37, 0.7);
  border-color: var(--premium-border-default);
  color: var(--premium-text-secondary);
}

.ops-btn--ghost:hover {
  border-color: var(--premium-border-accent);
  color: var(--premium-text-primary);
  box-shadow: var(--premium-shadow-glow);
}

.ops-select-wrap,
.ops-order-card__status {
  display: block;
}

.ops-select {
  appearance: none;
  background: rgba(8, 12, 24, 0.9) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 6l3.5 4 3.5-4'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--premium-border-default);
  border-radius: 12px;
  color: var(--premium-text-primary);
  font-size: 12px;
  padding: 10px 34px 10px 12px;
  min-width: 150px;
  outline: none;
  transition: var(--premium-transition);
}

.ops-select:focus {
  border-color: var(--premium-border-accent);
  box-shadow: 0 0 0 3px var(--premium-accent-glow);
}

/* Inbox layout */
.ops-inbox__layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 14px;
  min-height: calc(100vh - 14rem);
  height: calc(100vh - 14rem);
}

.ops-inbox__list-pane,
.ops-inbox__thread-pane {
  background: var(--premium-bg-glass);
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
  border: 1px solid var(--premium-border-default);
  border-radius: 18px;
  box-shadow: var(--premium-shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ops-inbox__list-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--premium-border-default);
}

.ops-inbox__list-meta > span {
  font-size: 11px;
  color: var(--premium-text-tertiary);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ops-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ops-chip {
  border: 1px solid var(--premium-border-default);
  background: rgba(8, 12, 24, 0.55);
  color: var(--premium-text-tertiary);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  transition: var(--premium-transition);
}

.ops-chip:hover {
  color: var(--premium-text-secondary);
  border-color: rgba(99, 102, 241, 0.35);
}

.ops-chip.is-active {
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.45);
  background: rgba(99, 102, 241, 0.14);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.12);
}

.ops-inbox__list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ops-conv-card {
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  text-align: left;
  border: 1px solid transparent;
  background: rgba(8, 12, 24, 0.35);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: var(--premium-transition);
  color: inherit;
}

.ops-conv-card:hover {
  border-color: rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.06);
  transform: translateY(-1px);
}

.ops-conv-card.is-active {
  border-color: rgba(99, 102, 241, 0.45);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(13, 18, 37, 0.55));
  box-shadow: var(--premium-shadow-glow);
}

.ops-conv-card__avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ops-conv-card__avatar.is-wa {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}

.ops-conv-card__avatar.is-web {
  background: rgba(99, 102, 241, 0.14);
  color: #a5b4fc;
}

.ops-conv-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ops-conv-card__title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--premium-text-primary);
  line-height: 1.35;
}

.ops-conv-card__top time {
  font-size: 10px;
  color: var(--premium-text-muted);
  white-space: nowrap;
  margin-top: 2px;
}

.ops-conv-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  font-size: 10px;
  color: var(--premium-text-muted);
}

.ops-channel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

.ops-channel.is-wa { color: #6ee7b7; }
.ops-channel.is-web { color: #a5b4fc; }

.ops-conv-card__preview {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--premium-text-tertiary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ops-thread__header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--premium-border-default);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.06), transparent);
}

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

.ops-thread__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--premium-text-primary);
  line-height: 1.35;
}

.ops-thread__meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--premium-text-tertiary);
}

.ops-thread__messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(ellipse at top right, rgba(99, 102, 241, 0.05), transparent 45%),
    rgba(8, 12, 24, 0.25);
}

.ops-msg {
  display: flex;
  width: 100%;
}

.ops-msg.is-user { justify-content: flex-start; }
.ops-msg.is-assistant { justify-content: flex-end; }

.ops-msg__bubble {
  max-width: min(82%, 560px);
  border-radius: 16px;
  padding: 11px 13px;
  box-shadow: var(--premium-shadow-sm);
}

.ops-msg.is-user .ops-msg__bubble {
  background: rgba(30, 41, 59, 0.72);
  border: 1px solid rgba(71, 85, 105, 0.45);
  border-bottom-left-radius: 6px;
}

.ops-msg.is-assistant .ops-msg__bubble {
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.16), rgba(79, 70, 229, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-bottom-right-radius: 6px;
}

.ops-msg__meta {
  font-size: 10.5px;
  margin-bottom: 5px;
}

.ops-msg__who {
  font-weight: 700;
}

.ops-msg.is-user .ops-msg__who { color: #cbd5e1; }
.ops-msg.is-assistant .ops-msg__who { color: #a5b4fc; }

.ops-msg__time {
  color: var(--premium-text-muted);
}

.ops-msg__text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--premium-text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Kitchen / pedidos */
.ops-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.ops-kpi {
  background: var(--premium-bg-glass);
  border: 1px solid var(--premium-border-default);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--premium-shadow-sm);
}

.ops-kpi__label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--premium-text-muted);
  margin-bottom: 6px;
}

.ops-kpi strong {
  font-size: 1.35rem;
  font-weight: 650;
  color: var(--premium-text-primary);
}

.ops-kpi--amber strong { color: #fbbf24; }
.ops-kpi--indigo strong { color: #a5b4fc; }
.ops-kpi--emerald strong { color: #6ee7b7; }
.ops-kpi--slate strong { color: #cbd5e1; }

.ops-kitchen__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.ops-order-card {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.78), rgba(13, 18, 37, 0.72));
  border: 1px solid var(--premium-border-default);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--premium-shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--premium-transition);
  position: relative;
  overflow: hidden;
}

.ops-order-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.5), transparent);
  opacity: 0.7;
}

.ops-order-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: var(--premium-shadow-elevated);
}

.ops-order-card.status-novo::before { background: linear-gradient(90deg, transparent, #f59e0b, transparent); }
.ops-order-card.status-preparando::before { background: linear-gradient(90deg, transparent, #6366f1, transparent); }
.ops-order-card.status-pronto::before { background: linear-gradient(90deg, transparent, #10b981, transparent); }
.ops-order-card.status-entregue::before { background: linear-gradient(90deg, transparent, #94a3b8, transparent); }
.ops-order-card.status-cancelado::before { background: linear-gradient(90deg, transparent, #ef4444, transparent); }

.ops-order-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ops-order-card__head h4 {
  font-size: 14px;
  font-weight: 650;
  color: var(--premium-text-primary);
}

.ops-order-card__head p {
  margin-top: 4px;
  font-size: 11px;
  color: var(--premium-text-tertiary);
}

.ops-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  white-space: nowrap;
}

.ops-status--novo { background: rgba(245, 158, 11, 0.12); color: #fbbf24; border-color: rgba(245, 158, 11, 0.28); }
.ops-status--preparando { background: rgba(99, 102, 241, 0.12); color: #a5b4fc; border-color: rgba(99, 102, 241, 0.28); }
.ops-status--pronto { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.28); }
.ops-status--entregue { background: rgba(148, 163, 184, 0.12); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.25); }
.ops-status--cancelado { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.28); }

.ops-order-card__items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.ops-order-card__items li {
  font-size: 12.5px;
  color: var(--premium-text-secondary);
  line-height: 1.4;
}

.ops-order-card__items li.is-muted {
  color: var(--premium-text-muted);
}

.ops-order__qty {
  display: inline-block;
  min-width: 1.8em;
  color: var(--premium-text-primary);
  font-weight: 700;
}

.ops-order-card__addr {
  font-size: 11.5px;
  color: var(--premium-text-tertiary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}

.ops-order-card__addr i {
  color: #818cf8;
  margin-top: 2px;
}

.ops-order-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}

.ops-order-card__foot strong {
  color: #6ee7b7;
  font-size: 14px;
  font-weight: 700;
}

.ops-order-card__foot code {
  font-size: 10px;
  color: var(--premium-text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.ops-order-card__status span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--premium-text-muted);
  margin-bottom: 6px;
}

.ops-order-card__status .ops-select {
  width: 100%;
}

/* Empty states */
.ops-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 36px 18px;
  color: var(--premium-text-tertiary);
  min-height: 180px;
}

.ops-empty--thread,
.ops-empty--wide {
  min-height: 280px;
}

.ops-empty__icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  margin-bottom: 4px;
}

.ops-empty p {
  font-size: 13px;
  font-weight: 600;
  color: var(--premium-text-secondary);
}

.ops-empty span {
  font-size: 11.5px;
  color: var(--premium-text-muted);
  max-width: 34ch;
  line-height: 1.45;
}

.ops-error {
  color: #fca5a5 !important;
}

/* Responsive */
@media (max-width: 1100px) {
  .ops-kitchen__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ops-kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .ops-inbox__layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .ops-inbox__list-pane {
    max-height: 42vh;
  }
  .ops-inbox__thread-pane {
    min-height: 48vh;
  }
  .ops-kitchen__grid {
    grid-template-columns: 1fr;
  }
  .ops-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ops-title {
    font-size: 1.4rem;
  }
  .ops-panel {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .ops-panel__header {
    align-items: stretch;
  }
  .ops-panel__actions {
    width: 100%;
  }
  .ops-search {
    min-width: 0;
    flex: 1;
  }
  .ops-btn span {
    display: none;
  }
  .ops-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ops-msg__bubble {
    max-width: 92%;
  }
}

/* Final conversation toolbar safety: never clip actions at any viewport */
.ops-inbox .ops-panel__header,
.ops-kitchen .ops-panel__header {
  width: 100%;
  min-width: 0;
  overflow: visible;
}
.ops-inbox .ops-panel__heading,
.ops-kitchen .ops-panel__heading {
  min-width: 0;
  flex: 1 1 340px;
}
.ops-inbox .ops-panel__actions,
.ops-kitchen .ops-panel__actions {
  flex: 0 1 auto;
  min-width: 0;
  overflow: visible;
  padding: 2px;
}
.ops-inbox .ops-search input,
.ops-kitchen .ops-select,
.ops-inbox .ops-btn,
.ops-kitchen .ops-btn {
  min-height: 40px;
}
@media (max-width: 760px) {
  .ops-inbox .ops-panel__actions,
  .ops-kitchen .ops-panel__actions {
    flex: 1 1 100%;
    justify-content: stretch;
  }
  .ops-inbox .ops-search {
    flex: 1 1 auto;
    width: auto;
  }
  .ops-kitchen .ops-select-wrap,
  .ops-kitchen .ops-select {
    flex: 1 1 auto;
    width: 100%;
  }
  .ops-kitchen .ops-btn,
  .ops-inbox .ops-btn {
    flex: 0 0 auto;
  }
}

/* Client conversations: preserve normal flow and remove mobile clipping. */
.ops-panel__header {
  height: auto !important;
  min-height: 0;
  padding: 0 !important;
  position: static;
  overflow: visible !important;
  z-index: auto;
}
.ops-panel__heading,
.ops-panel__actions,
.ops-inbox__layout,
.ops-inbox__list-pane,
.ops-inbox__thread-pane,
.ops-thread__header,
.ops-thread__messages {
  min-width: 0;
}
.ops-panel__heading,
.ops-title,
.ops-subtitle,
.ops-thread__title,
.ops-thread__meta,
.ops-empty span {
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .ops-inbox__layout {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    gap: 12px;
  }
  .ops-inbox__list-pane,
  .ops-inbox__thread-pane {
    width: 100%;
    max-width: 100%;
  }
  .ops-inbox__list-pane { max-height: none; }
  .ops-inbox__list { max-height: 32vh; }
  .ops-inbox__thread-pane { min-height: 420px; }
}

@media (max-width: 640px) {
  .app-header { height: 52px !important; padding: 0 12px !important; }
  main:not(.login-page) { padding: 14px !important; min-width: 0; overflow-x: hidden; }
  .ops-panel { width: 100%; min-width: 0; gap: 12px; }
  .ops-panel__header { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .ops-panel__heading { width: 100%; flex: none; }
  .ops-title { font-size: 1.65rem; line-height: 1.1; }
  .ops-subtitle { max-width: 100%; margin-top: 8px; font-size: 12px; line-height: 1.5; }
  .ops-panel__actions { display: grid; grid-template-columns: minmax(0, 1fr) 44px; width: 100%; gap: 8px; padding: 0; }
  .ops-search { width: 100%; min-width: 0; }
  .ops-search input, .ops-btn, .ops-inbox .ops-btn { min-height: 44px; }
  .ops-inbox .ops-btn { width: 44px; justify-content: center; padding: 0; }
  .ops-inbox .ops-btn span { display: none; }
  .ops-inbox__list-meta { padding: 12px; }
  .ops-chip { min-height: 34px; padding: 7px 9px; }
  .ops-inbox__list { max-height: 36vh; padding: 8px; }
  .ops-inbox__thread-pane { min-height: 360px; border-radius: 14px; }
  .ops-thread__header { padding: 13px 14px; }
  .ops-thread__messages { min-height: 270px; padding: 16px 12px; }
  .ops-empty--thread { min-height: 240px; }
  .ops-empty span { max-width: 26ch; }
}

/* Elite IA Pro bridge: shared brand layer for the application shell.
   Behavior and semantic states remain in the existing rules above. */
:root {
  --premium-bg-primary: var(--elite-color-bg);
  --premium-bg-secondary: var(--elite-color-bg-soft);
  --premium-bg-tertiary: var(--elite-color-surface-elevated);
  --premium-bg-card: var(--elite-color-surface);
  --premium-bg-glass: rgba(10, 20, 27, 0.72);
  --premium-bg-elevated: rgba(16, 29, 37, 0.72);
  --premium-border-default: var(--elite-color-line);
  --premium-border-light: rgba(210, 174, 103, 0.28);
  --premium-border-accent: rgba(70, 201, 230, 0.45);
  --premium-text-primary: var(--elite-color-text);
  --premium-text-secondary: var(--elite-color-text-soft);
  --premium-text-tertiary: var(--elite-color-text-muted);
  --premium-accent-primary: var(--elite-color-blue);
  --premium-accent-secondary: var(--elite-color-blue-deep);
  --premium-accent-glow: rgba(70, 201, 230, 0.2);
  --premium-accent-gradient: linear-gradient(135deg, var(--elite-color-champagne-light), var(--elite-color-champagne));
  --premium-accent-gradient-hover: linear-gradient(135deg, #f1dda4, var(--elite-color-champagne));
  --premium-gold: var(--elite-color-champagne);
  --premium-gold-light: var(--elite-color-champagne-light);
  --premium-radius-sm: var(--elite-radius-sm);
  --premium-radius-md: var(--elite-radius-md);
  --premium-radius-lg: var(--elite-radius-lg);
  --premium-radius-xl: var(--elite-radius-xl);
  --premium-font-sans: var(--elite-font-sans);
  --premium-font-serif: var(--elite-font-display);
}

body { background: var(--elite-color-bg) !important; color: var(--elite-color-text) !important; }
.app-header { background: rgba(3, 7, 11, 0.78) !important; border-color: var(--elite-color-line) !important; }
aside, .sidebar { background: linear-gradient(180deg, rgba(7, 16, 25, 0.96), rgba(3, 7, 11, 0.98)) !important; }
aside .fa-crown, .sidebar .fa-crown { color: var(--elite-color-champagne-light) !important; filter: drop-shadow(0 0 8px rgba(210, 174, 103, 0.26)); }
.tab-btn.active { background: rgba(70, 201, 230, 0.1) !important; color: var(--elite-color-champagne-light) !important; border-left-color: var(--elite-color-champagne) !important; }
.tab-btn:not(.active):hover { background: rgba(70, 201, 230, 0.07) !important; color: var(--elite-color-text) !important; }
button:not(.tab-btn):not(.conv-item):not(.skill-card):not(.toast button):not(.bg-emerald-600):not(.bg-red-600) { background: var(--premium-accent-gradient) !important; color: #171108 !important; }
button:not(.tab-btn):not(.conv-item):not(.skill-card):not(.toast button):not(.bg-emerald-600):not(.bg-red-600):hover { background: var(--premium-accent-gradient-hover) !important; }
button.bg-emerald-600, button.bg-emerald-500 { background: #12805e !important; color: #fff !important; }
button.bg-red-600, button.bg-red-700 { background: #a33d46 !important; color: #fff !important; }
.form-input, .form-select, input, select, textarea { border-color: var(--elite-color-line) !important; }
.form-input:focus, .form-select:focus, input:focus, select:focus, textarea:focus { border-color: var(--elite-color-blue) !important; box-shadow: var(--elite-shadow-focus) !important; }

/* Elite IA Pro — agents workspace layer (visual-only). */
#tab-agents > section:first-child {
  border-color: rgba(210, 174, 103, 0.25) !important;
  background:
    radial-gradient(circle at top left, rgba(70, 201, 230, 0.14), transparent 38%),
    radial-gradient(circle at top right, rgba(210, 174, 103, 0.10), transparent 34%),
    linear-gradient(180deg, rgba(10, 20, 27, 0.96), rgba(3, 7, 11, 0.98)) !important;
  border-radius: var(--elite-radius-xl) !important;
}
#tab-agents > section:first-child .inline-flex {
  border-color: rgba(210, 174, 103, 0.30) !important;
  background: rgba(210, 174, 103, 0.08) !important;
  color: var(--elite-color-champagne-light) !important;
}
#tab-agents > section:first-child h3 { font-family: var(--elite-font-display) !important; }
#tab-agents > section:first-child .text-indigo-300,
#tab-agents > section:first-child .text-indigo-200\/90 { color: var(--elite-color-blue) !important; }
#tab-agents > section:first-child .text-amber-300 { color: var(--elite-color-champagne-light) !important; }
#tab-agents > section:first-child .border-indigo-500\/15 { border-color: rgba(210, 174, 103, 0.25) !important; }
#tab-agents > section:first-child button:first-child {
  background: rgba(255, 255, 255, 0.04) !important;
  color: var(--elite-color-text) !important;
  border-color: var(--elite-color-line) !important;
}
#tab-agents > section:first-child button:first-child:hover { background: rgba(70, 201, 230, 0.08) !important; }
#tab-agents > section:first-child button:first-child i { color: var(--elite-color-blue) !important; }
#tab-agents > section:first-child button[data-admin-only] { color: #171108 !important; }
#factory-kpis > *, #factory-health-grid > *, #factory-top-agents > *, #factory-appointment-breakdown > * {
  border-color: var(--elite-color-line) !important;
}
#tab-agents .bg-gray-900\/35,
#tab-agents .bg-gray-900\/30,
#tab-agents .bg-gray-900\/20 {
  background: rgba(10, 20, 27, 0.62) !important;
  border-color: var(--elite-color-line) !important;
}
#tab-agents .text-indigo-400, #tab-agents .text-indigo-300 { color: var(--elite-color-blue) !important; }
#tab-agents .text-amber-300 { color: var(--elite-color-champagne-light) !important; }
#tab-agents .border-emerald-500\/20 { border-color: rgba(72, 217, 154, 0.28) !important; }
#tab-agents .text-emerald-300 { color: var(--elite-color-green) !important; }
#agents-grid > * { border-color: var(--elite-color-line) !important; }
#agents-grid > *:hover { border-color: rgba(210, 174, 103, 0.36) !important; }

@media (max-width: 640px) {
  #tab-agents > section:first-child { border-radius: var(--elite-radius-lg) !important; padding: 20px !important; }
  #tab-agents > section:first-child h3 { font-size: 1.75rem !important; }
  #tab-agents > section:first-child button { width: 100%; }
}

/* Agents Elite IA Pro — Chat Web, WhatsApp e modais. */
#tab-chat > div:first-child { gap: 16px !important; }
#tab-chat > div:first-child > div,
#tab-whatsapp .bg-gray-900\/30,
#tab-whatsapp .bg-gray-900\/20 {
  background: rgba(10, 20, 27, 0.68) !important;
  border-color: var(--elite-color-line) !important;
  border-radius: var(--elite-radius-lg) !important;
}
#tab-chat #chat-messages { background: radial-gradient(circle at 50% 0, rgba(70, 201, 230, 0.045), transparent 42%); }
#tab-chat .fa-comment-dots { color: rgba(70, 201, 230, 0.5) !important; }
#tab-chat #chat-send-btn { background: var(--premium-accent-gradient) !important; color: #171108 !important; min-width: 44px; }
#tab-chat #chat-send-btn:disabled { opacity: .45; filter: saturate(.55); }
#tab-chat .border-t { border-color: var(--elite-color-line) !important; }
#tab-chat .text-indigo-400, #tab-chat .text-indigo-300 { color: var(--elite-color-blue) !important; }
#tab-whatsapp h3 { font-family: var(--elite-font-display) !important; color: var(--elite-color-text) !important; }
#tab-whatsapp .text-emerald-400, #tab-whatsapp .text-emerald-300 { color: var(--elite-color-green) !important; }
#tab-whatsapp #wa-connect-btn { background: #12805e !important; color: #fff !important; }
#tab-whatsapp #wa-disconnect-btn { background: rgba(163, 61, 70, .13) !important; border-color: rgba(245, 143, 143, .32) !important; color: var(--elite-color-danger) !important; }
#tab-whatsapp #wa-status-card { border-color: rgba(72, 217, 154, .22) !important; }
#tab-whatsapp #wa-qr-container { border: 1px solid rgba(210, 174, 103, .25) !important; }

/* Global modal treatment: preserves IDs, forms and actions. */
#agent-modal > div:first-child, #product-modal > div:first-child, #lead-modal > div:first-child,
#kb-modal > div:first-child, #personality-modal > div:first-child, #user-modal > div:first-child,
#google-drive-modal > div:first-child {
  background: linear-gradient(180deg, rgba(10, 20, 27, .98), rgba(3, 7, 11, .99)) !important;
  border-color: rgba(210, 174, 103, .24) !important;
  border-radius: var(--elite-radius-lg) !important;
}
#agent-modal .sticky, #product-modal .sticky, #lead-modal .sticky,
#kb-modal .sticky, #personality-modal .sticky, #user-modal .sticky,
#google-drive-modal .sticky { background: rgba(10, 20, 27, .96) !important; border-color: var(--elite-color-line) !important; }
.modal-section-title { color: var(--elite-color-champagne-light) !important; }
.modal-section-title i { color: var(--elite-color-blue) !important; }
#agent-modal .text-indigo-400, #agent-modal .text-indigo-300, #product-modal .text-indigo-400, #lead-modal .text-indigo-400 { color: var(--elite-color-blue) !important; }
#agent-modal .text-amber-400, #agent-modal .text-amber-300 { color: var(--elite-color-champagne-light) !important; }
#agent-modal .text-emerald-400, #agent-modal .text-emerald-300 { color: var(--elite-color-green) !important; }

@media (max-width: 1023px) {
  #tab-chat > div:first-child { height: auto !important; min-height: 0; flex-direction: column; }
  #tab-chat > div:first-child > div:first-child { width: 100% !important; flex: none; }
  #tab-chat > div:first-child > div:last-child { min-height: 520px; }
}
@media (max-width: 640px) {
  #tab-chat > div:first-child > div:last-child { min-height: 440px; }
  #tab-whatsapp .flex.items-end { flex-direction: column; align-items: stretch; }
  #tab-whatsapp .flex.items-end > * { width: 100%; }
  #tab-whatsapp #wa-connect-btn, #tab-whatsapp #wa-disconnect-btn { justify-content: center; }
  #agent-modal > div:first-child, #product-modal > div:first-child, #lead-modal > div:first-child, #kb-modal > div:first-child, #personality-modal > div:first-child, #user-modal > div:first-child, #google-drive-modal > div:first-child { border-radius: var(--elite-radius-lg) var(--elite-radius-lg) 0 0 !important; }
}

