:root {
  --primary: #003366;
  --primary-dark: #001a33;
  --primary-light: #004080;
  --accent: #FFD700;
  --accent-light: #FFED4B;
  --info: #17a2b8;
  --info-dark: #138496;
  --bg: #f8f9fa;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #e9ecef;
  --gray-200: #dee2e6;
  --gray-400: #adb5bd;
  --gray-600: #6c757d;
  --gray-800: #343a40;
  --text: #212529;
  --danger: #dc3545;
  --success: #28a745;
  --section-border: #FFD700;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,51,102,0.15);
  --shadow-sm: 0 2px 8px rgba(0,51,102,0.10);
}

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

body {
  font-family: 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

/* ===== HEADER IMAGE ===== */
.header-image-container {
  width: 100%;
  text-align: center;
  background: var(--white);
  padding: 20px 0;
  border-bottom: 4px solid var(--accent);
  box-shadow: 0 2px 8px rgba(255,215,0,0.2);
}

.header-image {
  max-width: 100%;
  height: auto;
  max-height: 120px;
  object-fit: contain;
}

/* ===== HEADER ===== */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: white;
  padding: 0;
  box-shadow: 0 4px 20px rgba(0,51,102,0.35);
  position: relative;
  overflow: hidden;
}
.site-header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255,215,0,0.15);
}
.site-header::after {
  content: '';
  position: absolute;
  bottom: 100px; left: 30%;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 32px 24px;
  display: flex;
  align-items: center;
  gap: 22px;
  position: relative;
  z-index: 1;
}
.header-emblem {
  width: 68px; height: 68px;
  background: rgba(255,255,255,0.12);
  border: 2.5px solid var(--accent-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 28px;
}
.header-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.3;
}
.header-text p {
  font-size: 0.88rem;
  font-weight: 300;
  opacity: 0.85;
  margin-top: 4px;
  letter-spacing: 0.3px;
}
.header-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 5px 14px;
  border-radius: 20px;
  letter-spacing: 1px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(255,215,0,0.4);
}

/* ===== PROGRESS BAR ===== */
.progress-bar-wrap {
  background: var(--primary-dark);
  padding: 0 32px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.progress-bar-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  gap: 0;
}
.prog-step {
  flex: 1;
  padding: 11px 8px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prog-step.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.prog-step:hover { color: rgba(255,255,255,0.8); }

/* ===== FORM LAYOUT ===== */
.form-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* ===== FORM HEADER ===== */
.form-header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 32px;
  color: white;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.form-header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(200,169,74,0.1);
}

.form-header::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 20%;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.form-progress {
  position: relative;
  z-index: 1;
}

.progress-steps {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 8px;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s;
  min-width: 80px;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.3s;
}

.step-item.active .step-number {
  background: var(--accent);
  border-color: var(--accent-light);
  color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(255,215,0,0.4);
}

.step-item.completed .step-number {
  background: var(--success);
  border-color: #27ae60;
  color: white;
}

.step-label {
  font-size: 0.75rem;
  text-align: center;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.step-item.active .step-label {
  opacity: 1;
  font-weight: 600;
}

.step-line {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.2);
  margin: 0 8px;
  min-width: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  opacity: 0.9;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  position: relative;
  z-index: 1;
}

