/* Lifelink อสม. · โทนเขียวอมฟ้า สะอาด อ่านง่าย · ปุ่มสูงอย่างน้อย 48px */
:root {
  /* CI ของ Lifelink (ชุดเดียวกับ Lifelink Lite v2) */
  --brand: #0380c0; --brand-ink: #01579b; --teal: #0380c0; --navy: #0e2658; --ink: #101828; --muted: #56636e; --bg: #f8fafb; --panel: #fff; --line: #e8ecef;
  --mint: #edf6fc; --soft-line: #b7ddf4; --blue: #f0f3fc; --blue-ink: #3e64d6; --amber: #fcf3e7; --amber-ink: #b75800; --red: #dc3223; --red-ink: #b3261a; --red-bg: #fceeec;
  --ok: #088a4b; --ok-bg: #eaf7f0;
  --fh: "Kanit", "Noto Sans Thai", sans-serif;
  font-family: "Noto Sans Thai", "Kanit", system-ui, sans-serif; font-size: 16px; line-height: 1.55; color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #e9eef2; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: 8px; justify-content: center; }
h2 { font-size: 1.05rem; font-weight: 700; }
:focus-visible { outline: 3px solid #1c5fa8; outline-offset: 2px; border-radius: 8px; }
.ic { flex: none; }
.nw { white-space: nowrap; }
.muted { color: var(--muted); font-size: .9rem; } .sm { font-size: .82rem; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; } .between { justify-content: space-between; }
.pad { padding: 0 4px; margin: 14px 0 8px; }

.app { max-width: 440px; min-height: 100dvh; margin: 0 auto; background: var(--bg); position: relative; }
.page { padding: 0 14px calc(92px + env(safe-area-inset-bottom)); }
@media (min-width: 480px) { .app { box-shadow: 0 0 0 1px var(--line); } }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -14px 12px; padding: 8px 10px; background: var(--bg); min-height: 60px; }
.top.red { background: var(--red); color: #fff; }
.top h1 { flex: 1; }
.iconbtn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; position: relative; flex: none; }
.iconbtn.line { border: 1px solid var(--line); background: var(--panel); color: var(--teal); }
.iconbtn.ghost { visibility: hidden; }
.iconbtn .dot { position: absolute; top: 10px; right: 11px; width: 11px; height: 11px; border-radius: 50%; background: var(--red); border: 2px solid var(--bg); }
.brandbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 0 4px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.25rem; color: var(--navy); } .brand img { width: 40px; height: auto; display: block; }
.brand b { font-family: "Montserrat", var(--fh); font-weight: 700; letter-spacing: .04em; } .brand span { font-family: var(--fh); font-weight: 500; color: var(--brand); }

