/* ========================================
   Sistema EPI - Design System
   ======================================== */

:root {
  /* Colors */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-bg: rgba(37, 99, 235, 0.1);

  --secondary: #10b981;
  --secondary-dark: #059669;
  --secondary-light: #34d399;

  --warning: #f59e0b;
  --warning-dark: #d97706;
  --warning-bg: rgba(245, 158, 11, 0.1);

  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-bg: rgba(239, 68, 68, 0.1);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);

  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.1);

  /* Neutrals */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-hover: #334155;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-color: #334155;
  --border-light: #475569;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --gradient-dark: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);

  /* Sizing */
  --sidebar-width: 160px;
  --sidebar-collapsed: 40px;
  --header-height: 56px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;

  --bg-sidebar: var(--bg-secondary);
  --bg-topbar: var(--bg-secondary);
  --bg-topbar-input: var(--bg-tertiary);
  --text-sidebar: var(--text-primary);
  --text-sidebar-muted: var(--text-muted);
  --text-topbar: var(--text-primary);
  --text-topbar-muted: var(--text-muted);
  --bg-topbar-hover: var(--bg-hover);
  --border-sidebar: var(--border-color);
}

/* Light Theme */
/* Light Theme */
[data-theme="light"] {
  /* Neutrals - Light */
  --bg-primary: #d8dee4;
  /* Mais cinza para contraste com branco */
  --bg-secondary: #ffffff;
  /* Sidebar e Topbar Brancas */
  --bg-tertiary: #f8f9fa;
  /* Inputs bem claros */
  --bg-card: #ffffff;
  /* Cards Brancos */
  --bg-hover: #f1f5f9;

  --text-primary: #0f172a;
  /* Texto preto azulado, max contraste */
  --text-secondary: #334155;
  --text-muted: #64748b;

  --border-color: #cbd5e1;
  /* Borda visível */
  --border-light: #e2e8f0;

  /* Shadows - Light (mais suaves) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.1);

  /* Gradient for light theme */
  --gradient-dark: linear-gradient(135deg, #f0f2f5 0%, #e3e8ee 100%);

  /* FORCE DARK SIDEBAR & TOPBAR IN LIGHT THEME (EXACTLY LIKE DARK) */
  --bg-sidebar: #1e293b;
  --bg-topbar: #1e293b;
  --bg-topbar-input: #334155;
  /* Dark theme tertiary */
  --text-sidebar: #f8fafc;
  --text-sidebar-muted: #94a3b8;
  --text-topbar: #f8fafc;
  --text-topbar-muted: #94a3b8;
  --bg-topbar-hover: #334155;
  --border-sidebar: #334155;

  /* Reset specific light theme overrides if they exist */
}

/* Specific improvement for Light Theme visibility - REMOVED SHADOWS, USING DARK BACKGROUND */
[data-theme="light"] .sidebar {
  box-shadow: none;
}

[data-theme="light"] .topbar {
  box-shadow: none;
}

/* Fix for highlight in Light Theme - BACK TO GRADIENT FOR DARK SIDEBAR */
[data-theme="light"] .nav-item.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

/* Light Theme Input Contrast Enhancement */
[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not(.search-box input),
[data-theme="light"] select,
[data-theme="light"] textarea {
  background-color: #f8fafc;
  border: 1px solid #94a3b8;
  /* Borda bem definida (Slate-400) */
  color: var(--text-primary);
}

[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]):not(.search-box input):focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Light theme - Ensure form-group fields have visible borders */
[data-theme="light"] .form-group input:not([type="checkbox"]):not([type="radio"]),
[data-theme="light"] .form-group select,
[data-theme="light"] .form-group textarea {
  background-color: #f8fafc;
  border: 1px solid #cbd5e1 !important;
  color: var(--text-primary);
}

[data-theme="light"] .form-group input:not([type="checkbox"]):not([type="radio"]):focus,
[data-theme="light"] .form-group select:focus,
[data-theme="light"] .form-group textarea:focus {
  background-color: #ffffff;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Fix label spacing - closer to field */
[data-theme="light"] .form-group label,
.form-group label {
  margin-bottom: 0.35rem;
}

/* Light Theme - Progress bar background for visibility */
[data-theme="light"] .capacity-bar-bg {
  background: #e2e8f0 !important;
  border: 1px solid #cbd5e1;
}

/* Light Theme - Table headers with better contrast */
[data-theme="light"] .data-table thead th {
  background-color: #f1f5f9;
  color: #334155;
  border-bottom: 2px solid #cbd5e1;
}

/* ========================================
   Reset & Base
   ======================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacMacSystemFont, sans-serif;
  background: var(--bg-secondary);
  /* Dark background for the frame */
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  /* Allow scrolling on body if content dictates, though main layout usually handles it */
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
}

table {
  border-collapse: collapse;
  width: 100%;
}

img {
  max-width: 100%;
  height: auto;
}

.hidden {
  display: none !important;
}

/* ========================================
   Login Screen
   ======================================== */

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-dark);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: var(--gradient-primary);
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.3;
  top: -200px;
  right: -200px;
}

.login-container::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: var(--gradient-success);
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.2;
  bottom: -150px;
  left: -150px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 80px;
  height: 80px;
  background: var(--gradient-primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2rem;
  color: white;
  box-shadow: var(--shadow-lg);
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ========================================
   Forms
   ======================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.form-group label i {
  color: var(--primary);
  font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 1rem;
  min-height: 48px;
  font-size: 0.95rem;
  color: var(--text-primary);
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.form-group textarea {
  padding: 1rem;
  min-height: auto;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.1);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:disabled,
.form-group select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 768px) {

  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }
}

