/* ==========================================================================
   AND FINANCIAL - DESIGN SYSTEM & STYLESHEET
   Design System Corporativo Premium (Dark Luxury Navy & Royal Blue)
   ========================================================================== */

:root {
  /* Cores Base */
  --bg-body: #080c14;
  --bg-sidebar: #0b111d;
  --bg-surface: #101927;
  --bg-card: #141f32;
  --bg-card-hover: #1a2942;
  --bg-glass: rgba(20, 31, 50, 0.75);
  --bg-glass-modal: rgba(13, 20, 33, 0.88);

  /* Bordas */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-light: rgba(255, 255, 255, 0.12);
  --border-focus: #3b82f6;

  /* Cores da Marca AND */
  --brand-primary: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-glow: rgba(37, 99, 235, 0.35);
  --brand-accent: #38bdf8;
  --brand-gradient: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 50%, #06b6d4 100%);

  /* Cores Semânticas Financeiras */
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-success-border: rgba(16, 185, 129, 0.3);

  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-warning-border: rgba(245, 158, 11, 0.3);

  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  --color-danger-border: rgba(239, 68, 68, 0.3);

  --color-info: #3b82f6;
  --color-info-bg: rgba(59, 130, 246, 0.12);
  --color-info-border: rgba(59, 130, 246, 0.3);

  /* Formas de Pagamento */
  --badge-pix: #06b6d4;
  --badge-pix-bg: rgba(6, 182, 212, 0.15);
  --badge-dinheiro: #10b981;
  --badge-dinheiro-bg: rgba(16, 185, 129, 0.15);
  --badge-credito: #3b82f6;
  --badge-credito-bg: rgba(59, 130, 246, 0.15);
  --badge-debito: #a855f7;
  --badge-debito-bg: rgba(168, 85, 247, 0.15);

  /* Tipografia & Textos */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-heading: #ffffff;

  /* Sombras & Efeitos */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-brand: 0 0 20px rgba(37, 99, 235, 0.25);

  /* Raios */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: var(--bg-body);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Customizada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Otimizações para scroll suave em mobile */
@media (hover: none) and (pointer: coarse) {
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: all 0.3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  box-shadow: var(--shadow-brand);
}

.sidebar-header .brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-header .brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Menu de Navegação */
.nav-list {
  list-style: none;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  transition: transform 0.2s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.25) 0%, rgba(37, 99, 235, 0.05) 100%);
  color: #60a5fa;
  border-left: 3px solid var(--brand-primary);
  font-weight: 600;
}

.nav-link.active svg {
  stroke: #60a5fa;
  transform: translateX(2px);
}

/* Melhorias de toque em nav links mobile */
@media (max-width: 768px) {
  .nav-link {
    padding: 16px 20px;
    min-height: 56px;
  }

  .nav-link:active {
    background: rgba(255, 255, 255, 0.08);
  }
}

