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

body {
  font-family: 'Sarabun', Arial, sans-serif;
  background: linear-gradient(135deg, #adb9f1 0%, #f7ba06 100%);
  min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
  background: white;
  padding: 14px 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.header h1 {
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #333;
}
.neon-badge {
  background: #00e699;
  color: #fff;
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: bold;
}

/* ===== CONTAINER ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ===== PANEL (หน้าจอหลัก) ===== */
.panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  overflow: hidden;
  margin-bottom: 20px;
}
.panel-title {
  background: linear-gradient(90deg, #c0392b, #e67e22);
  color: #fff;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.panel-body {
  padding: 20px;
}
.panel-status {
  background: #fff8f0;
  border-left: 4px solid #e67e22;
  padding: 8px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #7f4500;
  border-radius: 0 4px 4px 0;
}

/* ===== TABLE ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead tr th {
  background: linear-gradient(90deg, #7b2811, #c0392b);
  color: #fff;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
thead tr th.sub-header {
  background: #a93226;
  font-weight: 500;
  font-size: 12px;
}
tbody tr td {
  border-bottom: 1px solid #f0e8e8;
  padding: 8px 12px;
  color: #333;
  vertical-align: middle;
}
tbody tr:hover { background: #fff5f5; }
tbody tr.selected { background: #fdecea; outline: 2px solid #c0392b; outline-offset: -1px; }
tbody tr.empty-row td {
  color: #bbb;
  font-style: italic;
  text-align: center;
  padding: 28px;
}

/* ===== FORM ELEMENTS ===== */
.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.form-label {
  font-size: 13px;
  color: #555;
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}
.form-input {
  font-size: 13px;
  font-family: 'Sarabun', Arial, sans-serif;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #333;
  min-width: 140px;
}
.form-input:focus {
  outline: none;
  border-color: #c0392b;
  box-shadow: 0 0 0 2px rgba(192,57,43,0.15);
}
.form-input.display {
  background: #fff0e8;
  border-color: #f5cba7;
  color: #7f4500;
}
.form-input[readonly] {
  background: #f5f5f5;
  color: #777;
}

select.form-input {
  cursor: pointer;
}

/* ===== BUTTONS ===== */
.btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f0e8e8;
}
.btn {
  font-size: 13px;
  font-family: 'Sarabun', Arial, sans-serif;
  padding: 7px 22px;
  border-radius: 4px;
  border: 1px solid #aaa;
  background: #fff;
  color: #333;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.btn:hover { background: #f5f5f5; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  color: #fff;
  border-color: #c0392b;
}
.btn-primary:hover { background: linear-gradient(135deg, #a93226, #c0392b); }
.btn-success {
  background: linear-gradient(135deg, #1a7a50, #27ae60);
  color: #fff;
  border-color: #1a7a50;
}
.btn-success:hover { background: linear-gradient(135deg, #145a3c, #1a7a50); }
.btn-danger {
  background: #fff0f0;
  color: #c0392b;
  border-color: #e0a0a0;
}
.btn-danger:hover { background: #ffd5d5; }
.btn-warning {
  background: #fff8e0;
  color: #b7700a;
  border-color: #f0c060;
}
.btn-warning:hover { background: #fff0c0; }

/* ===== ACTION LINKS ===== */
a.action-link {
  color: #2980b9;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
}
a.action-link:hover { text-decoration: underline; }
a.action-link.del { color: #c0392b; }

/* ===== ALERT / MESSAGE ===== */
.alert {
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-error { background: #fdecea; border-left: 4px solid #e74c3c; color: #922b21; }
.alert-success { background: #eafaf1; border-left: 4px solid #27ae60; color: #1a5c35; }
.alert-info { background: #eaf4fb; border-left: 4px solid #2980b9; color: #1a4a7a; }

/* ===== LOADING OVERLAY ===== */
#loading {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#loading.active { display: flex; }
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #fff3;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== INDEX PAGE STYLES ===== */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.header h1 {
  font-size: 24px;
  margin-bottom: 5px;
}
.user-info {
  font-size: 14px;
  opacity: 0.9;
}
.neon-badge {
  background: #00e699;
  color: white;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: bold;
  margin-left: 10px;
}
.container {
  max-width: 1200px;
  margin: 30px auto;
  padding: 0 20px;
}
.welcome {
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  text-align: center;
}
.welcome h2 {
  color: #333;
  margin-bottom: 10px;
}
.welcome p {
  color: #666;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
.menu-section {
  background: white;
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.menu-section h3 {
  color: #667eea;
  margin-bottom: 15px;
  font-size: 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid #667eea;
}
.menu-item {
  display: block;
  padding: 12px 15px;
  margin-bottom: 10px;
  background: #f8f9fa;
  color: #333;
  text-decoration: none;
  border-radius: 5px;
  transition: all 0.3s;
  border-left: 3px solid #667eea;
}
.menu-item:hover {
  background: #667eea;
  color: white;
  transform: translateX(5px);
}
.menu-item::before {
  content: "→ ";
  margin-right: 5px;
}
.logout-section {
  background: #fff3e0;
}
.logout-section h3 {
  color: #ff9800;
  border-bottom-color: #ff9800;
}
.logout-item {
  background: #ffe0b2;
  border-left-color: #ff9800;
  color: #e65100;
}
.logout-item:hover {
  background: #ff9800;
  color: white;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}
.stat-box {
  background: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  text-align: center;
}
.stat-number {
  font-size: 32px;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 5px;
}
.stat-label {
  color: #666;
  font-size: 14px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .form-row { flex-direction: column; align-items: flex-start; }
  .form-label { text-align: left; min-width: unset; }
  table { font-size: 12px; }
  thead tr th, tbody tr td { padding: 6px 8px; }
  .menu-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}
/* จัดระเบียบกล่องใส่ปุ่ม */
.btn-row {
  display: flex;
  justify-content: flex-end; /* ดันปุ่มไปชิดขวา */
  gap: 12px; /* ระยะห่างระหว่างปุ่ม */
  margin-top: 15px;
  padding: 10px 0;
}

/* สไตล์พื้นฐานของปุ่มทุกอัน (หน้าตา โมเดิร์นขึ้น) */
.btn-row button {
  padding: 10px 20px;
  font-size: 14px;
  border: none;
  border-radius: 6px; /* มุมโค้งมนนิดๆ */
  cursor: pointer;
  color: white;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* ใส่เงาบางๆ */
  transition: all 0.2s ease-in-out; /* แอนิเมชันตอนชี้เมาส์ */
}

/* เอฟเฟกต์ตอนกดคลิกปุ่ม (ยุบลงไปนิดนึง) */
.btn-row button:active {
  transform: scale(0.95);
  box-shadow: none;
}

/* สีเฉพาะของแต่ละปุ่ม และเอฟเฟกต์ตอนชี้เมาส์ (Hover) */
.btn-add {
  background-color: #0d6efd; /* น้ำเงิน */
}
.btn-add:hover { background-color: #0b5ed7; }

.btn-save {
  background-color: #198754; /* เขียว */
}
.btn-save:hover { background-color: #157347; }

.btn-del {
  background-color: #dc3545; /* แดง */
}
.btn-del:hover { background-color: #bb2d3b; }

.btn-exit {
  background-color: #f3f305; /* เทา */
}
.btn-exit:hover { background-color: #cbd76e; }

.btn-refresh {
  background-color: #05bc51; /* เทา */
}
.btn-refresh:hover { background-color: #08f83c; }

.btn-cancel {
  background-color: #15a3e0; /* เทา */
}
.btn-cancel:hover { background-color: #128bc9; }