/* ==========================================================================
   PROJETO: O Orçamento na Hora (SENAI-SP)
   DESIGN SYSTEM: HIGH-CONTRAST MODERN SAAS / SWISS INDUSTRIAL
   Inspirado na precisão estética de Linear, Stripe e Vercel.
   Linhas nítidas de 1px, zero glassmorphism, tipografia sólida e layout adaptativo.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. VARIÁVEIS DO DESIGN SYSTEM (HARD COLORS & TOKENS)
   -------------------------------------------------------------------------- */
:root {
  /* Bases Estruturais (Zinco & Branco Puro) */
  --bg-canvas: #ffffff;
  --bg-surface: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-sidebar: #fafafa;
  --bg-active: #e4e4e7;

  /* Bordas Nítidas (Linhas duras de 1px) */
  --border-subtle: #e4e4e7;
  --border-strong: #d4d4d8;
  --border-focus: #1e40af;

  /* Tipografia de Alto Contraste */
  --text-primary: #09090b;   /* Tinta preta sólida */
  --text-secondary: #27272a; /* Corpo de alto contraste */
  --text-muted: #71717a;     /* Legendas e rótulos */
  --text-dim: #a1a1aa;       /* Placeholders e elementos secundários */

  /* Cores de Destaque e Ação (Solid Cobalt & Emerald) */
  --brand-primary: #1e40af;  /* Azul Cobalto Industrial */
  --brand-hover: #1d4ed8;
  --brand-subtle: #eff6ff;
  --brand-border: #bfdbfe;

  --emerald-solid: #047857;  /* Verde Esmeralda Corporativo */
  --emerald-hover: #065f46;
  --emerald-bg: #ecfdf5;
  --emerald-border: #a7f3d0;

  --amber-solid: #b45309;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;

  /* Fontes do Sistema e Monospace para Cifras */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Geometria e Raios Precisos */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;

  /* Sombras Duras e Quase Inexistentes (Apenas relevo tátil de 1px) */
  --shadow-none: none;
  --shadow-subtle: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------------------------------------
   2. RESET E NORMAS TIPOGRÁFICAS GLOBAIS
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Utilitários Monospace e Numéricos */
.font-mono {
  font-family: var(--font-mono) !important;
  font-variant-numeric: tabular-nums !important;
}

.font-semibold { font-weight: 600 !important; }
.font-bold { font-weight: 700 !important; }
.text-right { text-align: right !important; }
.text-emerald { color: var(--emerald-solid) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-xs { font-size: 0.75rem !important; }
.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   3. LAYOUT SPLIT (2 COLUNAS REAIS EM DESKTOP)
   -------------------------------------------------------------------------- */
.app-layout {
  display: flex;
  flex-direction: row;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg-canvas);
}

/* ==========================================================================
   4. COLUNA DA ESQUERDA: PAINEL INSTITUCIONAL & TARIFAS DO PRESTADOR
   ========================================================================== */
.provider-panel {
  flex: 0 0 430px;
  max-width: 460px;
  min-width: 380px;
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  z-index: 10;
}

/* Topo / Header da Coluna */
.panel-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.brand-identity {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--brand-primary);
  color: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.25;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.badges-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.status-pulse {
  width: 7px;
  height: 7px;
  background: #16a34a;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.badge-senai {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Corpo / Seções do Painel */
.panel-body {
  padding: 24px 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.section-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--brand-subtle);
  border: 1px solid var(--brand-border);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Tabela de Tarifas Oficial */
.tariff-table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
}

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

.tariff-table th {
  background: var(--bg-subtle);
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

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

.tariff-table tr:last-child td {
  border-bottom: none;
}

.service-name-cell {
  display: flex;
  flex-direction: column;
}

.service-name-cell strong {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 600;
}

.service-name-cell span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.highlight-val {
  font-weight: 700;
  color: var(--text-primary);
}

/* Callout de Desconto */
.discount-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: #065f46;
  line-height: 1.45;
}

.discount-icon {
  color: var(--emerald-solid);
  flex-shrink: 0;
  margin-top: 1px;
}

/* Pilares de Garantia */
.guarantees-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guarantee-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-subtle);
}

