/* Premium Light Theme variables */
:root {
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  
  --primary: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.08);
  --primary-hover: #3730a3;
  
  --secondary: #0d9488;
  --secondary-glow: rgba(13, 148, 136, 0.08);
  
  --warning: #d97706;
  --warning-glow: rgba(217, 119, 6, 0.08);
  
  --danger: #e11d48;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

*, *::before, *::after {
  box-sizing: border-box !important;
}

html, body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 0 !important;
}

.app-container {
  width: 100% !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-family);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Layout Classes */
.app-container {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: 210px;
  padding: 1.25rem 2rem;
  transition: var(--transition);
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0 !important;
    margin-top: 52px !important;
    padding: 0.6rem 0.6rem 4.5rem 0.6rem !important;
  }
}

/* Glassmorphism Panel style - Soft light shadows */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  transition: var(--transition);
}

.glass-panel:hover {
  border-color: var(--border-hover);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.gradient-text {
  background: linear-gradient(135deg, #0f172a 0%, #475569 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.25);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px 0 rgba(79, 70, 229, 0.35);
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: var(--text-secondary);
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--secondary);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(13, 148, 136, 0.25);
}
.btn-success:hover {
  background: #0b7a70;
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--warning);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(217, 119, 6, 0.25);
}
.btn-warning:hover {
  background: #b45309;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(225, 29, 72, 0.25);
}
.btn-danger:hover {
  background: #be123c;
  transform: translateY(-1px);
}

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

/* Sidebar navigation */
.sidebar {
  width: 210px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.65rem;
  z-index: 100;
  box-shadow: 4px 0 20px rgba(0,0,0,0.01);
  box-sizing: border-box;
}

.main-content {
  margin-left: 210px;
  padding: 1.5rem 2rem;
  min-height: 100vh;
  box-sizing: border-box;
  width: calc(100% - 210px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
  padding-left: 0.5rem;
  text-decoration: none;
}

.sidebar-brand span {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
  width: 100%;
  box-sizing: border-box;
}

.sidebar-link i {
  font-size: 1.15rem;
  width: 20px;
  text-align: center;
  transition: var(--transition);
}

.sidebar-link:hover {
  color: var(--primary);
  background: rgba(79, 70, 229, 0.04);
}

.sidebar-link.active {
  color: white;
  background: var(--primary);
  box-shadow: 0 4px 12px 0 rgba(79, 70, 229, 0.2);
}

.sidebar-link.active i {
  color: white;
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-glow);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 1px solid var(--primary);
}

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

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

/* Form layouts */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Table Design */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

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

.custom-table th {
  background: #f1f5f9;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.custom-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.9rem;
  background: #ffffff;
  transition: var(--transition);
}

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

.custom-table tbody tr:hover td {
  background: #f8fafc;
}

/* Badges / Pill tags */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

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

.badge-danger {
  background: #ffe4e6;
  color: #9f1239;
}

.badge-primary {
  background: #e0e7ff;
  color: #3730a3;
}

/* Dashboard Insights Card Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.insight-card {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-color);
}

.insight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.insight-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.insight-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.insight-icon-sales {
  background: #e0e7ff;
  color: var(--primary);
}

.insight-icon-outstanding {
  background: #fef3c7;
  color: var(--warning);
}

.insight-icon-customers {
  background: #ccfbf1;
  color: var(--secondary);
}

.insight-icon-products {
  background: #ffe4e6;
  color: var(--danger);
}

.insight-value {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.insight-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.trend-up {
  color: #047857;
  font-weight: 600;
}

.trend-down {
  color: #b91c1c;
  font-weight: 600;
}

/* Modal UI */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 550px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: scale(0.97);
  transition: var(--transition);
}

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

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
}

/* Utility classes */
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mr-2 { margin-right: 0.5rem; }

/* Login Page Styles */
.login-wrapper {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 10% 20%, rgba(79, 70, 229, 0.06) 0%, transparent 40%),
              radial-gradient(circle at 90% 80%, rgba(13, 148, 136, 0.04) 0%, transparent 40%), #f8fafc;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text-primary);
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Tabs System */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.75rem 0.5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
  transition: var(--transition);
}

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

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

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary);
}

.tab-content {
  display: none;
}

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

/* Dropdown styling */
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

/* Autocomplete suggestion container */
.suggestions-container {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  z-index: 99999;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.suggestion-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  color: var(--text-primary);
}

.suggestion-item:hover {
  background: #f1f5f9;
  color: var(--primary);
}

/* Custom Toast Notification System */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.custom-toast {
  pointer-events: auto;
  min-width: 320px;
  max-width: 440px;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  border-left: 4px solid var(--primary);
  animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transition: all 0.3s ease;
}

