/* ====================================================================
   DESIGN SYSTEM & CUSTOM VARIABLES (Light Mode Premium)
   ==================================================================== */
:root {
  /* Color Palette */
  --bg-app: #f8fafc;            /* Fundo principal da aplicação (Slate 50) */
  --bg-surface: #ffffff;        /* Branco puro para containers e cards */
  --bg-surface-hover: #f1f5f9;  /* Fundo de hover cinza sutil */
  --bg-card: #ffffff;
  
  --border-color: #e2e8f0;      /* Cor de borda leve padrão (Slate 200) */
  --border-color-hover: #cbd5e1; /* Borda ao passar o mouse (Slate 300) */
  
  /* Accent colors */
  --accent: #2563eb;            /* Azul Royal Corporativo */
  --accent-glow: rgba(37, 99, 235, 0.08);
  --accent-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  
  /* Status Colors */
  --color-open: #d97706;
  --color-open-bg: #fef3c7;
  --color-progress: #0284c7;
  --color-progress-bg: #e0f2fe;
  --color-resolved: #059669;
  --color-resolved-bg: #d1fae5;
  --color-closed: #64748b;
  --color-closed-bg: #f1f5f9;

  /* Priority / Categories background indicators */
  --bg-blue-light: #eff6ff;
  --bg-green-light: #ecfdf5;
  --bg-amber-light: #fff7ed;
  --bg-red-light: #fef2f2;
  --bg-gray-light: #f8fafc;
  
  /* Text colors */
  --text-primary: #0f172a;        /* Azul escuro (Slate 900) */
  --text-secondary: #475569;      /* Cinza escuro (Slate 600) */
  --text-muted: #64748b;          /* Cinza médio (Slate 500) */
  
  /* Typography & Spacing */
  --font-main: 'Outfit', -apple-system, sans-serif;
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.02);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

/* ====================================================================
   BASE RESET
   ==================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ====================================================================
   TELA DE LOGIN
   ==================================================================== */
.login-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 50% 50%, #f8fafc 0%, #e2e8f0 100%);
  padding: 20px;
}

.login-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.login-header {
  text-align: center;
}

.brand-logo-img {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin: 0 auto 16px auto;
}

.login-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-header h2 span {
  color: var(--accent);
}

.login-header p {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Campos de Formulário */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.form-group label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.input-wrapper input,
.form-group .input-wrapper input {
  width: 100%;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 12px 16px 12px 42px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

.input-wrapper input:focus,
.form-group .input-wrapper input:focus {
  background-color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-main);
  font-size: 14.5px;
  font-weight: 500;
  padding: 12px 20px;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

.btn-secondary {
  background-color: #f1f5f9;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: #e2e8f0;
  color: var(--text-primary);
  border-color: var(--border-color-hover);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn i {
  width: 16px;
  height: 16px;
}

.login-footer {
  text-align: center;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.login-version {
  align-self: flex-end;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  margin-top: -12px;
  user-select: none;
}

.brand-text-small p .app-version {
  display: inline;
  align-self: auto;
  margin-top: 0;
  margin-left: 6px;
  font-size: 10px;
  text-transform: none;
  letter-spacing: normal;
}

.help-text {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* ====================================================================
   APP LAYOUT (SIDEBAR + CONTENT AREA)
   ==================================================================== */
.app-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Menu Lateral (Sidebar) */
.sidebar {
  background-color: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  height: 100%;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  padding: 0 8px;
}

.brand-logo-small-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text-small h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-text-small h2 span {
  color: var(--accent);
}

.brand-text-small p {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--border-radius-md);
  transition: var(--transition-smooth);
}

.nav-item i {
  width: 18px;
  height: 18px;
}

.nav-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--bg-blue-light);
  color: var(--accent);
  font-weight: 600;
}

/* Área de Rodapé da Sidebar */
.sidebar-user {
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid var(--border-color-hover);
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-info h4 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background-color: #f1f5f9;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 2px;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-logout:hover {
  background-color: #fef2f2;
  color: #ef4444;
}

.btn-logout i {
  width: 16px;
  height: 16px;
}

/* Área do Conteúdo Principal */
.content-area {
  padding: 32px 40px;
  overflow-y: auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Cabeçalho da página fixo: fica sempre visível enquanto apenas o grid rola */
.content-header {
  position: sticky;
  top: 0;
  z-index: 30;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  background-color: var(--bg-app);
  box-shadow: 0 10px 14px -12px rgba(15, 23, 42, 0.12);
}

/* Cards de resumo (métricas) e barra de filtros fixos acima do grid */
.sticky-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--bg-app);
  box-shadow: 0 10px 14px -12px rgba(15, 23, 42, 0.12);
}

.page-title h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-title p {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Barra de Informações do Cliente/Filial no Dashboard */
.branch-info-bar {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent);
  border-radius: var(--border-radius-md);
  padding: 12px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.branch-info-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.branch-info-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.branch-info-main > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.branch-info-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.branch-info-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.branch-info-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.branch-info-line #branch-client-doc {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.branch-info-line .branch-info-dash {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.branch-info-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.branch-info-address-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 26px;
}

.branch-info-address {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ====================================================================
   DASHBOARD METRICS & SEÇÕES
   ==================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-color-hover);
}

