/* ============================================
   SISTEMA DE COMPRAS - DESIGN MODERNO 2025
   ============================================ */

:root {
  /* Cores Principais */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --success: #10b981;
  --success-dark: #059669;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warning: #f59e0b;
  --info: #06b6d4;

  /* Cores Neutras */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;

  /* Texto */
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  /* Bordas e Sombras */
  --border-color: #e5e7eb;
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Sidebar */
  --sidebar-width: 280px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #e2e8f0;
  --sidebar-text-muted: #94a3b8;

  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET E BASE
   ============================================ */

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

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.logo-text {
  flex: 1;
}

.logo-title {
  font-size: 18px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.5px;
}

.logo-subtitle {
  font-size: 12px;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Botão Voltar ao Dashboard */
.btn-back-dashboard {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.2);
  border-radius: 8px;
  color: #60a5fa;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-back-dashboard:hover {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.4);
  transform: translateX(-2px);
}

.btn-back-dashboard svg {
  width: 18px;
  height: 18px;
}

/* Navegação */
.sidebar-nav {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 32px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding: 0 12px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(4px);
}

.nav-btn:active {
  transform: translateX(4px) scale(0.98);
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.nav-label {
  flex: 1;
  text-align: left;
}

.nav-btn-primary {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.nav-btn-primary:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateX(4px);
}

.nav-btn:disabled,
.nav-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-btn-success {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-weight: 600;
}

.nav-btn-success:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.5);
  transform: translateX(4px);
}

.nav-btn-info {
  color: #60a5fa;
}

.nav-btn-info:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateX(4px);
}

.nav-btn-danger {
  color: #fca5a5;
}

.nav-btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Footer da Sidebar */
.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Informações do Usuário */
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 12px;
  color: var(--sidebar-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--sidebar-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.btn-logout {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  transform: scale(1.05);
}

.stats-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--sidebar-text-muted);
  font-weight: 500;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.stat-item.warn .stat-value {
  color: var(--warning);
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--sidebar-text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-400);
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.status-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   CONTEÚDO PRINCIPAL
   ============================================ */

.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-secondary);
  height: 100vh;
}

/* Esconder scrollbar mas manter funcionalidade */
.main-content::-webkit-scrollbar {
  width: 8px;
}

.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.main-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

.page-header {
  background: white;
  padding: 16px 40px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title-section {
  max-width: 1400px;
  margin: 0 auto;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ============================================
   SEÇÕES DE FORMULÁRIO
   ============================================ */

.form-section,
.table-section {
  max-width: calc(100vw - 320px);
  /* Ocupa mais espaço considerando sidebar */
  margin: 16px auto;
  padding: 0 20px;
}

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

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  font-size: 18px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header-left {
  flex: 1;
}

.total-value-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 18px;
  background: white;
  border: 2px solid var(--success);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  min-width: 180px;
  transition: all 0.3s ease;
}

.total-value-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.total-value-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.total-icon {
  color: var(--success);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.total-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.total-amount {
  font-size: 22px;
  font-weight: 800;
  color: var(--success);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.required-badge {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
}

/* Card de Formulário */
.form-card {
  background: white;
  padding: 20px 24px;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  /* gap: 16px; */
}

/* Linhas do Formulário */
.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  width: 100%;
}

.form-group {
  display: flex;
  flex-direction: column;
  /* gap: 6px; */
  min-width: 0;
  overflow: hidden;
  flex-shrink: 1;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.label-text {
  flex: 1;
}

.label-required {
  color: var(--danger);
  font-weight: 700;
  font-size: 14px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  background: white;
  transition: var(--transition);
  font-family: inherit;
  height: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-control:hover {
  border-color: var(--gray-300);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  min-height: 60px;
  height: auto;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
  padding: 8px 12px;
  white-space: normal;
  overflow: auto;
  text-overflow: clip;
}

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
  appearance: none;
}

/* ============================================
   TABELA
   ============================================ */

.table-container {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

/* Overlay de bloqueio da tabela */
.table-lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.40);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.table-lock-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.table-lock-message {
  text-align: center;
  padding: 2rem;
  max-width: 400px;
}

.lock-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.table-lock-message h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem 0;
}

.table-lock-message p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

.table-lock-message strong {
  color: var(--primary);
  font-weight: 600;
}

/* Indicador de scroll horizontal */
.table-container::after {
  content: '';
  position: absolute;
  top: 60px;
  right: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to left, rgba(0, 0, 0, 0.05), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 600px);
  min-height: 400px;
  position: relative;
}

/* Scrollbar personalizada */
.table-wrap::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.table-wrap::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 5px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 5px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

#sheet {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#sheet thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--gray-50);
}

#sheet th {
  padding: 14px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#sheet tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition-fast);
}

