* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sarabun", "Noto Sans Thai", sans-serif;
  background: #f4f6f8;
  color: #1f2937;
  min-height: 100vh;
}
.container { max-width: 480px; margin: 0 auto; padding: 16px; }
.card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}
h1 { font-size: 22px; margin-bottom: 8px; color: #06c755; }
h2 { font-size: 18px; margin-bottom: 12px; }
.subtitle { color: #6b7280; font-size: 14px; margin-bottom: 16px; }

.profile { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.profile img { width: 56px; height: 56px; border-radius: 50%; }
.profile-name { font-weight: 600; font-size: 16px; }
.profile-status { color: #6b7280; font-size: 13px; }

video, canvas, .photo-preview {
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  background: #000;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
}
/* mirror only the live camera preview so it feels like a mirror; the captured
   photo is already mirrored in its pixel data (ctx.scale(-1,1) in checkin.html) */
#video { transform: scaleX(-1); }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.hidden { display: none !important; }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: opacity 0.2s;
}
.btn-primary { background: #06c755; color: #fff; }
.btn-secondary { background: #e5e7eb; color: #1f2937; }
.btn-danger { background: #ef4444; color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.status-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.status-row:last-child { border-bottom: none; }
.status-label { color: #6b7280; font-size: 14px; }
.status-value { font-weight: 600; font-size: 14px; }
.status-value.ok { color: #06c755; }
.status-value.warn { color: #f59e0b; }
.status-value.err { color: #ef4444; }

.message {
  padding: 12px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 14px;
}
.message.error { background: #fee2e2; color: #991b1b; }
.message.success { background: #d1fae5; color: #065f46; }
.message.info { background: #dbeafe; color: #1e3a8a; }

.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.35; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
th { background: #f9fafb; font-weight: 600; white-space: nowrap; }
/* ช่องกรอกที่อยู่ในตาราง: บีบให้เตี้ยลง แถวจะได้ไม่สูงเกิน */
table input, table select { margin-top: 0; padding: 5px 6px; font-size: 13px; border-radius: 6px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 8px; background: #e5e7eb; cursor: pointer; font-weight: 600; font-size: 14px; }
.tab.active { background: #06c755; color: #fff; }
input, select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 14px;
  margin-top: 4px;
}
label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
/* ปุ่มในแถวตัวกรอง ไม่ต้องสูงเท่าปุ่มหลัก */
.row .btn { margin-top: 0; padding: 9px 14px; font-size: 14px; }

/* ---------- responsive: ย่อฟอนต์/ระยะห่างตามขนาดจอ ---------- */
@media (max-width: 900px) {
  .container { padding: 12px; }
  .card { padding: 14px; border-radius: 12px; margin-bottom: 12px; }
  h1 { font-size: 19px; }
  h2 { font-size: 16px; }
  table { font-size: 12.5px; }
  th, td { padding: 5px 6px; }
}
@media (max-width: 600px) {
  .container { padding: 8px; }
  .card { padding: 12px; }
  h1 { font-size: 18px; }
  .subtitle { font-size: 13px; margin-bottom: 10px; }
  .btn { padding: 12px; font-size: 15px; }
  .tab { padding: 7px 12px; font-size: 13px; }
  label { font-size: 13px; margin-bottom: 6px; }
  input, select { padding: 8px; font-size: 13px; }
  table { font-size: 12px; }
  th, td { padding: 4px 6px; }
  table input, table select { padding: 4px 5px; font-size: 12px; }
}
