:root {
  --primary: #16a34a;
  --primary-hover: #15803d;
  --primary-light: #dcfce7;
  --primary-subtle: #f0fdf4;
  --primary-dark: #14532d;
  
  --secondary: #0f172a;
  --secondary-light: #1e293b;
  --secondary-card: #1e293b;
  
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-white: #ffffff;
  
  --border-color: #e2e8f0;
  --border-radius-sm: 8px;
  --border-radius: 14px;
  --border-radius-lg: 20px;
  
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-text: #991b1b;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-text: #92400e;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --info-text: #1e40af;
  
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.05), 0 1px 2px -1px rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   AUTH LAYOUT
   ========================================= */
.auth-wrapper {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 80% 20%, #166534 0%, #0f172a 60%, #020617 100%);
  padding: 24px 16px;
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 450px;
  height: 450px;
  background: rgba(34, 197, 94, 0.08);
  border-radius: 50%;
  filter: blur(80px);
  top: 10%;
  left: 15%;
}

.auth-card {
  position: relative;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  width: 100%;
  max-width: 440px;
  border-radius: var(--border-radius-lg);
  padding: 42px 36px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-logo {
  max-height: 80px;
  max-width: 190px;
  object-fit: contain;
  border-radius: 10px;
  margin: 0 auto 16px auto;
  display: block;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.08));
}

.auth-header h1 {
  font-size: 1.65rem;
  color: var(--text-main);
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* =========================================
   FORMS & INPUTS
   ========================================= */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
  letter-spacing: 0.2px;
}

.form-control {
  width: 100%;
  padding: 11px 15px;
  font-size: 0.925rem;
  font-family: inherit;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background-color: #fff;
  transition: all 0.2s ease-in-out;
  outline: none;
  color: var(--text-main);
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
  background-color: #fff;
}

.form-control.is-invalid,
.filter-select.is-invalid {
  border-color: #ef4444 !important;
  background-color: #fef2f2 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.field-error-msg {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #dc2626;
  font-size: 0.81rem;
  font-weight: 600;
  margin-top: 5px;
  line-height: 1.35;
}

textarea.form-control {
  resize: vertical;
  min-height: 85px;
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-size: 0.925rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  line-height: 1.25;
}

.btn-primary {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: #fff;
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #15803d 0%, #166534 100%);
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.35);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.35);
  transform: translateY(-1px);
}

.btn-action {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 6px;
  font-weight: 600;
}

/* =========================================
   ALERTS
   ========================================= */