#sheet tbody tr:hover {
  background: var(--gray-50);
}

#sheet td {
  padding: 12px;
  vertical-align: middle;
}

.cell-input,
.cell-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  background: white;
  transition: var(--transition);
}

.cell-input:focus,
.cell-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Campos inválidos - validação visual aprimorada */
.cell-input.invalid,
.cell-select.invalid,
.cell-text.invalid {
  border-color: var(--danger) !important;
  background: rgba(239, 68, 68, 0.08) !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
  animation: shake 0.4s ease;
}

.cell-input.invalid:focus,
.cell-select.invalid:focus,
.cell-text.invalid:focus {
  border-color: var(--danger) !important;
  background: rgba(239, 68, 68, 0.12) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Animação de shake para campos inválidos */
@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-2px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(2px);
  }
}

/* Campos de texto (contenteditable) */
.cell-text {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  background: white;
  transition: var(--transition);
  min-height: 36px;
  max-height: 80px;
  overflow-y: auto;
  line-height: 1.4;
  word-wrap: break-word;
}

.cell-text:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
  background: #fafbfc;
}

.cell-text:empty:before {
  content: attr(data-placeholder);
  color: var(--gray-400);
  font-style: italic;
}

/* Campo de referência - aceita texto ou links */
.cell-text[data-col="referencia"] {
  font-size: 12px;
  color: var(--text-primary);
}

/* Campo de observações - input com limite de caracteres */
.cell-input[data-col="observacoes"] {
  background: #fffbeb;
  border-color: #fbbf24;
  width: 100%;
  max-width: 220px;
  /* Largura fixa, não cresce indefinidamente */
}

.cell-input[data-col="observacoes"]:focus {
  background: #fef3c7;
  border-color: #f59e0b;
}

/* Campo de especificação */
.cell-text[data-col="especificacao"] {
  font-weight: 500;
}

/* Campo valor total por linha - somente leitura */
.cell-input[data-col="valor_total_linha"] {
  background: var(--gray-50);
  font-weight: 700;
  color: var(--success-dark);
  font-family: 'Courier New', monospace;
  text-align: right;
  cursor: not-allowed;
}

/* Campos calculados (readonly) */
.cell-input[readonly] {
  background: var(--gray-50);
  cursor: not-allowed;
  color: var(--text-secondary);
}

.cell-total {
  font-weight: 600;
  text-align: center;
}

/* ============================================
   COLUNAS STICKY (FIXAS)
   ============================================ */

/* Coluna Código Omie - Sticky à esquerda */
#sheet th:first-child,
#sheet td:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  background: white;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
}

#sheet thead th:first-child {
  z-index: 15;
  background: var(--gray-50);
}

#sheet tbody tr:hover td:first-child {
  background: var(--gray-50);
}

/* Coluna Ações - Sticky à direita */
#sheet th:last-child,
#sheet td:last-child {
  position: sticky;
  right: 0;
  z-index: 5;
  background: white;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.05);
}

/* Borda sempre visível na coluna de ações usando pseudo-elemento */
#sheet th:last-child::before,
#sheet td:last-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: var(--border-color);
  z-index: 10;
}

#sheet thead th:last-child {
  z-index: 15;
  background: var(--gray-50);
}

#sheet tbody tr:hover td:last-child {
  background: var(--gray-50);
}

/* Larguras das colunas */
.col-codigo {
  width: 150px;
  min-width: 150px;
}

.col-descricao {
  width: 250px;
  min-width: 250px;
}

.col-espec {
  width: 200px;
  min-width: 200px;
}

.col-quantidade {
  width: 100px;
  min-width: 100px;
}

.col-quantidade-total {
  width: 80px;
  min-width: 80px;
}

.col-estoque {
  width: 80px;
  min-width: 80px;
}

/* Colunas de estoque adicionais - comentadas para uso futuro
.col-usar-estoque {
  width: 110px;
  min-width: 110px;
}

.col-usar-estoque {
  width: 110px;
  min-width: 110px;
}

.col-estoque-cliente {
  width: 120px;
  min-width: 120px;
}
*/

.col-unidade {
  width: 110px;
  min-width: 110px;
}

.col-valor {
  width: 120px;
  min-width: 120px;
}

.col-valor-total-linha {
  width: 140px;
  min-width: 140px;
}

.col-referencia {
  width: 180px;
  min-width: 180px;
}

.col-observacoes {
  width: 220px;
  min-width: 220px;
}

.col-acoes {
  width: 70px;
  min-width: 70px;
}

/* Botões de ação da linha */
.row-actions {
  text-align: center;
  padding: 8px !important;
}

