body {
  box-sizing: border-box;
  transition: background-color 0.3s ease, color 0.3s ease;
}
@media print {
  .no-print {
    display: none;
  }
  body {
    font-size: 12px;
  }
}
.dashboard-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.stats-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s ease,
    color 0.3s ease;
}
.stats-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.glass-effect {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}
.dark .stats-card {
  background: #374151;
  color: white;
}
.dark .glass-effect {
  background: rgba(55, 65, 81, 0.95);
  border: 1px solid rgba(75, 85, 99, 0.2);
}
.table-container {
  max-height: 600px;
  overflow-y: auto;
}
.table-container thead th {
  position: sticky;
  top: 0;
  z-index: 10;
}
/* ===== RESPONSIVIDADE COMPLETA ===== */

/* Breakpoints personalizados */
@media (max-width: 1536px) {
  .max-w-7xl {
    max-width: 1280px;
    padding: 0 2rem;
  }
}

@media (max-width: 1280px) {
  .max-w-7xl {
    max-width: 1024px;
    padding: 0 1.5rem;
  }

  .dashboard-card h1 {
    font-size: 2.5rem;
  }

  .glass-effect h2,
  .glass-effect h3 {
    font-size: 1.75rem;
  }
}

@media (max-width: 1024px) {
  .max-w-7xl {
    max-width: 768px;
    padding: 0 1rem;
  }

  .dashboard-card {
    padding: 2rem 1.5rem !important;
  }

  .dashboard-card h1 {
    font-size: 2.25rem;
  }

  .glass-effect {
    padding: 1.5rem !important;
  }

  .glass-effect h2,
  .glass-effect h3 {
    font-size: 1.5rem;
  }

  /* Ajustar grid de estatísticas para tablet */
  .hidden.md\\:grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  /* Botões de ação em 4 colunas no tablet */
  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6 {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
  }

  .max-w-7xl {
    max-width: 100%;
    padding: 0 1rem;
  }

  /* ===== DASHBOARD HEADER MOBILE ===== */
  .dashboard-card {
    border-radius: 0;
    margin: 0 -1rem;
    padding: 1.5rem 1rem !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }

  .dashboard-card > .flex {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    gap: 1rem;
    width: 100%;
  }

  .dashboard-card .mb-4 {
    margin-bottom: 1rem !important;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .dashboard-card .text-center {
    width: 100% !important;
    text-align: center !important;
  }

  .dashboard-card h1 {
    font-size: 1.75rem !important;
    line-height: 1.3;
    margin-bottom: 0.5rem;
  }

  .dashboard-card p {
    font-size: 0.9rem !important;
    opacity: 0.9;
  }

  .dashboard-card .text-right .text-2xl {
    font-size: 1.1rem !important;
  }

  /* ===== CARDS DE ESTATÍSTICAS MOBILE ===== */
  .hidden.md\\:grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 0 -0.5rem;
  }

  .stats-card {
    padding: 0.75rem !important;
  }

  .stats-card .w-12 {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }

  .stats-card .text-lg {
    font-size: 1rem !important;
  }

  .stats-card .text-xs {
    font-size: 0.7rem !important;
  }

  /* ===== CARDS PRINCIPAIS MOBILE ===== */
  .glass-effect {
    margin: 0 -0.5rem;
    border-radius: 16px;
    padding: 1.25rem !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  }

  .glass-effect h2,
  .glass-effect h3 {
    font-size: 1.5rem !important;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  /* ===== FORMULÁRIO PRINCIPAL MOBILE ===== */
  .grid.grid-cols-1.md\\:grid-cols-3 {
    gap: 1.25rem;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 input,
  .grid.grid-cols-1.md\\:grid-cols-3 textarea {
    font-size: 16px; /* Evita zoom no iOS */
    padding: 1rem;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 input:focus,
  .grid.grid-cols-1.md\\:grid-cols-3 textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 label {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #374151;
    display: block;
  }

  /* ===== TABELA MOBILE MELHORADA ===== */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    margin: 0 -0.5rem;
    background: white;
    position: relative;
  }

  .table-container table {
    min-width: 1000px;
    font-size: 13px;
    width: 100%;
  }

  .table-container th {
    padding: 12px 8px !important;
    font-size: 12px !important;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: #3b82f6;
    z-index: 10;
  }

  .table-container td {
    padding: 10px 6px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }

  .table-container input {
    padding: 6px 4px !important;
    font-size: 12px !important;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    width: 100%;
    min-width: 60px;
    box-sizing: border-box;
  }

  .table-container input[type="date"] {
    min-width: 110px;
  }

  .table-container input[type="text"] {
    min-width: 120px;
  }

  .mobile-scroll-hint {
    display: block;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    color: white;
    text-align: center;
    padding: 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 0 0 12px 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
  }

  .mobile-scroll-hint i {
    animation: bounce 2s infinite;
    margin-right: 8px;
  }

  @keyframes bounce {
    0%,
    20%,
    50%,
    80%,
    100% {
      transform: translateX(0);
    }
    40% {
      transform: translateX(-8px);
    }
    60% {
      transform: translateX(8px);
    }
  }

  /* ===== RESUMO FINANCEIRO MOBILE ===== */
  .grid.grid-cols-1.md\\:grid-cols-3 > div {
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }

  .grid.grid-cols-1.md\\:grid-cols-3 > div input,
  .grid.grid-cols-1.md\\:grid-cols-3 > div > div {
    font-size: 1.1rem !important;
    padding: 0.875rem !important;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
  }

  /* ===== BOTÕES DE AÇÃO MOBILE ===== */
  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6 button {
    padding: 1rem 0.75rem;
    font-size: 0.8rem;
    min-height: 70px;
    border-radius: 12px;
    font-weight: 600;
    line-height: 1.3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    text-align: center;
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6
    button:active {
    transform: scale(0.95);
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6
    button
    i {
    font-size: 1.2rem;
    margin-bottom: 0;
  }

  /* ===== UPLOAD DE ARQUIVOS MOBILE ===== */
  .grid.grid-cols-1.lg\\:grid-cols-2 {
    gap: 1.5rem;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 > div {
    padding: 1.25rem !important;
    border-radius: 12px;
  }

  .grid.grid-cols-2.md\\:grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 input[type="file"] {
    padding: 1rem;
    font-size: 14px;
    border-radius: 8px;
    border: 2px dashed #d1d5db;
    width: 100%;
    box-sizing: border-box;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 button {
    padding: 0.875rem;
    font-size: 0.9rem;
    border-radius: 8px;
    font-weight: 600;
    width: 100%;
  }

  /* ===== ASSINATURA MOBILE ===== */
  .signature-canvas {
    height: 140px !important;
    touch-action: none;
    border-radius: 8px;
    border: 2px dashed #d1d5db;
    width: 100%;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 {
    gap: 1.5rem;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 > div:last-child {
    background: #f8fafc;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
  }

  /* ===== MODAL MOBILE ===== */
  .max-w-4xl {
    max-width: calc(100vw - 24px);
    margin: 12px;
    border-radius: 16px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }

  /* ===== CARTA DE ACEITE MOBILE ===== */
  .bg-orange-50 textarea {
    min-height: 100px;
    resize: vertical;
  }

  .bg-gray-50 .bg-white {
    padding: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
  }

  /* ===== MELHORIAS GERAIS DE TOQUE ===== */
  button,
  input,
  select,
  textarea {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Scroll suave */
  * {
    -webkit-overflow-scrolling: touch;
  }

  /* Ajustes de espaçamento */
  .mb-4 {
    margin-bottom: 1.5rem !important;
  }

  .mb-8 {
    margin-bottom: 2rem !important;
  }

  /* Otimizações de performance */
  .table-container {
    will-change: scroll-position;
  }

  /* Melhor contraste para leitura */
  .dark .table-container input {
    background: #374151;
    border-color: #4b5563;
    color: white;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .max-w-7xl {
    padding: 0 0.75rem;
  }

  /* ===== DASHBOARD AINDA MAIS COMPACTO ===== */
  .dashboard-card {
    margin: 0 -0.75rem;
    padding: 1rem 0.75rem !important;
  }

  .dashboard-card h1 {
    font-size: 1.5rem !important;
    margin-bottom: 0.5rem;
    line-height: 1.2;
  }

  .dashboard-card p {
    font-size: 0.8rem !important;
  }

  .dashboard-card .text-right .text-2xl {
    font-size: 1rem !important;
  }

  /* ===== ESTATÍSTICAS COMPACTAS ===== */
  .hidden.md\\:grid {
    margin: 0 -0.25rem;
    gap: 0.5rem;
  }

  .stats-card {
    padding: 0.5rem !important;
  }

  .stats-card .w-12 {
    width: 2rem !important;
    height: 2rem !important;
  }

  .stats-card .text-lg {
    font-size: 0.9rem !important;
  }

  .stats-card .text-xs {
    font-size: 0.65rem !important;
  }

  /* ===== CARDS PRINCIPAIS MENORES ===== */
  .glass-effect {
    margin: 0 -0.25rem;
    padding: 1rem !important;
    border-radius: 12px;
  }

  .glass-effect h2,
  .glass-effect h3 {
    font-size: 1.3rem !important;
    margin-bottom: 1rem;
    gap: 0.5rem;
  }

  /* ===== FORMULÁRIOS COMPACTOS ===== */
  .grid.grid-cols-1.md\\:grid-cols-3 {
    gap: 1rem;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 input,
  .grid.grid-cols-1.md\\:grid-cols-3 textarea {
    padding: 0.875rem;
    font-size: 16px;
    border-radius: 10px;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }

  /* ===== TABELA ULTRA COMPACTA ===== */
  .table-container {
    border-radius: 10px;
    margin: 0 -0.25rem;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.12);
  }

  .table-container table {
    min-width: 950px;
    font-size: 11px;
  }

  .table-container th {
    padding: 8px 4px !important;
    font-size: 10px !important;
    font-weight: 700;
  }

  .table-container td {
    padding: 6px 3px !important;
    font-size: 10px !important;
  }

  .table-container input {
    padding: 4px 2px !important;
    font-size: 10px !important;
    border-radius: 4px;
    min-width: 50px;
  }

  .table-container input[type="date"] {
    min-width: 95px;
    font-size: 9px !important;
  }

  .table-container input[type="text"] {
    min-width: 100px;
  }

  .mobile-scroll-hint {
    font-size: 11px;
    padding: 8px;
    margin-bottom: 1rem;
  }

  /* ===== BOTÕES DE AÇÃO COMPACTOS ===== */
  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6 {
    gap: 0.75rem;
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6 button {
    padding: 0.75rem 0.5rem;
    font-size: 0.7rem;
    min-height: 60px;
    border-radius: 10px;
    gap: 0.25rem;
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6
    button
    i {
    font-size: 1rem;
  }

  /* ===== RESUMO FINANCEIRO COMPACTO ===== */
  .grid.grid-cols-1.md\\:grid-cols-3 > div {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 10px;
  }

  .grid.grid-cols-1.md\\:grid-cols-3 > div input,
  .grid.grid-cols-1.md\\:grid-cols-3 > div > div {
    font-size: 1rem !important;
    padding: 0.75rem !important;
    border-radius: 6px;
  }

  /* ===== UPLOAD DE ARQUIVOS COMPACTO ===== */
  .grid.grid-cols-1.lg\\:grid-cols-2 {
    gap: 1rem;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 > div {
    padding: 1rem !important;
    border-radius: 10px;
  }

  .grid.grid-cols-2.md\\:grid-cols-3 {
    gap: 0.5rem;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 input[type="file"] {
    padding: 0.875rem;
    font-size: 13px;
    border-radius: 6px;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 button {
    padding: 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
  }

  /* ===== ASSINATURA COMPACTA ===== */
  .signature-canvas {
    height: 120px !important;
    border-radius: 6px;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 {
    gap: 1rem;
  }

  .grid.grid-cols-1.lg\\:grid-cols-2 > div:last-child {
    padding: 1rem;
    border-radius: 10px;
  }

  /* ===== MODAL COMPACTO ===== */
  .max-w-4xl {
    max-width: calc(100vw - 16px);
    margin: 8px;
    border-radius: 12px;
  }

  /* ===== CARTA DE ACEITE COMPACTA ===== */
  .bg-orange-50 textarea {
    min-height: 80px;
    font-size: 14px;
    padding: 0.75rem;
  }

  .bg-gray-50 .bg-white {
    padding: 0.75rem;
    font-size: 0.8rem;
    line-height: 1.5;
  }

  /* ===== AJUSTES DE ESPAÇAMENTO MENORES ===== */
  .mb-4 {
    margin-bottom: 1rem !important;
  }

  .mb-8 {
    margin-bottom: 1.5rem !important;
  }

  /* ===== MELHORIAS DE PERFORMANCE DE TOQUE ===== */
  .table-container {
    scroll-behavior: smooth;
  }

  /* ===== OTIMIZAÇÃO DE TEXTO ===== */
  .table-container .row-total {
    font-size: 10px !important;
    font-weight: 700;
  }

  /* ===== PREVIEW DE IMAGENS MENOR ===== */
  .grid.grid-cols-2.md\\:grid-cols-3 > div {
    border-radius: 6px;
  }

  .grid.grid-cols-2.md\\:grid-cols-3 img {
    height: 60px !important;
  }

  .grid.grid-cols-2.md\\:grid-cols-3 .p-2 {
    padding: 0.5rem !important;
  }

  .grid.grid-cols-2.md\\:grid-cols-3 .text-xs {
    font-size: 0.65rem !important;
  }
}

@media (max-width: 480px) {
  /* ===== EXTRA SMALL DEVICES ===== */
  body {
    font-size: 12px;
  }

  .max-w-7xl {
    padding: 0 0.5rem;
  }

  .dashboard-card {
    margin: 0 -0.5rem;
    padding: 0.75rem 0.5rem !important;
  }

  .dashboard-card h1 {
    font-size: 1.25rem !important;
  }

  .glass-effect {
    margin: 0;
    padding: 0.75rem !important;
  }

  .glass-effect h2,
  .glass-effect h3 {
    font-size: 1.1rem !important;
  }

  .table-container table {
    min-width: 900px;
    font-size: 10px;
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6 button {
    min-height: 50px;
    font-size: 0.65rem;
    padding: 0.5rem 0.25rem;
  }
}

@media (max-width: 360px) {
  /* ===== VERY SMALL DEVICES ===== */
  body {
    font-size: 11px;
  }

  .max-w-7xl {
    padding: 0 0.25rem;
  }

  .dashboard-card {
    margin: 0 -0.25rem;
    padding: 0.5rem 0.25rem !important;
  }

  .dashboard-card h1 {
    font-size: 1.1rem !important;
  }

  .glass-effect {
    padding: 0.5rem !important;
  }

  .glass-effect h2,
  .glass-effect h3 {
    font-size: 1rem !important;
  }

  .hidden.md\\:grid {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .table-container table {
    min-width: 850px;
    font-size: 9px;
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6 {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6 button {
    min-height: 45px;
    font-size: 0.6rem;
    padding: 0.5rem;
    flex-direction: row;
    gap: 0.5rem;
  }

  .grid.grid-cols-2.sm\\:grid-cols-3.md\\:grid-cols-4.lg\\:grid-cols-6
    button
    i {
    font-size: 0.9rem;
  }
}

/* ===== LANDSCAPE ORIENTATION ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .dashboard-card {
    padding: 1rem !important;
  }

  .dashboard-card h1 {
    font-size: 1.5rem !important;
  }

  .glass-effect {
    padding: 1rem !important;
  }

  .signature-canvas {
    height: 100px !important;
  }

  .max-w-4xl {
    max-height: calc(100vh - 16px);
    overflow-y: auto;
  }
}

/* ===== HIGH DPI DISPLAYS ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .signature-canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    font-size: 12px;
    background: white !important;
    color: black !important;
  }

  .glass-effect {
    background: white !important;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }

  .table-container {
    overflow: visible !important;
    box-shadow: none !important;
  }

  .table-container table {
    min-width: auto !important;
  }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .mobile-scroll-hint i {
    animation: none !important;
  }
}

@media (prefers-contrast: high) {
  .glass-effect {
    border: 2px solid #000 !important;
  }

  .table-container input {
    border: 2px solid #000 !important;
  }

  button {
    border: 2px solid #000 !important;
  }
}
.signature-canvas {
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;
}
.signature-canvas:hover {
  border-color: #3b82f6;
}
.theme-toggle-header {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.theme-toggle-header:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.history-item {
  transition: all 0.2s ease;
}
.history-item:hover {
  transform: translateX(5px);
  background-color: rgba(59, 130, 246, 0.05);
}
.dark .history-item:hover {
  background-color: rgba(59, 130, 246, 0.1);
}