.btn-action {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-family: 'Sarabun', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action.primary {
  background: var(--accent);
  color: var(--primary-dark);
}

.btn-action.primary:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

.btn-action.secondary {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

.btn-action.secondary:hover {
  background: rgba(255,255,255,0.25);
}

.btn-action.info {
  background: var(--info);
  color: white;
}

.btn-action.info:hover {
  background: var(--info-dark);
  transform: translateY(-1px);
}

.btn-action.warning {
  background: #f39c12;
  color: white;
}

.btn-action.warning:hover {
  background: #e67e22;
  transform: translateY(-1px);
}

.btn-action.success {
  background: #28a745;
  color: white;
}

.btn-action.success:hover {
  background: #218838;
  transform: translateY(-1px);
}

/* ===== PRINT STYLES ===== */
@media print {
  .no-print {
    display: none !important;
  }
  
  .page {
    background: white !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .form-wrap {
    background: white !important;
    box-shadow: none !important;
  }
  
  .form-header,
  .form-actions,
  .progress-footer,
  .font-tool,
  .site-footer {
    display: none !important;
  }
  
  .form-content {
    box-shadow: none !important;
    border: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  .field-group {
    break-inside: avoid;
  }
  
  .form-section {
    page-break-inside: avoid;
    margin-bottom: 20pt;
  }
}

/* ===== FORM CONTENT ===== */
.form-content {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--gray-100);
}

/* ===== FORM SECTIONS ===== */
.form-section {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.form-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.section-num {
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 1.1rem;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(255,215,0,0.3);
}

.section-title {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.section-body { 
  padding: 32px; 
}

/* ===== SECTION INTRO ===== */
.section-intro {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  margin-bottom: 24px;
}

.intro-icon {
  font-size: 2.5rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  flex-shrink: 0;
}

.intro-content h4 {
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.intro-content p {
  color: var(--gray-600);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ===== SUBSECTION HEADER ===== */
.subsection-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  padding: 20px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
}

.subsection-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  flex-shrink: 0;
}

.subsection-title-content {
  flex: 1;
}

.subsection-title-content h4 {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.subsection-title-content p {
  color: var(--gray-600);
  font-size: 0.85rem;
  line-height: 1.4;
}

.subsection-tag {
  background: var(--accent);
  color: var(--primary-dark);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ===== FORM NAVIGATION ===== */
.form-navigation {
  padding: 24px 32px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}

.nav-buttons-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.nav-spacer {
  flex: 1;
}

.btn-nav {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-family: 'Sarabun', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-nav.prev {
  background: var(--gray-100);
  color: var(--primary);
  border: 1.5px solid var(--gray-200);
}

.btn-nav.prev:hover {
  background: var(--gray-200);
}

.btn-nav.next {
  background: var(--primary);
  color: white;
  box-shadow: 0 3px 12px rgba(26,58,107,0.25);
}

.btn-nav.next:hover {
  background: var(--primary-light);
  box-shadow: 0 4px 16px rgba(26,58,107,0.35);
}

.btn-nav.submit {
  background: var(--success);
  color: white;
  box-shadow: 0 3px 12px rgba(30,126,52,0.25);
  font-weight: 600;
}

.btn-nav.submit:hover {
  background: #27ae60;
  box-shadow: 0 4px 16px rgba(30,126,52,0.35);
}

/* ===== ADD ROW BUTTON ===== */
.btn-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--gray-100);
  border: 1.5px dashed var(--primary-light);
  border-radius: 8px;
  color: var(--primary);
  font-family: 'Sarabun', sans-serif;
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 16px;
}

.btn-add-row:hover {
  background: #e8edf8;
  border-style: solid;
  transform: translateY(-1px);
}

.btn-icon {
  font-size: 1.2rem;
  font-weight: 700;
}

.btn-text {
  font-size: 0.85rem;
}

/* ===== RESPONSIVE FORM ===== */
@media (max-width: 768px) {
  .form-wrap {
    padding: 16px 8px 60px;
  }
  
  .form-header {
    padding: 20px;
  }
  
  .progress-steps {
    gap: 4px;
  }
  
  .step-item {
    min-width: 60px;
  }
  
  .step-number {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
  
  .step-label {
    font-size: 0.7rem;
  }
  
  .step-line {
    margin: 0 4px;
    min-width: 10px;
  }
  
  .progress-info {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .btn-action {
    width: 100%;
    justify-content: center;
  }
  
  .section-header {
    padding: 20px 24px;
  }
  
  .section-title {
    font-size: 1rem;
  }
  
  .section-body {
    padding: 24px 20px;
  }
  
  .section-intro,
  .subsection-header {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
  
  .intro-icon,
  .subsection-icon {
    margin: 0 auto;
  }
  
  .form-navigation {
    padding: 20px 24px;
  }
  
  .nav-buttons-group {
    flex-direction: column;
    gap: 12px;
  }
  
  .nav-spacer {
    display: none;
  }
  
  .btn-nav {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .step-label {
    display: none;
  }
  
  .step-item {
    min-width: 40px;
  }
}

/* ===== SECTION ===== */
.form-section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  overflow: hidden;
  border: 1px solid var(--gray-100);
  display: none;
}
.form-section.active { display: block; }

.section-header {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-num {
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.section-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.section-body { padding: 24px; }

/* ===== SUBSECTION ===== */
.subsection {
  margin-bottom: 28px;
}
.subsection:last-child { margin-bottom: 0; }
.subsection-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--primary);
  padding-bottom: 8px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 8px;
}
.subsection-title::before {
  content: '';
  display: inline-block;
  width: 4px; height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

/* ===== FORM ELEMENTS ===== */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}
.field-row.full { grid-template-columns: 1fr; }
.field-row.cols3 { grid-template-columns: 1fr 1fr 1fr; }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
label {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--gray-600);
}
label span.req { color: var(--danger); margin-left: 2px; }

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  font-family: 'Sarabun', sans-serif;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  padding: 9px 12px;
  transition: border-color 0.18s, box-shadow 0.18s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(42,82,152,0.10);
  background: white;
}

/* ===== ERROR STATES ===== */
input.error, select.error, textarea.error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(220,53,69,0.1) !important;
  background: #fef5f5;
}

input.error:focus, select.error:focus, textarea.error:focus {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(220,53,69,0.2) !important;
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.radio-group, .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}
.radio-opt, .check-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.87rem;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1.5px solid var(--gray-200);
  background: var(--gray-50);
  transition: all 0.15s;
  user-select: none;
}
.radio-opt:hover, .check-opt:hover {
  border-color: var(--primary-light);
  background: var(--gray-100);
}
.radio-opt input, .check-opt input { accent-color: var(--primary); }

/* ===== TABLE (Dynamic rows) ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: 7px;
  border: 1.5px solid var(--gray-200);
  margin-bottom: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
thead tr {
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
}
thead th {
  padding: 10px 10px;
  text-align: center;
  font-weight: 500;
  font-size: 0.8rem;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.15);
}
thead th:last-child { border-right: none; }
tbody tr { border-bottom: 1px solid var(--gray-100); }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--gray-50); }
tbody td {
  padding: 6px 6px;
  vertical-align: middle;
  text-align: center;
}
tbody td:first-child { color: var(--gray-400); font-size: 0.8rem; }
tbody td input, tbody td select {
  padding: 6px 8px;
  font-size: 0.82rem;
  border-radius: 5px;
  min-width: 70px;
}
.td-del {
  width: 36px;
}
.btn-del {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}
.btn-del:hover { background: #fde8e8; }

/* ===== SYNC BUTTON ===== */
.sync-section {
  background: linear-gradient(135deg, #e8f4fd 0%, #f0f8ff 100%) !important;
  border: 2px solid var(--info) !important;
  border-radius: var(--radius) !important;
  padding: 16px !important;
  margin-bottom: 24px !important;
  text-align: center !important;
  box-shadow: var(--shadow-sm) !important;
  display: block !important;
  visibility: visible !important;
  position: relative !important;
  z-index: 1000 !important;
}

.btn-sync {
  background: var(--info) !important;
  color: white !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 12px 24px !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 3px 12px rgba(23,162,184,0.25) !important;
  visibility: visible !important;
  position: relative !important;
  z-index: 1001 !important;
}

.btn-sync:hover {
  background: var(--info-dark) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 16px rgba(23,162,184,0.35) !important;
}

.btn-sync:active {
  transform: translateY(0) !important;
}

.sync-hint {
  display: block !important;
  color: var(--gray-600) !important;
  font-size: 0.8rem !important;
  margin-top: 8px !important;
  font-style: italic !important;
  visibility: visible !important;
}

/* ===== BUTTONS ===== */
.btn {
  font-family: 'Sarabun', sans-serif;
  font-weight: 500;
  font-size: 0.88rem;
  border: none;
  border-radius: 7px;
  padding: 9px 20px;
  cursor: pointer;
  transition: all 0.18s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-add {
  background: var(--gray-100);
  color: var(--primary);
  border: 1.5px dashed var(--primary-light);
  font-size: 0.83rem;
  padding: 7px 16px;
}
.btn-add:hover { background: #e8edf8; border-style: solid; }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 3px 12px rgba(0,51,102,0.25);
  font-size: 0.95rem;
  padding: 11px 28px;
}
.btn-primary:hover { background: var(--primary-light); box-shadow: 0 4px 16px rgba(0,51,102,0.35); }

.btn-outline {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font-size: 0.88rem;
}
.btn-outline:hover { background: var(--gray-50); }

.btn-accent {
  background: var(--accent);
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(255,215,0,0.3);
  font-size: 0.95rem;
  padding: 11px 28px;
}
.btn-accent:hover { background: var(--accent-light); }

.btn-success {
  background: var(--success);
  color: white;
  font-size: 0.95rem;
  padding: 11px 28px;
  box-shadow: 0 3px 12px rgba(30,126,52,0.25);
}

/* ===== NAV BUTTONS ===== */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  gap: 12px;
}

/* ===== HELPER ===== */
.help-text {
  font-size: 0.78rem;
  color: var(--gray-400);
  margin-top: 3px;
}
.divider {
  height: 1px;
  background: var(--gray-100);
  margin: 20px 0;
}
.tag {
  display: inline-block;
  background: #e8edf8;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 10px;
  margin-left: 6px;
}

/* ===== SUMMARY / REVIEW ===== */
.review-card {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 14px;
}
.review-card h4 {
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.review-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 6px 12px;
  font-size: 0.83rem;
}
.review-label { color: var(--gray-600); font-weight: 500; }
.review-value { color: var(--text); }

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--primary-dark);
  color: white;
  padding: 13px 22px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: 'Sarabun', sans-serif;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.3s;
  z-index: 9999;
  max-width: 320px;
  border-left: 4px solid var(--accent);
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ===== PAGE TOGGLE ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== NAV TOP TABS ===== */
.top-nav {
  background: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 32px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.top-nav-inner {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 0;
}
.top-tab {
  padding: 12px 22px;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 7px;
}
.top-tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.top-tab:hover { color: rgba(255,255,255,0.8); }

/* ===== DASHBOARD ===== */
.dash-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px;
}

.dash-header {
  text-align: center;
  margin-bottom: 32px;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  border-radius: var(--radius);
  color: white;
  position: relative;
  overflow: hidden;
}

.dash-header::before {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: rgba(255,215,0,0.1);
}

.dash-header::after {
  content: '';
  position: absolute;
  bottom: -30px; left: 20%;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.dash-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.dash-subtitle {
  font-size: 1.1rem;
  font-weight: 400;
  opacity: 0.9;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.dash-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

#report-date {
  font-size: 0.9rem;
  opacity: 0.8;
}

.btn-refresh {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.btn-refresh:hover {
  background: rgba(255,255,255,0.25);
}

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,51,102,0.15);
}

.kpi-card.primary {
  border-left: 4px solid var(--primary);
}

.kpi-card.success {
  border-left: 4px solid var(--success);
}

.kpi-card.warning {
  border-left: 4px solid #f39c12;
}

.kpi-card.info {
  border-left: 4px solid #3498db;
}

.kpi-icon {
  font-size: 3rem;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gray-50);
  flex-shrink: 0;
}

.kpi-content {
  flex: 1;
}

.kpi-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 8px;
}

.kpi-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.kpi-subtitle {
  font-size: 0.85rem;
  color: var(--gray-400);
}

.kpi-progress {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 4px;
  width: 0%;
  transition: width 0.8s ease;
}

.progress-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 40px;
}

/* ===== CHARTS SECTION ===== */
.charts-section {
  margin-bottom: 32px;
}

.chart-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-row:last-child {
  grid-template-columns: 1fr 1fr;
}

.chart-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  overflow: hidden;
}

.chart-container.large {
  min-height: 400px;
}

.chart-container.medium {
  min-height: 300px;
}

.chart-container.small {
  min-height: 300px;
}

.chart-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray-50);
}

