:root {
  /* ชุดสีหลักขององค์กร — แดงชาดเข้ม (Primary) / น้ำตาลไหม้ (Primary-dark) / ทองพรีเมียม (Accent) */
  --gold: #d4af37;
  --gold-dark: #b8902e;
  --maroon: #8b0000;
  --maroon-dark: #5c2c16;
  --bg: #fdfbf7;
  --panel: #ffffff;
  --text: #2c2c2c;
  --muted: #756b5f;
  --border: #ece3d2;
  --success: #2e7d32;
  --danger: #b3261e;
  --warn: #b8860b;
  --radius: 10px;
  --radius-lg: 12px;
  --shadow-soft: 0 10px 30px rgba(44, 28, 12, 0.08);
  --shadow-hover: 0 18px 40px rgba(139, 0, 0, 0.16);
  --font-heading: 'Kanit', 'Sarabun', 'Noto Sans Thai', sans-serif;
  --font-body: 'Sarabun', 'Noto Sans Thai', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

a { color: var(--maroon); }

/* --- Layout --- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: relative;
  background-color: #5c1717;
  background-image:
    linear-gradient(180deg, var(--maroon), #5c1717),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg fill='none' stroke='%23d4af37' stroke-width='1' opacity='0.07'%3E%3Ccircle cx='40' cy='40' r='22'/%3E%3Ccircle cx='40' cy='40' r='4'/%3E%3Cpath d='M40 18v44M18 40h44M25.6 25.6l28.8 28.8M54.4 25.6L25.6 54.4'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat, repeat;
  background-size: auto, 80px 80px;
  color: #f6ead0;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 3px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar .brand {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 20px;
  padding: 0 6px;
  color: #fff;
}

.sidebar .brand small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: #e4c98a;
}

.sidebar nav a {
  position: relative;
  display: block;
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius);
  color: #f0e2be;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.sidebar nav a:hover { background: rgba(255,255,255,.08); padding-left: 20px; }
.sidebar nav a.active {
  background: linear-gradient(160deg, var(--gold), var(--gold-dark));
  color: #241a00;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.nav-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger, #b3261e);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.sidebar .user-box {
  margin-top: auto;
  padding: 12px 6px 0;
  border-top: 1px solid rgba(255,255,255,.15);
  font-size: 13px;
}

.sidebar .user-box button {
  margin-top: 8px;
  width: 100%;
}

.main {
  padding: 24px 32px;
  max-width: 1200px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.topbar h1 { font-family: var(--font-heading); font-size: 20px; margin: 0; }

/* ปุ่มเมนู ☰ สำหรับเปิดเมนูด้านข้างบนมือถือ — ซ่อนไว้บนจอใหญ่ที่เมนูแสดงอยู่แล้วตลอด */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  padding: 6px 12px;
  margin-right: 12px;
  cursor: pointer;
  color: var(--maroon);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 40;
}

/* --- Cards / panels --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 18px 18px 16px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--gold), var(--maroon));
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }

.stat-card .num { font-family: var(--font-heading); font-size: 28px; font-weight: 700; color: var(--maroon); }
.stat-card .label { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* --- Forms --- */
label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--muted); }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; }

.field { margin-bottom: 12px; }