/* Sidebar Footer / System Badge */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--color-success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Conteúdo Principal */
.main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header Superior */
.topbar {
  height: 70px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

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

/* ==========================================================================
   COMPONENTES: BOTÕES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--brand-glow);
}
.btn-primary:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-success {
  background: var(--color-success);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  background: #059669;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-light);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-focus);
}

.btn-danger {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: #f87171;
}
.btn-danger:hover {
  background: var(--color-danger);
  color: #ffffff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* ==========================================================================
   DASHBOARD & CARDS
   ========================================================================== */
.view-section {
  display: none;
  padding: 32px;
  animation: fadeIn 0.25s ease forwards;
}

.view-section.active {
  display: block;
}

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

/* Grid de KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

/* Melhorias de toque em KPI cards */
@media (max-width: 768px) {
  .kpi-card {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
  }
  .kpi-card:active {
    transform: scale(0.98);
    background: var(--bg-card-hover);
  }
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

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

.kpi-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon.blue { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
.kpi-icon.green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.kpi-icon.amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.kpi-icon.red { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-heading);
  margin-bottom: 6px;
}

.kpi-footer {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Gráficos e Resumos */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Formas de Pagamento no Dashboard */
.formas-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.forma-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.forma-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-light);
}

.forma-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.forma-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.forma-val-recebido {
  font-weight: 700;
  color: var(--color-success);
}
.forma-val-pendente {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   TABELAS MODERNAS
   ========================================================================== */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-toolbar {
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 280px;
}

.search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 12px 8px 36px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--brand-primary);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 10px var(--brand-glow);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.filters-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-select {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

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

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.data-table th {
  padding: 14px 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.01);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   BADGES & STATUS
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-recebido {
  background: var(--color-success-bg);
  color: #34d399;
  border: 1px solid var(--color-success-border);
}

.badge-pendente {
  background: var(--color-warning-bg);
  color: #fbbf24;
  border: 1px solid var(--color-warning-border);
}

.badge-vencido {
  background: var(--color-danger-bg);
  color: #f87171;
  border: 1px solid var(--color-danger-border);
}

.badge-cancelado {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.badge-orcamento {
  background: var(--color-warning-bg);
  color: #fbbf24;
  border: 1px solid var(--color-warning-border);
}

.badge-faturado {
  background: var(--color-info-bg);
  color: #60a5fa;
  border: 1px solid var(--color-info-border);
}

/* Badges de Formas de Pagamento */
.badge-pay {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge-pay-pix { background: var(--badge-pix-bg); color: var(--badge-pix); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-pay-dinheiro { background: var(--badge-dinheiro-bg); color: var(--badge-dinheiro); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-pay-credito { background: var(--badge-credito-bg); color: var(--badge-credito); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-pay-debito { background: var(--badge-debito-bg); color: var(--badge-debito); border: 1px solid rgba(168, 85, 247, 0.3); }

/* ==========================================================================
   MODAIS MODERNOS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 7, 13, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  padding: 20px;
}

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

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-card.modal-lg {
  max-width: 880px;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 10;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 24px 28px;
}

.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(255, 255, 255, 0.01);
}

/* Formulários Modernos */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

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

/* Melhorias de toque em formulários mobile */
@media (max-width: 768px) {
  .form-row {
    gap: 12px;
  }

  .form-group {
    margin-bottom: 14px;
  }

  .form-control,
  .filter-select {
    border-width: 1.5px;
  }

  .form-control:focus,
  .filter-select:focus {
    border-width: 2px;
  }
}

.form-control {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

/* Previne zoom automático em inputs no iOS */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px !important;
  padding: 12px 14px !important;
  min-height: 44px;
  -webkit-appearance: none;
    appearance: none;
  }
}

.form-control:focus {
  border-color: var(--brand-primary);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 10px var(--brand-glow);
}

select.form-control {
  cursor: pointer;
}
select.form-control option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Tabela de Itens no Modal de Pedido */
.items-table-wrapper {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
}

.item-row {
  display: grid;
  grid-template-columns: 2.5fr 1fr 1.2fr 1.2fr 40px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

/* Resumo Financeiro no Modal */
.order-summary-box {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}

.summary-stat span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.summary-stat strong {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
}

/* Notificações Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 380px;
}

.toast.success { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-danger); }
.toast.info { border-left: 4px solid var(--color-info); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsividade */
@media (max-width: 1400px) {
  .dashboard-grid { grid-template-columns: 1.5fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .modal-card { max-width: 600px; }
  .modal-card.modal-lg { max-width: 800px; }
}

@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
  .topbar { padding: 0 24px; }
  .view-section { padding: 24px; }
}

@media (max-width: 900px) {
  .sidebar { width: 70px; }
  .sidebar-header { padding: 16px 12px; justify-content: center; }
  .sidebar-header img { width: 36px; height: 36px; }
  .sidebar-header .brand-title, .sidebar-header .brand-subtitle, .nav-link span, .system-status span { display: none; }
  .main-content { margin-left: 70px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
  .topbar { padding: 0 20px; }
  .topbar-actions { gap: 8px; }
  .btn { padding: 8px 14px; font-size: 12px; }
  .table-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .search-box { min-width: 100%; }
  .filters-group { flex-wrap: wrap; width: 100%; }
  .view-section { padding: 20px; }
  .modal-card { max-width: 95%; margin: 10px; }
  .kpi-value { font-size: 24px; }
}

/* Correção: garantir que sidebar mobile tenha transição correta */
@media (max-width: 768px) {
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.mobile-open .sidebar-header .brand-title,
  .sidebar.mobile-open .sidebar-header .brand-subtitle,
  .sidebar.mobile-open .nav-link span,
  .sidebar.mobile-open .system-status span {
    display: block;
  }
}

@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .topbar { padding: 0 16px; height: 60px; }
  .topbar-title h2 { font-size: 16px; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .btn { padding: 8px 12px; font-size: 11px; }
  .btn span { display: none; }
  .btn svg { display: block; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi-card { padding: 16px; }
  .kpi-value { font-size: 22px; }
  .kpi-header { flex-direction: row; }
  .view-section { padding: 16px; }
  .table-card { border-radius: var(--radius-md); }
  .data-table th, .data-table td { padding: 10px 12px; font-size: 12px; }
  .modal-card { max-width: 100%; height: 100vh; max-height: 100vh; border-radius: 0; }
  .modal-body { padding: 16px; max-height: calc(100vh - 140px); overflow-y: auto; }
  .modal-footer { padding: 12px 16px; }
  .form-row { grid-template-columns: 1fr; gap: 12px; }
  .item-row { grid-template-columns: 1fr; gap: 8px; }
  .item-row > div { width: 100%; }
  .order-summary-box { grid-template-columns: 1fr; gap: 10px; }
  .toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: 100%; }
  .chart-card { padding: 16px; }
  .formas-list { gap: 8px; }
  .forma-item { padding: 10px 12px; }
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; gap: 10px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .kpi-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .kpi-icon { width: 32px; height: 32px; }
  .topbar-title h2 { font-size: 14px; }
  .view-section { padding: 12px; }
  .table-toolbar { padding: 12px 16px; }
  .table-card { overflow: hidden; }
  .modal-header { padding: 14px 16px; }
  .modal-header h3 { font-size: 15px; }
  .modal-body { padding: 12px 16px; }
  .modal-footer { padding: 10px 16px; }
  .form-group { margin-bottom: 12px; }
  .form-control { padding: 10px 12px; font-size: 14px; }
  .btn-sm { padding: 6px 10px; font-size: 11px; }
  .nav-link { padding: 12px 16px; }
  .nav-link svg { width: 20px; height: 20px; }
  .table-actions { flex-direction: column; gap: 4px; }
  .table-actions .btn { width: 100%; }
  .data-table { font-size: 11px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .badge { font-size: 10px; padding: 3px 8px; }
  .badge-pay { font-size: 10px; padding: 2px 6px; }
  .mobile-menu-toggle { top: 12px; left: 12px; }
}

@media (max-width: 480px) {
  .kpi-value { font-size: 18px; }
  .kpi-title { font-size: 10px; }
  .kpi-footer { font-size: 10px; }
  .table-toolbar { gap: 8px; }
  .filters-group { flex-direction: column; align-items: stretch; }
  .filter-select { width: 100%; padding: 10px 12px; }
  .view-section { padding: 10px; }
  .table-card { border-radius: var(--radius-sm); }
  .data-table th, .data-table td { padding: 6px 8px; font-size: 10px; }
  .modal-header h3 { font-size: 14px; }
  .form-control { font-size: 16px; /* Previne zoom no iOS */ }
  .btn { font-size: 12px; }
  .btn-sm { font-size: 11px; padding: 5px 8px; }
  .badge { font-size: 9px; padding: 2px 6px; }
  .badge-pay { font-size: 9px; padding: 1px 4px; }
  .sidebar.mobile-open { width: 100%; }
  .modal-body { padding: 10px 14px; }
}

@media (max-width: 380px) {
  .kpi-grid { gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 16px; }
  .kpi-title { font-size: 9px; }
  .topbar { height: 56px; }
  .topbar-title h2 { font-size: 13px; }
  .view-section { padding: 8px; }
  .table-toolbar { padding: 10px 12px; }
  .modal-header { padding: 12px 14px; }
  .modal-header h3 { font-size: 13px; }
  .modal-body { padding: 8px 12px; }
  .modal-footer { padding: 8px 12px; }
  .form-group label { font-size: 11px; }
  .btn { padding: 6px 10px; }
  .btn-sm { padding: 4px 8px; font-size: 10px; }
  .data-table th, .data-table td { padding: 4px 6px; font-size: 9px; }
}

/* Menu Hamburguer para Mobile */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
}

.mobile-menu-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--brand-primary);
  transform: scale(1.05);
}

.mobile-menu-toggle:active {
  transform: scale(0.95);
}

.mobile-menu-toggle svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 768px) {
  .mobile-menu-toggle { display: block; }
  .main-content { padding-top: 60px; }
  .topbar { padding-left: 60px; }
  .sidebar { padding-top: 60px; }
}

/* Overlay do menu mobile */
.mobile-menu-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.3s ease;
  opacity: 0;
}

.mobile-menu-overlay.active {
  display: block;
  opacity: 1;
}

@media (max-width: 768px) {
  .mobile-menu-overlay.active { display: block; opacity: 1; }
}

/* Scroll horizontal em tabelas */
@media (max-width: 768px) {
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }
  .data-table {
    min-width: 600px;
  }
  .table-responsive::-webkit-scrollbar {
    height: 4px;
  }
  .table-responsive::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
  }
}

/* Ajustes específicos para tabelas grandes */
@media (max-width: 768px) {
  /* Esconde colunas menos importantes em tabelas grandes */
  .data-table th:nth-child(n+7),
  .data-table td:nth-child(n+7) {
    display: none;
  }
}

@media (max-width: 640px) {
  .data-table th:nth-child(n+6),
  .data-table td:nth-child(n+6) {
    display: none;
  }
}

@media (max-width: 480px) {
  .data-table th:nth-child(n+4),
  .data-table td:nth-child(n+4) {
    display: none;
  }
}

@media (max-width: 380px) {
  .data-table th:nth-child(n+3),
  .data-table td:nth-child(n+3) {
    display: none;
  }
}

/* Ajuste para KPI cards em telas muito pequenas */
@media (max-width: 380px) {
  .kpi-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .kpi-icon { width: 32px; height: 32px; }
  .kpi-value { font-size: 18px; }
  .kpi-title { font-size: 11px; }
  .kpi-footer { font-size: 10px; }
}

/* Ajustes para botões de ação em mobile */
@media (max-width: 768px) {
  .table-actions {
    flex-direction: column;
    gap: 4px;
  }
  .table-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 36px;
  }
}

/* Ajustes para search box em mobile */
@media (max-width: 480px) {
  .search-box {
    min-width: 100%;
  }
  .search-box input {
    font-size: 16px; /* Previne zoom no iOS */
    padding: 12px 12px 12px 40px;
  }
  .search-box svg {
    width: 18px;
    height: 18px;
    left: 14px;
  }
}

/* Ajustes para filtros em mobile */
@media (max-width: 480px) {
  .filters-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .filter-select {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px; /* Previne zoom no iOS */
  }
}

/* Melhorias de toque em mobile */
@media (max-width: 768px) {
  .btn, .nav-link, .mobile-menu-toggle {
    min-height: 44px; /* Tamanho mínimo para toque comfortable */
    min-width: 44px;
  }

  .btn-sm {
    min-height: 36px;
    min-width: 36px;
  }

  .form-control, .filter-select {
    min-height: 44px;
    padding: 12px 14px;
  }

  /* Espaçamento aumentado para evitar toques acidentais */
  .table-actions {
    gap: 8px;
  }

  .filters-group {
    gap: 8px;
  }
}

/* Ajustes para landscape em mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-card {
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }
  .modal-body {
    max-height: 50vh;
    overflow-y: auto;
  }
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .sidebar.mobile-open {
    width: 320px;
  }
}

/* Performance em mobile */
@media (max-width: 768px) {
  /* Reduz animações em dispositivos mobile para melhor performance */
  .kpi-card:hover,
  .forma-item:hover,
  .data-table tbody tr:hover {
    transform: none;
  }

  .modal-card {
    transition: none;
  }

  /* Desativa backdrop-filter em dispositivos mais antigos */
  @supports not (backdrop-filter: blur(8px)) {
    .topbar,
    .modal-overlay,
    .mobile-menu-overlay {
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      background: rgba(4, 7, 13, 0.9);
    }
  }
}

/* Ajustes para iPhone notch */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    .mobile-menu-toggle {
      top: max(16px, env(safe-area-inset-top));
      left: max(16px, env(safe-area-inset-left));
    }

    .topbar {
      padding-top: max(0px, env(safe-area-inset-top));
      height: max(60px, calc(60px + env(safe-area-inset-top)));
    }

    .sidebar.mobile-open {
      padding-top: max(60px, calc(60px + env(safe-area-inset-top)));
    }
  }
}