.row-actions button {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.row-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.row-actions button:active {
  transform: translateY(0);
}

/* ============================================
   FEEDBACK / TOAST
   ============================================ */

.feedback-msg {
  position: fixed;
  top: 24px;
  right: 24px;
  max-width: 420px;
  padding: 16px 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 4px solid transparent;
}

.feedback-msg::before {
  content: '';
  font-size: 20px;
  line-height: 1;
}

.feedback-msg.success {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  color: white;
  border-left-color: #059669;
}

.feedback-msg.success::before {
  content: '✓';
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.feedback-msg.error {
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
  color: white;
  border-left-color: #b91c1c;
}

.feedback-msg.error::before {
  content: '✕';
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@keyframes slideIn {
  from {
    transform: translateX(450px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(450px);
    opacity: 0;
  }
}

/* ============================================
   AUTOCOMPLETE
   ============================================ */

.auto-wrap {
  position: absolute;
  background: white;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 300px;
}

.auto-inner {
  position: relative;
}

.auto-row {
  position: absolute;
  left: 0;
  right: 0;
  height: 52px;
  padding: 8px 16px;
  cursor: pointer;
  transition: var(--transition-fast);
  border-bottom: 1px solid var(--gray-100);
  background: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.auto-row:hover {
  background: var(--gray-50);
}

.auto-row.active {
  background: var(--primary);
  color: white;
}

.auto-main {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  max-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-sub {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
  margin-top: 2px;
  max-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-row.active .auto-sub {
  color: rgba(255, 255, 255, 0.8);
}

/* ============================================
   MODAL DE CONFIRMAÇÃO
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  /* Hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-container {
  background: white;
  border-radius: var(--border-radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
  from {
    transform: scale(0.95) translateY(-20px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 20px 0;
  line-height: 1.6;
}

.modal-details {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 16px;
  border: 1px solid var(--border-color);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-row:first-child {
  padding-top: 0;
}

.detail-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.detail-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  background: var(--bg-secondary);
}

.modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  min-width: 120px;
}

.modal-btn-cancel {
  background: white;
  color: var(--text-primary);
  border: 1.5px solid var(--border-color);
}

.modal-btn-cancel:hover {
  background: var(--bg-tertiary);
  border-color: var(--gray-400);
}

.modal-btn-confirm {
  background: linear-gradient(135deg, var(--success), var(--success-dark));
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.modal-btn-confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

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

/* Estilos do formulário do modal */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: var(--transition);
  background: white;
  color: var(--text-primary);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.error-message {
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
}

.success-message {
  padding: 12px 16px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 8px;
  color: var(--success);
  font-size: 14px;
  margin-top: 12px;
}

/* ============================================
   MODAL DE AJUDA
   ============================================ */

.modal-help {
  max-width: 700px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-help-body {
  max-height: calc(85vh - 140px);
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.help-intro {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(99, 102, 241, 0.1));
  border-left: 4px solid var(--primary);
  border-radius: 8px;
}

.help-intro p {
  margin: 0;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
}

.help-section {
  margin-bottom: 1.25rem;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.help-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  transition: all 0.2s;
}

.help-item:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}

.help-field {
  font-weight: 700;
  color: var(--primary);
  font-size: 13px;
}

.help-description {
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.4;
}

.help-tip {
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.5rem;
  background: rgba(251, 191, 36, 0.1);
  border-left: 3px solid #fbbf24;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.help-tip:last-child {
  margin-bottom: 0;
}

.help-tip strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Botão de ajuda na sidebar */
.nav-btn-help {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-btn-help:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateX(4px);
}

.nav-btn-help .nav-icon {
  opacity: 0.85;
}

.nav-btn-help:hover .nav-icon {
  opacity: 1;
}

/* ============================================
   RESPONSIVO
   ============================================ */

@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }

  .form-section,
  .table-section {
    max-width: calc(100vw - 280px);
    padding: 0 16px;
  }

  .page-header {
    padding: 24px;
  }

  /* Ajustar proporções em telas médias */
  .form-row {
    flex-wrap: wrap;
  }

  .form-row .form-group {
    flex: 1 1 auto !important;
    min-width: 200px;
  }
}

@media (max-width: 768px) {
  .app-wrapper {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 60vh;
  }

  .form-section,
  .table-section {
    max-width: 100%;
    padding: 0 12px;
  }

  .form-card {
    padding: 16px;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row .form-group {
    width: 100% !important;
    flex: 1 1 100% !important;
  }

  /* Tabela em telas pequenas */
  .table-wrap {
    min-height: 300px;
    max-height: calc(100vh - 500px);
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .total-value-card {
    width: 100%;
    padding: 14px 18px;
  }

  .total-amount {
    font-size: 24px;
  }
}

/* ============================================
   UTILITÁRIOS
   ============================================ */

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

.mt-4 {
  margin-top: 16px;
}

.mb-4 {
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}