.metric-card.clickable {
  cursor: pointer;
}

.metric-info {
  min-width: 0;
  overflow: hidden;
}

.metric-info h3 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-number {
  font-size: 29px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
  margin-top: 4px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1199px) {
  .metric-number { font-size: 24px; }
}

@media (max-width: 899px) {
  .metric-number { font-size: 19px; }
}

@media (max-width: 599px) {
  .metric-number { font-size: 15px; }
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-icon i {
  width: 20px;
  height: 20px;
}

/* Cores de Fundo dos Ícones */
.bg-blue { background-color: var(--bg-blue-light); color: var(--accent); }
.bg-green { background-color: var(--bg-green-light); color: #059669; }
.bg-amber { background-color: var(--bg-amber-light); color: #d97706; }
.bg-orange { background-color: #fff3e6; color: #ea580c; }
.bg-red { background-color: var(--bg-red-light); color: #dc2626; }

/* Placeholders de Outras Abas */
.empty-placeholder {
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-color-hover);
  border-radius: var(--border-radius-lg);
  padding: 80px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.empty-placeholder i {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}

.empty-placeholder h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-placeholder p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
}

.badge-draft {
  font-size: 11px;
  font-weight: 600;
  background-color: #f1f5f9;
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  background-color: var(--bg-blue-light);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: default;
  transition: background-color 0.15s;
}
.filter-chip:hover {
  background-color: #dbeafe;
}
.filter-chip i {
  flex-shrink: 0;
}

.loading-dots span {
  animation: dotPulse 1.4s infinite;
  opacity: 0;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* ====================================================================
   ESTILOS DE TABELAS DE DADOS (DATA TABLES)
   ==================================================================== */
.card-table-wrapper {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  width: 100%;
}

/* Grid de dados com rolamento interno: apenas o corpo rola, o título das colunas fica fixo */
.grid-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Telas com grid de dados: topo, cards e filtros fixos; apenas o grid rola */
#view-orders,
#view-finance,
#view-invoices {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#view-dashboard {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 28px;
  padding-right: 4px;
}

#view-orders .sticky-top,
#view-finance .sticky-top,
#view-invoices .sticky-top,
#view-dashboard .sticky-top {
  flex-shrink: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

/* Cabeçalho fixo: coluna de nomes permanece visível, apenas os dados rolam */
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Rodapé do grid fixo no final do card enquanto o corpo rola */
.grid-footer {
  flex-shrink: 0;
  background-color: #ffffff;
}

.data-table th {
  background-color: #f8fafc;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: var(--bg-surface-hover);
}

/* Grids dentro de modais (ex.: itens do pedido) — espaçamento compacto */
.modal .data-table th,
.modal .data-table td {
  padding: 8px 10px;
  font-size: 12px;
}

/* Grid de itens do pedido: cabeçalho fixo no topo e total fixo no rodapé.
   Apenas as linhas de itens rolam (o container #order-items-container é o scrollport). */
.items-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #f8fafc;
}

.items-grid tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background-color: #f8fafc;
  box-shadow: inset 0 1px 0 var(--border-color);
}

/* Modal de detalhes do pedido: dados do pedido fixos; apenas o grid de itens rola */
#order-detail-content > *:not(:last-child) {
  flex-shrink: 0;
}

/* Bloco "Dados do Pedido" do modal: grade em 3 colunas, sem células vazias.
   Fonte um pouco menor que os dados do cliente, que permanecem inalterados. */
.order-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 18px;
}