.error-message {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-message::before {
  content: '\f071';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1.5rem;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  white-space: nowrap;
  line-height: 1.5;
  box-sizing: border-box;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-warning {
  background: var(--gradient-warning);
  color: white;
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  position: relative;
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 0.8rem;
}

.btn-logout {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem;
}

.btn-logout:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.btn-group {
  display: flex;
  gap: 0.5rem;
}

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle::after {
  content: '\f0d7';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-left: 0.5rem;
  font-size: 0.75rem;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  min-width: 160px;
  padding: 0.5rem 0;
  margin: 0.25rem 0 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
}

.dropdown.open .dropdown-menu {
  display: block;
  animation: fadeInDown 0.15s ease;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-item i {
  width: 16px;
  text-align: center;
}

.dropdown-item i.fa-file-csv {
  color: #10b981;
}

.dropdown-item i.fa-file-excel {
  color: #22c55e;
}

.dropdown-item i.fa-file-pdf {
  color: #ef4444;
}

/* ========================================
   Sidebar
   ======================================== */

/* ========================================
   New Layout (Topbar + Floating Main)
   ======================================== */

#main-app.layout-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.content-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
  background-color: var(--bg-sidebar);
  position: relative;
}

/* Creates contrast background for sidebar bottom-right rounded corner */
.content-wrapper::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 50px;
  background: linear-gradient(to top, var(--bg-primary) 24px, transparent 24px);
  pointer-events: none;
  z-index: 4;
}

/* Topbar */
.topbar {
  height: var(--header-height);
  background-color: var(--bg-topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  color: var(--text-topbar);
  flex-shrink: 0;
  z-index: 50;
  transition: background-color 0.3s ease;
}

.topbar .btn-ghost {
  color: var(--text-topbar-muted);
}

.topbar .btn-ghost:hover {
  background-color: var(--bg-topbar-hover);
  color: var(--text-topbar);
}

.topbar-search input {
  background: var(--bg-topbar-input);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  width: 300px;
  color: var(--text-topbar);
  font-size: 0.9rem;
  transition: width 0.3s ease;
}

.topbar-search i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-topbar-muted);
}

.topbar-search .kbd {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-topbar);
  border: 1px solid var(--border-sidebar);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  color: var(--text-topbar-muted);
}

.user-info-text span {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-topbar);
}

.user-info-text small {
  font-size: 0.75rem;
  color: var(--text-topbar-muted);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: var(--sidebar-width);
  padding-right: 0.5rem;
  transition: min-width 0.3s ease;
  position: relative;
  z-index: 10;
}


main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}

/* When sidebar is collapsed, also reduce topbar-left width */
.layout-container:has(.sidebar.collapsed) .topbar-left {
  min-width: var(--sidebar-collapsed);
}