.password-field-wrap { position: relative; }
.password-field-wrap input { padding-right: 56px; }
.password-field-wrap button.password-toggle-btn {
  position: absolute; top: 50%; right: 4px; left: auto; transform: translateY(-50%);
  width: auto; margin-top: 0; background: none; border: none; padding: 4px 8px; font-size: 12px;
  color: var(--maroon); font-weight: 600; cursor: pointer;
}
.password-field-wrap button.password-toggle-btn:hover { background: #f6f1e4; border-radius: 6px; }

/* ปุ่มกด — สไตล์โมเดิร์น ไล่เฉดสีมีมิติ เงานุ่มตอนพัก มีเอฟเฟกต์แสงวิ่งผ่านและยกตัวเบาๆ เมื่อเอาเมาส์ไปชี้ */
button, .btn {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .2px;
  background: linear-gradient(160deg, var(--gold), var(--gold-dark));
  color: #241a00;
  box-shadow: 0 2px 6px rgba(139, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

button::before, .btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 45%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  pointer-events: none;
}

button:hover::before, .btn:hover::before { animation: btn-shine 0.7s ease forwards; }
@keyframes btn-shine {
  from { left: -75%; }
  to { left: 130%; }
}

button:hover {
  background: linear-gradient(160deg, var(--gold-dark), #9c7522);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(139, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
button:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(139, 0, 0, 0.16); }

button.secondary, a.secondary {
  background: linear-gradient(160deg, #f7f1e0, #ece1c4);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(44, 28, 12, 0.06);
}
button.secondary:hover, a.secondary:hover { background: linear-gradient(160deg, #efe9d8, #e2d5ac); box-shadow: 0 6px 14px rgba(44, 28, 12, 0.12); }
/* ปุ่มลิงก์ (<a class="secondary">) ต้องประกาศพื้นฐานของ button เองด้วย เพราะ <a> ไม่ได้กติกา UA style เดียวกับ <button> */
a.secondary {
  display: inline-block;
  border-radius: 10px;
  padding: 9px 18px;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .2px;
  text-decoration: none;
  transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}
a.secondary:active { transform: translateY(0); }

button.danger { background: linear-gradient(160deg, var(--danger), #8f1e18); color: #fff; }
button.danger:hover { background: linear-gradient(160deg, #8f1e18, #6f1811); }

button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

td.actions button { border-radius: 8px; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar input, .toolbar select { width: auto; min-width: 160px; }

/* --- Table --- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--maroon); font-weight: 600; font-size: 12.5px; letter-spacing: .2px; background: rgba(139, 0, 0, 0.04); }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: #faf7ef; }
td.actions { display: flex; gap: 6px; }
td.actions button { padding: 5px 10px; font-size: 12px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.pass, .badge.active, .badge.completed { background: #e3f3e3; color: var(--success); }
.badge.fail, .badge.dropped { background: #fbe4e2; color: var(--danger); }
.badge.pending, .badge.studying { background: #fdf0d6; color: var(--warn); }
.badge.absent, .badge.withdrawn, .badge.transferred, .badge.graduated { background: #e9e5f5; color: #5b3fa0; }
.badge.type-activity { background: rgba(139, 0, 0, 0.08); color: var(--maroon); }
.badge.type-news { background: rgba(212, 175, 55, 0.18); color: var(--gold-dark); }

/* --- Modal --- */
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,20,10,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
  animation: modal-fade-in 0.2s ease;
}
.modal {
  background: #fff; border-radius: var(--radius-lg); padding: 22px 24px;
  width: 100%; max-width: 560px;
  box-shadow: 0 25px 60px rgba(44, 28, 12, 0.3);
  animation: modal-pop-in 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal h2 { font-family: var(--font-heading); margin-top: 0; font-size: 17px; color: var(--maroon); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal { animation: none; }
}

.error-text { color: var(--danger); font-size: 13px; margin-top: 6px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.empty-state { color: var(--muted); font-size: 14px; padding: 24px; text-align: center; }

/* --- Login page --- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--maroon), #3d0f0f);
}
.login-card {
  background: #fff; border-radius: 14px; padding: 34px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.login-card { border-top: 4px solid var(--gold); }
.login-card h1 { font-family: var(--font-heading); font-size: 18px; text-align: center; margin: 0 0 4px; color: var(--maroon); }
.login-card p.sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card button { width: 100%; margin-top: 8px; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-block; }
  /* เมนูกลายเป็นลิ้นชักเลื่อนออกจากซ้าย (off-canvas) แทนการซ่อนไปเฉยๆ — ไม่งั้นเข้าเว็บจากมือถือแล้วกดเมนูอะไรไม่ได้เลย */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    max-width: 80vw;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  /* ตารางส่วนใหญ่ในระบบมีหลายคอลัมน์ กว้างเกินจอมือถือ — ให้เลื่อนแนวนอนได้ในตัวตารางเอง แทนที่จะดันทั้งหน้าให้กว้างเกิน */
  table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ============================================================
   Public page (หน้าเว็บสาธารณะ) — หัวข้อ ๑: Hero Section
   แถบต้อนรับด้านบนสุด สีน้ำตาลไหม้/แดงชาดไล่เฉด พร้อมแสงทองฟุ้งเบาๆ
   ให้ความรู้สึกสงบ น่าเลื่อมใส สื่อถึงความเป็นสถาบันสงฆ์
   ============================================================ */
.public-hero, .hero-section {
  position: relative;
  background-color: var(--maroon-dark);
  background-image:
    radial-gradient(60% 90% at 50% -10%, rgba(212, 175, 55, 0.22), transparent 60%),
    linear-gradient(160deg, var(--maroon), var(--maroon-dark)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg fill='none' stroke='%23d4af37' stroke-width='1' opacity='0.12'%3E%3Ccircle cx='40' cy='40' r='22'/%3E%3Ccircle cx='40' cy='40' r='4'/%3E%3Cpath d='M40 18v44M18 40h44M25.6 25.6l28.8 28.8M54.4 25.6L25.6 54.4'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat, repeat;
  background-size: auto, auto, 80px 80px;
  background-position: center, center, center;
  color: #fdf6e6;
  padding: clamp(40px, 8vw, 64px) 24px clamp(56px, 10vw, 76px);
  text-align: center;
  overflow: hidden;
}
.hero-logo {
  position: relative;
  display: block;
  width: clamp(72px, 12vw, 110px);
  height: clamp(72px, 12vw, 110px);
  margin: 0 auto 12px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3));
}
.public-hero h1 { font-family: var(--font-heading); margin: 0 0 6px; font-size: clamp(20px, 4vw, 26px); letter-spacing: .2px; }
.public-hero p { margin: 4px 0; color: #e8d3ac; font-size: 14px; }
.public-hero .btn-login {
  position: relative;
  overflow: hidden;
  display: inline-block; margin-top: 18px; background: var(--gold); color: #241a00;
  padding: 10px 22px; border-radius: 999px; font-weight: 600; text-decoration: none; font-size: 14px;
  transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}
.public-hero .btn-login:hover { background: var(--gold-dark); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25); }

.public-body { max-width: 1000px; margin: 0 auto 40px; padding: 0 20px; flex: 1 0 auto; width: 100%; }

/* แอนิเมชันตอนเปลี่ยนแท็บ — เนื้อหาค่อยๆ ปรากฏขึ้นเบาๆ ให้ดูลื่นไหลทันสมัย */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.tab-panel.fade-in { animation: fade-in-up 0.4s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .tab-panel.fade-in { animation: none; }
}

/* ดัน footer ให้อยู่ล่างสุดของจอเสมอ แม้เนื้อหาในแท็บนั้นจะสั้นกว่าความสูงจอก็ตาม */
body.public-page { min-height: 100vh; display: flex; flex-direction: column; }
.public-section-title { font-family: var(--font-heading); font-size: 18px; color: var(--maroon); margin: 32px 0 16px; text-align: center; }

/* คำนำต้อนรับหน้าแรก — ลดขนาดตัวหนังสือและจำกัดความกว้าง อ่านสบายตา ไม่ใหญ่โด่งเด่นเกินไป */
.home-intro { text-align: center; }
.home-intro p {
  margin: 0 auto;
  max-width: 640px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--muted);
}

/* หน้าเกี่ยวกับสำนัก — ที่ตั้ง/สังกัด ลดขนาดตัวหนังสือให้เท่ากับส่วนอื่นของเว็บ */
#tab-about p { font-size: 14px; line-height: 1.9; color: var(--text); }
#tab-about p strong { color: var(--maroon); }

/* ============================================================
   หัวข้อ ๒: Navbar (แถบเมนู/แท็บ) — ลอยค้างด้านบนเมื่อเลื่อนจอ (sticky)
   พื้นหลังโปร่งใสเล็กน้อยพร้อม backdrop-filter blur ให้ความรู้สึกทันสมัย
   ============================================================ */
.public-tabs, .navbar {
  position: sticky;
  top: 12px;
  z-index: 40;
  /* nowrap เพื่อบังคับให้แท็บทั้งหมดอยู่แถวเดียวกันเสมอ (8 แท็บพอดีความกว้าง .public-body ถ้าลด padding ลง)
     overflow-x: auto เป็นทางออกสำรองถ้าจอแคบมากจนยังไม่พอ จะเลื่อนดูได้แทนการตกบรรทัด */
  display: flex; flex-wrap: nowrap; justify-content: center; gap: 4px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  width: fit-content;
  margin: -28px auto 24px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow-soft);
  transition: box-shadow 0.3s ease, background 0.3s ease;
}
.public-tabs::-webkit-scrollbar, .navbar::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none; border: none; padding: 9px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap; flex: 0 0 auto;
  transition: background 0.25s ease, color 0.25s ease;
}
.tab-btn:hover { background: rgba(139, 0, 0, 0.08); color: var(--maroon); }
.tab-btn.active { background: var(--maroon); color: #fdf6e6; }

/* ============================================================
   หัวข้อ ๓: Course Card / News Card — การ์ดหลักสูตรและข่าวสาร
   ขอบมน เงาฟุ้งนุ่มนวล ลอยขึ้นเบาๆ เมื่อ hover
   ============================================================ */
/* Grid แทน flex เดิม เพื่อบังคับให้การ์ดทุกใบกว้างเท่ากันทุกแถว — ปุ่ม "สมัครเรียน" ในแต่ละการ์ดจะได้ชิดขอบขวาตรงกันเป๊ะ
   ไม่เยื้องกันเวลาการ์ดขึ้นแถวใหม่ (flex เดิมปล่อยให้แต่ละแถวยืดความกว้างไม่เท่ากันตามจำนวนการ์ดในแถวนั้นๆ) */
.courses-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 260px)); justify-content: center; align-items: stretch; gap: 16px; }
/* ข้อความ "ยังไม่มี..." ตอนไม่มีการ์ดเลย ต้องกินเต็มความกว้างแถว ไม่งั้น grid จะบีบให้แคบเท่าการ์ดใบเดียว (~220-260px) ดูเหมือนหลุดไปทางซ้าย ไม่อยู่กึ่งกลางหน้า */
.courses-row .empty-state { grid-column: 1 / -1; }

.courses-row .panel, .course-card,
.post-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.courses-row .panel:hover, .course-card:hover,
.post-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); }

.courses-row .panel { margin-bottom: 0; padding: 16px 18px; }
.courses-row .panel h3, .course-card h3 { font-family: var(--font-heading); font-size: 14.5px; margin-top: 0; }
.courses-row .panel li { font-size: 13px; line-height: 1.6; }

.faq-item { border-bottom: 1px solid var(--border); padding: 12px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary { cursor: pointer; font-weight: 600; color: var(--maroon); list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: '+ '; color: var(--gold-dark); font-weight: 700; }
.faq-item[open] summary::before { content: '– '; }
.faq-item p { margin: 8px 0 0; color: var(--text); line-height: 1.6; }

.post-card { padding: 16px 20px; margin-bottom: 14px; }
.post-card h3 { font-family: var(--font-heading); margin: 0 0 4px; color: var(--maroon); font-size: 16px; }
.post-card .post-date { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.post-card p { margin: 0; font-size: 14px; line-height: 1.7; white-space: pre-line; }
.post-card .post-image {
  display: block; width: 100%; max-height: 320px; object-fit: cover;
  border-radius: 8px; margin-bottom: 12px;
}

@media (max-width: 640px) {
  .public-tabs, .navbar { top: 8px; border-radius: 16px; gap: 3px; padding: 5px; }
  .tab-btn { padding: 7px 12px; font-size: 12.5px; }
}

/* หัวข้อ ๓.๑: การ์ดดาวน์โหลดเอกสาร */
.download-card { max-width: 280px; text-align: center; padding: 22px 20px; }
.download-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(139, 0, 0, 0.08); color: var(--maroon);
}
.download-card h3 { font-size: 15px; }
.btn-download {
  position: relative; overflow: hidden;
  display: inline-block; background: var(--gold); color: #241a00;
  padding: 9px 20px; border-radius: 999px; font-weight: 600; text-decoration: none; font-size: 13.5px;
  transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}
.btn-download:hover { background: var(--gold-dark); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18); }

/* หัวข้อ ๓.๒: Skeleton Loading — กรอบเทาๆ เคลื่อนไหวเบาๆ (shimmer) ระหว่างรอข้อมูลโหลด แทนข้อความ "กำลังโหลด..." เฉยๆ */
@keyframes skeleton-shimmer {
  0% { background-position: -300px 0; }
  100% { background-position: 300px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #ece3d2 25%, #f7efdc 37%, #ece3d2 63%);
  background-size: 600px 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.skeleton-card { width: 220px; height: 110px; border-radius: var(--radius-lg); }
.skeleton-line { height: 13px; border-radius: 4px; margin: 8px auto; }
.skeleton-line.short { width: 60%; }
.skeleton-line.long { width: 85%; }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* org chart — compact stacked/wrap layout: never needs its own scrollbar (h or v) */
.org-chart { display: flex; flex-direction: column; align-items: center; gap: 0; }
.org-connector { width: 2px; height: 16px; background: var(--border); flex: none; }
.org-row {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch;
  gap: 10px; width: 100%;
}
.org-node {
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  padding: 8px 16px; font-size: 12.5px; line-height: 1.4; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  flex: 0 1 auto; min-width: 150px;
}
.org-node .role { display: block; font-weight: 700; color: var(--maroon); font-size: 12px; white-space: nowrap; }
.org-node .person { display: block; margin-top: 2px; }
.org-node .vacant { color: var(--muted); font-style: italic; }
.org-node.root { background: var(--maroon); border-color: var(--maroon); }
.org-node.root .role, .org-node.root .person { color: #fdf6e6; }

.org-person { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 6px; }
.org-avatar { border-radius: 50%; object-fit: cover; flex: none; display: block; }
.org-avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--gold); color: #241a00; font-weight: 700;
}
.org-node.root .org-avatar-placeholder.vacant-avatar { background: rgba(255,255,255,.25); color: #fdf6e6; }

.org-dept { flex: 1 1 260px; max-width: 340px; background: #fdf0d6; border-color: var(--gold); text-align: left; padding: 10px 14px; }
.org-dept .role { text-align: center; margin-bottom: 6px; }
.org-chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.org-chip {
  display: flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--gold); border-radius: 999px;
  padding: 3px 10px 3px 3px; font-size: 11.5px;
}
.org-chip-empty { color: var(--muted); font-style: italic; font-size: 11.5px; text-align: center; }

/* ============================================================
   หัวข้อ ๔: Footer — แถบท้ายเว็บ สีเข้มคู่กับ Hero พร้อมเส้นทองคาดหัว
   ============================================================ */
.public-footer, .footer {
  text-align: center;
  color: #e8d3ac;
  font-size: 13px;
  padding: 32px 20px;
  margin-top: 24px;
  background: linear-gradient(160deg, var(--maroon), var(--maroon-dark));
  border-top: 3px solid var(--gold);
}

/* หน่วยงานที่เกี่ยวข้อง — ลิงก์โลโก้แม่กองธรรม/แม่กองบาลีสนามหลวง ท้าย Footer */
.footer-agency-title {
  font-size: 12px;
  letter-spacing: .5px;
  color: rgba(232, 211, 172, 0.75);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
}
.footer-links a {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  padding: 3px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.footer-links a:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); }
.footer-links img { display: block; height: 40px; width: auto; }
.footer-copy { color: #e8d3ac; }