.hello { display: flex; align-items: center; gap: 14px; padding: 8px 2px 16px; }
.name { display: block; font-size: 1.15rem; line-height: 1.35; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--mint); display: grid; place-items: center; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.5rem; } .avatar.xl { width: 84px; height: 84px; font-size: 2rem; margin-bottom: 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 12px; }
.card > h2 { margin-bottom: 12px; }
.card.center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.card.list { padding: 4px 16px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stats > * { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; border-radius: 14px; background: var(--bg); color: var(--teal); min-height: 96px; text-align: center; }
.stats b { font-size: 1.5rem; line-height: 1.2; color: var(--ink); } .stats span { font-size: .78rem; color: var(--muted); line-height: 1.3; }
.stats .blue { color: var(--blue-ink); } .stats .green { color: var(--ok); } .stats .red { color: var(--red); }

.urgent { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px; border-radius: 14px; background: var(--red-bg); border: 1px solid #f3c2bd; color: var(--red-ink); min-height: 76px; }
.urgent b { display: block; color: var(--ink); line-height: 1.4; } .urgent .muted { display: flex; align-items: center; gap: 4px; }

.tile { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--mint); color: var(--brand); }
.tile.lg { width: 54px; height: 54px; }
.tile.red { background: #fbdcd8; color: var(--red); } .tile.amber { background: var(--amber); color: var(--amber-ink); } .tile.blue { background: var(--blue); color: var(--blue-ink); }

.menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.menu a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 100px; padding: 10px 4px; border-radius: 14px; background: var(--bg); font-weight: 600; font-size: .88rem; text-align: center; line-height: 1.3; }
.menu a:hover, .item:hover { background: #f3f8fc; }
.menu .tile { background: var(--panel); border: 1px solid var(--line); }

.tag { display: inline-flex; align-items: center; padding: 1px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.tag.red { background: var(--red); color: #fff; } .tag.wait { background: var(--amber); color: var(--amber-ink); } .tag.info { background: var(--blue); color: var(--blue-ink); }
.tag.ok { background: var(--ok-bg); color: var(--ok); } .tag.soft { background: var(--mint); color: var(--brand-ink); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.pills { display: flex; gap: 8px; overflow-x: auto; margin: 0 -14px 12px; padding: 2px 14px; scrollbar-width: none; } .pills::-webkit-scrollbar { display: none; }
.pills button { min-height: 48px; padding: 0 16px; border-radius: 24px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; font-size: .92rem; white-space: nowrap; flex: none; }
.pills button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #e8eef3; border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button { min-height: 48px; border-radius: 11px; font-weight: 600; color: var(--muted); } .seg button.on { background: var(--teal); color: #fff; }

.search { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; min-height: 52px; margin-bottom: 12px; color: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; background: none; min-width: 0; min-height: 48px; color: var(--ink); } .search:focus-within { border-color: var(--teal); }

.item { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; min-height: 76px; color: var(--muted); }
.item b { display: block; color: var(--ink); line-height: 1.4; margin: 2px 0; } .item .muted { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.item .grow > .tags { margin-top: 4px; }

.headline, .person, .househead { display: flex; align-items: center; gap: 12px; }
.headline b, .person b, .househead b { display: block; line-height: 1.4; } .headline .muted, .person .muted, .househead .muted { display: flex; align-items: center; gap: 4px; }
.headline b { font-size: 1.08rem; }
.person { margin-top: 14px; padding: 12px; border-radius: 14px; background: var(--bg); } .card > .person:first-child { margin-top: 0; }
.househead { padding: 0 2px 14px; } .househead b { font-size: 1.1rem; }
.star { width: 48px; height: 48px; display: grid; place-items: center; color: #a9b4be; flex: none; } .star.on { color: #f0a81c; } span.star { width: auto; height: auto; }
.line-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 2px 0; color: var(--teal); }
.line-item.red { color: var(--red); } .line-item > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; color: var(--ink); }
.okmark { width: 24px; height: 24px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; flex: none; }
.todo { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--mint); } .todo > b { display: flex; align-items: center; gap: 8px; color: var(--brand-ink); }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--brand); flex: none; } .check input:checked + span { color: var(--muted); }
.member { display: flex; align-items: center; gap: 12px; min-height: 52px; color: var(--teal); } .member + .member { border-top: 1px solid var(--line); } .member b, .member .grow { color: var(--ink); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; } .timeline li:last-child { padding-bottom: 0; } .timeline b, .timeline span { display: block; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }

.btn { min-height: 52px; width: 100%; padding: 10px 16px; border-radius: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.btn.primary { background: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-ink); }
.btn.danger { background: var(--red); color: #fff; }
.btn.line { background: var(--panel); border: 1.500px solid var(--soft-line); color: var(--teal); } .btn.danger-line { border-color: var(--red); color: var(--red-ink); }
.btn.soft { background: var(--mint); color: var(--brand-ink); width: auto; display: inline-flex; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card > .btn { margin-top: 14px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 12px; } .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field { display: block; margin-bottom: 14px; } .field > span { display: block; font-weight: 600; margin-bottom: 6px; } .field i { color: var(--red); font-style: normal; }
select, textarea { width: 100%; min-height: 52px; padding: 12px 14px; border: 1.500px solid #cfd8df; border-radius: 12px; background: #fff; } textarea { resize: vertical; }
.field.bad select, .field.bad textarea { border-color: var(--red); } .err { display: block; color: var(--red-ink); font-weight: 600; font-style: normal; font-size: .88rem; margin-top: 4px; } .err[hidden] { display: none; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.addphoto, .thumb { width: 96px; height: 96px; border-radius: 14px; flex: none; }
.addphoto { border: 1.500px dashed var(--soft-line); background: var(--bg); color: var(--teal); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: .82rem; font-weight: 600; cursor: pointer; }
.thumb { position: relative; overflow: hidden; } .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }

.emg .page, .emg { --bg-emg: #fff5f4; }
.emgcard { display: flex; gap: 12px; align-items: flex-start; border-color: #f3c2bd; } .emgcard b { display: block; line-height: 1.4; } .emgcard .muted { display: flex; align-items: center; gap: 4px; }
.call1669 { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; border-radius: 14px; background: var(--red-bg); border: 1px solid #f3c2bd; color: var(--red-ink); font-weight: 600; margin-bottom: 12px; padding: 8px 12px; }

.map { position: relative; aspect-ratio: 1 / 1; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: #e6f1e6; }
.maplayer { position: absolute; inset: 0; transform-origin: 45% 55%; transition: transform .2s; } .maplayer svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.me { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: var(--navy); border: 3px solid #fff; box-shadow: 0 0 0 10px rgba(14,38,88,.16); }
.mpin { position: absolute; transform: translate(-50%, -100%); min-width: 48px; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.drop { position: relative; width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; border: 2px solid #fff; margin-bottom: 7px; }
.drop::after { content: ""; position: absolute; left: 50%; bottom: -8px; margin-left: -6px; border: 6px solid transparent; border-top: 8px solid var(--brand); border-bottom: 0; }
.mpin.sel .drop { background: var(--red); } .mpin.sel .drop::after { border-top-color: var(--red); } .mpin.sel { z-index: 2; }
.bubble { background: #fff; border: 1.500px solid var(--red); border-radius: 10px; font-size: .78rem; font-weight: 700; white-space: nowrap; margin-bottom: 6px; overflow: hidden; text-align: center; padding: 0 10px 2px; line-height: 1.6; }
.bubble i { display: block; background: var(--red); color: #fff; font-style: normal; margin: 0 -10px; }
.mapctl { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.mapctl button { width: 48px; height: 48px; border-radius: 14px; background: #fff; border: 1px solid var(--line); color: var(--teal); display: grid; place-items: center; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; } .empty .btn { margin-top: 10px; }

.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 440px; z-index: 10; display: flex; background: var(--panel); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .76rem; font-weight: 500; border-radius: 12px; }
.tabbar a[aria-current="page"] { color: var(--teal); font-weight: 700; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30; width: max-content; max-width: min(400px, calc(100vw - 32px)); background: var(--navy); color: #fff; border-radius: 14px; padding: 12px 16px; box-shadow: 0 6px 24px rgba(0,0,0,.25); text-align: center; }
.toast[hidden] { display: none; }

/* ภาพประกอบ */
.avatar { overflow: hidden; border: 2px solid #fff; box-shadow: 0 0 0 1px #d5dde3; } .avatar svg { width: 100%; height: 100%; display: block; }
.avatar.sm { width: 38px; height: 38px; } .avatar.lg { width: 68px; height: 68px; }
.scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero { position: relative; overflow: hidden; border-radius: 20px; border: 1px solid var(--line); min-height: 178px; margin: 8px 0 12px; }
.hero .hello { position: relative; padding: 14px 16px; align-items: flex-start; } .hero .muted { color: #3b4b5a; }
.profilehead { position: relative; overflow: hidden; padding-top: 86px; } .profilehead .scene { height: 130px; bottom: auto; } .profilehead > :not(.scene) { position: relative; }
h1, h2, .name, .btn, .pills button, .seg button, .stats b, .item b, .headline b, .househead b, .person b, .tabbar a, .menu a, .tag { font-family: var(--fh); }
h1, h2, .name, .item b, .headline b, .househead b, .person b { font-weight: 600; } .btn, .tag { font-weight: 500; letter-spacing: .01em; }
.btn.primary { border-radius: 16px; } .tile, .stats > *, .menu a { border-radius: 16px; }
.pills button.on, .seg button.on { background: var(--brand); border-color: var(--brand); }

/* สถานะใหม่ + แบบฟอร์มที่เจ้าหน้าที่ตั้งเอง */
.tag.violet { background: #f5f1fc; color: #6a3fb8; }
input[type="text"] { width: 100%; min-height: 52px; padding: 12px 14px; border: 1.500px solid #cfd8df; border-radius: 12px; background: #fff; }
.field.bad input { border-color: var(--red); }
.unit { display: flex; align-items: center; gap: 10px; } .unit input { flex: 1; min-width: 0; } .unit span { color: var(--muted); min-width: 4.5rem; }
form hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0 16px; }
.answers { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 10px 0; } .answers dt { color: var(--muted); } .answers dd { margin: 0; font-weight: 600; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--mint); border: 1px solid var(--soft-line); color: var(--brand-ink); margin-bottom: 12px; }
.notice b { display: block; } .notice span { color: var(--ink); }

/* ช่องเลือกสูงเท่าช่องกรอกในทุกเบราว์เซอร์ (Safari ไม่ยอมรับความสูงของ select แบบดั้งเดิม) */
select { -webkit-appearance: none; appearance: none; height: 52px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2356636e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
/* โปรไฟล์: แถบหัวการ์ดเป็นภาพทีม รพ.สต.วังใหม่ (Patrick 30 พ.ย. 2569) · หน้าหลักยังใช้ภาพวาดเดิม */
.profilehead.photo { padding-top: 132px; }
.profilehead.photo .scene { height: 176px; background: url("hero-wangmai.jpg") center 42% / cover no-repeat; }
/* หน้าหลัก: ฉากหลังเป็นภาพถ่ายสมจริง (ภาพสร้างด้วย AI ไม่ใช่สถานที่จริง · Patrick 30 พ.ย. 2569) · ไล่ขาวด้านบนให้อ่านคำทักทายได้ */
.hero.photo { min-height: 0; height: 158px; background: linear-gradient(90deg, rgba(255,255,255,.9) 0%, rgba(255,255,255,.78) 42%, rgba(255,255,255,0) 74%), url("hero-home.jpg") right bottom / cover no-repeat; }
/* รูปโปรไฟล์ อสม. ตัวอย่างเป็นภาพคน (สร้างด้วย AI ไม่ใช่บุคคลจริง · Patrick 30 พ.ย. 2569) */
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* แถบสภาพอากาศวันนี้บนการ์ดทักทาย · อยู่มุมล่างซ้าย */
.hero .wx { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 10px; border-radius: 999px; background: rgba(255,255,255,.9); color: #24384a; font-size: .82rem; line-height: 1.3; }
.hero .wx[hidden] { display: none; }
.hero .wx svg { flex: none; color: #0380c0; } .hero .wx b { font-family: var(--fh); font-weight: 600; font-size: .95rem; }
.hero .wx span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* แผนที่จริง (Leaflet + OpenStreetMap) · หมุดใช้หน้าตาเดิม วางด้วย divIcon ขนาดศูนย์แล้วยกขึ้นเหนือจุด */
.lmap { position: absolute; inset: 0; z-index: 0; font-family: inherit; } .mapctl { z-index: 500; }
.lmap .mpin { position: absolute; left: 0; top: 0; cursor: pointer; } .lmap .me { left: 0; top: 0; display: block; }
.lmap .leaflet-control-attribution { font-size: .62rem; } .mapfail { padding: 40px 20px; text-align: center; color: #3b4b5a; }
/* หน้าเข้าสู่ระบบ (โหมดเชื่อมระบบจริง) */
.formerr { color: var(--red-ink); background: var(--red-bg); border-radius: 12px; padding: 10px 12px; font-size: .9rem; margin: 0 0 12px; }
.avatar > .ic { color: #5b6b7a; }

