* {
  box-sizing: border-box;
  font-family: 'Bai Jamjuree', 'Tahoma', 'Sarabun', sans-serif;
}

body {
  font-family: 'Bai Jamjuree', 'Tahoma', 'Sarabun', sans-serif;
  padding: 10px;
  background: #f5f5f5;
  font-size: 12px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  background: #fff;
  padding: 15px;
  border: 1px solid #333;
}

.header {
  display: flex;
  border-bottom: 2px solid #333;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.logo {
  width: 120px;
  padding: 5px;
  background: #a8d5a2;
  border: 1px solid #333;
}

.logo img {
  width: 100%;
  height: auto;
  display: block;
}

.title-section {
  flex: 1;
  text-align: center;
}

.title-section h2 {
  margin: 5px 0;
  color: #006400;
  font-size: 16px;
}

/* User Info Styles */
.user-info {
  background: #e8f5e8 !important;
  border: 1px solid #28a745;
  border-radius: 5px;
  padding: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info #currentUserDisplay {
  color: #155724;
  font-weight: 500;
}

.user-info #logoutBtn {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.user-info #logoutBtn:hover {
  background: #c82333;
}

.title-section h3 {
  margin: 5px 0;
  font-size: 14px;
}

.doc-info {
  width: 200px;
  font-size: 11px;
  border-left: 1px solid #333;
  padding-left: 10px;
}

.doc-info label {
  display: inline-block;
  width: 80px;
}

.doc-info input {
  width: 100px;
  font-size: 11px;
  border: 1px solid #ccc;
  padding: 2px;
  margin: 2px 0;
}

.section {
  margin-bottom: 15px;
}

.section h4 {
  background: #e8e8e8;
  padding: 5px 10px;
  margin: 0 0 5px 0;
  border: 1px solid #333;
  font-size: 12px;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table td {
  padding: 5px;
  border: 1px solid #333;
  font-size: 11px;
}

.info-table input {
  width: 100px;
  border: 1px solid #ccc;
  padding: 2px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.data-table th,
.data-table td {
  border: 1px solid #333;
  padding: 4px;
  text-align: center;
}

.data-table th {
  background: #d4edda;
  font-weight: bold;
}

.data-table tbody tr:nth-child(even) {
  background: #f9f9f9;
}

.small-input {
  width: 60px;
  border: 1px solid #ccc;
  padding: 2px;
  text-align: center;
}

.medium-input {
  width: 120px;
  border: 1px solid #ccc;
  padding: 2px;
}

.remark-input {
  width: 100%;
  border: 1px solid #ccc;
  padding: 2px;
}

.full-input {
  width: 300px;
  border: 1px solid #ccc;
  padding: 2px;
}

.remark-row {
  padding: 5px;
  border: 1px solid #333;
  border-top: none;
  background: #fffde7;
}

.remark-row label {
  font-weight: bold;
}

.result-section .data-table th {
  background: #fff3cd;
}

.test-table th {
  background: #cce5ff;
}

.summary-table th {
  background: #f8d7da;
}

.form-row {
  display: flex;
  gap: 20px;
  align-items: center;
  padding: 10px;
  flex-wrap: wrap;
}

.form-row label {
  font-weight: bold;
}

.form-row input,
.form-row select {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}

.form-row select {
  min-width: 150px;
}

.qty-input {
  width: 80px;
  text-align: center;
  padding: 5px;
  border: 1px solid #ccc;
}

.qty-input:read-only {
  background: #e9ecef;
}

.product-name {
  text-align: left;
  padding-left: 10px;
}

.summary-row {
  display: flex;
  gap: 15px;
  align-items: center;
  padding: 10px;
  background: #e8f5e9;
  border: 1px solid #333;
}

.summary-row label {
  font-weight: bold;
}

.summary-row select,
.summary-row input {
  padding: 5px;
  border: 1px solid #ccc;
}

.button-row {
  margin-top: 10px;
  display: flex;
  gap: 10px;
}

.button-row button {
  padding: 8px 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid #333;
  background: #4CAF50;
  color: white;
}

.button-row button:hover {
  background: #45a049;
}

.button-row button:nth-child(2) {
  background: #f44336;
}

.button-row button:nth-child(2):hover {
  background: #da190b;
}

.button-row button:nth-child(3) {
  background: #2196F3;
}

.button-row button:nth-child(3):hover {
  background: #0b7dda;
}

.production-info td {
  text-align: left;
  padding: 5px;
}

.final-section {
  background: #e8f5e9;
  padding: 10px;
  border: 2px solid #4CAF50;
}

.final-section h4 {
  background: #4CAF50;
  color: white;
}

#status {
  margin-top: 10px;
  padding: 10px;
  background: #f0f0f0;
  border: 1px solid #ccc;
  font-size: 11px;
  white-space: pre-wrap;
}

.result-select {
  padding: 3px;
  border: 1px solid #ccc;
}

@media print {
  body {
    background: white;
    padding: 0;
  }
  
  .container {
    border: none;
    max-width: 100%;
  }
  
  .button-row {
    display: none;
  }
  
  #status {
    display: none;
  }
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
  border-bottom: 2px solid #4CAF50;
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 25px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border: 1px solid #ccc;
  border-bottom: none;
  background: #f0f0f0;
  color: #333;
  border-radius: 5px 5px 0 0;
  transition: all 0.2s;
}