.custom-toast.toast-error {
  border-left-color: var(--danger);
  background: #fff5f5;
}

.custom-toast.toast-warning {
  border-left-color: var(--warning);
  background: #fffbeb;
}

.custom-toast.toast-success {
  border-left-color: #10b981;
  background: #f0fdf4;
}

.custom-toast .toast-icon {
  font-size: 1.25rem;
  margin-top: 0.1rem;
}

.custom-toast.toast-error .toast-icon { color: var(--danger); }
.custom-toast.toast-warning .toast-icon { color: var(--warning); }
.custom-toast.toast-success .toast-icon { color: #10b981; }

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

.custom-toast .toast-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.custom-toast .toast-message {
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.custom-toast .toast-close {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  background: none;
  border: none;
  padding: 0;
  margin-left: 0.5rem;
}
.custom-toast .toast-close:hover {
  color: var(--text-primary);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
/* Sidebar Overlay Backdrop for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99990;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

.mobile-topbar {
  display: none !important;
}

#mobile-menu-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.4rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  min-width: 40px;
  min-height: 40px;
}
#mobile-menu-toggle:hover,
#mobile-menu-toggle:focus,
#mobile-menu-toggle:active {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--primary);
  color: var(--primary);
}

/* Smartphone High-Density Compact Layout rules */
@media (max-width: 768px) {
  .mobile-topbar {
    display: flex !important;
    height: 54px !important;
    padding: 0 1rem !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 99995 !important;
    background: #ffffff !important;
    border-bottom: 1px solid var(--border-color) !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04) !important;
  }
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 99999 !important;
    background: #ffffff !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 10px 0 30px rgba(0,0,0,0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 1.25rem 1rem !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
  }
  .sidebar.active {
    transform: translateX(0) !important;
  }
  .sidebar .sidebar-brand {
    display: flex !important;
    margin-bottom: 1.25rem !important;
  }
  .sidebar-link span, .sidebar-footer {
    display: flex !important;
  }
  .sidebar-link {
    justify-content: flex-start !important;
    padding: 0.75rem 0.85rem !important;
  }
  
  .main-content {
    margin-left: 0 !important;
    margin-top: 54px !important;
    width: 100% !important;
    max-width: 100vw !important;
    padding: 0.6rem 0.6rem 4.5rem 0.6rem !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  
  /* Compact Typography & Titles */
  h1 { font-size: 1.25rem !important; margin-bottom: 0.15rem !important; }
  h2 { font-size: 1.15rem !important; }
  h3 { font-size: 0.95rem !important; margin-bottom: 0.5rem !important; }
  p { font-size: 0.8rem !important; }
  
  /* 1-Column Full-Width Cards for Mobile */
  .grid-2, .grid-3, .grid-4, .dashboard-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    margin-bottom: 0.75rem !important;
    width: 100% !important;
  }
  
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .flex-between {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  .flex-between > div, .flex-between .btn, .flex-between a {
    width: 100% !important;
  }
  
  .glass-panel {
    padding: 0.75rem 0.85rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: var(--radius-md) !important;
  }
  
  /* Compact Form Controls */
  .form-control, input, select, textarea {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem !important;
    min-height: 38px !important;
    border-radius: 8px !important;
  }
  
  .form-label {
    font-size: 0.75rem !important;
    margin-bottom: 0.2rem !important;
  }

  .btn {
    padding: 0.45rem 0.75rem !important;
    font-size: 0.825rem !important;
    min-height: 38px !important;
    border-radius: 8px !important;
  }
  
  /* High-Density Compact Table Rows */
  .custom-table th {
    padding: 0.45rem 0.6rem !important;
    font-size: 0.75rem !important;
    text-transform: uppercase;
  }
  
  .custom-table td {
    padding: 0.45rem 0.6rem !important;
    font-size: 0.8rem !important;
    white-space: nowrap !important;
  }

  .badge {
    padding: 0.15rem 0.4rem !important;
    font-size: 0.7rem !important;
    border-radius: 6px !important;
  }
  
  /* Mobile Tab Bar */
  .tabs {
    gap: 0.25rem !important;
    margin-bottom: 0.75rem !important;
    overflow-x: auto;
    white-space: nowrap;
  }

  .tab-btn {
    padding: 0.4rem 0.75rem !important;
    font-size: 0.8rem !important;
  }

  /* Template designer canvas mobile helper */
  .detail-workspace {
    flex-direction: column !important;
    gap: 1rem !important;
  }
  .preview-panel {
    overflow-x: auto !important;
    width: 100% !important;
  }
}

/* Native Mobile Bottom Navigation Bar Styles */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .main-content {
    padding-bottom: 5.5rem !important; /* Space for fixed bottom navigation bar */
  }

  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    z-index: 99999;
    justify-content: space-around;
    align-items: center;
    padding: 0 0.5rem;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.06);
  }

  .mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.725rem;
    font-weight: 600;
    gap: 3px;
    flex: 1;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav .nav-item i {
    font-size: 1.2rem;
  }

  .mobile-bottom-nav .nav-item.active {
    color: var(--primary);
  }

  .mobile-bottom-nav .nav-item-create {
    position: relative;
    top: -12px;
  }

  .mobile-bottom-nav .create-btn-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.4);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .mobile-bottom-nav .create-btn-circle i {
    color: #ffffff !important;
    font-size: 1.35rem !important;
  }

  .mobile-bottom-nav .nav-item-create:active .create-btn-circle {
    transform: scale(0.92);
  }

  /* Bottom sheet modal styling for native app feel */
  .modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
    animation: mobileBottomSheet 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  @keyframes mobileBottomSheet {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }
}