/* Ajustes para tablets em portrait */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-link span { font-size: 13px; }
  .sidebar-header .brand-title { font-size: 16px; }
}

/* Otimizações para scroll em mobile */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }

  .modal-body,
  .table-responsive,
  .sidebar {
    scroll-behavior: smooth;
  }

  /* Scrollbar mais fina em mobile */
  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }
}

/* Ajustes para modo escuro em mobile (redução de brilho) */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  .kpi-card,
  .table-card,
  .modal-card {
    box-shadow: none;
    border: 1px solid var(--border-subtle);
  }
}

/* Ajustes para tablets em landscape */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  .view-section { padding: 16px 20px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
}

/* Ajustes para dispositivos com PPI alto (Retina) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .sidebar-header img,
  .kpi-icon svg {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Ajustes para economizar bateria em mobile */
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Ajustes para impressão em mobile */
@media print and (max-width: 768px) {
  .sidebar,
  .mobile-menu-toggle,
  .mobile-menu-overlay,
  .topbar {
    display: none !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding-top: 0 !important;
  }
  .view-section {
    padding: 10px !important;
  }
}

/* Ajustes finais para mobile */
@media (max-width: 768px) {
  /* Ajuste para modal de entrada de estoque */
  .modal-lg {
    max-width: 100%;
  }

  /* Ajuste para tabela de movimentações de estoque */
  .data-table th:nth-child(n+9),
  .data-table td:nth-child(n+9) {
    display: none;
  }

  /* Ajuste para tabela de fornecedores */
  #fornecedores-tbody .data-table th:nth-child(n+6),
  #fornecedores-tbody .data-table td:nth-child(n+6) {
    display: none;
  }

  /* Melhorias para botões de ação rápida */
  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-actions .btn {
    flex: 0 0 auto;
  }

  /* Ajuste para gráficos em mobile */
  .chart-card {
    padding: 16px;
  }

  #chart-formas {
    height: 150px !important;
  }
}