.order-fields .profile-field-label {
  font-size: 10.5px;
}

.order-fields .profile-field-value {
  font-size: 13px;
}

@media (max-width: 599px) {
  .order-fields { grid-template-columns: 1fr 1fr; }
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Botões de Ação na Tabela */
.btn-action-sm {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-action-sm:hover {
  background-color: var(--bg-surface-hover);
  color: var(--accent);
  border-color: var(--border-color-hover);
}

.btn-action-sm i {
  width: 15px;
  height: 15px;
}

/* Botão de impressão do pedido (azul padrão do sistema) */
.btn-print-order {
  background: var(--accent-gradient);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-print-order:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* Modais (Efeito Glassmorphism & Transições) */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.45); /* Sombra escura suave */
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

/* Alerta sempre acima dos demais modais e camadas de interface */
#modal-alert {
  z-index: 3000;
}

.modal .modal-content:focus {
  outline: none;
}

.modal-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color-hover);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8fafc;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-modal:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

/* Formulário Interno do Modal */
form {
  padding: 24px;
  overflow-y: auto;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  transition: var(--transition-smooth);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background-color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-footer {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ====================================================================
   ESTILOS EXTRAS: CONTROLE MULTI-FILIAL E FILTROS DINÂMICOS
   ==================================================================== */

/* Seletor de Filial no Cabeçalho */
.branch-selector-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--border-radius-md);
  margin-right: 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}

.branch-selector-wrapper:hover {
  border-color: var(--border-color-hover);
}

.branch-selector-wrapper i.branch-icon {
  color: var(--accent);
  width: 18px;
  height: 18px;
}

/* Custom Select (Dropdown Buscável) */
.custom-select {
  position: relative;
  min-width: 200px;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  font-family: var(--font-main);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0 4px;
  outline: none;
}

.custom-select-trigger span {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.branch-selector-wrapper .custom-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: auto;
  right: 0;
  width: max-content;
  min-width: 200px;
  max-width: 360px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow: hidden;
}

.branch-selector-wrapper .custom-select-dropdown.open {
  display: block;
}

.custom-select-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
}

.custom-select-search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--text-primary);
}

.custom-select-search input::placeholder {
  color: var(--text-muted);
}

.custom-select-options {
  max-height: 260px;
  overflow-y: auto;
}

.branch-option {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.15s;
}

.branch-option:hover {
  background-color: var(--bg-surface-hover);
}

