/* Premium Light CSS variables & design system */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Colors - Light Theme */
  --bg-dark: #f8fafc;        /* Soft gray background */
  --bg-deep: #ffffff;        /* Pure white background */
  --card-bg: #ffffff;        /* White card background */
  --card-border: #e2e8f0;    /* Slate-200 border */
  --card-blur: 0px;
  
  --primary: #2563eb;        /* Darker blue for light mode readability */
  --primary-rgb: 37, 99, 235;
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  --accent-gradient: linear-gradient(135deg, #ec4899 0%, #3b82f6 100%);
  --success-gradient: linear-gradient(135deg, #10b981 0%, #047857 100%);
  
  --success: #10b981;
  --warning: #d97706;        /* Darker amber for contrast */
  --danger: #dc2626;         /* Darker red */
  --info: #0891b2;           /* Darker cyan */
  
  --text-main: #0f172a;      /* Slate-900 for primary text */
  --text-muted: #475569;     /* Slate-600 for secondary text */
  --text-dim: #64748b;       /* Slate-500 for captions */
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.03);
  --shadow-glow: 0 0 15px rgba(37, 99, 235, 0.08);
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.05) 0px, transparent 40%),
    radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.03) 0px, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: 40px;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 0 24px;
  flex-grow: 1;
}

/* Header styling */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 16px 28px;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.brand-title {
  display: flex;
  flex-direction: column;
}

.brand-title h1 {
  font-size: 20px;
  letter-spacing: 0.5px;
  color: var(--text-main);
}

.brand-title span {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 1px;
}

/* Connection status badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid var(--card-border);
}

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

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

/* Filters Panel */
.filters-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  position: relative;
  overflow: hidden;
}

.filters-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-gradient);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 200px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}

.filter-input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  background: #ffffff;
  border: 1px solid #cbd5e1; /* slate-300 */
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: var(--transition-fast);
}

.filter-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.filter-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  transition: var(--transition-fast);
}

.filter-input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.filter-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

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

.btn-secondary {
  background: #ffffff;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text-main);
}

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

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition-normal);
  position: relative;
}

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