.chart-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
}

.chart-actions {
  display: flex;
  gap: 8px;
}

.chart-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

.chart-btn:hover {
  background: var(--primary-light);
}

.chart-body {
  padding: 24px;
  position: relative;
}

.chart-body canvas {
  max-height: 300px;
}

/* ===== STATS TABLE ===== */
.stats-table {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  overflow: hidden;
}

.table-content {
  max-height: 300px;
  overflow-y: auto;
}

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

.stats-table-data th {
  background: var(--primary);
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.stats-table-data td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.stats-table-data tr:hover {
  background: var(--gray-50);
}

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

.text-center {
  text-align: center;
  color: var(--gray-400);
}

/* ===== RECENT ACTIVITIES ===== */
.recent-section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  overflow: hidden;
}

.section-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray-50);
}

.section-header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2c3e50;
  text-align: center;
  margin: 10px 0;
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.1);
}

.view-toggle {
  display: flex;
  background: var(--white);
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.toggle-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--gray-600);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.toggle-btn.active {
  background: var(--primary);
  color: white;
}

.toggle-btn:not(.active):hover {
  background: var(--gray-50);
}

.activities-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--gray-100);
  margin-bottom: 12px;
  background: var(--gray-50);
  transition: all 0.15s;
}

.activity-item:hover {
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.activity-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.activity-meta {
  font-size: 0.85rem;
  color: var(--gray-400);
}

.activity-time {
  font-size: 0.8rem;
  color: var(--gray-400);
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.95rem;
  margin: 0;
}

/* refresh button */
.btn-refresh {
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  color: var(--primary);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  transition: all 0.15s;
}
.btn-refresh:hover { background: #e8edf8; border-color: var(--primary-light); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
  font-size: 0.88rem;
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: 10px; }

/* ===== PROGRESS FOOTER ===== */
.progress-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 2px solid var(--gray-100);
  box-shadow: 0 -4px 18px rgba(26,58,107,0.10);
  z-index: 900;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'Sarabun', sans-serif;
}
.pf-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.pf-bar-wrap {
  flex: 1;
  height: 10px;
  background: var(--gray-100);
  border-radius: 10px;
  overflow: hidden;
}
.pf-bar {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 60%, var(--accent) 100%);
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}
.pf-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}
.pf-steps {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.pf-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-200);
  transition: background 0.3s;
}
.pf-dot.done { background: var(--primary); }
.pf-dot.current { background: var(--accent); box-shadow: 0 0 0 2px rgba(200,169,74,0.35); }