/* Plain Pure White Login & Authentication Styling */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff !important;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff !important;
  border-radius: var(--radius-lg) !important;
  padding: 2.5rem 2rem !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05) !important;
  border: 1px solid var(--border-color) !important;
  position: relative;
  z-index: 2;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: #0f172a !important;
  letter-spacing: -0.03em;
  margin: 0;
}

/* Dedicated Search Input Icon Container */
.search-input-wrapper {
  position: relative !important;
  width: 100% !important;
  display: block !important;
}

.search-input-wrapper i,
.search-input-icon {
  position: absolute !important;
  left: 0.85rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  color: var(--text-muted) !important;
  font-size: 0.9rem !important;
  pointer-events: none !important;
  z-index: 10 !important;
}

.search-input-wrapper input,
input.search-input-box {
  padding-left: 2.6rem !important;
  width: 100% !important;
}

/* Responsive Grid Span Classes */
.grid-span-2 {
  grid-column: span 2;
}

.grid-span-1 {
  grid-column: span 1;
}

/* Mobile Layout Rules */
.mobile-invoices-cards {
  display: none;
}

@media (max-width: 768px) {
  .grid-span-2,
  .grid-span-1 {
    grid-column: span 1 !important;
    width: 100% !important;
    min-height: auto !important;
  }

  .chart-box-wrapper {
    height: 200px !important;
  }

  /* Ensure invoice-create items editor and form tables are fully visible and touch-scrollable on mobile */
  .table-responsive,
  .items-table-container,
  .items-table-container .table-responsive {
    display: block;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
  }

  /* Strictly hide desktop-only tables on mobile viewports */
  .desktop-only-table,
  div.desktop-only-table,
  .table-responsive.desktop-only-table {
    display: none !important;
  }
  
  .mobile-invoices-cards {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }

  /* Mobile Responsive Card Form for Line Items Table (#items-grid) */
  #items-grid table {
    display: block !important;
    width: 100% !important;
  }

  #items-grid thead {
    display: none !important;
  }

  #items-grid tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.85rem !important;
    width: 100% !important;
  }

  #items-grid tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    background: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    padding: 0.85rem !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03) !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }

  #items-grid td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border: none !important;
  }

  #items-grid td input,
  #items-grid td select {
    width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* Custom Error Message & Toast Notification Dynamic Sizing & Responsiveness */
#error-message,
.error-box,
.alert-danger {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 0.75rem 1rem !important;
  font-size: 0.85rem !important;
  line-height: 1.45 !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  white-space: normal !important;
  border-radius: var(--radius-sm) !important;
  transition: all 0.2s ease-in-out !important;
}

#toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.custom-toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12);
  word-break: break-word;
  overflow-wrap: anywhere;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  width: auto;
  min-width: 260px;
  max-width: 420px;
}

.custom-toast.toast-error {
  border-left: 4px solid var(--danger);
  background: #fff5f5;
}

.custom-toast.toast-warning {
  border-left: 4px solid var(--warning);
  background: #fffbeb;
}

.custom-toast.toast-success {
  border-left: 4px solid var(--secondary);
  background: #f0fdf4;
}

.custom-toast.toast-info {
  border-left: 4px solid var(--primary);
  background: #f5f3ff;
}

.toast-icon {
  font-size: 1.1rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-success .toast-icon { color: var(--secondary); }
.toast-info .toast-icon { color: var(--primary); }

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  margin-left: 0.5rem;
  flex-shrink: 0;
  line-height: 1;
}

@media (max-width: 768px) {
  #toast-container {
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    align-items: center;
  }
  .custom-toast {
    min-width: 240px;
    max-width: calc(100vw - 1.5rem);
    width: 100%;
  }
}