.kpi-card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.kpi-change {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.kpi-card:nth-child(1) .kpi-icon-wrapper {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.kpi-card:nth-child(2) .kpi-icon-wrapper {
  background: rgba(16, 185, 129, 0.08);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.kpi-card:nth-child(3) .kpi-icon-wrapper {
  background: rgba(236, 72, 153, 0.08);
  color: #db2777; /* pink-600 */
  border: 1px solid rgba(236, 72, 153, 0.15);
}

.kpi-card:nth-child(4) .kpi-icon-wrapper {
  background: rgba(8, 145, 178, 0.08);
  color: var(--info);
  border: 1px solid rgba(8, 145, 178, 0.15);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

#page-estoques .charts-grid {
  grid-template-columns: 1fr;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 380px;
}

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

.chart-header h3 {
  font-size: 16px;
  color: var(--text-main);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chart-header h3 i {
  color: var(--primary);
}

.chart-body {
  position: relative;
  flex-grow: 1;
  width: 100%;
  height: 100%;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Table Area styling */
.table-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

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

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

.table-title h3 {
  font-size: 18px;
  color: var(--text-main);
}

.table-counter {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}

.table-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  min-width: 260px;
}

.search-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: var(--transition-fast);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Table styling */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--card-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

thead {
  background: #f8fafc;
  border-bottom: 1px solid var(--card-border);
}

th {
  padding: 16px 20px;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

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

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: #f8fafc;
}

td {
  padding: 14px 20px;
  color: var(--text-main);
  vertical-align: middle;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

/* Status colors tailored for light mode readability (darker text on light background) */
.badge-faturado {
  background: rgba(16, 185, 129, 0.1);
  color: #065f46; /* emerald-800 */
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.badge-faturado::before { background: #10b981; }

.badge-aberto, .badge-digitacao, .badge-em-digitacao {
  background: rgba(59, 130, 246, 0.1);
  color: #1e3a8a; /* blue-900 */
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.badge-aberto::before, .badge-digitacao::before, .badge-em-digitacao::before { background: #3b82f6; }

.badge-cancelado, .badge-rejeitado {
  background: rgba(239, 68, 68, 0.1);
  color: #7f1d1d; /* red-900 */
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.badge-cancelado::before, .badge-rejeitado::before { background: #ef4444; }

.badge-atendido, .badge-entregue, .badge-enviado {
  background: rgba(6, 182, 212, 0.1);
  color: #083344; /* cyan-950 */
  border: 1px solid rgba(6, 182, 212, 0.2);
}
.badge-atendido::before, .badge-entregue::before, .badge-enviado::before { background: #06b6d4; }

.badge-pendente, .badge-verificacao {
  background: rgba(245, 158, 11, 0.1);
  color: #78350f; /* amber-900 */
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.badge-pendente::before, .badge-verificacao::before { background: #f59e0b; }

.badge-default {
  background: rgba(148, 163, 184, 0.1);
  color: #334155; /* slate-700 */
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.badge-default::before { background: #94a3b8; }

/* Status Summary Grid (Resumo por Status) */
.status-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.status-summary-card {
  background: #f8fafc;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 18px;
  transition: var(--transition-normal);
}

.status-summary-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.status-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--card-border);
}

.status-summary-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
}

.status-summary-totals {
  text-align: right;
  flex-shrink: 0;
}

.status-summary-count {
  display: block;
  font-size: 20px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: var(--text-main);
}

.status-summary-value {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.status-summary-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.status-summary-item-label {
  color: var(--text-muted);
  flex: 1;
}

.status-summary-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.status-summary-item-count {
  font-weight: 700;
  color: var(--text-main);
  background: #eef2f7;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  min-width: 28px;
  text-align: center;
}

.status-summary-item-value {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 75px;
  text-align: right;
}

/* Empty, Error, Loading states */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
  gap: 16px;
}

.state-icon {
  font-size: 48px;
  color: var(--text-dim);
  background: #f1f5f9;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-border);
  margin-bottom: 8px;
}

.state-container h4 {
  font-size: 18px;
  color: var(--text-main);
}

.state-container p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.6;
}

/* Loader animations */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(37, 99, 235, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: 100%;
}

.toast {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  transform: translateY(100px);
  opacity: 0;
  animation: slideIn 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition: var(--transition-fast);
}

@keyframes slideIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

.toast-icon {
  font-size: 16px;
  margin-top: 2px;
}

.toast.error .toast-icon { color: var(--danger); }
.toast.success .toast-icon { color: var(--success); }

.toast-content {
  flex-grow: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 2px;
}

.toast-msg {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
}

.toast-close:hover {
  color: var(--text-muted);
}

/* Utility / Helpers */
.text-right { text-align: right; }
.text-center { text-align: center; }
.bold { font-weight: 600; }
.price-tag {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}

/* Skeleton loader effect */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
}

@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.skeleton-text {
  height: 12px;
  border-radius: 4px;
}

.skeleton-title {
  height: 20px;
  border-radius: 6px;
}

/* Footer style */
footer {
  margin-top: auto;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 24px;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
}

footer a:hover {
  color: var(--primary);
}

/* Login Screen Overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-card {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: cardFadeIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.login-logo {
  height: 48px;
  margin-bottom: 24px;
  object-fit: contain;
}

.login-card h2 {
  font-size: 22px;
  color: var(--text-main);
  margin-bottom: 8px;
  text-align: center;
}

.login-card p {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-card form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.login-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.login-input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}

.login-input-wrapper input {
  width: 100%;
  padding: 12px 40px 12px 40px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: var(--transition-fast);
}

.login-input-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-toggle-pwd {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.btn-toggle-pwd:hover {
  color: var(--text-muted);
}

.login-error-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.login-btn {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  font-size: 15px;
}

/* Tab Navigation */
.tab-navigation {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 8px;
  width: 100%;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
  position: relative;
  outline: none;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.03);
}

.tab-btn.active {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--primary-gradient);
  border-radius: 3px 3px 0 0;
}

.tab-content {
  display: none;
  animation: fadeInContent 0.35s ease-out;
}

.tab-content.active {
  display: block;
}

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

/* Maintenance Card styling */
.maintenance-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 80px 40px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.maintenance-icon {
  font-size: 44px;
  color: var(--warning);
  background: rgba(217, 119, 6, 0.08);
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(217, 119, 6, 0.15);
  margin-bottom: 8px;
  animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {
  0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.2); }
  70% { box-shadow: 0 0 0 12px rgba(217, 119, 6, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}

.maintenance-card h3 {
  font-size: 22px;
  color: var(--text-main);
  margin-bottom: 4px;
}

.maintenance-card p {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 500px;
  line-height: 1.6;
}

/* ===== UPLOAD CSV PAGE ===== */
.page-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.upload-csv-container {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}

.upload-csv-header {
  text-align: center;
  margin-bottom: 32px;
}

.upload-csv-logo {
  height: 40px;
  margin-bottom: 20px;
}

.upload-csv-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.upload-csv-header p {
  font-size: 14px;
  color: var(--text-muted);
}

.upload-dropzone {
  border: 2px dashed var(--card-border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg-dark);
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.04);
}

.upload-icon {
  font-size: 40px;
  color: var(--primary);
  margin-bottom: 12px;
}

.upload-dropzone-label {
  font-size: 15px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.upload-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.upload-dropzone-hint {
  font-size: 12px;
  color: var(--text-dim);
}

.upload-file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(var(--primary-rgb), 0.06);
  border: 1px solid rgba(var(--primary-rgb), 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-main);
  font-weight: 500;
}

.upload-file-preview i {
  font-size: 20px;
}

.upload-file-preview span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.upload-remove-btn:hover { color: var(--danger); }

.upload-result {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.upload-result.success {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #065f46;
}

.upload-result.error {
  background: rgba(220, 38, 38, 0.07);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: #991b1b;
}

.upload-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: flex-end;
}

/* Responsive Lotes Grid */
@media (max-width: 992px) {
  .lotes-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Lotes Page Tab Styles */
.tab-btn-lote {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
  position: relative;
  outline: none;
}

.tab-btn-lote:hover {
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.03);
}

.tab-btn-lote.active {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.tab-btn-lote.active::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--primary-gradient);
  border-radius: 3px 3px 0 0;
}

.tab-content-lote {
  display: none;
  animation: fadeInContent 0.35s ease-out;
}

.tab-content-lote.active {
  display: block;
}

/* Responsive adjustments for Lotes page on Mobile & Tablet */
@media (max-width: 768px) {
  /* Tab navigation horizontal scrolling */
  .tab-navigation {
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding-bottom: 12px !important;
    margin-bottom: 20px !important;
    border-bottom: 1px solid var(--border) !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
  }
  .tab-navigation::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
  }
  .tab-btn-lote {
    font-size: 13px !important;
    padding: 8px 14px !important;
    flex-shrink: 0;
  }
  .tab-btn-lote.active::after {
    bottom: -13px !important;
  }

  /* Form layouts: stack grid columns */
  #tab-lotes-inserir form,
  #lotes-form,
  .lote-item-block,
  #lotes-mov-form {
    gap: 12px !important;
  }
  
  /* Select inputs & date grids stack */
  #lotes-form div[style*="grid-template-columns"],
  .lote-item-block div[style*="grid-template-columns"],
  #lotes-mov-form div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Main grid for movements tab */
  .lotes-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  
  /* Card transformations for batch table, movements table, and inventory table */
  #lotes-table, 
  #lotes-table thead, 
  #lotes-table tbody, 
  #lotes-table th, 
  #lotes-table td, 
  #lotes-table tr,
  #lotes-mov-table, 
  #lotes-mov-table thead, 
  #lotes-mov-table tbody, 
  #lotes-mov-table th, 
  #lotes-mov-table td, 
  #lotes-mov-table tr,
  #estoque-table, 
  #estoque-table thead, 
  #estoque-table tbody, 
  #estoque-table th, 
  #estoque-table td, 
  #estoque-table tr {
    display: block !important;
    width: 100% !important;
  }

  #lotes-table thead,
  #lotes-mov-table thead,
  #estoque-table thead {
    display: none !important; /* Hide headings */
  }

  #lotes-table tr,
  #lotes-mov-table tr,
  #estoque-table tr {
    margin-bottom: 16px !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    padding: 12px 16px !important;
    background: var(--surface) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
  }

  #lotes-table td,
  #lotes-mov-table td,
  #estoque-table td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 0 !important;
    border: none !important;
    border-bottom: 1px dashed rgba(15, 23, 42, 0.05) !important;
    font-size: 13px !important;
    text-align: right !important;
  }

  #lotes-table td:last-child,
  #lotes-mov-table td:last-child,
  #estoque-table td:last-child {
    border-bottom: none !important;
  }

  /* Add labels before the content */
  #lotes-table td::before,
  #estoque-table td::before {
    content: attr(data-label) !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 10px !important;
    color: var(--text-dim) !important;
    text-align: left !important;
    margin-right: 16px !important;
  }

  #lotes-mov-table td::before {
    content: attr(data-label) !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 10px !important;
    color: var(--text-dim) !important;
    text-align: left !important;
    margin-right: 16px !important;
  }

  /* Align action and right columns on mobile */
  #lotes-table td.text-right, 
  #lotes-table td.text-center,
  #lotes-mov-table td.text-right, 
  #lotes-mov-table td.text-center,
  #estoque-table td.text-right, 
  #estoque-table td.text-center {
    text-align: right !important;
  }
  
  #lotes-table td.text-center button,
  #lotes-mov-table td.text-center span,
  #estoque-table td.text-center button {
    margin: 0 !important;
  }

  /* Product details alignment on mobile card */
  #lotes-table td[data-label="Produto"],
  #lotes-mov-table td[data-label="Produto"],
  #estoque-table td[data-label="Produto"] {
    flex-direction: column !important;
    align-items: flex-end !important;
    text-align: right !important;
  }

  #lotes-table td[data-label="Produto"]::before,
  #lotes-mov-table td[data-label="Produto"]::before,
  #estoque-table td[data-label="Produto"]::before {
    align-self: flex-start !important;
    margin-bottom: 4px !important;
  }

  /* Table Header Controls stack nicely on mobile */
  .table-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 16px !important;
  }

  .table-header div[style*="margin-left: 24px"] {
    margin-left: 0 !important;
    max-width: 100% !important;
  }

  .table-controls {
    justify-content: stretch !important;
  }

  .table-controls button {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* ─────────────────────────────────────────────
   TREEMAP CHART STYLING
   ───────────────────────────────────────────── */
.treemap-container {
  position: relative;
  background: var(--surface-alt, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  height: 100%;
}

.treemap-block {
  position: absolute;
  box-sizing: border-box;
  padding: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, filter 0.2s ease;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.treemap-block:hover {
  transform: scale(0.99);
  filter: brightness(1.08);
  box-shadow: inset 0 0 16px rgba(255, 255, 255, 0.15), 0 8px 20px rgba(0, 0, 0, 0.18);
  z-index: 10;
}

.treemap-block-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.treemap-block-qty {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 18px;
  margin-top: 4px;
  white-space: nowrap;
}

.treemap-block-pct {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  opacity: 0.85;
  margin-top: 2px;
}

.treemap-block-sku {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 10px;
  opacity: 0.75;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 6px;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─────────────────────────────────────────────
   STOCK CHAT WIDGET
   ───────────────────────────────────────────── */
.stock-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  font-family: 'Inter', sans-serif;
}

.chat-toggle-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary, #2563eb);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.chat-toggle-btn:hover {
  transform: scale(1.05);
  background: #1d4ed8;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger, #ef4444);
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  height: 500px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-header {
  background: linear-gradient(135deg, var(--primary, #2563eb), #1d4ed8);
  padding: 16px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #ffffff;
}

.chat-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s ease;
  padding: 4px;
}

.chat-close-btn:hover {
  color: #ffffff;
}

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--background, #f8fafc);
}

.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.bot {
  background: var(--surface, #ffffff);
  color: var(--text-main, #0f172a);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border, #e2e8f0);
}

.chat-msg.user {
  background: var(--primary, #2563eb);
  color: #ffffff;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}

.chat-suggestions {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  background: var(--background, #f8fafc);
  overflow-x: auto;
  border-top: 1px solid var(--border, #e2e8f0);
  scrollbar-width: none;
}

.chat-suggestions::-webkit-scrollbar {
  display: none;
}

.chat-suggest-btn {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-main, #0f172a);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.chat-suggest-btn:hover {
  background: var(--primary-light, rgba(37, 99, 235, 0.05));
  border-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
}

.chat-input-area {
  display: flex;
  padding: 12px;
  background: var(--surface, #ffffff);
  border-top: 1px solid var(--border, #e2e8f0);
  gap: 8px;
}

.chat-input-area input {
  flex: 1;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  outline: none;
  background: var(--background, #f8fafc);
  color: var(--text-main, #0f172a);
  transition: border-color 0.2s ease;
}

.chat-input-area input:focus {
  border-color: var(--primary, #2563eb);
  background: #ffffff;
}

.btn-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary, #2563eb);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-chat-send:hover {
  background: #1d4ed8;
}

.btn-chat-send:active {
  transform: scale(0.95);
}

.chat-edit-link {
  color: var(--primary, #2563eb);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.chat-edit-link:hover {
  color: #1d4ed8;
}

