:root {
  --teal: #5bc0c7;
  --teal-dark: #3f9ba3;
  --teal-light: #eaf7f8;
  --danger: #e2544a;
  --danger-light: #fdecea;
  --text: #22333b;
  --text-muted: #5a6b73;
  --border: #dbe8ea;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(34, 51, 59, 0.08);
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans Thai", "Helvetica Neue", Arial, sans-serif;
  background: #f4fafb;
  color: var(--text);
  line-height: 1.5;
}

.th { color: var(--text-muted); font-weight: 400; font-size: 0.85em; }
.en-sub { display: block; font-size: 0.8em; font-weight: 400; opacity: 0.9; }

/* ---------- Header / Footer ---------- */
.site-header {
  background: var(--teal);
  color: #fff;
  text-align: center;
  padding: 1.5rem 1rem;
}
.site-header h1 { margin: 0; font-size: 1.3rem; }
.site-header p { margin: 0.25rem 0 0; opacity: 0.9; font-size: 0.9rem; }

.site-footer {
  background: #2b4a4d;
  color: #cfe9ea;
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.85rem;
}
.site-footer p { margin: 0.2rem 0; }

/* ---------- Layout ---------- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
}
.container-wide { max-width: 1400px; }

.page { display: none; }
.page.active { display: block; }

.page-title {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--teal-dark);
}

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.rule-card { text-align: center; }
.rule-emoji { font-size: 2rem; margin-bottom: 0.4rem; }
.rule-card h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.rule-card p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }

.warning-box {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  color: #a53328;
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  text-align: center;
}
.warning-box p { margin: 0.4rem 0 0; font-size: 0.85rem; }

.note-box {
  background: var(--teal-light);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-block { display: block; width: 100%; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-outline { background: #fff; color: var(--teal-dark); border: 1.5px solid var(--teal); }
.btn-outline:hover { background: var(--teal-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--teal-dark);
  text-decoration: none;
  font-weight: 600;
}
.back-link:hover { text-decoration: underline; }

/* ---------- Schedule page ---------- */
.action-bar {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.room-title {
  text-align: center;
  color: var(--teal-dark);
  margin: 0 0 0.75rem;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td {
  padding: 0.5rem 0.4rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { color: var(--text-muted); font-weight: 600; }
td.empty-row { text-align: center; color: var(--text-muted); padding: 1rem; }

.status-msg { min-height: 1.2em; margin: 0.75rem 0; font-size: 0.9rem; }
.status-msg.error { color: var(--danger); }
.status-msg.success { color: var(--teal-dark); }

.lookup-link-wrap { text-align: center; margin: 0 0 1.25rem; font-size: 0.85rem; }

.lookup-results { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.lookup-results li {
  background: var(--teal-light);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.lookup-results li .lookup-id { font-weight: 700; color: var(--teal-dark); }

/* ---------- Form ---------- */
.form-card { max-width: 600px; margin: 0 auto; }
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; color: var(--text-muted); }
.form-row input,
.form-row select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--teal);
}
.form-row-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.time-hint { font-size: 0.78rem; color: var(--text-muted); margin: -0.5rem 0 1rem; }

/* ---------- Admin dashboard ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.stat-tile { text-align: center; padding: 1rem 0.5rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--teal-dark); }
.stat-tile-warn .stat-value { color: var(--danger); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }

.filter-bar { margin-bottom: 1.25rem; }
.room-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.tab-btn {
  border: 1.5px solid var(--teal);
  background: #fff;
  color: var(--teal-dark);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.tab-btn.active { background: var(--teal); color: #fff; }
.filter-row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.filter-row #search-box {
  flex: 1;
  min-width: 220px;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
}
.filter-row #search-box:focus { outline: none; border-color: var(--teal); }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
}
.checkbox-label input { width: auto; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 0 0.75rem;
  flex-wrap: wrap;
}
.pagination-info { font-size: 0.85rem; color: var(--text-muted); }
.checkbox-label select,
.checkbox-label input[type="date"] {
  padding: 0.25rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
}
.filter-row-dates { margin-top: 0.75rem; }

.photo-modal { max-width: 560px; }
.photo-modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.photo-preview { max-width: 100%; max-height: 60vh; border-radius: 10px; display: block; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 51, 59, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal { width: 100%; max-width: 420px; }
.modal.hidden { display: none; }
.modal h3 { margin-top: 0; color: var(--teal-dark); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.5rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
  .rules-grid { grid-template-columns: repeat(2, 1fr); }
  .schedule-grid { grid-template-columns: 1fr; }
  .form-row-split { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-row { flex-direction: column; align-items: stretch; }
}
@media (max-width: 420px) {
  .rules-grid { grid-template-columns: 1fr; }
}