@media (max-width: 480px) {
  /* Ajuste para tabela de movimentações de estoque */
  .data-table th:nth-child(n+7),
  .data-table td:nth-child(n+7) {
    display: none;
  }

  /* Ajuste para tabela de fornecedores */
  #fornecedores-tbody .data-table th:nth-child(n+5),
  #fornecedores-tbody .data-table td:nth-child(n+5) {
    display: none;
  }

  /* Ajuste para KPI cards */
  .kpi-icon {
    width: 28px;
    height: 28px;
  }

  .kpi-icon svg {
    width: 14px;
    height: 14px;
  }

  /* Ajuste para gráficos */
  #chart-formas {
    height: 120px !important;
  }

  /* Ajuste para formas de pagamento */
  .formas-list {
    gap: 6px;
  }

  .forma-item {
    padding: 8px 10px;
  }

  .forma-label {
    font-size: 12px;
  }

  .forma-val-recebido,
  .forma-val-pendente {
    font-size: 11px;
  }
}

/* Melhorias de acessibilidade */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Suporte a temas de alto contraste */
@media (prefers-contrast: high) {
  .kpi-card,
  .table-card,
  .modal-card {
    border-width: 2px;
  }

  .btn {
    border-width: 2px;
  }

  .badge {
    border-width: 2px;
  }
}