.tab-btn:hover {
  background: #e0e0e0;
}

.tab-btn.active {
  background: #4CAF50;
  color: white;
  border-color: #4CAF50;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Stats Row */
.stats-row {
  display: flex;
  gap: 20px;
  padding: 15px;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 5px;
}

.stat-box {
  flex: 1;
  text-align: center;
  padding: 15px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 5px;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 5px;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: bold;
  color: #4CAF50;
}

@media print {
  .tab-nav {
    display: none;
  }
}

/* Summary Grid Table */
.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.summary-grid {
  min-width: max-content;
}

.summary-grid th,
.summary-grid td {
  min-width: 35px;
  padding: 4px 2px;
  font-size: 11px;
}

.summary-grid .sticky-col {
  position: sticky;
  left: 0;
  background: #d4edda;
  z-index: 1;
  min-width: 150px;
  text-align: left;
  padding-left: 8px;
}

.summary-grid tbody .sticky-col {
  background: #fff;
  border-right: 2px solid #333;
}

.summary-grid .day-col {
  background: #e3f2fd;
}

.summary-grid .total-col {
  background: #fff3cd;
  font-weight: bold;
  min-width: 50px;
}

.summary-grid .day-cell {
  text-align: center;
}

.summary-grid .total-cell {
  text-align: center;
  font-weight: bold;
  background: #fffde7;
}

.summary-grid tbody tr:nth-child(even) .sticky-col {
  background: #f9f9f9;
}

.summary-grid tbody tr:nth-child(even) .day-cell {
  background: #f9f9f9;
}
/* Difference Column Colors */
.difference-zero {
  background-color: #e8f5e8 !important; /* เขียว = ตรงกัน */
  color: #155724;
}

.difference-positive {
  background-color: #f8d7da !important; /* แดง = เกิน */
  color: #721c24;
  font-weight: bold;
}

.difference-negative {
  background-color: #fff3cd !important; /* เหลือง = ขาด */
  color: #856404;
  font-weight: bold;
}
/* Product List Styles */
#addProductSection {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 15px;
}

#addProductSection h4 {
  color: #28a745;
  margin-top: 0;
  margin-bottom: 15px;
  border-bottom: 1px solid #28a745;
  padding-bottom: 5px;
}

#addProductSection .form-row {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

#addProductSection .form-row label {
  font-weight: bold;
  color: #495057;
  white-space: nowrap;
}

#addProductSection .form-row input,
#addProductSection .form-row select {
  padding: 5px 8px;
  border: 1px solid #ced4da;
  border-radius: 3px;
  font-size: 12px;
}

#addProductSection .form-row input:focus,
#addProductSection .form-row select:focus {
  outline: none;
  border-color: #28a745;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.25);
}

#addProductSection .button-row {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

#addProductSection .button-row button {
  padding: 8px 15px;
  border: none;
  border-radius: 3px;
  color: white;
  font-size: 12px;
  cursor: pointer;
  font-weight: bold;
}

#addProductSection .button-row button:hover {
  opacity: 0.9;
}

#productListSection .table-scroll {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 3px;
}

#productListTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#productListTable th {
  background: #e9ecef;
  color: #495057;
  font-weight: bold;
  padding: 8px;
  text-align: left;
  border-bottom: 2px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 10;
}

#productListTable td {
  padding: 6px 8px;
  border-bottom: 1px solid #dee2e6;
  vertical-align: middle;
}

#productListTable tbody tr:hover {
  background-color: #f8f9fa;
}

#productListTable tbody tr:nth-child(even) {
  background-color: #f9f9f9;
}

#productListTable tbody tr:nth-child(even):hover {
  background-color: #f0f0f0;
}

#productListCount {
  color: #6c757d;
  font-style: italic;
}

/* Button styles for product list */
.tab-content button[onclick="showAddProductForm()"] {
  background: #28a745;
}

.tab-content button[onclick="showAddProductForm()"]:hover {
  background: #218838;
}

.tab-content button[onclick="loadProductList()"] {
  background: #007bff;
}

.tab-content button[onclick="loadProductList()"]:hover {
  background: #0056b3;
}

/* Loading message for product list */
#productListLoading {
  text-align: center;
  color: #6c757d;
  font-style: italic;
  padding: 20px;
}

/* Form validation styles */
#addProductForm input:invalid {
  border-color: #dc3545;
}

#addProductForm input:valid {
  border-color: #28a745;
}

/* Responsive adjustments for product list */
@media (max-width: 768px) {
  #addProductSection .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  #addProductSection .form-row label {
    margin-bottom: 5px;
  }
  
  #addProductSection .button-row {
    flex-direction: column;
  }
  
  #productListSection .table-scroll {
    max-height: 300px;
  }
}
/* Edit Product Form Styles */
#editProductSection {
  background: #e3f2fd;
  border: 1px solid #2196f3;
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 15px;
}

