:root {
    --primary-blue: #0067FF;
    --sidebar-bg: #1a212d;
    --sub-sidebar-bg: #293343;
    --app-bg: #d7f3ca;
    --text-dark: #2c3e50;
    --text-muted: #676613;
    --border-light: #e0e6ed;
    --accent-green: #2ecc71;
    --card-shadow: 0 2px 10px rgba(0,0,0,0.05);
    --sidebar-width: 70px;
    --sub-sidebar-width: 240px;
    --radius: 8px;
  }
  /* "Courier New", Courier, */
  * { box-sizing: border-box; margin: 0; padding: 0; font-family: Consolas, "Lucida Console", monospace;  }
  body {  background-color: var(--app-bg); color: var(--text-dark); height: 100vh; display: flex; flex-direction: column; overflow: hidden; overflow-x: hidden; }
  h1 { font-size: 22px;}
  .header { height: 60px; background: #fff; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; padding: 0 20px; justify-content: space-between; z-index: 100; }
  .header-left { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
  .header-center { flex: 1; display: flex; justify-content: center; padding: 0 20px; overflow-x: auto; }
  .header-right { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
  .logo { font-size: 20px; font-weight: 800; color: var(--primary-blue); letter-spacing: -1px; }
  .search-icon-btn { background: none; border: none; padding: 8px; cursor: pointer; color: var(--text-dark); border-radius: var(--radius); transition: 0.2s; display: flex; align-items: center; justify-content: center; outline: none; }
  .search-icon-btn:hover, .search-icon-btn:focus { background: #f0f3f7; color: var(--primary-blue); }
  .logout-icon-btn { background: none; border: none; padding: 8px; cursor: pointer; color: var(--text-dark); border-radius: var(--radius); transition: 0.2s; display: flex; align-items: center; justify-content: center; outline: none; }
  .logout-icon-btn:hover, .logout-icon-btn:focus { background: #fee; color: #dc3545; }
  .header-menu-toggle { display: none; background: none; border: 1px solid var(--border-light); padding: 6px 8px; border-radius: var(--radius); cursor: pointer; color: var(--text-dark); transition: 0.2s; margin-right: 10px; }
  .header-menu-toggle:hover, .header-menu-toggle:focus { background: #f0f3f7; color: var(--primary-blue); }
  
  /* Search Popup */
  .search-popup-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(26, 33, 45, 0.6); display: none; justify-content: center; align-items: flex-start; padding-top: 100px; z-index: 2000; }
  .search-popup-overlay.active { display: flex; }
  .search-popup-content { background: #fff; border-radius: var(--radius); box-shadow: 0 4px 20px rgba(0,0,0,0.2); width: 90%; max-width: 600px; animation: slideDown 0.3s ease-out; display: flex; flex-direction: column; max-height: 90vh; overflow: hidden; }
  .search-popup-header { padding: 20px 25px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; }
  .search-popup-header h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text-dark); }
  .search-popup-close { background: none; border: none; padding: 5px; cursor: pointer; color: var(--text-muted); border-radius: 4px; transition: 0.2s; display: flex; align-items: center; justify-content: center; outline: none; }
  .search-popup-close:hover, .search-popup-close:focus { background: #f0f3f7; color: var(--text-dark); }
  .search-popup-body { padding: 20px 25px; display: flex; flex-direction: column; gap: 15px; }
    .search-popup-input { padding: 12px 15px; border: 1px solid var(--border-light); border-radius: var(--radius); font-size: 16px; outline: none; transition: 0.2s; width: 100%; box-sizing: border-box; }
  .search-popup-input:focus { border-color: var(--primary-blue); box-shadow: 0 0 0 3px rgba(0,103,255,0.1); }
  .search-popup-results { max-height: 400px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  
  /* Horizontal Header Menu */
  .header-menu { display: flex; align-items: center; gap: 8px; list-style: none; padding: 0; margin: 0; position: relative; }
  .header-menu-item { padding: 8px 10px; border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-dark); transition: 0.2s; white-space: nowrap; outline: none; display: flex; align-items: center; gap: 3px; position: relative; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .header-menu-item:hover, .header-menu-item:focus { background: #f0f3f7; color: var(--primary-blue); }
  .header-menu-item.active { background: var(--primary-blue); color: #fff; }
  .header-menu-item .kb-badge { font-size: 9px; background: rgba(255,255,255,0.2); padding: 2px 2px; border-radius: 3px; color: inherit; }
  .header-menu-item:not(.active) .kb-badge { background: #e0e6ed; color: #666; }
  
  .app-main { display: flex; flex: 1; overflow: hidden; position: relative; }
  
  .sidebar-primary { width: var(--sidebar-width); background: var(--sidebar-bg); display: flex; flex-direction: column; align-items: center; padding-top: 20px; gap: 15px; }
  .nav-icon { width: 45px; height: 45px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #aeb9c7; cursor: pointer; transition: 0.2s; font-size: 20px; outline: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .nav-icon:hover, .nav-icon:focus { background: rgba(255,255,255,0.1); color: #fff; }
  .nav-icon.active { background: var(--primary-blue); color: #fff; box-shadow: 0 4px 12px rgba(0,103,255,0.3); }
  
  .sidebar-secondary { width: var(--sub-sidebar-width); background: var(--sub-sidebar-bg); border-right: 1px solid var(--border-light); display: none; flex-direction: column; }
  .sub-header { padding: 25px 20px 15px 20px; font-size: 18px; font-weight: 700; color: #d6e8f9; }
  .menu-list { list-style: none; padding: 10px; }
  .menu-item { padding: 12px 15px; border-radius: var(--radius); margin-bottom: 4px; cursor: pointer; font-size: 14px; color: #d6e8f9; transition: 0.2s; display: flex; justify-content: space-between; align-items: center; outline: none; }
  .menu-item:hover, .menu-item:focus { background: #f0f6ff; color: var(--primary-blue); }
  .menu-item.active { background: #eef4ff; color: var(--primary-blue); font-weight: 600; }
  .kb-badge { font-size: 10px; background: #ddd; padding: 2px 6px; border-radius: 4px; color: #666; }
  
  .content-area { flex: 1; padding: 25px; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 20px; -webkit-overflow-scrolling: touch; }
  .page-header { display: flex; justify-content: space-between; align-items: center; }
  .btn-add, .btn-delete, .btn-edit, .btn-view { 
    background: var(--primary-blue); 
    color: white; 
    border: none; 
    padding: 10px 20px; 
    border-radius: var(--radius); 
    font-weight: 600; 
    cursor: pointer; 
    box-shadow: 0 4px 10px rgba(0,103,255,0.2); 
    touch-action: manipulation; 
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    outline: none;
  }
  .btn-add:hover, .btn-add:focus {
    background: #0052cc;
    box-shadow: 0 6px 15px rgba(0,103,255,0.3);
    transform: translateY(-1px);
  }
  .btn-add svg {
    width: 16px;
    height: 16px;
    display: block;
  }
  
  /* Category Module Specific Styles */
  .page-title {
    font-size: 24px;
  }
  
  .icon-inline {
    vertical-align: middle;
    margin-right: 6px;
  }
  
  .search-filters {
    padding: 12px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
  }
  
  .search-select {
    width: 200px;
  }
  
  .keyboard-help {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
  }
  
  .pagination-wrapper {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    align-items: center;
  }
  
  .page-info {
    color: var(--text-muted);
  }
  
  .per-page-select {
    width: 120px;
    margin-left: auto;
  }
  
  .modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
  }
  
  .modal-close-btn:hover,
  .modal-close-btn:focus {
    background: #f0f3f7;
    color: var(--text-dark);
  }
  
  .file-input {
    margin-bottom: 8px;
  }
  
  .image-preview-container {
    margin-top: 8px;
    display: none;
  }
  
  .image-preview-container.show {
    display: block;
  }
  
  .preview-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    display: block;
  }
  
  .image-preview-controls {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
  }
  
  .btn-remove-image {
    background: #fee;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    outline: none;
  }
  
.btn-remove-image:hover,
.btn-remove-image:focus {
  background: #fecaca;
  border-color: #b91c1c;
  transform: translateY(-1px);
}

/* Autocomplete Styles */
.autocomplete-container {
  position: relative;
  width: 100%;
}

.autocomplete-list {
  display: none;
  position: fixed;
  /* top/left/width set by JS so dropdown is not clipped by overflow:hidden parents */
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  max-height: 300px;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.autocomplete-list.show {
  display: block;
}

.autocomplete-item {
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.2s;
}

.autocomplete-item:hover,
.autocomplete-item:focus {
  background: #f0f3f7;
}

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

  /* Production Page Styles */
  .production-container {
    display: flex;
    gap: 20px;
    height: calc(100vh - 100px);
    overflow: hidden;
  }

  .production-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
  }

  .production-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    overflow-y: auto;
  }

  .form-body {
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }

  .form-body .input-group {
    margin-bottom: 0;
  }

  .form-body .input-group.full-width {
    grid-column: 1 / -1;
  }

  .production-section-header {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-light);
    background: #f8f9fa;
  }

  /* Reports / Analytics */
  .reports-container { width: 95%; margin: 0 auto; padding: 20px; }
  .reports-container .page-title { margin-bottom: 24px; font-size: 1.5rem; }
  .report-section { margin-bottom: 32px; padding: 15px; }
  .report-section-title { font-size: 1.15rem; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
  .report-filters .filter-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
  .report-filters .input-group { min-width: 140px; }
  .report-filters .filter-actions .btn-add { margin-top: 0; }
  .report-table-wrap { overflow-x: auto; margin: 16px 0; }
  .report-table-wrap .modern-table { min-width: 600px; }
  @media (max-width: 768px) {
    .report-filters .filter-row { flex-direction: column; align-items: stretch; }
    .report-filters .input-group { min-width: 0; }
  }

  .production-section-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
  }

  .product-selection-container {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
  }

  .products-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 200px;
  }

  .production-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-light);
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .btn-search-icon,
  .btn-add-icon {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    outline: none;
  }

  .btn-search-icon:hover,
  .btn-search-icon:focus,
  .btn-add-icon:hover,
  .btn-add-icon:focus {
    background: #0052cc;
    transform: translateY(-1px);
  }

  .autocomplete-container {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .autocomplete-container .search-bar {
    flex: 1;
  }

  .inline-qty-input {
    width: 100px;
    padding: 6px 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    font-size: 14px;
  }

  /* Responsive Production Layout */
  @media (max-width: 1024px) {
    .production-container {
      flex-direction: column;
      height: auto;
      overflow: visible;
    }

    .production-left,
    .production-right {
      flex: 1;
       overflow: visible;
    }
    .content {
      padding:  10px !important;
    }
    .reports-container {
      width: 100%;
      padding: 0 !important;
    }
  }

.modal-footer-help {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
  }
  
  .category-name-cell {
    font-weight: 600;
    color: var(--primary-blue);
  }
  .btn-filter { background: #f0f3f7; color: var(--text-dark); border: 1px solid var(--border-light); padding: 8px 16px; border-radius: var(--radius); font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: 0.2s; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .btn-filter:hover, .btn-filter:focus { background: #e0e6ed; border-color: var(--primary-blue); color: var(--primary-blue); }
  .desktop-only { display: block; }
  .desktop-table-view { display: block; }
  .mobile-list-view { display: none; }
  
  /* Mobile List View Styles */
  .mobile-list-view { padding: 10px; }
  .mobile-list-item { background: #fff; border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 12px; padding: 16px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); transition: 0.2s; cursor: pointer; outline: none; }
  .mobile-list-item:hover, .mobile-list-item:focus { box-shadow: 0 4px 8px rgba(0,0,0,0.1); border-color: var(--primary-blue); }
  .mobile-list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-light); }
  .mobile-list-title { font-size: 16px; font-weight: 600; color: var(--primary-blue); flex: 1; }
  .mobile-list-actions { display: flex; gap: 6px; align-items: center; }
  .mobile-list-actions button { 
    background: none; 
    border: 1px solid var(--border-light); 
    padding: 8px; 
    cursor: pointer; 
    border-radius: 6px; 
    transition: all 0.2s; 
    touch-action: manipulation; 
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    color: var(--text-muted);
  }
  .mobile-list-actions button svg {
    display: block;
    width: 18px;
    height: 18px;
  }
  .mobile-list-actions .btn-view {
    color: #2196F3;
    border-color: #e3f2fd;
  }
  .mobile-list-actions .btn-view:hover,
  .mobile-list-actions .btn-view:focus {
    background: #e3f2fd;
    border-color: #2196F3;
    color: #1976D2;
    transform: translateY(-1px);
  }
  .mobile-list-actions .btn-edit {
    color: #FF9800;
    border-color: #fff3e0;
  }
  .mobile-list-actions .btn-edit:hover,
  .mobile-list-actions .btn-edit:focus {
    background: #fff3e0;
    border-color: #FF9800;
    color: #F57C00;
    transform: translateY(-1px);
  }
  .mobile-list-actions .btn-delete {
    color: #f44336;
    border-color: #ffebee;
  }
  .mobile-list-actions .btn-delete:hover,
  .mobile-list-actions .btn-delete:focus {
    background: #ffebee;
    border-color: #f44336;
    color: #d32f2f;
    transform: translateY(-1px);
  }
  .mobile-list-body { display: flex; flex-direction: column; gap: 10px; }
  .mobile-list-field { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
  .mobile-list-label { font-size: 14px; font-weight: 600; color: var(--text-muted); min-width: 80px; }
  .mobile-list-value { font-size: 14px; color: var(--text-dark); text-align: right; flex: 1; word-break: break-word; }
  
  .data-card { background: #fff; border-radius: var(--radius); border: 1px solid var(--border-light); box-shadow: var(--card-shadow);   }
  .modern-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 16px; }
  .modern-table th { background: #f8fafc; padding: 15px 20px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-light); cursor: pointer; }
  .modern-table td { font-weight: 500; padding: 4px 20px; border-bottom: 1px solid #f1f1f1; color: var(--text-dark); }
  .modern-table tr:last-child td { border-bottom: none; }
  .modern-table tr:hover { background: #fcfdfe; }
  
  /* Responsive table wrapper */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  .status-pill { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
  .pill-success { background: #e6f9ed; color: #27ae60; }
  
  .modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(26, 33, 45, 0.6);
    display: none;
    justify-content: center; /* center horizontally */
    align-items: flex-start; /* align to top */
    padding-top: 40px;       /* spacing from top */
    z-index: 1000;
  }
  .search-bar {
    background: #f0f3f7;
    border: 1px solid transparent;
    padding: 8px 15px;
    border-radius: var(--radius);
    width: 400px;
    outline: none;
    transition: 0.2s;
}
  .modal-content {
    width: 90%;              /* almost full width */
    max-width: 1200px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    animation: slideDown 0.3s ease-out;
    max-height: 90vh;
    overflow: hidden;
  }

  /* Advanced Product Search modal - base + responsive */
  .product-search-modal-overlay {
    align-items: flex-start;
    padding: 16px;
    overflow-y: auto;
  }
  .product-search-modal-content {
    width: 100%;
    max-width: 1100px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .product-search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
  }
  .product-search-filters .search-bar,
  .product-search-filters .search-select {
    min-width: 120px;
    flex: 1 1 140px;
  }
  .product-search-filters .btn-add {
    flex-shrink: 0;
  }
  .product-search-table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
    -webkit-overflow-scrolling: touch;
  }
  .product-search-table-wrap .modern-table {
    min-width: 500px;
  }
  .product-search-modal-content .pagination-wrapper {
    flex-shrink: 0;
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
  }
  @media (max-width: 768px) {
    .product-search-modal-overlay {
      padding: 8px;
      align-items: stretch;
    }
    .product-search-modal-content {
      max-height: calc(100vh - 16px);
    }
    .product-search-filters {
      flex-direction: column;
      align-items: stretch;
      padding: 12px;
    }
    .product-search-filters .search-bar,
    .product-search-filters .search-select {
      min-width: 0;
      flex: 1 1 auto;
      width: 100%;
    }
    .product-search-table-wrap {
      min-height: 180px;
    }
    .product-search-modal-content .modal-header {
      padding: 12px 16px;
    }
    .product-search-modal-content .modal-header h2 {
      font-size: 1.1rem;
    }
  }
  @media (max-width: 480px) {
    .product-search-filters {
      gap: 8px;
    }
    .product-search-table-wrap .modern-table {
      font-size: 13px;
    }
    .product-search-table-wrap .modern-table th,
    .product-search-table-wrap .modern-table td {
      padding: 8px 6px;
    }
  }

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

  .actions {
    display: flex;
    gap: 6px;
    align-items: center;
  }
  
  .actions button {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    outline: none;
    color: var(--text-muted);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  .actions button svg {
    display: block;
    width: 16px;
    height: 16px;
  }
  
  .actions .btn-view {
    color: #2196F3;
    border-color: #e3f2fd;
  }
  
  .actions .btn-view:hover,
  .actions .btn-view:focus {
    background: #e3f2fd;
    border-color: #2196F3;
    color: #1976D2;
    transform: translateY(-1px);
  }
  
  .actions .btn-edit {
    color: #FF9800;
    border-color: #fff3e0;
  }
  
  .actions .btn-edit:hover,
  .actions .btn-edit:focus {
    background: #fff3e0;
    border-color: #FF9800;
    color: #F57C00;
    transform: translateY(-1px);
  }
  
  .actions .btn-delete {
    color: #f44336;
    border-color: #ffebee;
  }
  
  .actions .btn-delete:hover,
  .actions .btn-delete:focus {
    background: #ffebee;
    border-color: #f44336;
    color: #d32f2f;
    transform: translateY(-1px);
  }

  
  /*
  .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(26, 33, 45, 0.6); display: none; justify-content: flex-end; z-index: 1000; }
  .modal-content { width: 80%; max-width: 1100px; background: #fff; height: 100%; animation: slideInRight 0.3s ease-out; display: flex; flex-direction: column; }
  @keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
  */
  .modal-header { padding: 25px 40px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; }
  .modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    outline: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .modal-close:hover, .modal-close:focus {
    background: #f0f3f7;
    color: var(--text-dark);
  }
  .modal-close svg {
    width: 20px;
    height: 20px;
    display: block;
  }
  .form-body { flex: 1; padding: 40px; overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; -webkit-overflow-scrolling: touch; }
  .input-group { display: flex; flex-direction: column; gap: 8px; }
  .input-group label { font-size: 14px; font-weight: 600; color: var(--text-dark); }
  .input-group input, .input-group select, .input-group textarea {     font-family: monospace; padding: 12px; border: 1px solid #a9a9a9; border-radius: 6px; font-size: 14px; outline: none; width: 100%; box-sizing: border-box; }
  .input-group input:focus { border-color: var(--primary-blue); box-shadow: 0 0 0 3px rgba(0,103,255,0.1); }
  #variantForm {
    gap: 30px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  /* Prevent zoom on input focus on iOS */
  @supports (-webkit-touch-callout: none) {
    .input-group input[type="text"],
    .input-group input[type="email"],
    .input-group input[type="number"],
    .input-group input[type="tel"],
    .input-group input[type="search"],
    .input-group select,
    .input-group textarea {
      font-size: 16px; /* Prevents zoom on iOS */
    }
  }
  .modal-footer { padding: 20px 40px; border-top: 1px solid var(--border-light); background: #f8fafc; display: flex; gap: 15px; }
  .btn-save { 
    background: var(--primary-blue); 
    color: #fff; 
    border: none; 
    padding: 12px 25px; 
    border-radius: 6px; 
    font-weight: 600; 
    cursor: pointer; 
    touch-action: manipulation; 
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    outline: none;
  }
  .btn-save:hover, .btn-save:focus {
    background: #0052cc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,103,255,0.3);
  }
  .btn-save svg {
    width: 16px;
    height: 16px;
    display: block;
  }
  .btn-cancel { 
    background: #fff; 
    border: 1px solid #d0d7de; 
    padding: 12px 25px; 
    border-radius: 6px; 
    cursor: pointer; 
    touch-action: manipulation; 
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    outline: none;
    color: var(--text-dark);
  }
  .btn-cancel:hover, .btn-cancel:focus {
    background: #f6f8fa;
    border-color: #8c959f;
    transform: translateY(-1px);
  }
  .btn-cancel svg {
    width: 16px;
    height: 16px;
    display: block;
  }
  
  /* ========================================
     RESPONSIVE DESIGN - Mobile First Approach
     ======================================== */
  
  /* Tablet and below (1024px) */
  @media (max-width: 1024px) {
    .modal-content { 
      width: 95%; 
      max-width: 95vw; 
    }
    .form-body { 
      grid-template-columns: repeat(2, 1fr); 
      gap: 20px;
      padding: 30px;
    }
    .modal-header {
      padding: 20px 30px;
    }
    .modal-footer {
      padding: 15px 30px;
    }
    .content-area {
      padding: 20px;
    }
    .header-center {
      padding: 0 10px;
    }
  }
  
  /* Mobile landscape and below (768px) */
  @media (max-width: 768px) {
    /* Header adjustments */
    .header {
      height: auto;
      min-height: 60px;
      flex-wrap: wrap;
      padding: 10px 15px;
    }
    .header-left {
      gap: 10px;
      flex: 1;
      min-width: 0;
    }
    .header-center {
      order: 3;
      width: 100%;
      padding: 10px 0 0 0; 
      position: relative;
      overflow: visible;
    }
    .header-right {
      gap: 10px;
    }
    .logo {
      font-size: 18px;
    }
    
    /* Primary sidebar - show as bottom nav on mobile */
    .sidebar-primary {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      width: 100%;
      height: 60px;
      flex-direction: row;
      justify-content: space-around;
      padding: 8px 10px;
      gap: 8px;
      z-index: 100;
      box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
    }
    .nav-icon {
      width: 44px;
      height: 44px;
      font-size: 16px;
      flex: 0 0 auto;
    }
    
    /* Content area - add bottom padding for mobile nav */
    .content-area {
      padding: 15px;
      padding-bottom: 80px; /* Space for bottom nav */
    }
    
    /* Header menu - hamburger dropdown */
    .header-menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .header-menu {
      display: none;
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      background: #fff;
      border: 1px solid var(--border-light);
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
      flex-direction: column;
      gap: 4px;
      padding: 8px 10px;
      margin-top: 6px;
      z-index: 200;
    }
    .header-menu.open { display: flex; }
    .header-menu-item {
      width: 100%;
      justify-content: flex-start;
      padding: 10px 12px;
      font-size: 13px;
    }
    .header-menu-item {
      flex-shrink: 0;
    }
    .header-menu-item .kb-badge {
      display: none; /* Hide badges on mobile to save space */
    }
    
    /* Modals */
    .modal-content {
      width: 100% !important;
      max-width: 100vw !important;
      max-height: 100vh !important;
      margin: 0 !important;
      border-radius: 0;
      padding-top: 0;
    }
    .modal-overlay {
      padding-top: 0;
      align-items: stretch;
    }
    .form-body {
      flex: none;
      grid-template-columns: 1fr !important;
      gap: 15px;
      padding: 20px 15px !important;
    }
    .form-body .input-group {
      grid-column: 1 !important;
      width: 100% !important;
      max-width: 100% !important;
    }
    .form-body .input-group[style*="grid-column"] {
      grid-column: 1 !important;
    }
    .form-body .input-group input,
    .form-body .input-group select,
    .form-body .input-group textarea {
      width: 100% !important;
      max-width: 100% !important;
      box-sizing: border-box;
    }
    .modal-header {
      padding: 15px 20px;
      position: sticky;
      top: 0;
      background: #fff;
      z-index: 10;
    }
    .modal-footer {
      padding: 15px 20px;
      position: sticky;
      bottom: 0;
      background: #f8fafc;
      z-index: 10;
      flex-wrap: wrap;
    }
    .btn-save, .btn-cancel {
      flex: 1;
      min-width: 120px;
    }
    
    /* Tables - make scrollable */
    .table-wrapper {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      margin: 0 -15px;
      padding: 0 15px;
      /* Hide scrollbar but keep functionality */
      scrollbar-width: thin;
    }
    .table-wrapper::-webkit-scrollbar {
      height: 6px;
    }
    .table-wrapper::-webkit-scrollbar-thumb {
      background: #ccc;
      border-radius: 3px;
    }
    .modern-table {
      min-width: auto; /* Ensure table doesn't get too compressed */
    }
    .modern-table th,
    .modern-table td {
      padding: 10px 12px;
      font-size: 16px;
    }
    
    /* Search popup */
    .search-popup-overlay {
      padding-top: 20px;
      align-items: flex-start;
    }
    .search-popup-content {
      width: 95% !important;
      max-width: 95vw !important;
      margin: 20px auto;
      max-height: 85vh;
    }
    .search-popup-header {
      padding: 15px 20px;
    }
    .search-popup-body {
      padding: 15px 20px;
    }
    .search-popup-results {
      max-height: calc(85vh - 150px);
    }
    
    /* Page header */
    .page-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 15px;
    } 
    /* Data card */
    .data-card {
      overflow-x: auto;
    }
    
    /* Show mobile list, hide desktop table on mobile */
    .desktop-table-view {
      display: none !important;
    }
    .mobile-list-view {
      display: block !important;
    }
    .desktop-only {
      display: none !important;
    }
    
    /* Pagination wrapper - use grid on mobile */
    .data-card > div:last-of-type {
      display: grid !important;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      padding: 10px 15px !important;
    }
    .data-card > div:last-of-type #pageInfo {
      grid-column: 1 / -1;
      text-align: center;
      margin: 5px 0;
    }
    .data-card > div:last-of-type #perPage {
      grid-column: 1 / -1;
      width: 100% !important;
      margin-left: 0 !important;
    }
  }
  
  /* Small mobile (480px and below) */
  @media (max-width: 480px) {
    .header {
      padding: 8px 10px;
    }
    .logo {
      font-size: 16px;
    }
    .header-menu-item {
      padding: 10px 12px;
      font-size: 12px;
    }
    .content-area {
      padding: 10px;
      padding-bottom: 70px;
    }
    .nav-icon {
      width: 40px;
      height: 40px;
      font-size: 14px;
      min-width: 40px;
    }
    .sidebar-primary {
      height: 55px;
      padding: 6px 5px;
      gap: 5px;
    }
    .modal-header h2 {
      font-size: 18px;
    }
    .form-body {
      padding: 15px 10px !important;
      gap: 12px;
      grid-template-columns: 1fr !important;
    }
    .form-body .input-group {
      grid-column: 1 !important;
      width: 100% !important;
      max-width: 100% !important;
    }
    .form-body .input-group[style*="grid-column"] {
      grid-column: 1 !important;
    }
    .input-group input,
    .input-group select,
    .input-group textarea {
      padding: 10px;
      font-size: 16px; /* Prevent zoom on iOS */
      width: 100% !important;
      max-width: 100% !important;
      box-sizing: border-box;
    }
    .btn-save, .btn-cancel {
      padding: 10px 15px;
      font-size: 14px;
    }
    .page-header h1 {
      font-size: 20px;
    }
    .modern-table th,
    .modern-table td {
      padding: 8px 10px; 
    }
    
    /* Mobile list adjustments for small screens */
    .mobile-list-item {
      padding: 12px;
      margin-bottom: 10px;
    }
    .mobile-list-title {
      font-size: 15px;
    }
    .mobile-list-label {
      font-size: 12px;
      min-width: 70px;
    }
    .mobile-list-value {
      font-size: 13px;
    }
    .mobile-list-actions button {
      padding: 5px;
      font-size: 16px;
    }

   .production-left, .production-right {
        flex: none;
    }
    
    /* Pagination wrapper - ensure grid layout on small mobile */
    .data-card > div:last-of-type {
      padding: 10px 10px !important;
    }
  }
  
  /* Landscape orientation adjustments */
  @media (max-height: 600px) and (orientation: landscape) {
    .header {
      height: 50px;
      padding: 5px 15px;
    }
    .sidebar-primary {
      height: 50px;
    }
    .content-area {
      padding: 10px 15px;
    }
    .modal-content {
      max-height: 95vh;
    }
  }
  
  /* Print styles */
  @media print {
    .sidebar-primary,
    .sidebar-secondary,
    .header,
    .btn-add,
    .actions,
    .modal-overlay {
      display: none !important;
    }
    .content-area {
      padding: 0;
      width: 100%;
    }
  }

  /* App header (web menu) – visible only when logged in via JS */
  .app-header { background: #fff; border-bottom: 1px solid var(--border-light); box-shadow: 0 1px 3px rgba(0,0,0,0.06); position: sticky; top: 0; z-index: 100; transition: opacity 0.2s, visibility 0.2s; }
  .app-header.hidden { opacity: 0; visibility: hidden; pointer-events: none; height: 0; overflow: hidden; border: none; }
  .app-header-inner { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; min-height: 56px; max-width: 100%; }
  .app-header-logo { font-size: 20px; font-weight: 800; color: var(--primary-blue); letter-spacing: -0.5px; text-decoration: none; padding: 8px 0; }
  .app-header-logo:hover, .app-header-logo:focus { color: #0052cc; outline: none; }
  .app-header-nav { display: flex; align-items: center; }
  .app-header-menu { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
  .app-header-menu li { margin: 0 3px; }
  .app-header-menu a { background:#f0f3f7; display: flex; align-items: center; gap: 4px; padding: 10px 8px; color: var(--text-dark); text-decoration: none; font-size: 14px; font-weight: 600; border-radius: var(--radius); transition: background 0.2s, color 0.2s; white-space: nowrap; }
  .app-header-menu a:hover, .app-header-menu a:focus { background: #f0f3f7; color: var(--primary-blue); outline: none; }
  .app-header-menu a kbd { font-size: 10px; padding: 2px 4px; background: rgba(0,0,0,0.06); border-radius: 4px; color: var(--text-muted); font-family: inherit; }
  .app-header-menu a:hover kbd, .app-header-menu a:focus kbd { background: rgba(0,103,255,0.15); color: var(--primary-blue); }
  .app-header-hamburger { display: none; background: none; border: 1px solid var(--border-light); padding: 10px 12px; border-radius: var(--radius); cursor: pointer; color: var(--text-dark); flex-direction: column; gap: 5px; align-items: center; justify-content: center; transition: background 0.2s; }
  .app-header-hamburger:hover, .app-header-hamburger:focus { background: #f0f3f7; outline: none; }
  .app-header-hamburger .hamburger-bar { display: block; width: 20px; height: 2px; background: currentColor; border-radius: 1px; transition: transform 0.2s; }
  .app-header-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .app-header-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(2) { opacity: 0; }
  .app-header-hamburger[aria-expanded="true"] .hamburger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .app-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

  @media (max-width: 768px) {
    .app-header-hamburger { display: flex; }
    .app-header-nav { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--border-light); box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-height: 0; overflow: hidden; opacity: 0; transition: max-height 0.3s, opacity 0.2s; }
    .app-header-nav.open { max-height: 80vh; overflow-y: auto; opacity: 1; }
    .app-header-menu { flex-direction: column; align-items: stretch; padding: 8px; gap: 0; width: 100%; }
    .app-header-menu a { padding: 14px 16px; border-radius: var(--radius); margin-bottom: 7px; }
  }

  /* Legacy layout compatibility */
  .layout { display:flex; min-height:100vh; }
  .sidebar { width: 240px; background: var(--sidebar-bg); color: #fff; padding: 16px; }
  .sidebar .logo { font-weight: 700; margin-bottom: 16px; }
  .sidebar a { color: #cbd5e1; text-decoration: none; display:block; padding: 8px; border-radius: 6px; }
  .sidebar a:focus, .sidebar a:hover { background: rgba(255,255,255,0.1); outline: none; }
  
  .content { flex:1; padding: 24px; }
  .content .header { display:flex; gap:8px; align-items:center; margin-bottom:16px; }
  .content .header input { flex:1; padding:8px 12px; border:1px solid var(--border-light); border-radius:8px; }
  .btn { padding:8px 12px; border:1px solid var(--border-light); background:#fff; border-radius:8px; cursor:pointer; box-shadow: 0 1px 2px var(--card-shadow); }
  .btn.primary { background: var(--primary-blue); color:#fff; border-color: var(--primary-blue); }
  
  .table-container { background:#fff; border:1px solid var(--border-light); border-radius:12px; box-shadow: var(--card-shadow); }
  .table { width:100%; border-collapse: collapse; }
  .table th, .table td { padding:10px; border-bottom:1px solid var(--border-light); }
  .table tr:focus { outline: 2px solid var(--primary-blue); }
  
  .badge { padding:4px 8px; border-radius:999px; font-size:12px; }
  .badge.active { background:#dcfce7; color:#166534; }
  .badge.inactive { background:#fee2e2; color:#991b1b; }
  
  .pager { display:flex; gap:8px; align-items:center; padding:12px; }
  
  .modal { position:fixed; inset:0; background: rgba(0,0,0,0.3); display:flex; align-items:center; justify-content:center; }
  .modal .modal-content { background:#fff; width: 520px; max-width: 90vw; border-radius:12px; padding:16px; box-shadow: 0 6px 20px var(--card-shadow); }
  .modal .modal-content form { display:grid; gap:8px; }
  .modal-actions { display:flex; gap:8px; justify-content:flex-end; }
  label { display:flex; flex-direction:column; gap:4px; }
  input, select { padding:8px; border:1px solid var(--border-light); border-radius:8px; }
  
  .production-right .form-body {
    flex: none;
    gap:0
  }
 .production-right .form-body .input-group {
    margin-bottom: 0;
    margin: 5px;
}

.hider {
  display: none;
}

 @media print {
  .report-filters,
  .btn-add,
  .btn-cancel {
    display: none !important;
  }

  /* Optional: adjust table layout for printing */
  .report-table-wrap {
    overflow: visible !important;
  }
}

.autocomplete-item.highlight {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--primary-blue);
}