/* Otimizações para dispositivos móveis antigos */
@media (max-width: 768px) and (max-height: 600px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .kpi-card {
    padding: 10px;
  }

  .kpi-value {
    font-size: 16px;
  }

  .kpi-title {
    font-size: 9px;
  }

  .view-section {
    padding: 8px;
  }

  .topbar {
    height: 50px;
  }

  .topbar-title h2 {
    font-size: 14px;
  }
}

/* Ajustes para iPad e tablets grandes */
@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar { width: 240px; }
  .main-content { margin-left: 240px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .modal-card { max-width: 700px; }
  .modal-card.modal-lg { max-width: 900px; }
}

/* Ajustes para iPad Pro em landscape */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
  .sidebar { width: 260px; }
  .main-content { margin-left: 260px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .dashboard-grid { grid-template-columns: 1.5fr 1fr; }
}

/* Otimizações de scroll para mobile */
@media (max-width: 768px) {
  .view-section {
    scroll-behavior: smooth;
  }

  .table-responsive {
    overflow-x: auto;
    overflow-y: hidden;
  }

  /* Esconde scrollbar mas mantém funcionalidade */
  .table-responsive::-webkit-scrollbar {
    display: none;
  }

  .table-responsive {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

/* Ajustes para telas com notch */
@media (max-width: 768px) {
  @supports (padding: max(0px)) {
    .view-section {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }

    .topbar {
      padding-left: max(60px, calc(60px + env(safe-area-inset-left)));
      padding-right: max(16px, env(safe-area-inset-right));
    }
  }
}

/* Melhorias de performance para animações em mobile */
@media (max-width: 768px) and (prefers-reduced-motion: no-preference) {
  .kpi-card,
  .table-card,
  .modal-card {
    will-change: transform;
  }

  .kpi-card:hover,
  .table-card:hover {
    will-change: auto;
  }
}

/* Ajustes finais para inputs em mobile */
@media (max-width: 768px) {
  input[type="date"]::-webkit-calendar-picker-indicator {
    padding: 8px;
  }

  input[type="date"]::-webkit-inner-spin-button,
  input[type="date"]::-webkit-outer-spin-button {
    margin: 0;
  }

  select {
    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='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 36px;
  }
}

/* Ajustes para textarea em mobile */
@media (max-width: 768px) {
  textarea {
    min-height: 80px;
    resize: vertical;
  }
}

/* Otimizações para carregamento em mobile */
@media (max-width: 768px) {
  .view-section {
    opacity: 0;
    animation: fadeInMobile 0.3s ease forwards;
  }

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

/* Ajustes para tooltip em mobile */
@media (max-width: 768px) {
  [title] {
    position: relative;
  }

  [title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
    border: 1px solid var(--border-light);
  }
}

/* Melhorias para foco em mobile */
@media (max-width: 768px) {
  .form-control:focus,
  .filter-select:focus,
  .btn:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
  }
}

/* Ajustes para cards em mobile */
@media (max-width: 768px) {
  .kpi-card,
  .table-card,
  .chart-card {
    margin: 0;
  }

  .kpi-grid {
    margin-bottom: 16px;
  }
}

/* Ajustes para badges em mobile */
@media (max-width: 480px) {
  .badge,
  .badge-pay {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
  }
}

/* Otimizações finais de layout */
@media (max-width: 768px) {
  /* Ajuste para evitar scroll horizontal acidental */
  body {
    overscroll-behavior-x: none;
  }

  .table-responsive,
  .modal-body {
    overscroll-behavior-x: auto;
  }
}

/* Ajustes para iPhone SE e similares */
@media (max-width: 375px) {
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .kpi-card {
    padding: 12px;
  }

  .kpi-value {
    font-size: 18px;
  }

  .kpi-title {
    font-size: 9px;
  }

  .view-section {
    padding: 8px;
  }

  .table-toolbar {
    padding: 8px 12px;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-header h3 {
    font-size: 14px;
  }

  .modal-body {
    padding: 10px 12px;
  }

  .modal-footer {
    padding: 8px 12px;
  }

  .btn {
    padding: 8px 12px;
    font-size: 11px;
  }

  .btn-sm {
    padding: 6px 10px;
    font-size: 10px;
  }
}

/* Ajustes para modo escuro forçado */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    background: rgba(20, 31, 50, 0.95);
    border-color: rgba(255, 255, 255, 0.15);
  }
}

/* Otimizações para animações em mobile */
@media (max-width: 768px) {
  @keyframes fadeInMobile {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .view-section {
    animation: fadeInMobile 0.2s ease forwards;
  }
}

/* Ajustes para dispositivos com tela pequena mas não mobile */
@media (min-width: 769px) and (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

/* Ajustes para telas ultra-wide */
@media (min-width: 1920px) {
  .kpi-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 2fr 1fr;
  }

  .modal-card {
    max-width: 800px;
  }

  .modal-card.modal-lg {
    max-width: 1000px;
  }
}

/* Ajuste para modais em landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-card { max-height: 85vh; }
  .modal-body { max-height: 60vh; overflow-y: auto; }
}

/* ==========================================================================
   MELHORIAS MOBILE ADICIONAIS
   ========================================================================== */

/* Swipe-to-close sidebar em mobile - sombra melhorada */
@media (max-width: 768px) {
  .sidebar.mobile-open {
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
  }
}

/* Bottom Navigation Bar para mobile (alternativa ao sidebar) */
@media (max-width: 768px) {
  .bottom-nav {
    display: none;
  }
}

/* Ajustes para topbar em mobile - botões em scroll horizontal */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    gap: 12px;
    padding: 12px 60px 12px 12px;
  }

  .topbar-title {
    width: 100%;
  }

  .topbar-title h2 {
    font-size: 16px;
  }

  .topbar-actions {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 4px;
    gap: 8px;
  }

  .topbar-actions::-webkit-scrollbar {
    display: none;
  }

  .topbar-actions .btn {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 12px;
    padding: 8px 12px;
  }

  .topbar-actions .btn svg {
    display: none;
  }

  .topbar-actions .btn-primary span {
    display: inline;
  }
}