.branch-option.selected {
  background-color: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

/* Barra de Filtro / Busca nas Tabelas */
.table-header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrapper i.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.search-input {
  width: 200px;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 8px 12px 8px 36px;
  font-size: 13px;
  font-family: var(--font-main);
  color: var(--text-primary);
  outline: none;
  transition: var(--transition-smooth);
}

.search-input:focus {
  background-color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  width: 250px;
}

/* ====================================================================
   SEARCHABLE SELECT COMPONENT (DROPDOWN PESQUISÁVEL)
   ==================================================================== */
.custom-select-wrapper {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-select-control {
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  min-height: 44px;
  box-sizing: border-box;
}

.custom-select-control:hover {
  border-color: var(--border-color-hover);
  background-color: #ffffff;
}

.custom-select-wrapper.open .custom-select-control {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background-color: #ffffff;
}

.custom-select-wrapper.disabled .custom-select-control {
  background-color: #e2e8f0;
  cursor: not-allowed;
  opacity: 0.7;
}

.custom-select-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-text.placeholder {
  color: var(--text-muted);
}

.custom-select-arrow {
  color: var(--text-muted);
  transition: transform 0.2s ease;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.custom-select-wrapper.open .custom-select-arrow {
  transform: rotate(180deg);
  color: var(--accent-blue);
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background-color: #ffffff;
  border: 1px solid var(--border-color-hover);
  border-radius: var(--border-radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.18), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 2500;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.custom-select-wrapper.open .custom-select-dropdown {
  display: flex;
}

.custom-select-search-box {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  background-color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-select-search-box svg {
  color: var(--text-muted);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.custom-select-search-input {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  background-color: #ffffff;
  color: var(--text-primary);
}

.custom-select-search-input:focus {
  border-color: var(--accent-blue);
}

.custom-select-options {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 220px;
  overflow-y: auto;
}

.custom-select-option {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.custom-select-option:hover {
  background-color: #f1f5f9;
  color: var(--accent-blue);
}

.custom-select-option.selected {
  background-color: #eff6ff;
  color: var(--accent-blue);
  font-weight: 600;
}

.custom-select-option.disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
  background-color: transparent !important;
}

.custom-select-empty {
  padding: 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ====================================================================
   VALIDAÇÃO DE CAMPOS (Diretiva 3)
   ==================================================================== */
.input-error {
  border-color: #ef4444 !important;
}
.input-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}
.error-feedback {
  color: #ef4444;
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
  display: block;
}

/* ====================================================================
   DADOS CADASTRAIS (PERFIL DO CLIENTE)
   ==================================================================== */
.brand-icon-sm {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: middle;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-field-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.profile-field-value {
  font-size: 14.5px;
  color: #1a202c;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ====================================================================
   SKELETON LOADING
   ==================================================================== */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.skeleton,
.skeleton-number,
.skeleton-text {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s infinite;
  border-radius: 6px;
  color: transparent !important;
}

.skeleton-number {
  display: inline-block;
  width: 100px;
  height: 32px;
}

.skeleton-text {
  display: inline-block;
  width: 140px;
  height: 16px;
}

.skeleton-table-row {
  display: table-row;
}

.skeleton-table-row td,
.skeleton-table-row th {
  padding: 16px 20px;
  border-bottom: 1px solid transparent;
}

.skeleton-table-row td > *,
.skeleton-table-row th > * {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s infinite;
  border-radius: 6px;
  color: transparent !important;
  display: block;
  height: 16px;
  width: 80%;
}

/* ====================================================================
   DASHBOARD EXPANDED METRICS & PANELS (MOCKUP)
   ==================================================================== */
.bg-indigo {
  background-color: #eef2ff;
  color: #4f46e5;
}

.dash-mockup-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 22px;
}

.dash-section-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px dashed var(--border-color);
}

.dash-section-divider-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dash-ficticio-pill {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #b45309;
  background-color: #fef3c7;
  border: 1px solid #fde68a;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.4px;
  line-height: 1.3;
  white-space: nowrap;
}

.dash-side-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dash-kpi-secondary .metric-number {
  font-size: 24px;
  margin-top: 6px;
}

.dash-metric-sub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 6px;
}

.dot-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.dot-amber {
  background-color: #d97706;
  box-shadow: 0 0 0 3px #fef3c7;
}

.dash-credit-bar {
  width: 100%;
  height: 6px;
  background-color: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.dash-credit-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981 0%, #059669 100%);
  border-radius: 999px;
}

.dash-panels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.dash-bottom-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
}

@media (max-width: 1080px) {
  .dash-panels-grid,
  .dash-bottom-grid {
    grid-template-columns: 1fr;
  }
}

.dash-panel-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dash-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.dash-panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dash-panel-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dash-panel-icon i {
  width: 18px;
  height: 18px;
}

.dash-panel-title h4 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.dash-panel-title p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dash-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-main);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: var(--transition-smooth);
}

.dash-link-btn:hover {
  background-color: var(--bg-blue-light);
}

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background-color: #fcfdff;
  transition: var(--transition-smooth);
}

.dash-list-item:hover {
  border-color: var(--border-color-hover);
  background-color: var(--bg-surface-hover);
}

.dash-list-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.dash-list-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-item-code {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.dash-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.dash-list-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.dash-item-amount {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.dash-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dash-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-warning {
  background-color: #fef3c7;
  color: #b45309;
}

.badge-info {
  background-color: #e0f2fe;
  color: #0369a1;
}

.badge-success {
  background-color: #d1fae5;
  color: #047857;
}

.badge-neutral {
  background-color: #f1f5f9;
  color: #475569;
}

.badge-danger {
  background-color: #fef2f2;
  color: #dc2626;
}

.dash-compact-table th {
  padding: 10px 14px;
  font-size: 11.5px;
}

.dash-compact-table td {
  padding: 11px 14px;
  font-size: 13px;
}

.dash-tag-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  font-family: var(--font-main);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background-color: var(--bg-blue-light);
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 4px;
  transition: var(--transition-smooth);
}

.dash-tag-btn:hover {
  background-color: #dbeafe;
  border-color: #93c5fd;
}

.dash-rep-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  border: 1px solid #dbeafe;
  border-radius: var(--border-radius-md);
}

.dash-rep-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: 700;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dash-rep-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.dash-rep-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.4px;
}

