* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Bai Jamjuree", "Segoe UI", Tahoma, sans-serif;
  background: #eef2f7;
  color: #1f2937;
}
.app {
  max-width: 1280px;
  margin: 0 auto;
  padding-bottom: 24px;
}
.hero {
  background: linear-gradient(90deg, #2f6df6, #3267ea);
  color: #fff;
  padding: 26px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.hero-icon {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255,255,255,.15);
  font-size: 22px;
}
.hero h1 { margin: 0; font-size: 30px; }
.hero p { margin: 4px 0 0; opacity: .95; font-size: 14px; }

.logout-btn {
  display: inline-block;
  margin-left: 12px;
  padding: 6px 16px;
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all .2s;
}
.logout-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  background: #ececec;
  border-bottom: 1px solid #d5dbe7;
}
.refresh-tab {
  border: 0; background: transparent;
  padding: 14px 16px; font-size: 18px;
  cursor: pointer; color: #475569;
  transition: transform .2s;
}
.refresh-tab:hover { transform: rotate(180deg); }
.tab {
  border: 0; background: transparent;
  padding: 14px 10px; font-size: 16px;
  cursor: pointer; color: #475569;
}
.tab.active {
  color: #2f6df6;
  border-bottom: 3px solid #2f6df6;
  font-weight: 600;
}
main { padding: 14px 10px; }
.panel { display: none; }
.panel.active { display: block; }
.form-card { display: grid; gap: 14px; }
.form-group {
  background: #f8fafc;
  border: 1px solid #dde5ef;
  border-radius: 18px;
  padding: 14px;
}
label {
  display: block; margin-bottom: 10px;
  font-size: 14px; color: #64748b;
}
input[type="text"], input[type="tel"], input[type="date"],
input[type="number"], select, textarea {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 12px;
  padding: 14px 15px;
  font-size: 16px;
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: #2f6df6;
  box-shadow: 0 0 0 3px rgba(47,109,246,.12);
}
input[readonly] {
  background: #e9ecef;
  color: #495057;
}
input[type="file"] {
  font-size: 14px;
  padding: 10px 0;
}
.priority-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Checkbox Group */
.checkbox-group {
  display: flex; gap: 16px; flex-wrap: wrap;
}
.checkbox-option {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 16px;
  background: #fff; border: 1px solid #cfd8e3;
  border-radius: 12px; padding: 12px 18px;
  transition: all .15s ease;
}
.checkbox-option:has(input:checked) {
  background: #e0edff; border-color: #2f6df6;
}
.checkbox-option input[type="checkbox"],
.checkbox-option input[type="radio"] {
  width: 18px; height: 18px; accent-color: #2f6df6; cursor: pointer;
}
.priority-option {
  border: 1px solid #cfd8e3;
  border-radius: 12px;
  padding: 14px;
  display: flex; gap: 8px;
  align-items: center; justify-content: center;
  cursor: pointer; background: #fff; font-size: 15px;
  text-align: center; line-height: 1.4;
}
.priority-option small {
  font-size: 12px; color: #64748b;
}
.priority-option input { display: none; }
.priority-option.selected {
  background: #e9f8ef;
  border-color: #4ade80;
}
.dot {
  width: 14px; height: 14px;
  border-radius: 999px;
  border: 1px solid #333;
  display: inline-block;
}
.green { background: #22c55e; }
.yellow { background: #facc15; }
.red { background: #ef4444; }
.submit-btn {
  width: 100%; border: 0;
  border-radius: 14px; padding: 16px;
  background: #2f6df6; color: #fff;
  font-size: 18px; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(47,109,246,.2);
}
.submit-btn:hover { opacity: .95; }

.back-btn {
  width: 100%; border: 2px solid #cfd8e3;
  border-radius: 14px; padding: 14px;
  background: #fff; color: #475569;
  font-size: 16px; font-weight: 600;
  cursor: pointer; margin-top: 4px;
}
.back-btn:hover { background: #f1f5f9; border-color: #94a3b8; }

/* Action Buttons */
.action-btn {
  border: none; border-radius: 12px;
  padding: 14px 12px; font-size: 14px;
  font-weight: 600; cursor: pointer;
  transition: all .15s ease;
}
.assess-btn {
  background: #fef3c7; color: #92400e;
}
.assess-btn:hover { background: #fde68a; }
.update-btn {
  background: #dbeafe; color: #1e40af;
}
.update-btn:hover { background: #bfdbfe; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998; padding: 16px;
}
.modal-content {
  background: #fff; border-radius: 20px;
  padding: 24px; width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
}
.modal-content h2 { margin: 0 0 8px; font-size: 20px; }

/* Percent Group */
.percent-group {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.percent-option {
  border: 2px solid #cfd8e3; border-radius: 12px;
  padding: 12px 8px; text-align: center;
  cursor: pointer; font-size: 15px; font-weight: 600;
  background: #fff; transition: all .15s ease;
}
.percent-option:has(input:checked) {
  background: #dbeafe; border-color: #2f6df6; color: #1e40af;
}
.percent-option input { display: none; }

/* Score Group */
.score-group {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px;
}
.score-btn {
  border: 2px solid #cfd8e3; border-radius: 10px;
  padding: 10px 0; text-align: center;
  cursor: pointer; font-size: 15px; font-weight: 600;
  background: #fff; transition: all .15s ease;
}
.score-btn.selected {
  background: #2f6df6; color: #fff; border-color: #2f6df6;
}

/* Media Preview */
.media-preview {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px;
}
.preview-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.preview-item img, .preview-item video {
  width: 100px; height: 80px;
  object-fit: cover; border-radius: 8px;
  border: 1px solid #cfd8e3;
}
.preview-item span {
  font-size: 11px; color: #64748b;
  max-width: 100px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* History */
.history-list { display: grid; gap: 12px; }
.card {
  background: #fff;
  border: 1px solid #dde5ef;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(15,23,42,.04);
}
.card h3 { margin: 0 0 8px; font-size: 18px; }
.meta { display: grid; gap: 5px; color: #475569; font-size: 14px; }
.badges {
  margin-top: 12px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.badge.priority { background: #eef2ff; color: #3730a3; }
.badge.status { background: #ecfeff; color: #155e75; }
.badge.status-waiting { background: #fef3c7; color: #92400e; }
.badge.status-accepted { background: #d1fae5; color: #065f46; }
.badge.status-progress { background: #dbeafe; color: #1e40af; }
.badge.status-done { background: #f0fdf4; color: #166534; }
.badge.status-reject { background: #fef2f2; color: #991b1b; }

/* Media Gallery in History */
.media-gallery {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.thumb-img, .thumb-vid {
  width: 120px; height: 90px;
  object-fit: cover; border-radius: 10px;
  border: 1px solid #dde5ef;
  cursor: pointer;
}

/* Menu Grid */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 14px 10px;
}
.menu-card {
  background: #fff;
  border: 2px solid #dde5ef;
  border-radius: 20px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.menu-card:hover {
  border-color: #2f6df6;
  box-shadow: 0 8px 24px rgba(47,109,246,.15);
  transform: translateY(-2px);
}
.menu-icon { font-size: 48px; }
.menu-label { font-size: 20px; font-weight: 700; color: #1f2937; }
.menu-desc { font-size: 13px; color: #64748b; }

@media (max-width: 480px) {
  .menu-grid { grid-template-columns: 1fr; }
}

/* Status Box */
.status-box {
  padding: 14px 18px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #94a3b8;
  font-size: 15px;
  text-align: center;
  border: 1px dashed #cbd5e1;
}
.status-box.status-active {
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #facc15;
  font-weight: 600;
}

/* Progress Bar */
.progress-wrap { margin-top: 10px; }
.progress-bar-container {
  position: relative; padding: 8px 0; margin-bottom: 4px;
}
.progress-bar {
  width: 100%; height: 10px;
  background: #e5e7eb; border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 999px;
  transition: width .3s ease;
}
.progress-dot {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2);
  z-index: 1;
}
.dot-label {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: #64748b; white-space: nowrap;
}
.progress-detail {
  margin-top: 8px; padding: 10px 14px;
  background: #f0f4ff; border-radius: 12px;
  font-size: 13px; color: #334155;
  border-left: 3px solid #2f6df6;
}
.detail-media {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.detail-thumb {
  width: 120px; height: 90px;
  object-fit: cover; border-radius: 8px;
  border: 1px solid #dde5ef;
  cursor: pointer;
}

.empty {
  background: #fff;
  border: 1px dashed #cbd5e1;
  padding: 28px; border-radius: 16px;
  text-align: center; color: #64748b;
}
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #111827; color: white;
  padding: 14px 24px; border-radius: 12px;
  opacity: 0; pointer-events: none;
  transition: all .3s ease;
  font-size: 15px;
  z-index: 9999;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Loading Overlay */
.loading-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 99999;
}
.loading-box {
  background: #fff; border-radius: 20px;
  padding: 32px 40px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.spinner {
  width: 40px; height: 40px; margin: 0 auto 14px;
  border: 4px solid #e5e7eb;
  border-top: 4px solid #2f6df6;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadingText {
  font-size: 15px; color: #334155; font-weight: 500;
}

@media (max-width: 768px) {
  .hero h1 { font-size: 24px; }
  .priority-group { grid-template-columns: 1fr; }
}