/* Cards estilo accordion em mobile para tabelas */
@media (max-width: 640px) {
  .data-table {
    display: none;
  }

  .data-table-mobile {
    display: block;
  }

  .mobile-card-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
  }

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

  .mobile-card-item-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
  }

  .mobile-card-item-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
  }

  .mobile-card-item-label {
    color: var(--text-muted);
  }

  .mobile-card-item-value {
    color: var(--text-primary);
    font-weight: 500;
  }

  .mobile-card-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
  }
}

/* Sticky header em mobile */
@media (max-width: 768px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-subtle);
  }

  .mobile-menu-toggle {
    position: fixed;
    z-index: 100;
  }
}

/* Melhorias para KPI cards - swipe actions */
@media (max-width: 768px) {
  .kpi-card {
    position: relative;
    overflow: hidden;
  }

  .kpi-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(37, 99, 235, 0.05) 100%);
    pointer-events: none;
  }
}

/* Botão flutuante para ações rápidas em mobile */
@media (max-width: 768px) {
  .fab-button {
    display: flex;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: white;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    z-index: 90;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .fab-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.5);
  }

  .fab-button:active {
    transform: scale(0.95);
  }

  .fab-button svg {
    width: 24px;
    height: 24px;
  }
}

@media (min-width: 769px) {
  .fab-button {
    display: none;
  }
}

