/* ผังหน้า: คอลัมน์เดียวสำหรับมือถือ ปุ่มเต็มความกว้าง เรียงจากเร่งด่วนที่สุดลงมา */

@font-face { font-family: "Sarabun"; font-weight: 400; font-display: swap;
  src: url("fonts/sarabun-thai-400.woff2") format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Sarabun"; font-weight: 700; font-display: swap;
  src: url("fonts/sarabun-thai-700.woff2") format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Sarabun"; font-weight: 400; font-display: swap;
  src: url("fonts/sarabun-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Sarabun"; font-weight: 700; font-display: swap;
  src: url("fonts/sarabun-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }

:root {
  --bg: #ffffff;
  --fg: #1a2320;
  --muted: #4a5753;
  --line: #c9d4cf;
  --brand: #1d6b45;       /* สีหลัก ถูกแทนด้วยค่า "สีหลัก" ใน ตั้งค่า/อำเภอ.csv */
  --green: var(--brand);
  --green-soft: #e8f2ec;
  --green-soft: color-mix(in srgb, var(--brand) 10%, #ffffff);
  --on-green: #ffffff;    /* ตัวหนังสือบนปุ่มสีหลัก */
  --red: #c4161c;         /* ปุ่มฉุกเฉิน */
  --red-fg: #ffffff;
  --warn-bg: #ffe14d;     /* แถบข้อมูลตัวอย่าง */
  --warn-fg: #1a1a1a;
  --font: "Sarabun", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  --radius: 10px;         /* ขอบมนเล็กน้อย ไม่ใช่ทรงแคปซูล */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121816; --fg: #f1f5f3; --muted: #b7c4bf; --line: #34413c;
    --green: color-mix(in srgb, var(--brand) 55%, #ffffff); --green-soft: color-mix(in srgb, var(--brand) 30%, #121816); --on-green: #121816; --red: #e0262d; --red-fg: #ffffff;
    --warn-bg: #ffe14d; --warn-fg: #1a1a1a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121816; --fg: #f1f5f3; --muted: #b7c4bf; --line: #34413c;
  --green: color-mix(in srgb, var(--brand) 55%, #ffffff); --green-soft: color-mix(in srgb, var(--brand) 30%, #121816); --on-green: #121816; --red: #e0262d; --red-fg: #ffffff;
  --warn-bg: #ffe14d; --warn-fg: #1a1a1a; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 1rem; line-height: 1.6;
}
.wrap { max-width: 560px; margin: 0 auto; padding-inline: 16px; }
p { margin: 0; }

/* หัวเว็บ */
.topbar { background: var(--brand); color: #fff; }
.topbar-inner {
  max-width: 560px; margin: 0 auto; padding: 14px 16px; min-height: 84px;
  display: flex; align-items: center; gap: 12px;
}
.logo { width: 56px; height: 56px; flex: none; object-fit: contain; }
.org-text { min-width: 0; overflow-wrap: anywhere; }
.org { font-weight: 700; font-size: 1.15rem; line-height: 1.35; }
.org-sub { font-size: 0.9rem; opacity: 0.92; }

.sample-bar {
  background: var(--warn-bg); color: var(--warn-fg);
  font-weight: 700; text-align: center; padding: 8px 16px; font-size: 0.95rem;
}

/* โหมดตรวจร่าง (?ร่าง=1) */
.draft-bar { font-size: 1.05rem; border-bottom: 3px solid var(--warn-fg); position: sticky; top: 0; z-index: 5; }
.draft-tag {
  display: inline-block; vertical-align: middle; margin-left: 8px;
  background: var(--warn-bg); color: var(--warn-fg); border: 2px solid var(--warn-fg);
  font-weight: 700; font-size: 0.8rem; line-height: 1.2; padding: 2px 8px; border-radius: 6px;
}
.head-text .draft-tag { margin: 6px 0 0; }

.error-bar {
  background: var(--red); color: var(--red-fg);
  font-weight: 700; text-align: center; padding: 10px 16px;
}

main.wrap { padding-block: 18px 8px; }
.page { display: flex; flex-direction: column; gap: 14px; }

/* ปุ่ม */
.btn {
  display: flex; align-items: center; gap: 14px;
  min-height: 72px; padding: 12px 16px;
  border-radius: var(--radius); text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible { outline: 4px solid var(--warn-bg); outline-offset: 2px; }
.btn:active { transform: translateY(1px); filter: brightness(0.95); }
.btn-icon { font-size: 2rem; line-height: 1; flex: none; width: 2.4rem; text-align: center; }
.btn-text { display: flex; flex-direction: column; min-width: 0; }
.btn-title { font-weight: 700; font-size: 1.2rem; line-height: 1.3; }
.btn-hint { font-size: 0.85rem; line-height: 1.35; }

.btn-emergency {
  background: var(--red); color: var(--red-fg);
  min-height: 104px; border: 3px solid var(--red);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.btn-emergency .btn-icon { font-size: 2.6rem; width: 3rem; }
.btn-emergency .btn-title { font-size: 1.5rem; }
.btn-emergency .btn-hint { font-size: 0.95rem; opacity: 0.95; }

.menu { display: flex; flex-direction: column; gap: 12px; }
.btn-menu {
  background: var(--green-soft); color: var(--fg);
  border: 2px solid var(--green);
}
.btn-menu .btn-hint { color: var(--muted); }

.btn-back {
  min-height: 56px; background: var(--bg); color: var(--green);
  border: 2px solid var(--green); font-weight: 700; font-size: 1.05rem;
  align-self: flex-start;
}

.btn-call {
  background: var(--green); color: var(--on-green); justify-content: center;
  font-weight: 700; font-size: 1.15rem; min-height: 64px;
}

/* ข้อความเหนือเบอร์โทร ด้านล่างหน้าหลัก */
.home-call-label { color: var(--muted); font-size: 1rem; }
.phone-text { font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; user-select: all; }

.page-title { font-size: 1.5rem; line-height: 1.3; margin: 4px 0 0; text-wrap: balance; }
.lead, .message { color: var(--muted); }
.crumb { color: var(--muted); font-weight: 700; margin-bottom: -10px; }

/* ตารางปุ่มเลือกสัตว์ 2 คอลัมน์ */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.btn-tile {
  flex-direction: column; justify-content: center; gap: 6px;
  min-height: 120px; text-align: center;
  background: var(--green-soft); color: var(--fg); border: 2px solid var(--green);
}
.tile-icon { width: 88px; height: 88px; object-fit: contain; }
.tile-icon.emoji { width: auto; height: auto; font-size: 2.8rem; line-height: 1; }

/* หัวหน้ารายชื่อโรค / รายละเอียดโรค: การ์ตูนสัตว์ + ชื่อ */
.disease-head { display: flex; align-items: center; gap: 14px; }
.head-pic { width: 96px; height: 96px; flex: none; object-fit: contain; }
.head-pic.emoji { width: auto; height: auto; font-size: 3.2rem; line-height: 1; }
.head-text { min-width: 0; }
.head-text .crumb { margin: 0; }

/* รายชื่อโรค */
.list { display: flex; flex-direction: column; gap: 10px; }
.btn-list {
  justify-content: space-between; min-height: 64px;
  background: var(--bg); color: var(--fg); border: 2px solid var(--green);
}
.btn-list .btn-title { font-size: 1.15rem; }
.btn-list .btn-hint { color: var(--muted); font-size: 0.95rem; margin-top: 2px; }

/* กล่องสรุปบนสุดของหน้าโรค */
.summary-box {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--green-soft); border: 3px solid var(--green);
  border-radius: var(--radius); padding: 14px 16px;
}
.summary-label { font-weight: 700; color: var(--green); font-size: 0.95rem; }
.summary-label-red { color: var(--red); margin-top: 8px; }
.summary-key { font-weight: 700; font-size: 1.25rem; line-height: 1.4; }
.summary-urgent { font-weight: 700; font-size: 1.25rem; line-height: 1.4; color: var(--red); }
.summary-box .btn-call-big { margin-top: 10px; font-size: 1.2rem; text-align: center; }
.chev { color: var(--green); font-size: 0.9rem; flex: none; }

/* กล่องอาการ / วิธีป้องกัน / เรียกหมอ */
.info-box {
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; background: var(--bg);
}
.info-title { font-size: 1.2rem; margin: 0 0 6px; color: var(--green); }
.info-alert { border: 3px solid var(--red); }
.info-alert .info-title { color: var(--red); }
.alert-call-label { font-weight: 700; color: var(--red); margin: 12px 0 6px; font-size: 1.05rem; }
.alert-line {
  font-weight: 700; font-size: 1.15rem; line-height: 1.4; color: var(--red);
  border-left: 5px solid var(--red); padding-left: 10px; margin-bottom: 8px;
}
.info-sub { font-size: 1.1rem; margin: 12px 0 4px; color: var(--green); }

/* กล่องเกณฑ์แจ้งเจ้าหน้าที่ (หน้าโรค): กลุ่มแรก = ตัวใหญ่ เห็นชัดที่สุด */
.criteria-lead { font-weight: 700; margin: 0 0 6px; }
.criteria-card {
  border: 2px solid var(--line); border-left: 6px solid var(--red); border-radius: var(--radius);
  padding: 10px 12px; margin-top: 10px; background: var(--bg);
}
.criteria-who { font-weight: 700; margin: 0 0 2px; }
.criteria-when { margin: 0; }
.criteria-main { border-color: var(--red); }
.criteria-main .criteria-who { font-size: 1.15rem; }
.criteria-main .criteria-when { font-size: 1.4rem; font-weight: 700; color: var(--red); line-height: 1.35; }
.bullets { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }

.call-box {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--green-soft); border-radius: var(--radius); padding: 14px 16px;
}
.call-box-label { font-weight: 700; }

/* รายชื่อผู้ติดต่อ: ชื่อ ตำแหน่ง ปุ่มโทรของแต่ละท่าน */
.contact-list { display: flex; flex-direction: column; gap: 14px; }
.contact { display: flex; flex-direction: column; gap: 2px; }
.contact-name { font-weight: 700; font-size: 1.1rem; line-height: 1.35; }
.contact-role { color: var(--muted); font-size: 0.95rem; line-height: 1.35; }
.contact .btn-call-big { margin-top: 6px; font-variant-numeric: tabular-nums; }
.summary-label-call { color: var(--fg); margin-top: 10px; }
.note { color: var(--muted); font-size: 0.85rem; }

/* ปุ่มที่เป็น <button> ให้หน้าตาเหมือนปุ่มลิงก์ */
button.btn { font: inherit; width: 100%; text-align: left; cursor: pointer; }
button.btn:disabled { opacity: 0.6; cursor: wait; }
button.btn-call, button.btn-go { border: 0; }
button.btn-call-big { font-size: 1.35rem; font-weight: 700; text-align: center; }
.btn-save { align-self: stretch; justify-content: center; }

/* บันทึกเป็นรูป */
.card-maker { display: flex; flex-direction: column; gap: 10px; }
.btn-card { background: var(--bg); color: var(--fg); border: 2px dashed var(--green); }
.btn-card .btn-hint { color: var(--muted); }
.card-result { display: flex; flex-direction: column; gap: 10px; }
.card-preview {
  width: 100%; height: auto; border: 2px solid var(--line); border-radius: var(--radius);
}

/* ติดต่อสัตวแพทย์ */
.vet-warn {
  background: var(--red); color: var(--red-fg);
  font-weight: 700; font-size: 1.15rem; line-height: 1.4;
  border-radius: var(--radius); padding: 12px 16px;
}
.filter-box { display: flex; flex-direction: column; gap: 6px; }
.filter { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.btn-filter {
  justify-content: center; min-height: 56px; padding: 8px;
  background: var(--bg); color: var(--fg); border: 2px solid var(--green);
  font-weight: 700; font-size: 1.1rem; text-align: center;
}
.btn-filter.is-on { background: var(--green); color: var(--on-green); }
.btn-filter.is-on::before { content: "✓ "; }

.vet-list { display: flex; flex-direction: column; gap: 14px; }
.vet-card {
  display: flex; flex-direction: column; gap: 10px;
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; background: var(--bg);
}
.vet-sample {
  align-self: flex-start; background: var(--warn-bg); color: var(--warn-fg);
  font-weight: 700; font-size: 0.85rem; padding: 2px 10px; border-radius: 6px;
}
.vet-name { font-size: 1.3rem; line-height: 1.35; margin: 0; overflow-wrap: anywhere; }
.vet-role { color: var(--muted); margin-top: -8px; }
.vet-info { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.vet-info dt { color: var(--muted); font-weight: 700; }
.vet-info dd { margin: 0; display: flex; flex-direction: column; }
.btn-call-big { min-height: 80px; font-size: 1.4rem; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ขึ้นทะเบียนฟาร์ม */
.page-sample {
  background: var(--warn-bg); color: var(--warn-fg); font-weight: 700;
  border-radius: var(--radius); padding: 10px 14px; line-height: 1.4;
}
.scope-note {
  font-weight: 700; color: var(--fg); margin-top: -4px;
  border-left: 6px solid var(--green); padding: 4px 0 4px 12px;
}
.why-box { background: var(--green-soft); border-radius: var(--radius); padding: 14px 16px; }
.section-title { font-size: 1.35rem; line-height: 1.3; margin: 10px 0 -4px; }

.checklist { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex; align-items: flex-start; gap: 14px; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-height: 64px;
}
.check-item input {
  flex: none; width: 32px; height: 32px; margin: 2px 0 0; accent-color: var(--green); cursor: pointer;
}
.check-item:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.check-item:has(input:focus-visible) { outline: 4px solid var(--warn-bg); outline-offset: 2px; }
.check-text { display: flex; flex-direction: column; min-width: 0; }
.check-title { font-weight: 700; font-size: 1.1rem; line-height: 1.4; }
.check-hint { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.check-count { font-weight: 700; color: var(--green); margin-top: 10px; font-size: 1.05rem; }

.way-card {
  display: flex; flex-direction: column; gap: 12px;
  border: 3px solid var(--green); border-radius: var(--radius); padding: 14px 16px; background: var(--bg);
}
.way-tag {
  align-self: flex-start; background: var(--green); color: var(--on-green);
  font-weight: 700; font-size: 0.9rem; padding: 2px 10px; border-radius: 6px;
}
.way-title { font-size: 1.35rem; line-height: 1.3; margin: -4px 0 0; }
.way-sub { color: var(--muted); margin-top: -8px; overflow-wrap: anywhere; }
.qual-list { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.qual-list li { position: relative; padding-left: 1.8em; font-size: 1.1rem; line-height: 1.45; }
.qual-list li::before { content: "✔"; position: absolute; left: 0.2em; color: var(--green); font-weight: 700; }
.doc-note {
  margin-top: 10px; font-weight: 700; font-size: 1.05rem; line-height: 1.45;
  background: var(--green-soft); border-radius: var(--radius); padding: 10px 12px;
}
.steps { margin: 0; padding-left: 1.5em; display: flex; flex-direction: column; gap: 6px; }
.steps li::marker { font-weight: 700; color: var(--green); }
.step-detail { display: block; color: var(--muted); font-size: 0.9rem; }

.btn-go {
  justify-content: space-between; min-height: 88px;
  background: var(--green); color: var(--on-green);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}
.btn-go .btn-title { font-size: 1.3rem; }
.btn-go .chev { color: var(--on-green); }
.btn-nav-go .btn-hint { opacity: 0.95; }

/* ส่งตำแหน่งบ้านให้หมอ */
.loc-box {
  display: flex; flex-direction: column; gap: 10px;
  border: 3px solid var(--green); border-radius: var(--radius); padding: 14px 16px;
}
.btn-locate { min-height: 96px; }
.btn-locate .btn-title { font-size: 1.4rem; }
.loc-status { font-weight: 700; font-size: 1.1rem; line-height: 1.45; }
.loc-status:empty { display: none; }
.loc-result { display: flex; flex-direction: column; gap: 10px; }
.loc-result:empty { display: none; }
.loc-link { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; user-select: all; }
.line-howto { background: var(--green-soft); border-radius: var(--radius); padding: 12px 14px; }
.line-howto-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 6px; }
.line-howto .steps { font-size: 1.1rem; }

/* แผนที่สำนักงาน (ฝังในหน้าติดต่อสำนักงาน) */
.map-box {
  position: relative; height: 240px; overflow: hidden;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--green-soft);
}
.map-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.map-box.is-loaded .map-wait { display: none; }
.map-frame { position: relative; width: 100%; height: 100%; border: 0; display: block; }
.office-photo { width: 100%; height: auto; border-radius: var(--radius); border: 2px solid var(--line); }
.office-info { margin-top: 2px; }

.faq { display: flex; flex-direction: column; gap: 10px; }
.faq-item { border: 2px solid var(--green); border-radius: var(--radius); background: var(--bg); }
.faq-item summary {
  list-style: none; cursor: pointer; min-height: 64px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 700; font-size: 1.1rem; line-height: 1.4;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "＋"; color: var(--green); font-size: 1.4rem; flex: none; }
.faq-item[open] summary::after { content: "－"; }
.faq-item[open] summary { border-bottom: 2px solid var(--line); }
.faq-item summary:focus-visible { outline: 4px solid var(--warn-bg); outline-offset: 2px; }
.faq-answer { padding: 12px 16px 14px; display: flex; flex-direction: column; gap: 6px; }

/* ปกแอป (หน้าแรก) */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--green-soft); border: 2px solid var(--green); border-radius: var(--radius);
  padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 10px;
}
.hero-map-slot { position: absolute; inset: 0; z-index: -1; pointer-events: none; color: var(--green); }
.hero-map { position: absolute; right: -8%; top: -12%; height: 125%; width: auto; opacity: 0.16; }
.hero-name { margin: 0; font-size: 2rem; line-height: 1.2; color: var(--green); text-wrap: balance; }
.hero-tagline { font-size: 1.05rem; font-weight: 700; color: var(--fg); }
.hero-animals { display: flex; gap: 2px; align-items: flex-end; }
.hero-animals img { width: 15%; max-width: 64px; height: auto; margin-right: -2%; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.08)); }
.hero .map-credit { font-size: 0.65rem; margin: 0; opacity: 0.85; }

/* แผนที่ */
.map-credit { color: var(--muted); font-size: 0.75rem; line-height: 1.4; margin-top: 6px; }
.map-open { display: block; width: 100%; padding: 0; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; cursor: zoom-in; overflow: hidden; font: inherit; }
.map-open-hint { display: block; padding: 8px; font-weight: 700; color: var(--green); background: var(--green-soft); }
.pinned-map { position: relative; line-height: 0; }
.pinned-map img { width: 100%; height: auto; display: block; }
.map-pin { position: absolute; transform: translate(-50%, -100%); font-size: 1.8rem; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.4)); }
.map-pin-label {
  position: absolute; transform: translate(-50%, 4px); white-space: nowrap; line-height: 1.3;
  background: var(--red); color: #fff; font-weight: 700; font-size: 0.75rem; padding: 1px 6px; border-radius: 4px;
}
.pinned-map.is-big .map-pin { font-size: 2.6rem; }
.pinned-map.is-big .map-pin-label { font-size: 1rem; }
.map-viewer {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; padding: 10px; gap: 8px;
}
.viewer-bar { display: flex; gap: 8px; }
.viewer-bar .btn { flex: 1; min-height: 56px; justify-content: center; }
.viewer-scroll { flex: 1; overflow: auto; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; }
.viewer-inner { min-width: 100%; }
.viewer-open { overflow: hidden; }

/* แผนที่ตำบลแบบกดได้ (หน้าภัยพิบัติ) */
.tambon-map { width: 100%; height: auto; display: block; }
.tambon-map path { stroke: #ffffff; stroke-width: 2; cursor: pointer; transition: filter 0.15s; }
.tambon-map path:hover, .tambon-map path:focus-visible { filter: brightness(0.92); outline: none; stroke: var(--green); stroke-width: 3; }
.tambon-map path.is-on { stroke: var(--green); stroke-width: 5; filter: brightness(0.85); }
.tambon-labels { pointer-events: none; }
.tambon-labels text {
  font-family: var(--font); font-weight: 700; font-size: 21px; fill: #1a2320;
  paint-order: stroke; stroke: #ffffff; stroke-width: 5px; stroke-linejoin: round;
}
.tambon-leader { stroke: #4a5753; stroke-width: 1.5; }
.tambon-panel:empty { display: none; }
.tambon-panel { border-top: 2px solid var(--line); padding-top: 10px; margin-top: 8px; display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 12px; }
.tambon-title { margin: 0; font-size: 1.4rem; color: var(--green); }
.tambon-sub { margin: 4px 0 0; font-size: 1.1rem; }
.tambon-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tambon-buttons .btn-filter { font-size: 1.05rem; padding: 8px 4px; }
.tambon-box .page-sample { margin: 6px 0; }

/* อาหารสัตว์ */
.golden-box {
  background: var(--green-soft); border: 3px solid var(--green);
  border-radius: var(--radius); padding: 14px 16px;
}
.golden-list { font-size: 1.05rem; gap: 8px; }
.feed-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.type-tag, .risk-tag, .pending-tag {
  display: inline-block; vertical-align: middle; font-weight: 700; line-height: 1.3;
  border-radius: 6px; padding: 2px 8px;
}
.type-tag { background: var(--green-soft); color: var(--green); border: 2px solid var(--green); font-size: 0.85rem; }
.risk-tag { background: var(--warn-bg); color: var(--warn-fg); border: 2px solid var(--warn-fg); font-size: 0.85rem; }
.btn-title .risk-tag { margin-left: 8px; }
.pending-tag {
  background: var(--warn-bg); color: var(--warn-fg); font-size: 0.75rem;
  padding: 0 6px; margin-left: 6px;
}
.info-warn { border: 3px solid #b38600; }
.info-warn .info-title { color: #8a6500; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .info-warn .info-title { color: var(--warn-bg); }
}
.related-text { color: var(--muted); margin-top: 4px; }
.fruit-box {
  display: flex; flex-direction: column; gap: 8px;
  border: 3px solid #b38600; border-radius: var(--radius); padding: 14px 16px;
}
.fruit-box > .info-title { color: #8a6500; margin: 0; }
.season-bar {
  background: var(--warn-bg); color: var(--warn-fg); font-weight: 700; font-size: 1.1rem; line-height: 1.4;
  border-radius: var(--radius); padding: 12px 14px; border-left: 8px solid #b38600;
}
.verdict-tag {
  display: inline-block; vertical-align: middle; font-weight: 700; font-size: 0.85rem; line-height: 1.3;
  border-radius: 6px; padding: 2px 8px; border: 2px solid;
}
.btn-title .verdict-tag { margin-left: 8px; }
.verdict-ok { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.verdict-warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-fg); }
.verdict-no { background: var(--red); color: var(--red-fg); border-color: var(--red); }
.info-box .btn-list { margin-top: 8px; }

/* สมุดบันทึกวัคซีน */
.btn-logbook { margin-top: 10px; min-height: 64px; }
.sheet-scroll { overflow-x: auto; border: 2px solid var(--line); border-radius: var(--radius); }
.print-sheet {
  min-width: 760px; padding: 18px 20px; background: #ffffff; color: #1a1a1a;
  font-family: var(--font);
}
.sheet-title { font-size: 1.3rem; margin: 0 0 10px; text-align: center; }
.sheet-fields { display: grid; grid-template-columns: 2fr 1fr 2fr 0.8fr; gap: 6px 18px; margin-bottom: 12px; font-size: 0.9rem; }
.sheet-field { display: flex; gap: 6px; align-items: flex-end; white-space: nowrap; }
.sheet-blank { flex: 1; border-bottom: 1.5px dotted #1a1a1a; min-height: 1.3em; }
.sheet-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 0.85rem; }
.sheet-table th, .sheet-table td { border: 1.5px solid #1a1a1a; padding: 4px 6px; }
.sheet-table th { background: #e9ecea; line-height: 1.3; }
.sheet-table td { height: 34px; }
.sheet-table th:nth-child(1) { width: 15%; }
.sheet-table th:nth-child(2) { width: 10%; }
.sheet-table th:nth-child(3) { width: 11%; }
.sheet-table th:nth-child(4) { width: 16%; }
.sheet-table th:nth-child(5) { width: 13%; }
.sheet-table th:nth-child(6) { width: 12%; }
.sheet-note { font-size: 0.8rem; margin-top: 8px; color: #333333; }

/* ตอนกดพิมพ์โบรชัวร์ (body มี class brochure-print): เหลือแค่รูปโบรชัวร์เต็มแผ่น A4 */
@page brochure { size: A4 portrait; margin: 0; }
@media print {
  .brochure-print .topbar, .brochure-print .sample-bar, .brochure-print .error-bar,
  .brochure-print .foot, .brochure-print #page-home { display: none !important; }
  .brochure-print #page-view > *:not(.card-maker),
  .brochure-print .card-maker > *:not(.card-result),
  .brochure-print .card-result > *:not(.brochure-preview) { display: none !important; }
  .brochure-print main.wrap { max-width: none; padding: 0; }
  .brochure-print .brochure-preview { page: brochure; display: block; width: 210mm; height: 297mm; border: 0; border-radius: 0; }
}

/* ตอนพิมพ์หน้าสมุดบันทึก (body มี class logbook-page): เหลือเฉพาะแผ่นตาราง A4 แนวนอน */
@page logbook { size: A4 landscape; margin: 10mm; }
@media print {
  .logbook-page { font-size: 16px; background: #ffffff; }
  .logbook-page .topbar, .logbook-page .sample-bar, .logbook-page .error-bar,
  .logbook-page .foot, .logbook-page #page-home { display: none !important; }
  .logbook-page #page-view > *:not(.sheet-scroll) { display: none !important; }
  .logbook-page main.wrap { max-width: none; padding: 0; }
  .logbook-page .sheet-scroll { border: 0; overflow: visible; }
  .logbook-page .print-sheet { page: logbook; min-width: 0; padding: 0; }
  .logbook-page .sheet-table td { height: 36px; }
}

.foot { padding-block: 20px 28px; color: var(--muted); font-size: 0.85rem; text-align: center; }

@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }

/* ---------- หน้าหลัก: รูปสำนักงานด้านบน + แผนที่และผู้ติดต่อด้านล่าง ---------- */
/* หน้าหลักมีชื่อสำนักงานบนรูปแล้ว จึงซ่อนแถบเขียวด้านบน */
body.home-page .topbar { display: none; }
/* หัวหน้าหลัก: กว้างเต็มจอ (ชนขอบ) รูปอยู่ข้างหลัง แถบไล่สีเขียวเข้มทับด้านล่าง */
.home-head {
  position: relative; margin: -18px -16px 0; min-height: 110px;
  background: #1d6b45; background: var(--brand); color: #ffffff;
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
}
.home-photo { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; object-position: 50% 30%; }
.home-band {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 16px 16px 14px; text-align: left;
}
.home-head.has-photo .home-band {
  position: absolute; left: 0; right: 0; bottom: 0; padding-top: 36px;
  background: linear-gradient(to top, rgba(8, 48, 28, 0.94) 0%, rgba(8, 48, 28, 0.82) 55%, rgba(8, 48, 28, 0));
}
.home-logo { width: 64px; height: 64px; flex: none; object-fit: contain; background: #ffffff; border-radius: 50%; padding: 3px; }
.home-org { margin: 0; font-size: 1.2rem; font-weight: 700; line-height: 1.35; color: #ffffff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }

.home-office { border-top: 2px solid var(--line); padding-top: 16px; margin-top: 4px; display: flex; flex-direction: column; gap: 12px; }
.home-office-title { margin: 0; font-size: 1.3rem; color: var(--green); }
.home-map { display: block; width: 100%; padding: 6px 6px 0; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; cursor: zoom-in; overflow: hidden; font: inherit; }
.home-map:disabled { cursor: default; }
.home-map .tambon-map path { cursor: inherit; }
.home-map .tambon-map path:hover { filter: none; stroke: #ffffff; stroke-width: 2; }
.home-map .map-open-hint { margin: 6px -6px 0; }
.office-pin-label { font-size: 18px; font-weight: 700; fill: #d62828; paint-order: stroke; stroke: #ffffff; stroke-width: 4px; stroke-linejoin: round; }
.home-address { margin: 0; font-size: 1.1rem; line-height: 1.5; display: flex; gap: 6px; align-items: flex-start; }
.home-office .map-credit { margin: 0; font-size: 0.75rem; text-align: center; }

/* หัวเว็บเป็นลิงก์กลับหน้าแรก (กดโลโก้หรือชื่อสำนักงาน) */
a.topbar-inner { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
a.topbar-inner:focus-visible { outline: 4px solid var(--warn-bg); outline-offset: -4px; }
.org, .org-sub { display: block; }

/* ---------- แถบล่างจอ: กลับ / หน้าแรก (อยู่ที่เดิมทุกหน้า) ---------- */
body.has-page-nav { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
.page-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--bg); border-top: 2px solid var(--line);
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.12);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
}
.page-nav[hidden] { display: none; }
.page-nav-inner { max-width: 560px; margin: 0 auto; padding-inline: 16px; display: flex; gap: 10px; }
.nav-btn {
  flex: 1 1 0; min-width: 0; min-height: 64px; padding: 6px 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--radius); text-decoration: none; text-align: center; line-height: 1.25;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn:active { transform: translateY(1px); filter: brightness(0.95); }
.nav-btn:focus-visible { outline: 4px solid var(--warn-bg); outline-offset: 2px; }
.nav-title { font-weight: 700; font-size: 1.25rem; }
.nav-hint { font-size: 0.85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-back { background: var(--bg); color: var(--green); border: 3px solid var(--green); }
.nav-home { background: var(--green); color: var(--on-green); border: 3px solid var(--green); }
body.viewer-open .page-nav { display: none; }
@media print { .page-nav { display: none !important; } body.has-page-nav { padding-bottom: 0; } }

/* ชนิดสัตว์ที่ยังไม่มีโรคผ่านการตรวจ */
.pending-box { background: var(--green-soft); border: 2px solid var(--green); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.pending-text { font-size: 1.15rem; font-weight: 700; line-height: 1.5; }

/* ไอคอนเมนูที่เป็นรูปการ์ตูนสัตว์ (ขนาดเท่าไอคอนอีโมจิ) */
.btn-icon-img { height: 2.4rem; object-fit: contain; }

/* ขึ้นทะเบียนแล้ว ต้องปรับปรุงข้อมูลทุกปี */
.renew-card { border-style: dashed; }
.renew-lead { font-size: 1.1rem; line-height: 1.45; margin: 0; }
.renew-period {
  margin: 0; font-size: 1.1rem; line-height: 1.45;
  background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius); padding: 10px 12px;
}
.renew-period-label { font-weight: 700; }
.renew-why { margin-top: 0; font-weight: 700; }

/* ---------- ติดต่อ 3 ระดับ ---------- */
/* ข้อความเตือนใต้ปุ่มโทรหาหมอ */
.doctor-call { display: flex; flex-direction: column; gap: 8px; }
.doctor-call-note {
  margin: 0; font-weight: 700; font-size: 1.05rem; line-height: 1.45;
  background: var(--warn-bg); color: var(--warn-fg); border-radius: var(--radius); padding: 8px 12px;
}
/* หน้าติดต่อสัตวแพทย์: บอกว่าโทรหาหมอได้จากไหน */
.vet-how { display: flex; flex-direction: column; gap: 10px; border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.vet-how-title { margin: 0; font-weight: 700; font-size: 1.2rem; }
.btn-emergency-small { min-height: 80px; box-shadow: none; }
.btn-emergency-small .btn-title { font-size: 1.25rem; }

/* ฝากคำถาม / แจ้งปัญหา */
.ask-card { display: flex; flex-direction: column; gap: 10px; }
.ask-note { margin: 0; font-size: 1.1rem; line-height: 1.5; color: var(--fg); }
.btn-soon { opacity: 0.75; cursor: default; border-style: dashed; }
.btn-soon:active { transform: none; filter: none; }
.soon-tag {
  margin-left: auto; flex: none; font-weight: 700; font-size: 0.95rem;
  background: var(--warn-bg); color: var(--warn-fg); border-radius: 6px; padding: 4px 10px;
}
.faq-by { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }
.nav-ask { background: var(--bg); color: var(--fg); border: 3px solid var(--line); }

/* สัตว์ปีก: ข้อควรรู้เฉพาะชนิด และปุ่มวิธีเลี้ยง */
.type-note { border-color: var(--green); background: var(--green-soft); }
.btn-raise { border-width: 3px; }

/* สัตว์กินหญ้าที่พ่นยา / ได้รับสารพิษ */
.btn-poison { border-width: 3px; }
.poison-steps { gap: 10px; }
.poison-steps .doctor-call { margin-top: 8px; }
.poison-note { margin: 8px 0 0; font-weight: 700; }
.poison-dont { border-width: 4px; }
.poison-dont .info-title { font-size: 1.4rem; }
.poison-dont .bullets { gap: 12px; }
.poison-dont li { font-weight: 700; font-size: 1.15rem; line-height: 1.45; }
.poison-why { display: block; font-weight: 400; font-size: 1rem; color: var(--fg); margin-top: 2px; }

/* ฟาร์มตัวอย่าง */
.farm-list { display: flex; flex-direction: column; gap: 18px; }
.farm-card { display: flex; flex-direction: column; gap: 10px; border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--bg); }
.farm-photo { width: 100%; height: auto; border-radius: var(--radius); }
.farm-name { font-size: 1.35rem; line-height: 1.3; margin: 0; }
.farm-story p { margin: 0 0 6px; font-size: 1.1rem; line-height: 1.55; }

/* ---------- โปรแกรมวัคซีนไก่พื้นเมือง (#vaccine-chicken) ---------- */
/* สีประจำวัคซีน 3 สี ใช้คู่กับชื่อวัคซีนเสมอ */
:root { --vac-0: #1d6b45; --vac-1: #a14f00; --vac-2: #1f4fa8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --vac-0: #6fcf9a; --vac-1: #f0a65a; --vac-2: #8fb3f5; }
}
:root[data-theme="dark"] { --vac-0: #6fcf9a; --vac-1: #f0a65a; --vac-2: #8fb3f5; }
.vac-0 { --vac: var(--vac-0); }
.vac-1 { --vac: var(--vac-1); }
.vac-2 { --vac: var(--vac-2); }

.vac-note { font-weight: 700; }
.vac-note + .vac-note { margin-top: 6px; }

.vac-timeline { list-style: none; margin: 0 0 8px; padding: 0; position: relative; }
.vac-timeline::before {
  content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px;
  width: 4px; background: var(--line); border-radius: 2px;
}
.vac-step { position: relative; padding: 0 0 18px 34px; }
.vac-step::before {
  content: ""; position: absolute; left: 0; top: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg); border: 4px solid var(--green);
}
.vac-when { font-size: 1.25rem; font-weight: 700; color: var(--green); line-height: 1.4; margin-bottom: 6px; }
.vac-items { display: flex; flex-direction: column; gap: 8px; }
.vac-chip {
  border: 2px solid var(--line); border-left: 8px solid var(--vac, var(--green));
  border-radius: var(--radius); padding: 8px 12px; background: var(--bg);
}
.vac-chip-name { display: block; font-weight: 700; font-size: 1.1rem; color: var(--vac, var(--fg)); }
.vac-chip-note { display: block; color: var(--muted); }

.vac-card { border-left: 8px solid var(--vac, var(--green)); }
.vac-card-title { font-size: 1.2rem; margin: 0 0 4px; color: var(--vac, var(--green)); }
.vac-for { color: var(--muted); margin-bottom: 6px; }
.vac-card-note {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--green-soft); font-weight: 700;
}
.vac-card-sub { font-size: 1.05rem; margin: 10px 0 4px; color: var(--vac, var(--green)); }
.vac-x { --vac: var(--muted); }
.vac-site-img { display: block; width: 100%; max-width: 420px; height: auto; margin: 6px auto 0; background: #ffffff; border-radius: var(--radius); }
.vac-key-text { font-size: 1.25rem; font-weight: 700; color: var(--red); line-height: 1.45; }
.steps strong { display: block; }

/* หน้าวิธีเลี้ยง: ตาราง (เช่น ตู้ฟัก ตู้เกิด) และการ์ดพันธุ์ */
.table-wrap { overflow-x: auto; margin-top: 8px; }
.raise-table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.raise-table th, .raise-table td { border: 2px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.raise-table thead th { background: var(--green-soft); color: var(--fg); }
.raise-table tbody th { font-weight: 700; }
.breed-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 6px; }
.breed-card { border: 2px solid var(--line); border-left: 6px solid var(--green); border-radius: var(--radius); padding: 10px 12px; background: var(--bg); }
.breed-name { font-weight: 700; font-size: 1.1rem; color: var(--green); line-height: 1.35; margin-bottom: 2px; }
.breed-info { color: var(--fg); }

/* แท็บในหน้าโปรแกรมวัคซีน (เช่น โคเนื้อ / โคนม) ทรงสี่เหลี่ยม ไม่ใช่แคปซูล */
.vac-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0; border: 2px solid var(--green); border-radius: var(--radius); overflow: hidden; }
.vac-tab { display: block; text-align: center; padding: 12px 8px; font-size: 1.15rem; font-weight: 700; color: var(--green); text-decoration: none; background: var(--bg); }
.vac-tab + .vac-tab { border-left: 2px solid var(--green); }
.vac-tab.is-active { background: var(--green); color: var(--on-green); }
.vac-tab:focus-visible { outline: 3px solid var(--fg); outline-offset: -3px; }

/* กล่องเหลือง: ข้อควรรู้สำคัญ */
.yellow-box { background: var(--warn-bg); color: var(--warn-fg); border-color: #b08900; }
.yellow-box p + p { margin-top: 8px; }

/* ป้ายหน้าฟาร์ม */
.farm-sign {
  border: 4px solid var(--red); border-radius: var(--radius); padding: 14px 12px;
  text-align: center; font-size: 1.3rem; font-weight: 700; color: var(--red); background: var(--bg); line-height: 1.4;
}

/* กล่องติดต่อสู่คนได้: ขอบซ้ายแดง บรรทัดแรกตัวหนา */
.zoonosis-box { border-left: 8px solid var(--red); }
.zoonosis-box > p:first-of-type { font-weight: 700; font-size: 1.1rem; }
.outbreak-note { margin-top: 10px; font-weight: 700; }
/* คำเตือนในการ์ดวัคซีน */
.vac-warn {
  margin: 8px 0; padding: 10px 12px; border: 3px solid var(--red); border-radius: var(--radius);
  font-weight: 700; font-size: 1.15rem; color: var(--red); background: var(--bg);
}

/* อาการเป็นลำดับวัน (เช่น ไข้สามวัน) */
.day-steps { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.day-steps li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.day-label {
  font-weight: 700; color: var(--on-green); background: var(--green); border-radius: 6px;
  padding: 2px 10px; white-space: nowrap; line-height: 1.6;
}

/* หัวข้อการเลี้ยงแบบการ์ดข้อปฏิบัติ (#pig-safe) */
.rule-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rule-card {
  display: flex; gap: 12px; align-items: flex-start;
  border: 2px solid var(--line); border-left: 6px solid var(--green); border-radius: var(--radius);
  padding: 10px 12px; background: var(--bg);
}
.rule-icon { flex: none; font-size: 2rem; line-height: 1.2; }
.rule-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rule-text { margin: 0; font-size: 1.15rem; font-weight: 700; line-height: 1.45; }
.rule-no { color: var(--green); }

/* ป้าย "ติดต่อสู่คนได้" (รายชื่อโรค / หัวหน้าโรค) สีแดงเรียบ ๆ ไม่ใช่ตัวเตือนใหญ่ */
.zoo-tag {
  display: inline-block; vertical-align: middle; margin-left: 8px;
  background: var(--bg); color: var(--red); border: 2px solid var(--red);
  font-weight: 700; font-size: 0.8rem; line-height: 1.2; padding: 2px 8px; border-radius: 6px;
}
.head-text .zoo-tag { margin: 6px 6px 0 0; }

/* ดูแลสัตว์หน้าหนาว: ปุ่มในหน้าแรก (เฉพาะ พ.ย.–ก.พ.) + กลุ่มโรคที่ควรเฝ้าระวัง */
.btn-season { border-width: 3px; }
.winter-group + .winter-group { margin-top: 6px; }
.winter-disease { border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.winter-disease-name { font-weight: 700; font-size: 1.15rem; margin: 0 0 8px; }
.winter-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.winter-link { min-height: 56px; }