.guarantee-icon {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.guarantee-text strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.guarantee-text p {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 1px;
}

/* Rodapé do Painel */
.panel-footer {
  padding: 18px 28px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-admin-portal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  text-decoration: none;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-admin-portal:hover {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
}

.academic-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
}

/* ==========================================================================
   5. COLUNA DA DIREITA: ÁREA OPERACIONAL DO CHAT (FULL SCREEN NATIVO)
   ========================================================================== */
.chat-wrapper {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  position: relative;
}

/* Header Operacional */
.chat-header {
  height: 60px;
  min-height: 60px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.terminal-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.terminal-status-dot {
  width: 8px;
  height: 8px;
  background: var(--brand-primary);
  border-radius: 50%;
}

.terminal-title {
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.terminal-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.btn-action-minimal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-action-minimal:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.mobile-tariff-strip {
  display: none; /* Oculto no desktop, ativo no mobile */
}

/* ==========================================================================
   6. CONTAINER DE MENSAGENS E BALÕES HIGH-CONTRAST
   ========================================================================== */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #ffffff;
}

.messages-container::-webkit-scrollbar {
  width: 5px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: #d4d4d8;
  border-radius: 4px;
}

.message-row {
  display: flex;
  gap: 10px;
  max-width: 82%;
  animation: fadeRowIn 0.15s ease-out forwards;
}

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

.message-row.user-row {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-row.bot-row {
  align-self: flex-start;
}

.avatar-small {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  margin-top: 4px;
}

.avatar-small.avatar-bot {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.avatar-small.avatar-user {
  background: var(--brand-primary);
  border: 1px solid var(--brand-primary);
  color: #ffffff;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: break-word;
}

/* Balão do Assistente (High-Contrast Zinc) */
.message-row.bot-row .bubble {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-subtle);
}

/* Balão do Usuário (Cobalt Industrial Sólido) */
.message-row.user-row .bubble {
  background: var(--brand-primary);
  color: #ffffff;
  border: 1px solid var(--brand-hover);
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  padding: 0 4px;
}

.message-row.user-row .message-time {
  text-align: right;
}

/* ==========================================================================
   7. CARDS ESPECIAIS (FATURA COMERCIAL & LEAD CONFIRMADO)
   ========================================================================== */

/* 7.1 CARD DE ORÇAMENTO (FATURA FORMAL) */
.orcamento-card {
  margin-top: 10px;
  background: #ffffff;
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

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

.orcamento-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald-solid);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
}

.orcamento-protocol {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.invoice-summary-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.invoice-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  padding: 4px 0;
  border-bottom: 1px dashed #f4f4f5;
}

.invoice-label {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.invoice-value {
  color: var(--text-primary);
}

.invoice-adjustments {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.orcamento-calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
}

.orcamento-calc-row.discount-row {
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald-solid);
  font-weight: 600;
}

.orcamento-calc-row.fee-row {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
  font-weight: 600;
}

.orcamento-total-box {
  background: #ffffff;
  border: 1.5px solid var(--emerald-solid);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.total-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--emerald-solid);
  display: block;
}

.total-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.total-number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--emerald-solid);
  letter-spacing: -0.02em;
}

.orcamento-cta-prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.orcamento-cta-prompt svg {
  color: var(--brand-primary);
  flex-shrink: 0;
}

/* 7.2 CARD DE LEAD SALVO */
.lead-card {
  margin-top: 10px;
  background: #ffffff;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

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

.lead-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-subtle);
  border: 1px solid var(--brand-border);
  color: var(--brand-primary);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
}

.lead-subtag {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.lead-details-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.lead-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  padding: 4px 0;
  border-bottom: 1px dashed #f4f4f5;
}

.lead-detail-label {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.lead-detail-val {
  color: var(--text-primary);
}

.lead-status-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #1e293b;
  font-size: 0.82rem;
  line-height: 1.45;
}