/* Toast notifications otimizados para mobile */
@media (max-width: 768px) {
  .toast {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    margin: 0;
    max-width: none;
    z-index: 200;
    animation: slideUpMobile 0.3s ease;
  }

  @keyframes slideUpMobile {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
}

/* Search otimizado para mobile com cancel button */
@media (max-width: 768px) {
  .search-box {
    position: relative;
    width: 100%;
  }

  .search-box input {
    padding-right: 80px;
  }

  .search-cancel {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
  }

  .search-box input:not(:placeholder-shown) + .search-cancel {
    display: block;
  }
}

/* Modal em tela cheia para mobile */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 0;
  }

  .modal-card {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .modal-header {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 10;
    border-bottom: 1px solid var(--border-subtle);
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    z-index: 10;
    border-top: 1px solid var(--border-subtle);
  }
}

/* Ajustes para select picker nativo em mobile */
@media (max-width: 768px) {
  select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%2394a3b8' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
  }
}

/* Melhorias para touch feedback */
@media (max-width: 768px) {
  .btn:active,
  .nav-link:active,
  .kpi-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* Ajustes para table toolbar em mobile */
@media (max-width: 768px) {
  .table-toolbar {
    flex-direction: column;
    gap: 12px;
  }

  .table-toolbar h3 {
    font-size: 14px;
  }

  .filters-group {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .filter-select {
    width: 100%;
  }
}

/* Ajustes para form-row em mobile */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  .form-row .form-group {
    width: 100%;
  }
}

/* ==========================================================================
   ESTILOS ESPECÍFICOS DE DESPESAS, RECORRÊNCIA E COMPROVANTES
   ========================================================================== */
.badge-pago {
  background: var(--color-success-bg);
  color: #34d399;
  border: 1px solid var(--color-success-border);
}

.badge-recorrente {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-pay-boleto {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-pay-transferencia {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

/* Upload de Arquivos / Comprovantes */
.file-upload-box {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.01);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.file-upload-box:hover {
  border-color: var(--brand-primary);
  background: rgba(37, 99, 235, 0.04);
}

.file-upload-box input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-preview-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  color: #60a5fa;
  text-decoration: none;
  transition: all 0.2s ease;
}

.file-preview-pill:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: var(--brand-primary);
}

.kpi-card.balance-positive {
  border-left: 4px solid var(--color-success);
}

.kpi-card.balance-negative {
  border-left: 4px solid var(--color-danger);
}

