/* ==========================================================================
   COMPONENTES CORPORATIVOS & INTERATIVOS
   ========================================================================== */

/* --- KPI CARDS --- */
.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
}

.kpi-card.emerald::before { background: linear-gradient(90deg, #059669, #10b981); }
.kpi-card.cyan::before { background: linear-gradient(90deg, #0891b2, #06b6d4); }
.kpi-card.amber::before { background: linear-gradient(90deg, #d97706, #f59e0b); }
.kpi-card.purple::before { background: linear-gradient(90deg, #7c3aed, #8b5cf6); }
.kpi-card.rose::before { background: linear-gradient(90deg, #e11d48, #f43f5e); }

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

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

.kpi-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-light);
  line-height: 1.15;
  margin-bottom: 0.35rem;
  letter-spacing: -0.02em;
}

.kpi-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.kpi-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
}

.badge-emerald { background: var(--accent-emerald-glow); color: var(--accent-emerald); }
.badge-amber { background: var(--accent-amber-glow); color: var(--accent-amber); }
.badge-cyan { background: var(--accent-cyan-glow); color: var(--accent-cyan); }
.badge-rose { background: var(--accent-rose-glow); color: var(--accent-rose); }

/* --- CARDS DE SEÇÃO / PAINEIS --- */
.section-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  position: relative;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

/* --- TABELAS CORPORATIVAS MODERNAS --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

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

.data-table th {
  background: var(--bg-table-header);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-table);
  color: var(--text-main);
  transition: background var(--transition-fast);
}

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

.data-table tbody tr.clickable {
  cursor: pointer;
}

.data-table tbody tr.clickable:hover {
  background: rgba(16, 185, 129, 0.08);
}

.data-table tbody tr.clickable:hover td:first-child {
  color: var(--accent-emerald);
  font-weight: 600;
}

.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }
.data-table .font-mono { font-family: var(--font-mono); }

.data-table tfoot td {
  background: var(--bg-table-striped);
  font-weight: 700;
  color: var(--text-light);
  border-top: 1px solid var(--border-subtle);
  border-bottom: none;
}

/* Indicador de clique na linha para abrir detalhamento */
.row-drilldown-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--accent-emerald);
  opacity: 0.7;
}

tr:hover .row-drilldown-hint {
  opacity: 1;
}

/* --- MOENDAS E STATUS INDUSTRIAL --- */
.moenda-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.moenda-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  position: relative;
  overflow: hidden;
}

.moenda-card.rodando {
  border-left: 4px solid var(--accent-emerald);
}

.moenda-card.parada {
  border-left: 4px solid var(--accent-rose);
}

.moenda-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
}

.moenda-status-badge.rodando {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.moenda-status-badge.parada {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.moenda-gauge-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
}

.moenda-gauge-val {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-light);
}

.moenda-gauge-lbl {
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* --- HORÁRIO / TIMELINE BAR CHART --- */
.timeline-scroll {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.timeline-hour-card {
  flex: 0 0 74px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.35rem;
  text-align: center;
  transition: all var(--transition-fast);
}

.timeline-hour-card.active {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.timeline-hour-card.future {
  opacity: 0.4;
}

.timeline-hour-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.timeline-hour-bar-container {
  height: 48px;
  width: 14px;
  margin: 0.25rem auto;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  position: relative;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.timeline-hour-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, #34d399, #059669);
  border-radius: var(--radius-full);
  transition: height 0.5s ease;
}

.timeline-hour-val {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-light);
}

.timeline-hour-viagens {
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* --- SLIDE-OVER DRAWER (SUBSTITUIÇÃO DOS IFRAMES) --- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 780px;
  background: #0f172a;
  border-left: 1px solid var(--border-subtle);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.7);
  z-index: 210;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.drawer-overlay.open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.15rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-light);
}

.drawer-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.drawer-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.drawer-close:hover {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.4);
}

.drawer-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.drawer-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.5rem;
}

.drawer-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.drawer-tab-btn.active {
  background: var(--accent-emerald-glow);
  color: #34d399;
}

/* --- MODAL --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.8);
  transform: scale(0.95);
  transition: transform 0.25s ease;
  overflow: hidden;
}

.modal-overlay.open .modal-content {
  transform: scale(1);
}

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

.modal-body {
  padding: 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
}

/* --- ESTILOS ESPECÍFICOS DO PAINEL AGRÍCOLA & TABELAS DE SAFRA --- */
.agricola-dashboard-layout {
  display: grid;
  grid-template-columns: 46% 54%;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
  .agricola-dashboard-layout {
    grid-template-columns: 1fr;
  }
}

.mapa-header-banner {
  background: linear-gradient(135deg, rgba(8, 145, 178, 0.25) 0%, rgba(16, 185, 129, 0.2) 100%);
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.mapa-header-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Linha de Destaque Safra (Amarelo / Ouro) */
.data-table tbody tr.row-safra {
  background: var(--bg-row-safra) !important;
  font-weight: 700;
  border-left: 3px solid var(--border-row-safra);
}

.data-table tbody tr.row-safra td {
  color: var(--text-row-safra) !important;
  font-weight: 700;
}

/* Linha Selecionada pelo Usuário para Drilldown */
.data-table tbody tr.row-selected {
  background: rgba(16, 185, 129, 0.22) !important;
  border-left: 3px solid #10b981;
}

.data-table tbody tr.row-selected td:first-child {
  color: #34d399 !important;
  font-weight: 700;
}

/* Badges Sólidas do Screenshot */
.badge-solid-green {
  background: #059669;
  color: #ffffff;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  display: inline-block;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.badge-solid-yellow {
  background: #d97706;
  color: #ffffff;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* Mini Cards de Estimativa e TCH */
.kpi-mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-bottom: 0.85rem;
}

.kpi-mini-table th {
  background: var(--bg-table-header);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
}

.kpi-mini-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-table);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
}

