:root {
  --red-900: #7f1d1d;
  --red-700: #b91c1c;
  --red-600: #c81e1e;
  --red-500: #dc2626;
  --red-100: #fde2e2;
  --red-50: #fdf3f3;
  --ink: #2a1414;
  --muted: #7a5a5a;
  --line: #f0d3d3;
  --bg: #fff8f8;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(120, 20, 20, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --ok-bg: #e7f6ec;
  --ok-fg: #1a7a3a;
  --err-bg: #fde8e8;
  --err-fg: #a11212;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Sarabun", "TH Sarabun New", -apple-system, "Segoe UI", Tahoma, sans-serif;
  line-height: 1.6;
}

img { max-width: 100%; display: block; }

a { color: var(--red-700); }

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- Topbar / header ---------- */
.site-header {
  position: relative;
  background: linear-gradient(180deg, var(--red-700), var(--red-600));
  padding: 22px 16px 34px;
  text-align: center;
  color: #fff;
}

.site-header .corner-photo {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: var(--shadow);
  background: #fff;
}

.site-header .corner-photo img { width: 100%; height: 100%; object-fit: cover; }

.site-header .logo {
  width: 92px;
  height: 92px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.site-header .logo img { width: 100%; height: 100%; object-fit: contain; }

.site-header h1 {
  margin: 4px 0 2px;
  font-size: 1.4rem;
  font-weight: 700;
}

.site-header p {
  margin: 0;
  opacity: 0.92;
  font-size: 0.95rem;
}

/* ---------- Main ---------- */
main { padding: 24px 0 56px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.hero { text-align: center; padding: 36px 20px; }
.hero h2 { margin-top: 0; color: var(--red-700); }
.hero p { color: var(--muted); }

.stat-text {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 14px 0 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.06s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--red-600);
  color: #fff;
  box-shadow: 0 6px 16px rgba(200, 30, 30, 0.35);
}
.btn-primary:hover { background: var(--red-700); }
.btn-primary:disabled { background: #d9a3a3; cursor: not-allowed; box-shadow: none; }

.btn-outline {
  background: transparent;
  color: var(--red-700);
  border: 2px solid var(--red-600);
  padding: 11px 24px;
}
.btn-outline:hover { background: var(--red-50); }

.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: 8px 16px; font-size: 0.88rem; }

/* ---------- Forms ---------- */
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 0 0 18px;
  padding: 14px 16px 18px;
}
legend {
  padding: 0 8px;
  font-weight: 700;
  color: var(--red-700);
}

.form-row { margin-bottom: 14px; }
.form-row label.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="number"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--red-500);
  box-shadow: 0 0 0 3px var(--red-100);
}

.choice-group { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.choice-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}
.choice-group input[type="radio"],
.choice-group input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--red-600); }

.other-input { margin-top: 8px; }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

.required-mark { color: var(--red-600); }

/* ---------- Photo capture widget ---------- */
.photo-widget {
  border: 2px dashed var(--red-100);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  background: var(--red-50);
}
.photo-widget video, .photo-widget canvas, .photo-widget img.preview {
  max-width: 260px;
  width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
}
.photo-widget .preview-wrap { margin: 12px auto; max-width: 260px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-weight: 500;
}
.alert-error { background: var(--err-bg); color: var(--err-fg); }
.alert-success { background: var(--ok-bg); color: var(--ok-fg); }

/* ---------- Confirm page ---------- */
.pdf-frame {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.reg-no-badge {
  display: inline-block;
  background: var(--red-600);
  color: #fff;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ---------- Admin ---------- */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.admin-topbar h1 { margin: 0; font-size: 1.2rem; color: var(--red-700); }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
table.admin-table { width: 100%; border-collapse: collapse; background: #fff; min-width: 760px; }
table.admin-table th, table.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.92rem;
  white-space: nowrap;
}
table.admin-table th { background: var(--red-50); color: var(--red-700); }
table.admin-table tr:hover { background: #fffafa; }

.thumb { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #eee; }

.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.9rem;
}
.pagination .active { background: var(--red-600); color: #fff; border-color: var(--red-600); }

.search-form { display: flex; gap: 8px; }
.search-form input { flex: 1; }

.login-wrap {
  max-width: 380px;
  margin: 60px auto;
  padding: 0 16px;
}

footer.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 20px 0 40px;
}