.layout-container:has(.sidebar.collapsed) .topbar-left .logo span {
  display: none;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
  background: transparent;
  border: none;
  color: #e2e8f0;
  /* Brighter color for better visibility */
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.sidebar-toggle:hover {
  background: var(--bg-tertiary);
  color: #ffffff;
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 2rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Search Box in Topbar */
.search-box {
  display: flex;
  align-items: center;
  background: #334155;
  /* Always Dark Tertiary */
  border: 1px solid #334155;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  width: 100%;
  max-width: 500px;
  color: #f8fafc;
  /* Always Light Text */
  transition: all 0.2s;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.search-box i {
  margin-right: 0.75rem;
}

.search-box input {
  color: #f8fafc;
  /* Always Light Text */
  width: 100%;
  outline: none;
  font-size: 0.9rem;
  background: transparent;
  border: none;
}

.search-box .kbd {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  color: #94a3b8;
  opacity: 0.7;
}

/* Global Search Results Dropdown */
.search-box {
  position: relative;
}

.global-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 70vh;
  overflow-y: auto;
  z-index: 9999;
  animation: fadeInDown 0.2s ease;
  min-width: 400px;
}

.global-search-results.hidden {
  display: none;
}

.global-search-results::-webkit-scrollbar {
  width: 6px;
}

.global-search-results::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.search-results-section {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}

.search-results-section:last-child {
  border-bottom: none;
}

.search-results-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.search-results-section-title i {
  font-size: 0.75rem;
  color: var(--primary);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.search-result-item:hover {
  background: var(--bg-hover);
}

.search-result-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.search-result-icon.product {
  background: rgba(37, 99, 235, 0.15);
  color: var(--primary);
}

.search-result-icon.client {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.search-result-icon.supplier {
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
}

.search-result-icon.sale {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.search-result-icon.accounting {
  background: rgba(6, 182, 212, 0.15);
  color: var(--info);
}

.search-result-content {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  flex-shrink: 0;
}

.search-no-results {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.search-no-results i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.search-loading {
  padding: 2rem;
  text-align: center;
}

.search-loading .spinner {
  width: 24px;
  height: 24px;
  margin: 0 auto;
}

/* User Profile in Topbar */
.user-profile-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.user-profile-top:hover {
  background: rgba(255, 255, 255, 0.1);
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-info-text span {
  font-size: 0.9rem;
  font-weight: 600;
}

.user-info-text small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

/* Adjusted Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: none;
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  transition: width 0.3s ease, min-width 0.3s ease;
  border-bottom-right-radius: 24px;
  position: relative;
  z-index: 5;
  color: var(--text-sidebar);
}

/* Sidebar Collapsed State */
.sidebar.collapsed {
  width: var(--sidebar-collapsed) !important;
  min-width: var(--sidebar-collapsed) !important;
}

.sidebar.collapsed .nav-item span {
  display: none !important;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.5rem !important;
  width: auto !important;
}

.sidebar.collapsed .nav-item i {
  margin: 0;
  font-size: 1.1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.5rem 0;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: clamp(0.25rem, 0.5vh, 0.5rem);
  padding: clamp(0.25rem, 0.5vh, 0.5rem) clamp(0.5rem, 1vh, 0.75rem);
  margin: clamp(0.1rem, 0.15vh, 0.15rem) clamp(0.25rem, 0.5vh, 0.5rem);
  border-radius: var(--radius-md);
  color: var(--text-sidebar-muted);
  font-weight: 500;
  font-size: clamp(0.65rem, 1.2vh, 0.85rem);
  transition: var(--transition-fast);
  flex-shrink: 0;
  width: calc(100% - clamp(0.5rem, 1vh, 1rem));
  box-sizing: border-box;
}

.nav-item i {
  font-size: clamp(0.8rem, 1.1vh, 1rem);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-sidebar);
}

.nav-item.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

/* Adjusted Main Content */
.main-content {
  flex: 1;
  background-color: var(--bg-primary);
  border-top-left-radius: 24px;
  margin-left: 0;
  padding: 1.25rem 1.5rem;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: -4px -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 10;
}

/* Remove old Sidebar Header/Footer styles that might conflict */
.sidebar-header,
.sidebar-footer {
  display: none !important;
}

/* Logo styling for Topbar */
.topbar .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-topbar);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 0.5px;
}

.topbar .logo i {
  color: var(--primary);
  font-size: 1.4rem;
}


/* ========================================
   Main Content - Removed duplicate definition
   The main-content styles are defined above (line 800)
   This section was causing the gap issue
   ======================================== */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-title i {
  color: var(--primary);
  font-size: 1.5rem;
}

.page-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ========================================
   Cards
   ======================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -0.25rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title i {
  color: var(--primary);
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: var(--transition-fast);
  overflow: hidden;
  min-width: 0;
  min-height: 85px;
  /* Ensure uniform height across all stat cards */
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.stat-icon.primary {
  background: var(--primary-bg);
  color: var(--primary);
}

.stat-icon.success {
  background: var(--success-bg);
  color: var(--success);
}

.stat-icon.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.stat-icon.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.stat-icon.info {
  background: var(--info-bg);
  color: var(--info);
}

.stat-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.15rem;
  word-break: break-word;
  hyphens: auto;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.stat-change {
  font-size: 0.7rem;
  margin-top: 0.15rem;
  color: var(--text-muted);
}

.stat-change.positive {
  color: var(--success);
}

.stat-change.negative {
  color: var(--danger);
}

/* Responsive stat cards */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-value {
    font-size: 1rem;
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stat-card {
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 0.9rem;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .stat-change {
    font-size: 0.6rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-value {
    font-size: 1.1rem;
  }
}

/* ========================================
   Tables
   ======================================== */

.table-container {
  overflow-x: auto;
  margin: -1.5rem;
  margin-top: 0;
  padding: 0 1.5rem 1.5rem;
}

.data-table {
  width: 100%;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-tertiary);
}

.data-table th:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.data-table th:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.data-table td:first-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.data-table td:last-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

/* ========================================
   Badges
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-primary {
  background: var(--primary-bg);
  color: var(--primary);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

/* Light Theme Badges - Solid Colors for Clarity */
[data-theme="light"] .badge-primary {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

[data-theme="light"] .badge-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

[data-theme="light"] .badge-warning {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

[data-theme="light"] .badge-danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

[data-theme="light"] .badge-info {
  background: #ecfeff;
  color: #0e7490;
  border: 1px solid #a5f3fc;
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  min-width: 300px;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.toast-exit {
  animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error .toast-icon {
  color: var(--danger);
}

.toast-warning .toast-icon {
  color: var(--warning);
}

.toast-info .toast-icon {
  color: var(--info);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.toast-message {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.toast-close {
  background: transparent;
  color: var(--text-muted);
  padding: 0.25rem;
  font-size: 1rem;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* ========================================
   Modal
   ======================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-lg {
  max-width: 800px;
}

.modal-xl {
  max-width: 1000px;
}

.modal-header {
  padding: 1.5rem 2rem;
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-title i {
  color: var(--primary);
}

.modal-close {
  background: transparent;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-body {
  padding: 0 2rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1.5rem 2rem;
  border-top: none;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  background: transparent;
}

/* ========================================
   PDV (Point of Sale)
   ======================================== */

.pdv-container {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 1rem;
  height: calc(100vh - 110px);
  /* Adjusted to fit laptop screens without scroll */
  min-height: 500px;
}

@media (max-width: 1366px) {
  .pdv-container {
    grid-template-columns: 1fr 340px;
    /* Narrower cart on smaller screens */
    height: calc(100vh - 150px);
  }
}

@media (max-width: 1024px) {
  .pdv-container {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.pdv-products {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdv-search {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  /* Reduced margin */
}

.pdv-search input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  color: var(--text-primary);
}

.pdv-search input:focus {
  outline: none;
  border-color: var(--primary);
}

.pdv-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  overflow-y: auto;
  padding-right: 0.5rem;
  flex: 1;
}

.pdv-product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  /* Reduced padding for better fit */
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  /* Reduced gap */
  min-height: 110px;
  /* Ensure minimum height */
  height: 100%;
  /* Fill grid cell */
  justify-content: space-between;
  /* Distribute content */
}

.pdv-product-card i {
  font-size: 2rem;
  /* Limit icon size */
  margin: 0.5rem auto;
  color: var(--text-muted);
}

.pdv-product-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.pdv-product-card.out-of-stock {
  opacity: 0.5;
  cursor: not-allowed;
}

.pdv-product-name {
  font-weight: 600;
  font-size: 0.8rem;
  /* Smaller text */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pdv-product-code {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pdv-product-price {
  font-size: 1rem;
  /* Smaller price */
  font-weight: 700;
  color: var(--primary);
}

.pdv-product-stock {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ========================================
   Dynamic Product Grid Density
   ======================================== */

/* Compact Mode (> 20 items) */
.pdv-product-grid.grid-compact {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

.pdv-product-grid.grid-compact .pdv-product-card {
  padding: 0.5rem;
  min-height: 120px;
}

.pdv-product-grid.grid-compact .pdv-product-name {
  font-size: 0.8rem;
}

.pdv-product-grid.grid-compact .pdv-product-price {
  font-size: 0.9rem;
}

.pdv-product-grid.grid-compact .pdv-product-code {
  font-size: 0.7rem;
}

/* Micro Mode (> 50 items) - Optimized for 200+ list */
.pdv-product-grid.grid-micro {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
}

.pdv-product-grid.grid-micro .pdv-product-card {
  padding: 0.4rem;
  min-height: 110px;
  gap: 0.2rem;
}

.pdv-product-grid.grid-micro .pdv-product-name {
  font-size: 0.75rem;
  line-height: 1.1;
  -webkit-line-clamp: 2;
}

.pdv-product-grid.grid-micro .pdv-product-code {
  display: none;
  /* Hide code to save space */
}

.pdv-product-grid.grid-micro .pdv-product-price {
  font-size: 0.85rem;
  margin-top: 0;
}

.pdv-product-grid.grid-micro .pdv-product-stock {
  font-size: 0.7rem;
}

.pdv-product-grid.grid-micro .pdv-product-image i {
  font-size: 1.5rem;
  /* Smaller placeholder icon */
}

.pdv-product-grid.grid-micro .pdv-product-image img {
  height: 80px;
  /* Constrain image height if needed, though object-contain handles it usually */
}

.pdv-product-stock.low {
  color: var(--warning);
}

.pdv-product-stock.critical {
  color: var(--danger);
}

.pdv-cart {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  /* Fill available height */
}

.pdv-cart-header {
  padding: 0.5rem 1rem;
  /* Reduced padding */
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  /* Don't shrink */
}

.pdv-cart-title {
  font-weight: 600;
  font-size: 0.9rem;
  /* Slightly smaller */
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pdv-cart-count {
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  /* Smaller */
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.pdv-cart-items {
  flex: 1;
  /* Share space equally */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem;
  min-height: 0;
  border-bottom: 1px solid var(--border-color);
  /* Separator */
}

.pdv-cart-summary {
  flex: 1;
  /* Share space equally */
  overflow-y: auto;
  /* Allow scrolling within summary if needed */
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* Center content vertically */
}

.pdv-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 1.5rem;
}

.pdv-cart-empty i {
  font-size: 2.5rem;
  /* Smaller icon */
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.pdv-cart-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* Reduced gap */
  padding: 0.5rem;
  /* More compact */
  border-radius: var(--radius-md);
  margin-bottom: 0.4rem;
  /* Tighter spacing */
  background: var(--bg-tertiary);
  transition: all 0.2s;
}

.pdv-cart-item:hover {
  background: var(--bg-hover);
}

.pdv-cart-item-info {
  flex: 1;
  min-width: 0;
}

.pdv-cart-item-name {
  font-weight: 500;
  font-size: 0.8rem;
  /* Smaller text */
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdv-cart-item-price {
  font-size: 0.7rem;
  /* Smaller */
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

.pdv-cart-item-qty {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  /* Tighter */
}

.pdv-cart-item-qty button {
  width: 24px;
  /* Smaller buttons */
  height: 24px;
  background: var(--bg-hover);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.pdv-cart-item-qty button:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.1);
}

.pdv-cart-item-qty span {
  min-width: 20px;
  /* Narrower */
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.pdv-cart-item-total {
  font-weight: 600;
  color: var(--primary);
  min-width: 70px;
  /* Narrower */
  text-align: right;
  font-size: 0.85rem;
}

.pdv-cart-item-remove {
  background: transparent;
  color: var(--text-muted);
  padding: 0.2rem;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.pdv-cart-item-remove:hover {
  color: var(--danger);
  transform: scale(1.2);
}

/* .pdv-cart-summary style moved/merged above for 50/50 split */

.pdv-cart-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
  /* Tighter */
  font-size: 0.8rem;
  /* Smaller */
}

.pdv-cart-row:last-of-type {
  margin-bottom: 0;
}

.pdv-cart-total {
  font-size: 1.1rem;
  /* Much smaller - was 1.25rem */
  font-weight: 700;
  color: var(--primary);
}

.pdv-cart-actions {
  display: flex;
  gap: 0.4rem;
  /* Tighter */
  margin-top: 0.5rem;
  /* Reduced */
}

.pdv-cart-actions .btn {
  flex: 1;
  padding: 0.5rem 0.6rem;
  /* More compact buttons */
  font-size: 0.8rem;
  /* Smaller text */
}

/* ========================================
   Dynamic Cart Item Sizes
   ======================================== */

/* Compact mode: 3-4 items */
.pdv-cart-item.cart-item-compact {
  padding: 0.4rem;
  margin-bottom: 0.3rem;
  gap: 0.4rem;
}

.pdv-cart-item.cart-item-compact .pdv-cart-item-name {
  font-size: 0.75rem;
}

.pdv-cart-item.cart-item-compact .pdv-cart-item-price {
  font-size: 0.65rem;
}

.pdv-cart-item.cart-item-compact .pdv-cart-item-qty button {
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
}

.pdv-cart-item.cart-item-compact .pdv-cart-item-qty span {
  font-size: 0.8rem;
  min-width: 18px;
}

.pdv-cart-item.cart-item-compact .pdv-cart-item-total {
  font-size: 0.8rem;
  min-width: 65px;
}

/* Mini mode: 5-7 items */
.pdv-cart-item.cart-item-mini {
  padding: 0.3rem;
  margin-bottom: 0.25rem;
  gap: 0.3rem;
}

.pdv-cart-item.cart-item-mini .pdv-cart-item-image {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

.pdv-cart-item.cart-item-mini .pdv-cart-item-name {
  font-size: 0.7rem;
  line-height: 1.1;
}

.pdv-cart-item.cart-item-mini .pdv-cart-item-price {
  font-size: 0.6rem;
  margin-top: 0;
}

.pdv-cart-item.cart-item-mini .pdv-cart-item-qty {
  gap: 0.2rem;
}

.pdv-cart-item.cart-item-mini .pdv-cart-item-qty button {
  width: 20px;
  height: 20px;
  font-size: 0.65rem;
}

.pdv-cart-item.cart-item-mini .pdv-cart-item-qty span {
  font-size: 0.75rem;
  min-width: 16px;
}

.pdv-cart-item.cart-item-mini .pdv-cart-item-total {
  font-size: 0.75rem;
  min-width: 60px;
}

.pdv-cart-item.cart-item-mini .pdv-cart-item-remove {
  font-size: 0.8rem;
  padding: 0.1rem;
}

/* Micro mode: 8+ items */
.pdv-cart-item.cart-item-micro {
  padding: 0.25rem;
  margin-bottom: 0.2rem;
  gap: 0.25rem;
}

.pdv-cart-item.cart-item-micro .pdv-cart-item-image {
  width: 24px;
  height: 24px;
  font-size: 0.6rem;
}

.pdv-cart-item.cart-item-micro .pdv-cart-item-name {
  font-size: 0.65rem;
  line-height: 1;
}

.pdv-cart-item.cart-item-micro .pdv-cart-item-price {
  font-size: 0.55rem;
  margin-top: 0;
}

.pdv-cart-item.cart-item-micro .pdv-cart-item-qty {
  gap: 0.15rem;
}

.pdv-cart-item.cart-item-micro .pdv-cart-item-qty button {
  width: 18px;
  height: 18px;
  font-size: 0.6rem;
}

.pdv-cart-item.cart-item-micro .pdv-cart-item-qty span {
  font-size: 0.7rem;
  min-width: 14px;
}

.pdv-cart-item.cart-item-micro .pdv-cart-item-total {
  font-size: 0.7rem;
  min-width: 55px;
}

.pdv-cart-item.cart-item-micro .pdv-cart-item-remove {
  font-size: 0.75rem;
  padding: 0.05rem;
}

/* ========================================
   Search and Filters
   ======================================== */

.search-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-input input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  color: var(--text-primary);
}

.search-input input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-input i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filter-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  min-width: 150px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ========================================
   Loading
   ======================================== */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {

  /* Sidebar always visible, but collapsed on small screens */
  .sidebar {
    width: var(--sidebar-collapsed);
  }

  .sidebar .logo span,
  .sidebar .nav-item span,
  .sidebar .user-details {
    display: none;
  }

  .sidebar .nav-item {
    justify-content: center;
  }

  .sidebar .sidebar-footer {
    padding: 0.5rem;
  }

  .sidebar .sidebar-theme span {
    display: none;
  }

  .sidebar .sidebar-theme button {
    justify-content: center;
    padding: 0.5rem;
  }

  .sidebar .sidebar-version span {
    display: none;
  }

  .sidebar .sidebar-preferences span {
    display: none;
  }

  .sidebar .sidebar-preferences button {
    justify-content: center;
    padding: 0.5rem;
  }

  .main-content {
    margin-left: var(--sidebar-collapsed);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   Print Styles
   ======================================== */

.print-container {
  display: none;
}

@media print {
  @page {
    margin: 10mm;
    size: auto;
  }

  body,
  html {
    margin: 0;
    padding: 0;
    background: white;
    height: auto;
  }

  /* Hide everything by default using visibility to keep structure if needed, 
     but display:none for main layout blocks to collapse height */
  body * {
    visibility: hidden;
  }

  /* Keep app container visible purely for nesting context if needed */
  #app {
    visibility: visible;
    position: static;
    margin: 0;
    padding: 0;
  }

  /* Explicitly remove layout elements */
  #sidebar,
  .sidebar,
  #main-content,
  .main-content,
  #login-screen,
  .login-container,
  #modal-overlay,
  #toast-container,
  .sidebar-toggle,
  .mobile-nav {
    display: none !important;
  }

  /* Print container logic */
  .print-container,
  .print-container * {
    visibility: visible;
  }

  .print-container {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    background: white;
    color: black;
    z-index: 9999;
  }

  .print-container * {
    page-break-inside: avoid;
  }
}

/* ========================================
   Stock Indicators
   ======================================== */

.stock-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.stock-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.stock-indicator.normal .dot {
  background: var(--success);
}

.stock-indicator.low .dot {
  background: var(--warning);
}

.stock-indicator.critical .dot {
  background: var(--danger);
  animation: pulse 1s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ========================================
   Tabs
   ======================================== */

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-weight: 500;
  transition: var(--transition-fast);
  position: relative;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.tab-btn.active {
  color: var(--primary);
  background: var(--primary-bg);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ========================================
   Alerts List
   ======================================== */

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--warning);
}

.alert-item.critical {
  border-left-color: var(--danger);
}

.alert-item .product-name {
  flex: 1;
  font-weight: 500;
}

.alert-item .stock-info {
  text-align: right;
}

.alert-item .stock-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.alert-item .stock-value {
  font-weight: 600;
}

.alert-item .stock-value.zero {
  color: var(--danger);
}

.alert-item .stock-value.low {
  color: var(--warning);
}

/* ========================================
   Category Tabs (PDV)
   ======================================== */

.category-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.category-tabs::-webkit-scrollbar {
  height: 4px;
}

.category-tabs::-webkit-scrollbar-track {
  background: transparent;
}

.category-tabs::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

.category-tab {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.category-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}

.category-tab i {
  font-size: 0.75rem;
}

.category-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.category-tab.active {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}

/* ========================================
   Product Cards with Images (PDV)
   ======================================== */

.pdv-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  max-height: calc(100vh - 320px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.pdv-product-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-fast);
  overflow: hidden;
}

.pdv-product-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.pdv-product-card.out-of-stock {
  opacity: 0.6;
  cursor: not-allowed;
}

.pdv-product-card.out-of-stock:hover {
  transform: none;
  border-color: var(--border-color);
  box-shadow: none;
}

.pdv-product-image {
  width: 100%;
  height: 120px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.pdv-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pdv-product-no-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.pdv-product-no-image i {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.out-of-stock-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--danger);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.pdv-product-info {
  padding: 0.75rem;
}

.pdv-product-name {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdv-product-code {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.pdv-product-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.pdv-product-stock {
  font-size: 0.75rem;
  color: var(--success);
}

.pdv-product-stock.low {
  color: var(--warning);
}

.pdv-product-stock.critical {
  color: var(--danger);
}

/* ========================================
   Cart Item with Image
   ======================================== */

.pdv-cart-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.pdv-cart-item-image {
  width: 40px;
  height: 40px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.pdv-cart-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pdv-cart-item-image i {
  color: var(--text-muted);
  font-size: 1rem;
}

.pdv-cart-item-info {
  flex: 1;
  min-width: 0;
}

.pdv-cart-item-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdv-cart-item-price {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pdv-cart-item-qty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pdv-cart-item-qty button {
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.pdv-cart-item-qty button:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.pdv-cart-item-qty span {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
}

.pdv-cart-item-total {
  font-weight: 700;
  color: var(--primary);
  min-width: 70px;
  text-align: right;
}

.pdv-cart-item-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  transition: var(--transition-fast);
}

.pdv-cart-item-remove:hover {
  color: var(--danger);
}

/* ========================================
   Product Image Upload
   ======================================== */

.product-image-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.image-preview {
  width: 160px;
  height: 160px;
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.image-placeholder i {
  font-size: 3rem;
}

.image-placeholder span {
  font-size: 0.85rem;
}

.image-loading {
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-upload-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ========================================
   Product Thumbnail (Table)
   ======================================== */

.product-thumb {
  width: 50px;
  height: 50px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-thumb i {
  color: var(--text-muted);
  font-size: 1.25rem;
}

/* ========================================
   PDV Container Updates
   ======================================== */

.pdv-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  height: calc(100vh - 180px);
}

@media (max-width: 1200px) {
  .pdv-container {
    grid-template-columns: 1fr;
    height: auto;
  }

  .pdv-cart {
    max-height: 500px;
  }
}

.pdv-products {
  display: flex;
  flex-direction: column;
}

.pdv-search {
  margin-bottom: 1rem;
}

.pdv-search input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  color: var(--text-primary);
  font-size: 1rem;
}

.pdv-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.pdv-cart {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdv-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.pdv-cart-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.pdv-cart-count {
  background: var(--primary);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}

.pdv-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.pdv-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
}

.pdv-cart-empty i {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.pdv-cart-summary {
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.pdv-cart-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.pdv-cart-total {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.pdv-cart-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pdv-cart-actions .btn {
  width: 100%;
}

/* Make the 3rd button (Finalizar) span full width */
.pdv-cart-actions .btn:last-child {
  grid-column: span 2;
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
  .category-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.35rem;
  }

  .category-tab {
    min-width: 55px;
    max-width: 70px;
    padding: 0.4rem 0.5rem;
    font-size: 0.55rem;
    gap: 0.25rem;
  }

  .category-tab i {
    font-size: 0.9rem;
  }

  .pdv-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .pdv-product-image {
    height: 100px;
  }
}

/* ========================================
   Settings Page
   ======================================== */

.sub-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.sub-tabs .tab-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

.profiles-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.profile-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: var(--transition-fast);
}

.profile-item:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.profile-info strong {
  font-size: 1rem;
}

.profile-actions {
  display: flex;
  gap: 0.5rem;
}

.permissions-table th,
.permissions-table td {
  padding: 1rem;
  vertical-align: middle;
}

.permissions-table th:first-child,
.permissions-table td:first-child {
  min-width: 180px;
}

.integrations-grid {
  display: grid;
  gap: 1rem;
}

.integration-item {
  display: flex;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: var(--transition-fast);
}

.integration-item:hover {
  border-color: var(--primary);
}

.integration-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.integration-info h4 {
  margin: 0 0 0.25rem 0;
  font-size: 1rem;
}

.integration-info p {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Deliveries Grid Layout */
.deliveries-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1rem;
}

@media (max-width: 768px) {
  .deliveries-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Auto-appended Print Fix --- */
@media print {
  @page {
    margin: 0;
    size: auto;
  }

  body,
  html {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    background: white !important;
  }

  /* Override the generic hide that causes whitespace */
  body * {
    visibility: visible !important;
  }

  /* Collapse layout */
  #app>* {
    display: none !important;
  }

  /* Show app container */
  #app {
    display: block !important;
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Show print container */
  #app>.print-container {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    z-index: 99999 !important;
  }

  .print-container table {
    width: 100% !important;
  }
}

/* ========================================
   Responsive PDV Height Adjustments (Laptop Screens)
   ======================================== */
@media (max-height: 900px) {
  .pdv-cart-summary {
    padding: 0.4rem 0.6rem;
    min-height: auto;
  }

  .pdv-cart-row {
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
  }

  .pdv-cart-total {
    font-size: 1.2rem;
    /* Reduced from 1.5rem */
  }

  .pdv-cart-actions {
    margin-top: 0.5rem;
    gap: 0.4rem;
  }

  .pdv-cart-actions .btn {
    padding: 0.5rem 0.5rem !important;
    height: auto;
    min-height: 38px;
    font-size: 0.85rem !important;
  }

  .pdv-cart-actions .btn i {
    font-size: 1rem;
  }
}

/* ========================================
   PDV Large Screen Enhancement (Responsive Expansion)
   Restores larger UI elements on big monitors (Like Sidebar logic)
   ======================================== */
@media (min-width: 1441px) and (min-height: 901px) {
  .pdv-container {
    height: calc(100vh - 160px);
    gap: 1.5rem;
    margin-top: -1.5rem;
    /* Force move up to avoid scroll */
  }

  /* Compact header */
  .page-header {
    margin-bottom: 0.5rem !important;
  }

  .pdv-product-card {
    min-height: 125px;
    /* Reduced */
    padding: 1rem;
    gap: 0.5rem;
  }

  .pdv-product-card i {
    font-size: 3rem;
    /* Bigger icon */
    margin: 0.5rem auto;
  }

  .pdv-product-name {
    font-size: 1rem;
    font-weight: 700;
  }

  .pdv-product-price {
    font-size: 1.25rem;
  }

  .pdv-search {
    margin-bottom: 1rem;
  }

  .pdv-search input {
    padding: 1rem;
    font-size: 1rem;
  }
}

/* ========================================
   FINAL PROPORTION FIX (Cart Footer Optimization)
   Restores layout beauty while slimming down buttons
   ======================================== */

/* 1. Restore Large Screen Aesthetics (Removing Hacks) */
@media (min-width: 1441px) and (min-height: 901px) {
  .pdv-container {
    height: calc(100vh - 140px) !important;
    margin-top: 0 !important;
  }

  .page-header {
    margin-bottom: 1.5rem !important;
    margin-top: 0 !important;
  }

  .pdv-product-card {
    min-height: 145px !important;
  }
}

/* 2. Slim Down the Cart Footer (The Real Fix) */
.pdv-cart-summary {
  padding: 0.5rem 0.75rem !important;
}

.pdv-cart-row {
  margin-bottom: 0.15rem !important;
}

.pdv-cart-total {
  margin: 0.25rem 0 0.5rem 0 !important;
}

/* Make Buttons Slimmer & Elegant */
.pdv-cart-actions .btn {
  height: 40px !important;
  padding: 0 1rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: auto !important;
}

/* ========================================
   ABSOLUTE FINAL SCROLL FIX 
   Adjusting calculation to strictly prevent overflow
   ======================================== */
@media (min-width: 1441px) and (min-height: 901px) {
  .pdv-container {
    /* Increasing subtraction to 190px ensures header+margins fit */
    height: calc(100vh - 190px) !important;
    margin-top: 0 !important;
  }

  /* ========================================
   ROOT CAUSE FIX: Element Sizing
   Directly shrinking the elements causing overflow
   ======================================== */

  /* 1. Fix Products Sizing (The main culprit) */
  .pdv-product-card {
    min-height: 120px !important;
    /* Reduced heavy height */
    padding: 0.6rem !important;
    /* Less padding = more space */
    gap: 0.25rem !important;
  }

  .pdv-product-card i {
    font-size: 2rem !important;
    /* Manageable icon size */
    margin: 0.25rem auto !important;
  }

  .pdv-product-name {
    font-size: 0.9rem !important;
    /* Balanced text */
    line-height: 1.2 !important;
  }

  /* 2. Fix Cart Footer Sizing (Secondary culprit) */
  .pdv-cart-summary {
    padding: 0.5rem !important;
  }

  .pdv-cart-total {
    font-size: 1.25rem !important;
    margin: 0.25rem 0 !important;
  }

  /* Ensure container allows inner scroll instead of window scroll */
  .pdv-container {
    overflow: hidden !important;
  }

  .pdv-product-grid {
    overflow-y: auto !important;
    padding-bottom: 1rem;
  }
}

/* ========================================
   ZOOM OUT FIX (USER REQUESTED)
   Scaling down specifically for large screens to prevent scroll
   ======================================== */
@media (min-width: 1441px) {
  .pdv-container {
    zoom: 0.92 !important;
    /* The "Little Zoom Out" - 8% smaller */
  }
}

/* ========================================
   AGGRESSIVE FOOTER COMPACTING (USER REQUEST)
   Removing all wasted whitespace in the cart footer
   ======================================== */
.pdv-cart-summary {
  padding: 0.5rem 0.5rem 0.25rem 0.5rem !important;
  /* Zero bottom padding */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.pdv-cart-total {
  margin-bottom: 0 !important;
  line-height: 1.1;
}

.pdv-cart-actions {
  margin-top: 0.25rem !important;
  gap: 0.25rem !important;
}

.pdv-cart-actions .btn {
  margin-bottom: 0 !important;
}

/* Fix Card Container Sizing */
.pdv-cart {
  height: 100% !important;
  overflow: hidden !important;
  border-radius: var(--radius-lg);
  /* Ensure it fits */
}

@media (max-width: 1440px) {
  .pdv-container {
    zoom: 0.95 !important;
    /* 5% reduction for laptops to ensure fit */
  }
}

/* ========================================
   PROPORTIONAL REDUCTION (ZOOM OUT 85%)
   Scales down the entire module proportionally to fit screen
   ======================================== */
@media (min-width: 1024px) {
  .pdv-container {
    /* Scale everything down by 15% */
    zoom: 0.85 !important;

    /* Compensate width to fill screen (100% / 0.85 = ~117.6%) */
    width: 117.65% !important;

    /* Reset heights to let zoom handle fit */
    height: calc((100vh - 100px) / 0.85) !important;

    /* Ensure no extra margins */
    margin: 0 !important;
  }

  /* Restore footer padding slightly for aesthetics (undo aggressive cut), relying on zoom to fit */
  .pdv-cart-summary {
    padding: 0.75rem !important;
    padding-bottom: 0.5rem !important;
    justify-content: flex-end;
  }

  .pdv-cart-total {
    margin-bottom: 0.5rem !important;
  }

  /* ========================================
   EMERGENCY FIX: ZOOM + FLEX LAYOUT
   1. Zoom 0.9 (90%) for perfect proportional fit.
   2. Reset width to 100% to fix overflow.
   3. Force Flex layout on Cart to fill white space properly.
   ======================================== */
  @media (min-width: 1024px) {
    .pdv-container {
      zoom: 0.9 !important;
      /* The precise zoom level */
      width: 100% !important;
      /* Fix horizontal overflow */
      height: auto !important;
      margin: 0 !important;
      overflow: hidden !important;
    }

    /* Force Cart Card to be a full-height Flex Column */
    .pdv-cart {
      display: flex !important;
      flex-direction: column !important;
      /* Calculate height considering zoom: (100vh - header) / zoom */
      height: calc((100vh - 100px) / 0.9) !important;
    }

    /* The Item List MUST grow to eat empty space */
    .pdv-cart-items {
      flex: 1 1 auto !important;
      overflow-y: auto !important;
      min-height: 0 !important;
      /* Critical for scroll */
    }

    /* Footer stays at bottom, compact but clean */
    .pdv-cart-summary {
      flex-shrink: 0 !important;
      padding: 0.5rem 0.75rem !important;
      justify-content: flex-end !important;
    }

  }
}

/* ========================================
   FINAL VERTICAL COMPACT FIX (PRICE MODAL)
   Resets previous zoom errors and compacts vertical height ONLY
   ======================================== */
@media (min-width: 1024px) {

  /* 1. RESET BROKEN ZOOM/WIDTH */
  .pdv-container {
    zoom: 1 !important;
    width: 100% !important;
    height: calc(100vh - 140px) !important;
    margin: 0 !important;
    overflow: hidden !important;
    transform: none !important;
  }

  /* 2. COMPACT CART FOOTER VERTICALLY (Approved Strategy) */
  .pdv-cart-summary {
    padding: 0.5rem !important;
    flex-shrink: 0 !important;
  }

  .pdv-cart-row {
    margin-bottom: 0.1rem !important;
    /* Tighten rows */
    font-size: 0.85rem !important;
  }

  .pdv-cart-total {
    margin: 0.2rem 0 0.4rem 0 !important;
    /* Tighten total */
    font-size: 1.3rem !important;
    line-height: 1 !important;
  }

  .pdv-cart-actions {
    margin-top: 0.2rem !important;
    gap: 0.3rem !important;
  }

  .pdv-cart-actions .btn {
    height: 38px !important;
    /* Fixed small height */
    padding: 0 !important;
    min-height: 0 !important;
    margin-bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Ensure flex fills space correctly */
  /* REMOVE WHITE SPACE: Auto Height */
  /* AREA X FIX: Shrink Vertically & Remove White Space */
  .pdv-cart {
    display: flex !important;
    flex-direction: column !important;
    height: fit-content !important;
    /* KEY: Only take needed space */
    min-height: 0 !important;
    max-height: 85vh !important;
    zoom: 0.9 !important;
    /* Diminua Bastante */
  }

  .pdv-cart-items {
    flex: 0 0 auto !important;
    /* Do not grow */
    height: auto !important;
    max-height: 50vh !important;
    /* Scroll internally if needed */
    overflow-y: auto !important;
    min-height: 0 !important;
  }
}

/* ========================================
   ULTIMATE SCROLL FIX (AGGRESSIVE CUT)
   Cutting height drastically to calc(100vh - 250px) to guarantee NO SCROLL
   ======================================== */
@media (min-width: 1024px) {
  .pdv-container {
    height: calc(100vh - 250px) !important;
    /* The scroll killer */
    min-height: 0 !important;
    overflow: hidden !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
  }

  /* ========================================
   NOTEBOOK/CHROME RESCUE FIX
   Fixes cut-off buttons on smaller screens by zooming out
   ======================================== */
  @media (max-width: 1440px),
  (max-height: 900px) {
    .pdv-container {
      /* Zoom out contents to fit in limited vertical space */
      zoom: 0.85 !important;

      /* Adjust height allows space for header but fits in viewport */
      /* (100vh - 160px header) scaled by zoom - KILL SCROLL */
      height: calc((100vh - 160px) / 0.85) !important;

      min-height: 0 !important;
      overflow: hidden !important;
      padding-bottom: 0 !important;
      margin-bottom: 0 !important;
    }

    /* Ensure footer items are compact */
    .pdv-cart-actions .btn {
      height: 34px !important;
    }
  }

  /* Calendar Module */
  .calendar-cell {
    transition: background-color 0.2s;
    user-select: none;
  }

  .calendar-cell:hover {
    background-color: var(--bg-tertiary) !important;
  }

  .calendar-cell.outside-month:hover {
    background-color: var(--bg-primary) !important;
    cursor: default;
  }

  .event-chip {
    font-size: 0.75rem;
    padding: 2px 4px;
    border-radius: 4px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .event-chip:hover {
    opacity: 0.8;
  }

  /* Notification Dismiss Button */
  .notification-dismiss {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%) translateX(10px);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 2;
  }

  .notification-item:hover .notification-dismiss {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }

  .notification-dismiss:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
  }

  .notification-item {
    position: relative;
    /* Needed for absolute positioning of dismiss button */
  }