.dash-rep-info strong {
  font-size: 13.5px;
  color: var(--text-primary);
}

.dash-rep-info span {
  font-size: 12px;
  color: var(--text-secondary);
}

.dash-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-quick-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
}

.dash-quick-btn i {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

.dash-quick-btn:hover {
  background-color: var(--bg-blue-light);
  border-color: #bfdbfe;
  color: var(--accent);
}




/* ====================================================================
   LAYOUT OFICIAL DO BOLETO BANCÁRIO (Ficha de Compensação FEBRABAN)
   ==================================================================== */
.boleto-paper {
  background: #ffffff;
  color: #111111;
  font-family: Arial, Helvetica, sans-serif;
  border: none;
  border-radius: 0;
  padding: 10px 4px;
  box-shadow: none;
  max-width: 840px;
  margin: 0 auto;
}

.boleto-bank-header {
  display: flex;
  align-items: flex-end;
  border-bottom: 2.5px solid #000;
  padding-bottom: 6px;
  margin-bottom: 0;
  gap: 12px;
}

.boleto-bank-logo {
  height: 34px;
  max-width: 140px;
  object-fit: contain;
  display: block;
}

.boleto-bank-logo-fallback {
  font-size: 16px;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: -0.5px;
}

.boleto-bank-code {
  font-size: 20px;
  font-weight: 800;
  color: #000;
  border-left: 2px solid #000;
  border-right: 2px solid #000;
  padding: 0 12px;
  line-height: 1.1;
  white-space: nowrap;
}

.boleto-linha-digitavel {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14.5px;
  font-weight: 700;
  color: #000;
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  box-sizing: border-box;
  padding-left: 10px;
  width: 100%;
}

.boleto-linha-digitavel span {
  display: inline-block;
  white-space: nowrap;
}

.boleto-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
  font-size: 10px;
  border: 1px solid #000;
  border-top: none;
}

.boleto-table td,
.boleto-table th {
  border: 1px solid #000;
  padding: 3px 6px;
  vertical-align: top;
  text-align: left;
}

.boleto-label {
  display: block;
  font-size: 8.5px;
  color: #333333;
  text-transform: uppercase;
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: 1px;
}

.boleto-value {
  display: block;
  font-size: 11.5px;
  color: #000000;
  font-weight: 700;
  line-height: 1.25;
  min-height: 14px;
}

.boleto-value.lg {
  font-size: 13.5px;
}

.boleto-instructions {
  font-size: 10px;
  color: #111;
  line-height: 1.35;
  min-height: 95px;
}

.boleto-barcode-wrap {
  padding-top: 14px;
  padding-bottom: 4px;
}

.boleto-cut-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9px;
  color: #64748b;
  margin: 16px 0;
  border-top: 1px dashed #94a3b8;
  padding-top: 4px;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 10mm;
  }

  /* Remove todos os fundos, sombras e bordas do documento na impressao */
  *,
  *::before,
  *::after {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
  }

  html,
  body {
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Oculta tudo do body */
  body > * {
    display: none !important;
  }

  /* Exibe exclusivamente o modal do boleto */
  body > #modal-boleto-data,
  #modal-boleto-data {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    z-index: auto !important;
  }

  #modal-boleto-data * {
    visibility: visible !important;
  }

  #modal-boleto-data .modal-content,
  #modal-boleto-data .modal-boleto-container {
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    display: block !important;
  }

  #modal-boleto-data .modal-header,
  #modal-boleto-data .btn-close-modal,
  #btn-copy-linha-modal,
  #btn-print-boleto-modal {
    display: none !important;
  }

  #boleto-data-content {
    background: #ffffff !important;
    background-color: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  .boleto-paper {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 auto !important;
    max-width: 100% !important;
    width: 100% !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    color: #000000 !important;
    box-sizing: border-box !important;
  }

  .boleto-table {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
  }

  .boleto-table td,
  .boleto-table th {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
  }

  .boleto-bank-header {
    background: #ffffff !important;
    background-color: #ffffff !important;
  }

  .boleto-cut-line {
    border-top: 1px dashed #000000 !important;
    color: #000000 !important;
  }
}