/* ===== FONT SIZE TOOL ===== */
.font-tool {
  position: fixed;
  bottom: 60px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 950;
}
.font-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 2px 10px rgba(26,58,107,0.30);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
  line-height: 1;
}
.font-btn:hover { background: var(--primary-light); transform: scale(1.08); }
.font-btn.minus { font-size: 1.2rem; background: var(--gray-600); }
.font-btn.minus:hover { background: var(--primary); }

/* ===== SITE FOOTER ===== */
.site-footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,0.75);
  text-align: center;
  padding: 18px 20px 80px;
  font-size: 0.78rem;
  line-height: 1.8;
  margin-top: 0;
}
.site-footer strong {
  color: var(--accent-light);
  font-weight: 600;
}
.site-footer .footer-logo {
  font-size: 1.4rem;
  display: block;
  margin-bottom: 6px;
}
.site-footer a {
  color: var(--accent-light);
  text-decoration: none;
}

/* ===== PRINT ===== */
@media print {
  .site-header, .progress-bar-wrap, .nav-buttons, #toast { display: none !important; }
  .form-section { display: block !important; box-shadow: none; border: 1px solid #ccc; }
  .main-wrap { padding: 0; max-width: 100%; }
  body { background: white; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .chart-row {
    grid-template-columns: 1fr !important;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .dash-header {
    padding: 20px 16px;
  }
  
  .dash-title {
    font-size: 1.4rem;
  }
  
  .dash-subtitle {
    font-size: 1rem;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .kpi-card {
    padding: 20px;
  }
  
  .kpi-icon {
    width: 60px;
    height: 60px;
    font-size: 2rem;
  }
  
  .kpi-value {
    font-size: 2rem;
  }
  
  .chart-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .chart-header {
    padding: 16px 20px;
  }
  
  .chart-header h3 {
    font-size: 1rem;
  }
  
  .chart-body {
    padding: 16px;
  }
  
  .stats-table-data th,
  .stats-table-data td {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  
  .activity-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .activity-time {
    align-self: flex-end;
  }
}

@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; gap: 14px; }
  .header-badge { margin-left: 0; }
  .field-row { grid-template-columns: 1fr; }
  .field-row.cols3 { grid-template-columns: 1fr; }
  .section-body { padding: 16px; }
  .main-wrap { padding: 16px 10px 40px; }
  .prog-step { font-size: 0.68rem; padding: 10px 4px; }
  
  .dash-wrap {
    padding: 16px 8px;
  }
  
  .dash-header {
    padding: 16px 12px;
  }
  
  .dash-title {
    font-size: 1.2rem;
  }
  
  .dash-subtitle {
    font-size: 0.9rem;
  }
  
  .dash-meta {
    flex-direction: column;
    gap: 8px;
  }
  
  .kpi-card {
    padding: 16px;
    flex-direction: column;
    text-align: center;
  }
  
  .kpi-icon {
    margin: 0 auto 12px;
  }
  
  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .chart-actions {
    align-self: stretch;
  }
  
  .chart-btn {
    width: 100%;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .view-toggle {
    width: 100%;
  }
  
  .toggle-btn {
    flex: 1;
  }
  
  .header-image-container {
    padding: 15px 0;
  }
  
  .header-image {
    max-height: 80px;
  }
}

/* ===== AUTOCOMPLETE ===== */
.autocomplete-container {
  position: relative;
  display: inline-block;
  width: 100%;
}

.autocomplete-dropdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
  z-index: 9999;
  display: none;
  min-width: 400px;
}

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

.autocomplete-header {
  padding: 12px 16px;
  border-bottom: 1px solid #ddd;
  background: #f5f5f5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.autocomplete-title {
  font-size: 14px;
  font-weight: normal;
  color: #333;
  margin: 0;
}

.autocomplete-close {
  background: none;
  border: none;
  font-size: 16px;
  color: #666;
  cursor: pointer;
  padding: 2px 6px;
}

.autocomplete-close:hover {
  color: #333;
}

.autocomplete-content {
  padding: 4px;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 10px;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: #f0f0f0;
}

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

.autocomplete-code {
  font-weight: bold;
  color: #0066cc;
  display: inline-block;
  min-width: 80px;
  font-size: 12px;
  text-align: center;
}

.autocomplete-name {
  color: #333;
  flex: 1;
  font-size: 13px;
}

.autocomplete-loading {
  padding: 16px;
  text-align: center;
  color: #666;
  font-style: italic;
  font-size: 13px;
}

.autocomplete-no-results {
  padding: 16px;
  text-align: center;
  color: #666;
  font-style: italic;
  font-size: 13px;
}