.lead-status-box svg {
  color: var(--brand-primary);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ==========================================================================
   8. INDICADOR DE DIGITAÇÃO (PULSO SUAVE)
   ========================================================================== */
.typing-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 28px 12px;
}

.typing-container.hidden {
  display: none !important;
}

.typing-bubble {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.typing-bubble .dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: typingBounceClassic 1.3s infinite ease-in-out both;
}

.typing-bubble .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-bubble .dot:nth-child(2) { animation-delay: -0.16s; }
.typing-bubble .dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounceClassic {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
    background: var(--brand-primary);
  }
}

/* ==========================================================================
   9. SUGESTÕES RÁPIDAS (CHIPS MINIMALISTAS)
   ========================================================================== */
.quick-chips-wrapper {
  padding: 8px 24px;
  border-top: 1px solid var(--border-subtle);
  background: #ffffff;
}

.chips-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chips-list::-webkit-scrollbar {
  height: 3px;
}

.chips-list::-webkit-scrollbar-thumb {
  background: #e4e4e7;
  border-radius: 3px;
}

.chip {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* ==========================================================================
   10. FORMULÁRIO DE ENTRADA (DOCKED BOTTOM)
   ========================================================================== */
.chat-form {
  padding: 14px 24px;
  background: #ffffff;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-input {
  flex: 1;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chat-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.15);
}

.chat-input::placeholder {
  color: var(--text-dim);
}

.chat-input:disabled {
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--border-subtle);
}

.btn-send {
  background: var(--brand-primary);
  border: 1px solid var(--brand-hover);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-send:hover:not(:disabled) {
  background: var(--brand-hover);
}

.btn-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-send.loading svg {
  animation: spinIcon 1s linear infinite;
}

@keyframes spinIcon {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   11. PAINEL ADMINISTRATIVO (ESTILOS MODERN SAAS / SWISS INDUSTRIAL)
   ========================================================================== */
.admin-body {
  background-color: var(--bg-subtle);
  min-height: 100vh;
  overflow-y: auto;
}

/* Tela de Bloqueio com Autenticação (Login Gate) */
.login-gate-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background-color: var(--bg-subtle);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 32px 28px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.login-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-error-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
}

.login-error-box svg {
  flex-shrink: 0;
  color: #b91c1c;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  border-color: var(--brand-hover);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15);
}

.btn-login-action {
  background: var(--brand-primary);
  border: 1px solid var(--brand-hover);
  color: #ffffff;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease;
  margin-top: 4px;
}

.btn-login-action:hover {
  background: var(--brand-hover);
}

.login-card-footer {
  text-align: center;
  margin-top: 8px;
}

.link-back-chat {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.link-back-chat:hover {
  color: var(--text-primary);
}

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

/* Header Fixo com Breadcrumbs */
.admin-header {
  height: 60px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.admin-header-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.btn-back-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: #ffffff;
  transition: all 0.15s ease;
}

.btn-back-nav:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.admin-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
}

.crumb-root {
  color: var(--text-muted);
  font-weight: 500;
}

.crumb-separator {
  color: var(--text-dim);
}

.crumb-current {
  color: var(--text-primary);
  font-weight: 600;
}

.admin-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-date-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-refresh-data {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-primary);
  border: 1px solid var(--brand-hover);
  color: #ffffff;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-refresh-data:hover {
  background: var(--brand-hover);
}

.btn-refresh-data.loading svg {
  animation: spinIcon 1s linear infinite;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

/* Área Principal */
.admin-main {
  flex: 1;
  padding: 32px;
}

.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Cabeçalho da Página */
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.live-sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 5px 10px;
  border-radius: var(--radius-xs);
}

.sync-dot {
  width: 6px;
  height: 6px;
  background: #16a34a;
  border-radius: 50%;
}

/* Grid de KPIs (Bordas Duras 1px) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-subtle);
}

.kpi-card.highlight-card {
  border-color: var(--emerald-border);
  background: #ffffff;
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-tag-mono {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.kpi-tag-mono.emerald {
  background: var(--emerald-bg);
  color: var(--emerald-solid);
  border-color: var(--emerald-border);
}

.kpi-value-wrap {
  margin-bottom: 6px;
}

.kpi-number {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
}

.kpi-text-val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.kpi-meta {
  font-size: 0.74rem;
  color: var(--text-dim);
}

/* Toolbar & Tabela Corporativa */
.admin-table-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
}