/* Barra de Progresso de Variedade */
.prog-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-table-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.25rem;
}

.prog-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0891b2, #10b981);
  border-radius: var(--radius-full);
}

/* Seletor Customizado de Timer TV */
.custom-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-light);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
}

.custom-select:hover, .custom-select:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald-glow);
}

.custom-select option {
  background: var(--bg-surface);
  color: var(--text-main);
}

.timer-select-wrapper {
  display: flex;
  align-items: center;
  background: var(--bg-table-striped);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.15rem 0.5rem;
}

.badge-slate { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }

/* --- CONTROLE DE ACESSO POR DISPOSITIVO --- */
body.acesso-bloqueado { overflow: hidden; }
body.acesso-bloqueado .app-header,
body.acesso-bloqueado .main-content { visibility: hidden; }

.acesso-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  background: var(--bg-main);
}

.acesso-card {
  width: 100%;
  max-width: 440px;
  margin: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.acesso-logo {
  height: 52px;
  background: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

.acesso-card h1 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.acesso-card h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text-light);
  margin: 0.5rem 0;
}

.acesso-icone { font-size: 2.2rem; margin-top: 0.5rem; }
.acesso-texto { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.5; }
.acesso-nota { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.75rem; }

.acesso-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
  text-align: left;
}

.acesso-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.acesso-form input {
  font: inherit;
  font-size: 1rem; /* 16px evita o zoom automático do iPhone */
  font-weight: 400;
  color: var(--text-light);
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  outline: none;
}

.acesso-form input:focus { border-color: var(--accent-emerald); box-shadow: 0 0 0 3px var(--accent-emerald-glow); }