.alert {
  padding: 14px 18px;
  border-radius: var(--border-radius-sm);
  margin-bottom: 22px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.alert-danger {
  background-color: var(--danger-light);
  color: var(--danger-text);
  border: 1px solid #fca5a5;
}

.alert-success {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #86efac;
}

/* =========================================
   APP SHELL / LAYOUT
   ========================================= */
.app-layout {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 270px;
  min-width: 270px;
  background-color: var(--bg-sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1), transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.app-layout.sidebar-collapsed .sidebar {
  margin-left: -270px;
  visibility: hidden;
  pointer-events: none;
}

.sidebar-brand {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-brand:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-brand:hover .sidebar-brand-text {
  color: #86efac;
}

.sidebar-logo {
  height: 40px;
  max-width: 65px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
}

.sidebar-brand-text {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
}

.sidebar-nav {
  padding: 20px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-link svg {
  flex-shrink: 0;
  transition: transform 0.2s;
}

.nav-link:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.08);
}

.nav-link:hover svg {
  transform: scale(1.1);
}

.nav-link.active {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

.sidebar-footer {
  padding: 18px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.btn-logout {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  text-decoration: none;
}

.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

/* =========================================
   MAIN WRAPPER & TOPBAR
   ========================================= */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  background: #ffffff;
  min-height: 64px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
  margin: 0;
  white-space: nowrap;
}

.content-container {
  padding: 24px 28px;
  flex: 1;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* =========================================
   STATS CARDS (SIMETRIA & ALINHAMENTO RIGOROSO)
   ========================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
  align-items: stretch;
}

.stat-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 20px 22px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  min-height: 105px;
}

.stat-card.vertical-stat {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.stat-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: transparent;
}

.stat-card:nth-child(1)::before { background: var(--primary); }
.stat-card:nth-child(2)::before { background: var(--info); }
.stat-card:nth-child(3)::before { background: var(--danger); }
.stat-card:nth-child(4)::before { background: var(--warning); }

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.stat-info h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 700;
}

.stat-info .value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-icon.green { background: #dcfce7; color: #15803d; }
.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.yellow { background: #fef3c7; color: #b45309; }
.stat-icon.red { background: #fee2e2; color: #b91c1c; }

/* =========================================
   CARDS & TABLES
   ========================================= */
.card {
  background: #fff;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 28px;
}

.card-header {
  padding: 20px 26px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #fafafa;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

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

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

.data-table th {
  background-color: #f8fafc;
  padding: 12px 16px;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  vertical-align: middle;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: #1e293b;
  vertical-align: top !important;
}

.data-table tr:hover td {
  background-color: #f8fafc;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Overlay Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
}

/* =========================================
   RESPONSIVIDADE (MOBILE & TABLETS)
   ========================================= */
@media (max-width: 900px) {
  .app-layout.sidebar-collapsed .sidebar {
    margin-left: 0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 270px;
    min-width: 270px;
    margin-left: 0 !important;
    transform: translateX(-100%);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
    z-index: 1001;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .sidebar.open + .sidebar-overlay,
  .sidebar-overlay.active {
    display: block;
  }
}

/* =========================================
   BUSCA COM LUPA & INPUTS COM ÍCONES
   ========================================= */
.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-icon-wrapper .input-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s ease;
}

.input-icon-wrapper .form-control.with-icon {
  padding-left: 42px;
}

.input-icon-wrapper:focus-within .input-icon {
  color: var(--primary);
}

/* Barra de Busca Global na Topbar */
.topbar-search-wrapper {
  position: relative;
  flex: 1;
  max-width: 480px;
  min-width: 240px;
}

.topbar-search-form {
  position: relative;
  width: 100%;
}

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

.search-icon-box {
  position: absolute;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  pointer-events: none;
  transition: color 0.2s ease, transform 0.2s ease;
  z-index: 2;
}

.topbar-search-input {
  width: 100%;
  height: 42px;
  padding: 10px 68px 10px 42px;
  font-size: 0.885rem;
  font-family: inherit;
  border-radius: 24px;
  border: 1.5px solid var(--border-color);
  background-color: #f8fafc;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease-in-out;
}

.topbar-search-input:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15);
}

.topbar-search-form:focus-within .search-icon-box {
  color: var(--primary);
  transform: scale(1.08);
}

.search-kbd {
  position: absolute;
  right: 14px;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  pointer-events: none;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.search-clear-btn {
  position: absolute;
  right: 36px;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.search-clear-btn:hover {
  color: #ef4444;
}

.search-spinner {
  position: absolute;
  right: 38px;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(22, 163, 74, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Dropdown de Resultados da Busca Instantânea */
.search-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: dropdownFadeIn 0.15s ease-out;
}

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

.search-dropdown-header {
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-results-list {
  max-height: 380px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s ease;
  gap: 12px;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
  background-color: #f0fdf4;
}

.search-item-info {
  flex: 1;
  min-width: 0;
}

.search-item-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-item-highlight {
  background-color: #fef08a;
  color: #854d0e;
  border-radius: 2px;
  padding: 0 2px;
}

.search-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.search-item-sku {
  font-family: monospace;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #334155;
}

.search-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.search-item-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.search-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.search-badge.in_stock {
  background-color: #dcfce7;
  color: #166534;
}

.search-badge.low_stock {
  background-color: #fef3c7;
  color: #92400e;
}

.search-badge.out_of_stock {
  background-color: #fee2e2;
  color: #991b1b;
}

.search-empty-state {
  padding: 28px 16px;
  text-align: center;
  color: #64748b;
  font-size: 0.88rem;
}

.search-empty-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.search-dropdown-footer {
  padding: 11px 16px;
  background-color: #f8fafc;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.search-view-all {
  font-size: 0.835rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s;
}

.search-view-all:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-location-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.btn-menu-toggle {
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  cursor: pointer;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-main);
  flex-shrink: 0;
  z-index: 20;
  position: relative;
  pointer-events: auto;
  transition: all 0.2s ease;
}

.btn-menu-toggle:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

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

/* Seletor de Local Ativo (Depósitos - 100% Clicável) */
.location-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  border: 1.5px solid var(--border-color);
  border-radius: 9px;
  padding: 0 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
  height: 40px;
  box-sizing: border-box;
  cursor: pointer;
  user-select: none;
}

.location-switcher:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
  background: #f0fdf4;
}

.location-switcher-header {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  pointer-events: none; /* O clique passa direto para o select */
}

.location-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.location-switcher-label {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #166534;
  white-space: nowrap;
}

.location-switcher-name {
  font-weight: 700;
  color: #0f172a;
  font-size: 0.86rem;
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-switcher-chevron {
  font-size: 0.72rem;
  color: #64748b;
  margin-left: 2px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.location-switcher:hover .location-switcher-chevron {
  color: var(--primary);
  transform: translateY(1px);
}

.location-switcher-select {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
  margin: 0;
  padding: 0;
  border: none;
  font-family: inherit;
}

.location-switcher-select option {
  font-weight: 600;
  color: #0f172a;
  padding: 8px;
  background: #fff;
}

.quick-access-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.quick-access-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border-radius: var(--border-radius);
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border-color);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.quick-access-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.quick-access-card strong {
  font-size: 1rem;
}

.quick-access-card span:last-child {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.quick-access-icon {
  font-size: 1.4rem;
}

.quick-access-in { border-top: 4px solid var(--primary); }
.quick-access-out { border-top: 4px solid var(--danger); }
.quick-access-users { border-top: 4px solid var(--info); }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.chart-body {
  padding: 16px 18px 22px;
}

.user-form,
.user-edit-row {
  padding: 18px 22px;
}

.form-grid-users,
.user-edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.user-edit-grid {
  grid-template-columns: 1.2fr 1.2fr 0.9fr 0.5fr 0.8fr 1.4fr;
  padding: 12px 16px;
}

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

.user-active-toggle,
.user-last-login {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Grids Especializados */
.categories-layout-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

.add-product-stock-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr auto;
  gap: 14px;
  align-items: end;
}

/* =========================================
   RESPONSIVIDADE E BREAKPOINTS GLOBAIS
   ========================================= */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .add-product-stock-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}

@media (max-width: 900px) {
  .categories-layout-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .quick-access-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .form-grid-users,
  .user-edit-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 10px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 14px;
    align-items: center;
    min-height: auto;
  }
  .topbar-left {
    grid-column: 1 / 2;
    grid-row: 1;
  }
  .topbar-right {
    grid-column: 2 / 3;
    grid-row: 1;
    justify-content: flex-end;
  }
  .topbar-search-wrapper {
    grid-column: 1 / 3;
    grid-row: 2;
    max-width: 100%;
    margin: 0;
  }
}

@media (max-width: 768px) {
  .content-container,
  .content-fluid {
    padding: 14px 14px !important;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .add-product-stock-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .topbar-title {
    font-size: 1.1rem;
  }
  .location-switcher-label {
    display: none;
  }
  .location-switcher {
    padding: 4px 8px;
    height: 36px;
  }
  .location-switcher-select {
    max-width: 135px;
    font-size: 0.8rem;
  }
}

/* =========================================
   ABAS DE NAVEGAÇÃO
   ========================================= */
.tab-nav {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.92rem;
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s ease;
  margin-bottom: -2px;
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

/* =========================================
   UTILITÁRIOS DE ALINHAMENTO RIGOROSO & TABELAS
   ========================================= */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.nowrap { white-space: nowrap !important; }
.tabular-nums { font-variant-numeric: tabular-nums; }

/* Larguras padronizadas para colunas de tabelas */
.col-sku { width: 120px; white-space: nowrap; }
.col-product { min-width: 220px; }
.col-cost { width: 100px; text-align: right; white-space: nowrap; }
.col-price { width: 105px; text-align: right; white-space: nowrap; }
.col-stock { width: 130px; text-align: right; white-space: nowrap; }
.col-locations { min-width: 240px; }
.col-min { width: 70px; text-align: center; white-space: nowrap; }
.col-actions { width: 140px; text-align: right; white-space: nowrap; }

/* Tabela de Depósitos & Locais - Alinhamento Perfeito */
.table-locations {
  width: 100%;
}

.table-locations th,
.table-locations td {
  padding: 12px 14px !important;
  vertical-align: middle !important;
}

.table-locations th {
  font-size: 0.78rem;
  letter-spacing: 0.5px;
}

/* Colunas Tabela de Depósitos */
.col-loc-id { width: 50px; text-align: center; white-space: nowrap; }
.col-loc-name { min-width: 180px; }
.col-loc-address { min-width: 220px; }
.col-loc-status { width: 90px; text-align: center; white-space: nowrap; }
.col-loc-products { width: 95px; text-align: center; white-space: nowrap; }
.col-loc-stock { width: 120px; text-align: right; white-space: nowrap; }
.col-loc-value { width: 140px; text-align: right; white-space: nowrap; }
.col-loc-actions { width: 250px; text-align: right; white-space: nowrap; }

.table-locations th.col-loc-actions,
.table-locations td.col-loc-actions {
  text-align: right !important;
  padding-right: 16px !important;
  white-space: nowrap !important;
}

/* Grupo de Ações Alinhadas em Linha */
.table-actions-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  vertical-align: middle;
}

.table-actions-group form {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

.table-actions-group .btn-action {
  height: 30px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  line-height: 1;
  box-sizing: border-box;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}

.btn-action-view {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.btn-action-view:hover {
  background: #bae6fd;
  color: #0284c7;
}

.btn-action-edit {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #cbd5e1;
}
.btn-action-edit:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-action-use {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #bbf7d0;
  font-weight: 600;
}
.btn-action-use:hover {
  background: #dcfce7;
  color: #15803d;
}

.btn-action-active {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
  font-weight: 600;
  cursor: default;
}

.btn-action-delete {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
  width: 30px;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}
.btn-action-delete:hover {
  background: #fecaca;
  color: #7f1d1d;
}

/* Filtro Select Otimizado (sem corte de texto) */
.filter-select {
  height: 38px;
  padding: 6px 32px 6px 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  font-family: inherit;
  border: 1.5px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background-color: #fff;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  min-width: 220px;
  max-width: 320px;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* =========================================
   LISTAGEM GERAL DE PRODUTOS - OTIMIZAÇÃO DE ESPAÇO
   ========================================= */
.content-fluid {
  max-width: 100% !important;
  padding: 20px 24px !important;
}

/* Tabela de Produtos Compacta & Responsiva */
.data-table-compact {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.885rem;
}

.data-table-compact th {
  background-color: #f8fafc;
  padding: 10px 14px;
  font-weight: 700;
  color: #475569;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table-compact td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  color: #1e293b;
  vertical-align: top !important; /* Início de linha perfeitamente alinhado */
}

.data-table-compact tr:hover td {
  background-color: #f8fafc;
}

.product-sku-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  display: inline-block;
  white-space: nowrap;
}

.product-barcode-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
}

.product-name-title {
  font-weight: 700;
  color: #0f172a;
  font-size: 0.92rem;
  line-height: 1.35;
  display: block;
}

.product-meta-sub {
  font-size: 0.77rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.product-loc-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  font-weight: 600;
  transition: transform 0.15s ease;
}

.product-loc-badge:hover {
  transform: translateY(-1px);
}

.product-loc-badge.in-stock {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.product-loc-badge.empty-stock {
  background: #f8fafc;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
}

.catalog-kpi-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #475569;
  font-weight: 600;
}

.catalog-kpi-pill strong {
  color: #0f172a;
}