/* ==========================================================================
   เว็บไซต์โรงพยาบาลสมเด็จพระยุพราชบ้านดุง — สไตล์ส่วนหน้า
   ชุดสีและตัวอักษรเป็นไปตามเอกสารโครงร่างการออกแบบ ข้อ 3
   ค่าความต่างของสีตัวอักษรกับพื้นหลังไม่น้อยกว่า 4.5:1 ตาม WCAG 2.1 ระดับ AA
   ========================================================================== */

:root {
  --primary: #1b3b8b;
  --dark: #0f2a66;
  --light: #e8f0fe;
  --gold: #c9a227;
  --gold-dark: #8a6f14;
  --text: #333333;
  --muted: #5f6b80;
  --success: #1e7e34;
  --alert: #c0392b;
  --white: #ffffff;
  --border: #e4e9f5;
  --surface: #f6f9ff;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(15, 42, 102, 0.08);
  --shadow: 0 6px 18px rgba(15, 42, 102, 0.1);
  --shadow-lg: 0 10px 28px rgba(15, 42, 102, 0.15);

  --font-base: 17px;
  --container: 1280px;
}

/* ปุ่มปรับขนาดตัวอักษร 3 ระดับ สำหรับผู้สูงอายุ (เอกสารข้อ 10) */
html[data-font="small"] { --font-base: 15px; }
html[data-font="normal"] { --font-base: 17px; }
html[data-font="large"] { --font-base: 20px; }