#editProductSection h4 {
  color: #1976d2;
  margin-top: 0;
  margin-bottom: 15px;
  border-bottom: 1px solid #2196f3;
  padding-bottom: 5px;
}

#editProductSection .form-row {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

#editProductSection .form-row label {
  font-weight: bold;
  color: #1565c0;
  white-space: nowrap;
}

#editProductSection .form-row input,
#editProductSection .form-row select {
  padding: 5px 8px;
  border: 1px solid #90caf9;
  border-radius: 3px;
  font-size: 12px;
}

#editProductSection .form-row input:focus,
#editProductSection .form-row select:focus {
  outline: none;
  border-color: #2196f3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.25);
}

#editProductSection .form-row input[readonly] {
  background-color: #f5f5f5;
  color: #666;
  cursor: not-allowed;
}

#editProductSection .button-row {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

#editProductSection .button-row button {
  padding: 8px 15px;
  border: none;
  border-radius: 3px;
  color: white;
  font-size: 12px;
  cursor: pointer;
  font-weight: bold;
}

#editProductSection .button-row button:hover {
  opacity: 0.9;
}

/* Product List Action Buttons */
#productListTable .action-buttons {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
}

#productListTable .action-buttons button {
  padding: 4px 8px;
  border: none;
  border-radius: 3px;
  color: white;
  font-size: 11px;
  cursor: pointer;
  font-weight: bold;
  min-width: 60px;
}

#productListTable .action-buttons button:hover {
  opacity: 0.8;
}

#productListTable .action-buttons .edit-btn {
  background: #007bff;
}

#productListTable .action-buttons .delete-btn {
  background: #dc3545;
}

#productListTable .action-buttons .no-permission {
  color: #999;
  font-size: 11px;
  font-style: italic;
}

/* Responsive adjustments for edit form */
@media (max-width: 768px) {
  #editProductSection .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  #editProductSection .form-row label {
    margin-bottom: 5px;
  }
  
  #editProductSection .button-row {
    flex-direction: column;
  }
  
  #productListTable .action-buttons {
    flex-direction: column;
    gap: 2px;
  }
  
  #productListTable .action-buttons button {
    font-size: 10px;
    padding: 3px 6px;
    min-width: 50px;
  }
}
/* Bai Jamjuree Font for all form elements */
input, button, select, textarea, option {
  font-family: 'Bai Jamjuree', 'Tahoma', 'Sarabun', sans-serif !important;
}

/* Ensure all text elements use Bai Jamjuree */
h1, h2, h3, h4, h5, h6, p, span, div, label, th, td {
  font-family: 'Bai Jamjuree', 'Tahoma', 'Sarabun', sans-serif;
}

/* Tab buttons */
.tab-btn {
  font-family: 'Bai Jamjuree', 'Tahoma', 'Sarabun', sans-serif;
  font-weight: 500;
}

/* Status and info text */
#status, .user-info, .status-message {
  font-family: 'Bai Jamjuree', 'Tahoma', 'Sarabun', sans-serif;
}
/* Progress Modal Styles */
.progress-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Bai Jamjuree', 'Tahoma', 'Sarabun', sans-serif;
}

.progress-modal-content {
  background: white;
  border-radius: 12px;
  padding: 30px;
  min-width: 400px;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  animation: progressModalFadeIn 0.3s ease-out;
}

@keyframes progressModalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.progress-header {
  text-align: center;
  margin-bottom: 25px;
}

.progress-header h3 {
  margin: 0;
  color: #333;
  font-size: 18px;
  font-weight: 600;
}

.progress-body {
  margin-bottom: 20px;
}

.progress-bar-container {
  margin-bottom: 15px;
  position: relative;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background-color: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #28a745, #20c997);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: progressShimmer 1.5s infinite;
}

@keyframes progressShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-percent {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #28a745;
  margin-top: 8px;
}

.progress-message {
  text-align: center;
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
  min-height: 20px;
}

.progress-details {
  text-align: center;
  font-size: 12px;
  color: #999;
  min-height: 16px;
}

.progress-footer {
  text-align: center;
  margin-top: 20px;
}

.progress-cancel-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Bai Jamjuree', 'Tahoma', 'Sarabun', sans-serif;
  font-size: 14px;
  transition: background-color 0.2s;
}

.progress-cancel-btn:hover {
  background: #c82333;
}

.progress-cancel-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

/* Loading spinner for indeterminate progress */
.progress-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e9ecef;
  border-top: 4px solid #28a745;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Success/Error states */
.progress-success .progress-bar-fill {
  background: linear-gradient(90deg, #28a745, #20c997);
}

.progress-error .progress-bar-fill {
  background: linear-gradient(90deg, #dc3545, #e74c3c);
}

.progress-success .progress-percent {
  color: #28a745;
}

.progress-error .progress-percent {
  color: #dc3545;
}