.toolbar-wrapper {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: #ffffff;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  width: 320px;
}

.toolbar-search svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-field {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  color: var(--text-primary);
  width: 100%;
}

.search-field::placeholder {
  color: var(--text-dim);
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.filter-pill {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  color: var(--text-primary);
}

.filter-pill.active {
  background: #ffffff;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.select-service-hidden {
  display: none;
}

.leads-counter-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 5px 10px;
  border-radius: var(--radius-xs);
}

/* Tabela de Dados */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.corporate-table th {
  background: var(--bg-sidebar);
  padding: 10px 16px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.corporate-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--bg-subtle);
  vertical-align: middle;
}

.corporate-table tr:hover td {
  background: #fafafa;
}

.client-name {
  font-weight: 600;
  color: var(--text-primary);
}

.badge-service {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-service.parede-lisa {
  background: var(--brand-subtle);
  color: var(--brand-primary);
  border: 1px solid var(--brand-border);
}

.badge-service.textura {
  background: #faf5ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}

.badge-service.teto {
  background: var(--emerald-bg);
  color: var(--emerald-solid);
  border: 1px solid var(--emerald-border);
}

.btn-whatsapp-solid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #15803d;
  color: #ffffff;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 600;
  transition: background 0.15s ease;
}

.btn-whatsapp-solid:hover {
  background: #166534;
}

/* Estado Vazio */
.empty-state-box {
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.empty-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 360px;
}

.admin-footer {
  padding: 16px 32px;
  border-top: 1px solid var(--border-subtle);
  background: #ffffff;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.admin-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   12. MODAL DE CONFIGURAÇÃO (SWISS INDUSTRIAL CLEAN)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 9, 11, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 460px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.modal-body label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.modal-input {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
}

.modal-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.15);
}

.helper-text {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.demo-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-subtle);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #d4d4d8;
  transition: 0.2s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--brand-primary);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.toggle-label strong {
  font-size: 0.82rem;
  color: var(--text-primary);
  display: block;
}

.toggle-label p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.modal-footer {
  padding: 14px 20px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--brand-primary);
  border: 1px solid var(--brand-hover);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

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

/* ==========================================================================
   13. RESPONSIVIDADE E ADAPTAÇÃO MOBILE (< 768px)
   ========================================================================== */
.mobile-only {
  display: none !important;
}

@media (max-width: 992px) {
  .provider-panel {
    flex: 0 0 340px;
    min-width: 320px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: inline-flex !important;
  }

  /* Chat Principal em tela cheia (100dvh) */
  .app-layout {
    flex-direction: column;
    height: 100dvh;
    min-height: 100dvh;
  }

  .provider-panel {
    display: none; /* Em telas móveis, recolhe a coluna institucional */
  }

  .chat-wrapper {
    height: 100%;
    max-height: 100dvh;
  }

  .chat-header {
    height: 52px;
    min-height: 52px;
    padding: 0 16px;
  }

  .mobile-tariff-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
  }

  .strip-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
  }

  .strip-pills {
    display: flex;
    gap: 6px;
    white-space: nowrap;
  }

  .tariff-pill {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    color: var(--text-secondary);
  }

  .tariff-pill strong {
    color: var(--emerald-solid);
    font-family: var(--font-mono);
  }

  .messages-container {
    padding: 14px 16px;
    gap: 12px;
  }

  .message-row {
    max-width: 92%;
  }

  .chat-form {
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  /* Painel Admin em Mobile */
  .admin-header {
    padding: 0 16px;
  }

  .admin-breadcrumbs .crumb-root {
    display: none;
  }

  .admin-main {
    padding: 16px;
  }

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

  .toolbar-wrapper {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-search {
    width: 100%;
  }

  .toolbar-filters {
    justify-content: space-between;
  }
}