/* โหมดความต่างสีสูง สำหรับผู้พิการทางสายตา */
html[data-contrast="high"] {
  --primary: #000000;
  --dark: #000000;
  --light: #ffffff;
  --gold: #b8860b;
  --text: #000000;
  --muted: #000000;
  --border: #000000;
  --surface: #ffffff;
  --shadow-sm: none;
  --shadow: none;
  --shadow-lg: none;
}
html[data-contrast="high"] body { background: #fff; }
html[data-contrast="high"] .card,
html[data-contrast="high"] .box,
html[data-contrast="high"] .q-item { border: 2px solid #000; }
html[data-contrast="high"] .hero { background: #000; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Sarabun', 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Tahoma', sans-serif;
  font-size: var(--font-base);
  color: var(--text);
  background: var(--white);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3, h4 { line-height: 1.35; color: var(--dark); }

.container { max-width: var(--container); margin: 0 auto; padding: 0 20px; }

/* จุดข้ามไปยังเนื้อหาหลักสำหรับผู้ใช้แป้นพิมพ์และโปรแกรมอ่านหน้าจอ */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--gold); color: #1c1200; padding: 10px 18px; font-weight: 700;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- แถบบนสุด */
.topbar { background: var(--dark); color: #fff; font-size: 0.85em; }
.topbar a { color: #fff; }
.topbar .container {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 40px; flex-wrap: wrap; gap: 6px;
}
.topbar .left span { margin-right: 18px; white-space: nowrap; }
.topbar .tools { display: flex; align-items: center; gap: 6px; }
.topbar .tools button {
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.45); color: #fff;
  border-radius: 6px; padding: 3px 9px; cursor: pointer; font-family: inherit; font-size: 0.95em;
  min-height: 30px;
}
.topbar .tools button:hover, .topbar .tools button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.22); }

/* ------------------------------------------------------------------ ส่วนหัว */
.site-header {
  background: #fff; border-bottom: 3px solid var(--primary);
  position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm);
}
.header-inner { display: flex; align-items: center; gap: 16px; padding: 12px 0; }
.logo {
  height: 64px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.logo img { height: 100%; width: auto; object-fit: contain; }
.site-title h1, .site-title .h1 { font-size: 1.2em; color: var(--primary); font-weight: 800; line-height: 1.25; }
.site-title p { font-size: 0.78em; color: var(--muted); }
.header-search { margin-left: auto; display: flex; }
.header-search input {
  border: 1.5px solid #ccd6ee; border-right: 0; border-radius: 8px 0 0 8px;
  padding: 9px 12px; font-family: inherit; font-size: 0.9em; width: 200px; min-height: 42px;
}
.header-search button {
  background: var(--primary); color: #fff; border: none; border-radius: 0 8px 8px 0;
  padding: 0 16px; cursor: pointer; font-size: 1em; min-height: 42px;
}
.hamburger {
  display: none; background: var(--primary); color: #fff; border: none;
  font-size: 1.3em; border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 44px;
}

/* ปุ่มเข้าระบบสารสนเทศภายในสำหรับเจ้าหน้าที่ (PRISM)
   จำเป็นเพราะหน้าแรกของโดเมนถูกเปลี่ยนไปเป็นเว็บไซต์โรงพยาบาลแล้ว */
.header-staff {
  display: flex; align-items: center; gap: 8px; margin-left: 10px; flex-shrink: 0;
  border: 1.5px solid var(--gold); border-radius: 10px; padding: 6px 14px; min-height: 44px;
  background: #fffaeb; color: var(--dark); text-decoration: none; line-height: 1.25;
}
.header-staff:hover { background: var(--gold); color: #2a2000; text-decoration: none; }
.header-staff .icon { font-size: 1.25em; }
.header-staff .label { display: flex; flex-direction: column; }
.header-staff .label strong { font-size: 0.92em; font-weight: 800; letter-spacing: 0.03em; }
.header-staff .label small { font-size: 0.68em; color: var(--muted); white-space: nowrap; }
.header-staff:hover .label small { color: #4a3a12; }


/* -------------------------------------------------------------------- เมนู */
.main-nav { background: var(--primary); }
.main-nav ul { list-style: none; display: flex; flex-wrap: wrap; }
.main-nav > .container > ul > li { position: relative; }
.main-nav a {
  display: block; color: #fff; padding: 12px 16px; font-weight: 600;
  font-size: 0.93em; transition: background 0.2s;
}
.main-nav a:hover, .main-nav a.active { background: var(--dark); text-decoration: none; }
.main-nav a.complaint { background: var(--alert); }
.main-nav a.complaint:hover { background: #96291c; }
/* ลิงก์ระบบภายในสำหรับเจ้าหน้าที่ — ใช้สีทองชุดเดียวกับปุ่มเข้าระบบที่หัวเว็บ ให้ต่างจากเมนูบริการประชาชน */
.main-nav a.risk { background: var(--gold); color: #1c1200; }
.main-nav a.risk:hover { background: var(--gold-dark); color: #fff; }
.main-nav a.risk small { font-size: 0.82em; font-weight: 600; opacity: 0.85; }
.main-nav .submenu {
  display: none; position: absolute; left: 0; top: 100%; min-width: 260px;
  background: #fff; box-shadow: var(--shadow-lg); border-radius: 0 0 var(--radius) var(--radius);
  flex-direction: column; z-index: 60; border-top: 3px solid var(--gold); padding: 6px 0;
}
.main-nav li:hover > .submenu, .main-nav li:focus-within > .submenu { display: flex; }
.main-nav .submenu a { color: var(--text); padding: 9px 18px; font-weight: 500; font-size: 0.92em; }
.main-nav .submenu a:hover { background: var(--light); color: var(--primary); }

/* -------------------------------------------------------------- ประกาศด่วน */
.announce { background: #fff6e5; border-bottom: 1px solid #f0ddb0; color: #7a4f00; font-size: 0.9em; }
.announce .container { display: flex; align-items: center; gap: 10px; padding: 9px 20px; }
.announce .tag {
  background: var(--alert); color: #fff; font-size: 0.8em; padding: 2px 12px;
  border-radius: 999px; white-space: nowrap; font-weight: 700;
}
.announce-track { overflow: hidden; flex: 1; }
.announce-track p { margin: 0; }

/* ------------------------------------------------------------------ แบนเนอร์ */
.hero {
  background: linear-gradient(120deg, var(--dark) 0%, var(--primary) 55%, #2f55b0 100%);
  color: #fff; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px;
  border-radius: 50%; background: rgba(201, 162, 39, 0.18);
}
.hero .container {
  display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 32px;
  padding: 54px 20px 62px; align-items: center; position: relative; z-index: 1;
}
.hero h2 { font-size: 2em; font-weight: 800; line-height: 1.3; margin-bottom: 14px; color: #fff; }
.hero p { font-size: 1.02em; opacity: 0.94; margin-bottom: 24px; }
.hero-card {
  background: rgba(255, 255, 255, 0.13); border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-lg); padding: 22px;
}
.hero-card h3 { font-size: 1.05em; margin-bottom: 12px; color: #ffe9a8; }

/* วิสัยทัศน์ของโรงพยาบาลบนแบนเนอร์หลัก */
.hero-vision {
  border: 0;
  border-left: 4px solid var(--gold);
  background: rgba(255, 255, 255, 0.1);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 20px 15px;
  margin: 0 0 24px;
  max-width: 640px;
}
.hero-vision .label {
  font-size: 0.76em;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #ffe9a8;
  margin: 0 0 4px;
  text-transform: uppercase;
}
.hero-vision .text {
  font-size: 1.02em;
  font-weight: 600;
  line-height: 1.6;
  color: #fff;
  opacity: 1;
  margin: 0;
}
.hero-vision a {
  display: inline-block;
  margin-top: 9px;
  font-size: 0.84em;
  font-weight: 600;
  color: #ffe9a8;
  text-decoration: underline;
}
.hero-vision a:hover { color: #fff; }

@media (max-width: 768px) {
  .hero-vision { padding: 12px 15px 13px; margin-bottom: 20px; }
  .hero-vision .text { font-size: 0.96em; }
}

html[data-contrast="high"] .hero-vision { background: transparent; border-left-color: #fff; }
html[data-contrast="high"] .hero-vision .label,
html[data-contrast="high"] .hero-vision a { color: #fff; }

.hero-card ul { list-style: none; }
.hero-card li {
  padding: 8px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.28);
  font-size: 0.92em; display: flex; justify-content: space-between; gap: 10px;
}
.hero-card li:last-child { border-bottom: none; }

.btn {
  display: inline-block; padding: 12px 24px; border-radius: 10px; font-weight: 700;
  font-size: 0.98em; margin-right: 10px; margin-bottom: 10px; cursor: pointer;
  border: 2px solid transparent; font-family: inherit; min-height: 46px; text-align: center;
}
.btn:hover { text-decoration: none; opacity: 0.92; }
.btn-gold { background: var(--gold); color: #1c1200; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.75); }
.btn-outline-primary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-danger { background: var(--alert); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 0.85em; min-height: 38px; border-radius: 8px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* -------------------------------------------------------------- บริการด่วน */
.quick { margin-top: -36px; position: relative; z-index: 2; }
.quick-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.q-item {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 18px 10px;
  text-align: center; border-top: 4px solid var(--primary); transition: transform 0.15s;
  color: var(--primary);
}
.q-item:hover { transform: translateY(-4px); text-decoration: none; }
.q-item .ico { font-size: 1.7em; line-height: 1.2; }
.q-item p { font-weight: 700; font-size: 0.88em; margin-top: 6px; }

/* ------------------------------------------------------------------- ส่วนเนื้อหา */
.section { padding: 46px 0; }
.section.tinted { background: var(--light); }
.section.surface { background: var(--surface); }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.sec-head h2 {
  font-size: 1.42em; color: var(--dark); font-weight: 800;
  border-left: 6px solid var(--gold); padding-left: 14px;
}
.sec-head a { font-weight: 700; font-size: 0.9em; }

/* ------------------------------------------------------------------ การ์ดข่าว */
.news-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.news-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; transition: box-shadow 0.2s, transform 0.2s; display: flex; flex-direction: column;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card > a { color: inherit; }
.card .thumb {
  height: 168px; background: linear-gradient(135deg, #c7d5f2, #8fa9dd);
  display: flex; align-items: center; justify-content: center; color: #41599b; font-size: 2em;
  overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 14px; flex: 1; display: flex; flex-direction: column; }
.card h3 {
  font-size: 0.98em; line-height: 1.5; font-weight: 700; color: #222;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card .meta { font-size: 0.82em; color: var(--muted); margin-top: 10px; }

.badge {
  display: inline-block; font-size: 0.76em; font-weight: 700; padding: 3px 11px;
  border-radius: 999px; margin-bottom: 8px; align-self: flex-start;
}
.badge-blue { background: var(--light); color: var(--primary); }
.badge-green { background: #e6f4ea; color: var(--success); }
.badge-red { background: #fdecea; color: var(--alert); }
.badge-gold { background: #fdf5dd; color: var(--gold-dark); }
.badge-gray { background: #eef1f6; color: var(--muted); }

.pin { color: var(--alert); font-weight: 700; }

/* ------------------------------------------------------------------- ตาราง */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow-sm); background: #fff; }
table.data { width: 100%; border-collapse: collapse; background: #fff; }
table.data th {
  background: var(--primary); color: #fff; padding: 12px; font-size: 0.92em; text-align: left; white-space: nowrap;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid #edf1fa; font-size: 0.92em; vertical-align: top; }
table.data tbody tr:nth-child(even) td { background: var(--surface); }
table.data tbody tr:last-child td { border-bottom: none; }

/* ------------------------------------------------------------------ กล่องข้อมูล */
.box {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm);
}
.box + .box { margin-top: 18px; }
.box h3 { font-size: 1.1em; margin-bottom: 12px; color: var(--primary); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }

/* -------------------------------------------------------------- โซเชียลมีเดีย */
.social-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.social-box {
  border-radius: 14px; padding: 24px; color: #fff; display: flex; gap: 18px; align-items: center;
}
.social-box.fb { background: linear-gradient(135deg, #1877f2, #0f5ec7); }
.social-box.line { background: linear-gradient(135deg, #06c755, #048038); }
.social-box .big { font-size: 2.2em; }
.social-box h3 { font-size: 1.1em; margin-bottom: 4px; color: #fff; }
.social-box p { font-size: 0.88em; opacity: 0.95; }
.social-box .cta {
  margin-left: auto; background: #fff; border-radius: 10px; padding: 10px 18px;
  font-weight: 800; white-space: nowrap;
}
.social-box.fb .cta { color: #1050a8; }
.social-box.line .cta { color: #046b30; }

/* --------------------------------------------------------------- เส้นทางหน้า */
.breadcrumb { background: var(--surface); border-bottom: 1px solid var(--border); font-size: 0.85em; }
.breadcrumb .container { padding: 10px 20px; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.breadcrumb li::after { content: "›"; margin-left: 8px; color: var(--muted); }
.breadcrumb li:last-child::after { content: ""; }
.breadcrumb li:last-child { color: var(--muted); }

.page-head { background: var(--primary); color: #fff; padding: 30px 0; }
.page-head h1 { color: #fff; font-size: 1.7em; }
.page-head p { opacity: 0.9; font-size: 0.95em; margin-top: 4px; }

/* --------------------------------------------------------------- เนื้อหาบทความ */
.content { font-size: 1em; }
.content p { margin-bottom: 1em; }
.content h2 { font-size: 1.3em; margin: 1.4em 0 0.5em; }
.content h3 { font-size: 1.12em; margin: 1.2em 0 0.4em; color: var(--primary); }
.content ul, .content ol { margin: 0 0 1em 1.4em; }
.content li { margin-bottom: 0.35em; }
.content img { border-radius: var(--radius); margin: 1em 0; }
.content table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
.content table th, .content table td { border: 1px solid var(--border); padding: 8px 10px; }
.content blockquote {
  border-left: 4px solid var(--gold); background: var(--surface);
  padding: 12px 18px; margin: 1em 0; border-radius: 0 var(--radius) var(--radius) 0;
}
.content .note {
  background: #fff6e5; border: 1px dashed #e0c37a; color: #7a4f00;
  padding: 10px 14px; border-radius: 8px; font-size: 0.92em;
}
.content a { text-decoration: underline; }

.article-meta {
  display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 0.87em;
  border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 20px;
}

.attachments { list-style: none; }
.attachments li { border-bottom: 1px dashed var(--border); padding: 9px 0; }
.attachments li:last-child { border-bottom: none; }
.attachments a { font-weight: 600; }
.attachments .size { color: var(--muted); font-size: 0.85em; }

.share-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 22px 0; }
.share-bar .lbl { font-weight: 700; color: var(--muted); font-size: 0.9em; }
.share-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px;
  color: #fff; font-weight: 700; font-size: 0.85em; min-height: 40px;
}
.share-btn:hover { text-decoration: none; opacity: 0.9; }
.share-fb { background: #1877f2; }
.share-line { background: #06c755; }
.share-copy { background: var(--muted); border: 0; cursor: pointer; font-family: inherit; }

.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.gallery-grid img { border-radius: 10px; aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }

/* ------------------------------------------------------------------- ฟอร์ม */
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.94em; }
.form-row .hint { font-size: 0.84em; color: var(--muted); margin-top: 4px; }
.req { color: var(--alert); }

input[type="text"], input[type="email"], input[type="tel"], input[type="password"],
input[type="date"], input[type="datetime-local"], input[type="number"], input[type="search"],
input[type="url"], select, textarea {
  width: 100%; border: 1.5px solid #ccd6ee; border-radius: 9px; padding: 11px 13px;
  font-family: inherit; font-size: 0.96em; color: var(--text); background: #fff; min-height: 46px;
}
textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid rgba(27, 59, 139, 0.18); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--alert); }
input[type="file"] { font-family: inherit; font-size: 0.9em; }

.field-error { color: var(--alert); font-size: 0.86em; margin-top: 5px; font-weight: 600; }

.checkbox { display: flex; align-items: flex-start; gap: 9px; font-size: 0.94em; }
.checkbox input { width: 20px; height: 20px; min-height: 20px; margin-top: 3px; flex-shrink: 0; }

.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.radio-card {
  border: 2px solid var(--border); border-radius: var(--radius); padding: 14px;
  cursor: pointer; display: flex; gap: 10px; align-items: flex-start; background: #fff;
}
.radio-card:hover { border-color: var(--primary); }
.radio-card input { width: 20px; height: 20px; min-height: 20px; margin-top: 3px; flex-shrink: 0; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--light); }
.radio-card strong { display: block; font-size: 0.96em; }
.radio-card span { font-size: 0.84em; color: var(--muted); }

.alert-box { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: 0.95em; border: 1px solid; }
.alert-success { background: #e8f6ec; border-color: #b8e0c4; color: #14572a; }
.alert-error { background: #fdecea; border-color: #f2c1bb; color: #8d2116; }
.alert-info { background: var(--light); border-color: #c4d6f9; color: var(--dark); }
.alert-warning { background: #fff6e5; border-color: #e8cf94; color: #7a4f00; }

.pdpa-notice {
  background: var(--light); border-left: 5px solid var(--primary); padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0; font-size: 0.9em; margin-bottom: 20px;
}

.steps { display: flex; gap: 10px; margin-bottom: 26px; flex-wrap: wrap; }
.step { flex: 1; min-width: 180px; border-top: 4px solid var(--border); padding-top: 10px; }
.step.active { border-top-color: var(--gold); }
.step .num { font-weight: 800; color: var(--primary); font-size: 0.85em; }
.step .txt { font-size: 0.9em; }

/* ---------------------------------------------------------------- แบ่งหน้า */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 30px; flex-wrap: wrap; list-style: none; }
.pagination a, .pagination span {
  display: block; min-width: 44px; min-height: 44px; line-height: 30px; padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 8px; text-align: center; background: #fff; font-size: 0.9em;
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.pagination a:hover { background: var(--light); text-decoration: none; }

.filter-bar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  background: var(--surface); padding: 16px; border-radius: var(--radius); margin-bottom: 22px;
  border: 1px solid var(--border);
}
.filter-bar .form-row { margin-bottom: 0; flex: 1; min-width: 160px; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .ico { font-size: 2.4em; }

/* ---------------------------------------------------------------- คำถามที่พบบ่อย */
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; background: #fff; }
.faq-item summary {
  padding: 14px 18px; font-weight: 700; cursor: pointer; font-size: 0.98em;
  display: flex; gap: 10px; align-items: flex-start; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: "?"; color: var(--gold); font-weight: 800; }
.faq-item[open] summary { border-bottom: 1px solid var(--border); color: var(--primary); }
.faq-item .answer { padding: 14px 18px; font-size: 0.95em; }

/* ---------------------------------------------------------------- ส่วนท้าย */
.site-footer { background: var(--dark); color: #cfd9ef; font-size: 0.9em; margin-top: 40px; }
.site-footer a { color: #cfd9ef; }
.site-footer a:hover { color: #fff; }
.f-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 28px; padding: 40px 0; }
.site-footer h4 {
  color: #fff; font-size: 1em; margin-bottom: 12px;
  border-bottom: 2px solid var(--gold); display: inline-block; padding-bottom: 4px;
}
.site-footer ul { list-style: none; }
.site-footer li { padding: 4px 0; }
.copy {
  border-top: 1px solid rgba(255, 255, 255, 0.15); text-align: center;
  padding: 14px 20px; font-size: 0.85em; color: #9fb0d6;
}

/* ----------------------------------------------------------- แบนเนอร์คุกกี้ */
.cookie-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200; background: rgba(15, 42, 102, 0.98);
  color: #fff; padding: 16px 20px; box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.25);
}
.cookie-bar .inner {
  max-width: var(--container); margin: 0 auto; display: flex; gap: 16px;
  align-items: center; flex-wrap: wrap; font-size: 0.88em;
}
.cookie-bar a { color: #ffe9a8; text-decoration: underline; }
.cookie-bar .actions { margin-left: auto; display: flex; gap: 8px; }
.cookie-bar button {
  border: 0; border-radius: 8px; padding: 9px 18px; font-weight: 700;
  cursor: pointer; font-family: inherit; min-height: 42px;
}
.cookie-accept { background: var(--gold); color: #1c1200; }
.cookie-close { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.5) !important; }

.back-to-top {
  position: fixed; right: 18px; bottom: 90px; z-index: 90; width: 48px; height: 48px;
  border-radius: 50%; background: var(--primary); color: #fff; border: 0; cursor: pointer;
  box-shadow: var(--shadow); font-size: 1.2em; display: none;
}
.back-to-top.show { display: block; }

/* ------------------------------------------------------------- Responsive */
@media (max-width: 1024px) {
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .news-grid, .news-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .hero .container { grid-template-columns: 1fr; }
  .grid-sidebar { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .f-grid { grid-template-columns: 1fr 1fr; }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}


/* จอขนาดกลาง (แท็บเล็ตแนวนอน/โน้ตบุ๊กจอเล็ก): ย่อช่องค้นหาและปุ่มเจ้าหน้าที่
   ไม่ให้แถบส่วนหัวแน่นจนชื่อโรงพยาบาลถูกบีบ */
@media (min-width: 769px) and (max-width: 1080px) {
  .header-search input { width: 140px; }
  .header-staff { padding: 6px 11px; }
  .header-staff .label small { display: none; }
}

@media (max-width: 768px) {
  .header-search { display: none; }
  .header-staff { margin-left: auto; padding: 6px 10px; gap: 6px; }
  .header-staff .label small { display: none; }
  .hamburger { display: block; margin-left: 8px; }
  .main-nav > .container > ul { display: none; flex-direction: column; }
  .main-nav > .container > ul.open { display: flex; }
  .main-nav .submenu { position: static; display: flex; box-shadow: none; border-radius: 0; background: rgba(255, 255, 255, 0.12); border-top: 0; }
  .main-nav .submenu a { color: #fff; padding-left: 34px; }
  .main-nav .submenu a:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
  .hero h2 { font-size: 1.5em; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .news-grid, .news-grid.cols-3, .social-grid, .f-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar .container { justify-content: center; text-align: center; }
  .topbar .left span { margin-right: 10px; display: inline-block; }
  .section { padding: 32px 0; }
  .social-box { flex-wrap: wrap; }
  .social-box .cta { margin-left: 0; }
}

@media print {
  .topbar, .main-nav, .hamburger, .header-search, .announce, .cookie-bar,
  .share-bar, .back-to-top, .site-footer, .header-staff { display: none !important; }
  body { font-size: 12pt; }
  a { color: #000; }
}

/* ==========================================================================
   แผนผังโครงสร้างองค์กร (หน้า /page/structure)
   ใช้เป็น HTML แทนรูปภาพ เพื่อให้ค้นหาได้ อ่านออกด้วยโปรแกรมอ่านหน้าจอ
   และย่อ-ขยายตามขนาดจอได้ตามมาตรฐาน WCAG 2.1 ระดับ AA
   ========================================================================== */
.orgchart { margin: 0.6em 0 0.4em; }

.orgchart .org-level { margin-bottom: 26px; }

.orgchart .org-level-title {
  font-size: 0.82em;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: none;
  text-align: center;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

.orgchart .org-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: stretch;
}

.orgchart .org-node {
  flex: 1 1 190px;
  max-width: 300px;
  min-width: 0;
  border: 1px solid rgba(15, 42, 102, 0.14);
  border-radius: 10px;
  padding: 11px 13px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.orgchart .org-node .role { display: block; font-weight: 700; line-height: 1.4; font-size: 0.95em; }
.orgchart .org-node .name { display: block; margin-top: 5px; font-size: 0.88em; color: #33405c; }

/* กล่องผู้อำนวยการ กว้างเต็มแถวและเด่นกว่าระดับอื่น */
.orgchart .org-node.lead { flex: 1 1 100%; max-width: 620px; padding: 16px 18px; }
.orgchart .org-node.lead .role { font-size: 1.08em; }
.orgchart .org-node.lead .name { font-size: 1em; font-weight: 700; color: var(--dark); }

/* กลุ่มงานย่อย: การ์ดรายชื่องานภายใต้แต่ละกลุ่มงาน */
.orgchart .org-units { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.orgchart .org-unit {
  border: 1px solid rgba(15, 42, 102, 0.14);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.orgchart .org-unit h4 {
  font-size: 0.98em;
  font-weight: 800;
  color: var(--dark);
  margin: 0 0 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(15, 42, 102, 0.14);
}

.orgchart .org-unit ul { list-style: none; margin: 0; padding: 0; }
.orgchart .org-unit li { margin: 0 0 9px; font-size: 0.9em; line-height: 1.5; }
.orgchart .org-unit li:last-child { margin-bottom: 0; }
.orgchart .org-unit li b { display: block; font-weight: 700; color: var(--text); }
.orgchart .org-unit li span { color: #33405c; }

/* ---------------------------------------------- ชุดสีตามแผนผังต้นฉบับของโรงพยาบาล */
.orgchart .c-cmte   { background: #fbdcc4; }
.orgchart .c-dir    { background: #f9cfe4; }
.orgchart .c-deputy { background: #f8dfa8; }
.orgchart .c-green  { background: #bfe9c8; }
.orgchart .c-blue   { background: #c3e4f6; }
.orgchart .c-mint   { background: #bfe9dd; }
.orgchart .c-purple { background: #e0cdf3; }
.orgchart .c-cyan   { background: #bfdff5; }
.orgchart .c-teal   { background: #a9e5da; }
.orgchart .c-rose   { background: #f7c0c0; }
.orgchart .c-aqua   { background: #bfeee6; }
.orgchart .c-lilac  { background: #dcd0f2; }
.orgchart .c-peach  { background: #f9c9a8; }
.orgchart .c-pink   { background: #f9c8dd; }
.orgchart .c-lime   { background: #d7edaa; }
.orgchart .c-lemon  { background: #f3f0a8; }

@media (max-width: 900px) {
  .orgchart .org-units { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .orgchart .org-row { gap: 10px; }
  .orgchart .org-node { flex: 1 1 100%; max-width: 100%; }
}

/* โหมดคอนทราสต์สูง: ตัดพื้นหลังสี ใช้เส้นขอบดำแทน */
html[data-contrast="high"] .orgchart .org-node,
html[data-contrast="high"] .orgchart .org-unit { background: #fff; border: 2px solid #000; box-shadow: none; }

@media print {
  .orgchart .org-node, .orgchart .org-unit { break-inside: avoid; box-shadow: none; }
}

/* ==========================================================================
   หน้าต่างซ้อนถวายพระพร / ประกาศพิเศษ บนหน้าแรก
   แสดงวันละครั้ง ปิดได้ด้วยปุ่มปิด แป้น Esc หรือคลิกพื้นหลัง
   ========================================================================== */
.splash-popup {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(12, 20, 40, 0.62);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.splash-popup[hidden] { display: none; }

.splash-popup-box {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: auto;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 22px 24px 26px;
}

.splash-popup-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: 700;
  padding: 6px 16px;
  min-height: 38px;
  cursor: pointer;
}
.splash-popup-close:hover { background: var(--dark); }

.splash-popup-title {
  font-size: 1.24em;
  font-weight: 800;
  color: var(--dark);
  margin: 0 96px 14px 0;
}

.splash-popup-poster {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 72vh;
  margin: 0 auto;
  border-radius: var(--radius);
}

/* ------------------------------------------- ข้อความถวายพระพร (กรณียังไม่ได้ใส่ภาพ) */
.splash-popup-greeting {
  background: radial-gradient(circle at 50% 0%, #fffdf7 0%, #fdf8ec 48%, #f4e6c8 100%);
  border: 1px solid #f3e3b3;
  border-radius: var(--radius);
  padding: 26px 20px 24px;
  text-align: center;
  color: #4a3a12;
}
.splash-popup-emblem { margin: 0 auto 14px; height: auto; }
.splash-popup-greeting .heading {
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  font-weight: 800;
  color: var(--gold-dark);
  line-height: 1.25;
  margin-bottom: 2px;
}
.splash-popup-greeting .date { font-size: clamp(1.1rem, 3.6vw, 1.4rem); font-weight: 700; margin-bottom: 14px; }
.splash-popup-greeting .occasion p { font-size: clamp(0.98rem, 3vw, 1.1rem); font-weight: 600; margin: 0; }
.splash-popup-greeting .wish { font-size: clamp(1rem, 3.2vw, 1.18rem); font-weight: 700; color: var(--gold-dark); margin-top: 14px; }
.splash-popup-greeting .divider { color: var(--gold); letter-spacing: 0.4em; margin: 16px 0 12px; font-size: 0.85rem; }
.splash-popup-greeting .signature p { font-size: clamp(0.86rem, 2.6vw, 0.96rem); color: #5d4c1f; margin: 0; }

/* --------------------------------------------------------- ปุ่มลงนามถวายพระพร */
.splash-popup-actions { text-align: center; margin-top: 20px; }

.splash-popup-btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), #b18d1c);
  color: #2a2000;
  font-weight: 800;
  text-decoration: none;
  padding: 13px 34px;
  border-radius: 999px;
  min-height: 48px;
  box-shadow: 0 6px 16px rgba(138, 111, 20, 0.3);
}
.splash-popup-btn:hover { opacity: 0.92; text-decoration: none; }

@media (max-width: 560px) {
  .splash-popup { padding: 14px 10px; }
  .splash-popup-box { padding: 18px 14px 20px; border-radius: var(--radius); }
  .splash-popup-title { font-size: 1.08em; margin-right: 86px; }
  .splash-popup-poster { max-height: 62vh; }
}

html[data-contrast="high"] .splash-popup-greeting { background: #fff; border: 2px solid #000; }

@media print { .splash-popup { display: none !important; } }

/* ==========================================================================
   สไลด์ภาพประชาสัมพันธ์บนหน้าแรก
   แทนระบบสไลด์ของเว็บไซต์เดิม เขียนเองทั้งหมด ไม่พึ่งไลบรารีภายนอก

   โปสเตอร์ของโรงพยาบาลเกือบทั้งหมดเป็นแนวตั้งหรือจัตุรัส ถ้าครอบให้เป็นแถบ
   แนวนอนเนื้อหาจะถูกตัดจนอ่านไม่ได้ จึงวางเป็นสองคอลัมน์: ภาพเต็มใบอยู่ซ้าย
   ข้อความอยู่ขวา บนพื้นหลังที่ไล่สีจากภาพเดียวกันแบบเบลอ
   ========================================================================== */
.banner-slider { background: var(--surface); border-bottom: 1px solid var(--border); }

.bs-viewport {
  position: relative;
  max-width: var(--container);
  margin: 0 auto;
  padding: 22px 20px 0;
}

.bs-track {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
  height: 430px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #e9eff9;
}

.bs-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.55s ease;
}
.bs-slide.is-current { opacity: 1; visibility: visible; }

/* พื้นหลังเบลอจากภาพของสไลด์นั้นเอง ทำให้กรอบไม่ว่างโหวงเวลาภาพเป็นแนวตั้ง */
.bs-slide::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--bs-bg);
  background-size: cover;
  background-position: center;
  filter: blur(38px) saturate(1.15);
  transform: scale(1.25);
}
.bs-slide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.9) 42%, rgba(255, 255, 255, 0.97) 100%);
}

.bs-body {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 34px;
  padding: 26px 40px;
  text-decoration: none;
  color: inherit;
}
a.bs-body:hover { text-decoration: none; }

.bs-figure { flex: 0 0 auto; height: 100%; display: flex; align-items: center; }
.bs-figure img {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 10px;
  margin: 0;
  box-shadow: 0 8px 24px rgba(15, 42, 102, 0.22);
  background: #fff;
}

/* ------------------------------------------------------------ ข้อความด้านขวา */
.bs-caption { flex: 1 1 auto; min-width: 0; }
.bs-caption .bs-title {
  font-size: clamp(1.15rem, 2.1vw, 1.65rem);
  font-weight: 800;
  color: var(--dark);
  line-height: 1.35;
  margin: 0 0 10px;
}
.bs-caption .bs-sub {
  font-size: clamp(0.9rem, 1.4vw, 1.02rem);
  color: #3d4a66;
  line-height: 1.65;
  margin: 0;
}
.bs-caption .bs-btn {
  display: inline-block;
  margin-top: 18px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.94em;
  padding: 11px 26px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
a.bs-body:hover .bs-btn { background: var(--dark); }

/* ------------------------------------------------------------ ปุ่มเลื่อนซ้ายขวา */
.bs-nav {
  position: absolute;
  z-index: 3;
  top: calc(50% + 11px);
  transform: translateY(-50%);
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.94);
  color: var(--primary);
  border: 1px solid var(--border); border-radius: 50%;
  font-size: 1.9rem; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow);
}
.bs-nav:hover { background: var(--primary); color: #fff; }
.bs-prev { left: 34px; }
.bs-next { right: 34px; }

/* --------------------------------------------------------- จุดบอกลำดับสไลด์ */
.bs-controls {
  max-width: var(--container);
  margin: 0 auto;
  padding: 14px 20px 20px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
}

.bs-dots { display: flex; gap: 9px; }
.bs-dots button {
  width: 11px; height: 11px; padding: 0;
  border: none; border-radius: 50%;
  background: #b9c6e3; cursor: pointer;
  transition: width 0.25s ease, background 0.25s ease;
}
.bs-dots button:hover { background: #8ea3cf; }
.bs-dots button[aria-selected="true"] { background: var(--primary); width: 30px; border-radius: 999px; }

.bs-play {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; width: 30px; height: 30px; cursor: pointer; font-size: 0.85em; line-height: 1;
}
.bs-play:hover { background: var(--light); color: var(--primary); }

/* ------------------------------------------------------------- จอขนาดกลาง */
@media (max-width: 1024px) {
  .bs-track { height: 360px; }
  .bs-body { gap: 24px; padding: 22px 28px; }
  .bs-prev { left: 20px; }
  .bs-next { right: 20px; }
}

/* --------------------------------- มือถือ: วางภาพไว้บน ข้อความอยู่ล่าง */
@media (max-width: 768px) {
  .bs-viewport { padding: 14px 12px 0; }
  .bs-track { height: auto; min-height: 0; border-radius: var(--radius); }

  .bs-slide { position: relative; inset: auto; display: none; }
  .bs-slide.is-current { display: block; }

  .bs-body { flex-direction: column; gap: 16px; padding: 18px 16px 22px; height: auto; }
  .bs-figure { height: auto; width: 100%; justify-content: center; }
  .bs-figure img { height: auto; max-height: 62vh; width: auto; max-width: 100%; }

  .bs-caption { text-align: center; }
  .bs-caption .bs-btn { margin-top: 14px; }

  .bs-nav { top: 34%; width: 38px; height: 38px; font-size: 1.5rem; }
  .bs-prev { left: 16px; }
  .bs-next { right: 16px; }
  .bs-controls { padding: 12px 12px 16px; }
}

/* ผู้ที่ตั้งค่าให้ลดการเคลื่อนไหว: ตัดการเปลี่ยนภาพแบบค่อย ๆ จาง */
@media (prefers-reduced-motion: reduce) {
  .bs-slide, .bs-dots button { transition: none; }
}

html[data-contrast="high"] .bs-slide::before { display: none; }
html[data-contrast="high"] .bs-slide::after { background: #fff; }
html[data-contrast="high"] .bs-figure img { border: 2px solid #000; box-shadow: none; }
html[data-contrast="high"] .bs-dots button { background: #fff; border: 2px solid #000; }
html[data-contrast="high"] .bs-dots button[aria-selected="true"] { background: #000; }

@media print { .banner-slider { display: none !important; } }

/* ปุ่มเข้าสู่ระบบสำหรับเจ้าหน้าที่ บนแถบบนสุด (แสดงทุกหน้า)
   เมื่อเข้าสู่ระบบอยู่แล้ว จะเปลี่ยนเป็นทางลัดกลับเข้าระบบหลังบ้านพร้อมชื่อผู้ใช้ */
.topbar-login {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  padding: 4px 14px;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  font-size: 0.95em;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-login:hover { background: rgba(255, 255, 255, 0.22); text-decoration: none; }

.topbar-login.is-in { background: var(--gold); border-color: var(--gold); color: #2a2000; }
.topbar-login.is-in:hover { background: #dab63b; }
.topbar-login .who {
  padding-left: 8px;
  margin-left: 2px;
  border-left: 1px solid rgba(0, 0, 0, 0.25);
  font-weight: 500;
  opacity: 0.85;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 560px) {
  .topbar-login { margin-left: 4px; padding: 4px 10px; }
  .topbar-login .who { display: none; }
}

html[data-contrast="high"] .topbar-login { border: 2px solid #fff; }
html[data-contrast="high"] .topbar-login.is-in { background: #fff; color: #000; border-color: #000; }

@media print { .topbar-login { display: none !important; } }