.acesso-codigo summary {
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.acesso-erro { color: var(--accent-rose); font-size: 0.8rem; min-height: 1em; }

.acesso-botao {
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: #059669;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.8rem;
  cursor: pointer;
}

.acesso-botao:hover { background: #047857; }
.acesso-botao:disabled { opacity: 0.6; cursor: wait; }

.acesso-admin-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent-rose);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.acesso-filtros { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }

.acesso-filtro {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}

.acesso-filtro span {
  background: var(--border-subtle);
  border-radius: 8px;
  padding: 0 0.4rem;
  margin-left: 0.2rem;
}

.acesso-filtro.ativo { color: #fff; background: #059669; border-color: #059669; }

.acesso-lista {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 0.75rem;
  max-height: 65vh;
  overflow-y: auto;
}

.acesso-disp {
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  min-width: 0;
}

.acesso-disp-pendente { border-left-color: var(--accent-amber); }
.acesso-disp-aprovado { border-left-color: var(--accent-emerald); }
.acesso-disp-bloqueado { border-left-color: var(--accent-rose); }

.acesso-disp-topo { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.acesso-disp-topo b { color: var(--text-light); font-size: 0.92rem; overflow-wrap: anywhere; }
.acesso-status { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: var(--text-secondary); white-space: nowrap; }
.acesso-disp-pendente .acesso-status { color: var(--accent-amber); }
.acesso-disp-aprovado .acesso-status { color: var(--accent-emerald); }
.acesso-disp-bloqueado .acesso-status { color: var(--accent-rose); }
.acesso-disp-desc { color: var(--text-main); font-weight: 600; overflow-wrap: anywhere; }
.acesso-disp-desc em { color: var(--accent-emerald); font-style: normal; font-weight: 500; }
.acesso-disp-linha { color: var(--text-secondary); overflow-wrap: anywhere; }
.acesso-disp-ua { color: var(--text-muted); font-size: 0.66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.acesso-acoes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }

.acesso-acao {
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.acesso-acao.liberar { color: #fff; background: #059669; border-color: #059669; }
.acesso-acao.bloquear { color: var(--accent-rose); border-color: var(--accent-rose); }
.acesso-acao.excluir { color: var(--text-muted); }

/* --- ASSISTENTE DE DADOS --- */
.assist-botao {
  position: fixed;
  right: 1.25rem;
  bottom: 1.5rem;
  z-index: 1500;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1.05rem;
  border: none;
  border-radius: var(--radius-full);
  background: #059669;
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.assist-botao:hover { background: #047857; }
.assist-botao.oculto { display: none; }

.assist-painel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.5rem;
  z-index: 1500;
  width: min(440px, calc(100vw - 2.5rem));
  height: min(640px, calc(100vh - 3rem));
  display: none;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.assist-painel.aberto { display: flex; }

.assist-topo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  background: #064e3b;
  color: #fff;
}
.assist-topo b { display: block; font-size: 0.95rem; }
.assist-topo small { font-size: 0.7rem; color: #a7f3d0; }
.assist-topo-acoes { display: flex; gap: 0.3rem; }
.assist-icone {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-md);
  background: transparent;
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}
.assist-icone.ativo { background: rgba(255, 255, 255, 0.2); }

.assist-mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.assist-msg {
  max-width: 92%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-size: 0.86rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.assist-msg p { margin: 0 0 0.4rem; }
.assist-msg p:last-child { margin-bottom: 0; }
.assist-msg ul, .assist-msg ol { margin: 0.2rem 0 0.4rem 1.1rem; }
.assist-usuario { align-self: flex-end; background: #059669; color: #fff; border-bottom-right-radius: 4px; }
.assist-bot { align-self: flex-start; background: var(--bg-table-striped); color: var(--text-main); border: 1px solid var(--border-subtle); border-bottom-left-radius: 4px; }
.assist-erro { color: var(--accent-rose); }
.assist-fontes { margin-top: 0.4rem; font-size: 0.68rem; color: var(--text-muted); }
.assist-tabela { overflow-x: auto; margin: 0.3rem 0; }
.assist-tabela table { border-collapse: collapse; font-size: 0.78rem; width: 100%; }
.assist-tabela th, .assist-tabela td { padding: 0.25rem 0.45rem; border-bottom: 1px solid var(--border-subtle); text-align: left; white-space: nowrap; }
.assist-tabela th { color: var(--text-secondary); font-weight: 700; }

.assist-sugestoes { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.6rem; }
.assist-sugestoes button {
  text-align: left;
  font: inherit;
  font-size: 0.78rem;
  color: var(--accent-emerald);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.assist-pensando { color: var(--text-secondary); }
.assist-pontos { display: inline-flex; gap: 3px; margin-right: 0.3rem; }
.assist-pontos i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-emerald); animation: assistPulso 1.2s infinite ease-in-out; }
.assist-pontos i:nth-child(2) { animation-delay: 0.2s; }
.assist-pontos i:nth-child(3) { animation-delay: 0.4s; }
@keyframes assistPulso { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.assist-form {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  padding: 0.65rem;
  border-top: 1px solid var(--border-subtle);
}
.assist-form textarea {
  flex: 1;
  resize: none;
  font: inherit;
  font-size: 1rem; /* 16px evita zoom automático no iPhone */
  color: var(--text-light);
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.65rem;
  max-height: 120px;
  outline: none;
}
.assist-form textarea:focus { border-color: var(--accent-emerald); }
.assist-mic, .assist-enviar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  font-size: 1.05rem;
  cursor: pointer;
}
.assist-mic { background: var(--bg-table-striped); border: 1px solid var(--border-subtle); }
.assist-mic.ouvindo { background: var(--accent-rose); animation: assistPulso 1.2s infinite ease-in-out; }
.assist-enviar { background: #059669; color: #fff; }
.assist-enviar:disabled { opacity: 0.5; cursor: wait; }

@media (max-width: 768px) {
  .assist-botao { right: 0.9rem; bottom: 1rem; }
  .assist-painel { inset: 0; width: 100%; height: 100%; border-radius: 0; border: none; }
}

/* Assistente: desligado pelo administrador + controle no painel de administração */
.assist-botao.desativado, .assist-painel.desativado { display: none !important; }
.assist-admin {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-emerald);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}
.assist-admin.desligado { border-left-color: var(--text-muted); }
.assist-admin b { display: block; color: var(--text-light); }
.assist-admin small { color: var(--text-secondary); }
.assist-admin button { flex-shrink: 0; }
