/* DOL Survey Logbook — สไตล์ร่วมของทั้งระบบ (เขียนเองทั้งหมด ไม่พึ่ง CDN ภายนอก เพื่อให้ deploy ได้แม้ไม่มีอินเทอร์เน็ต)
   ธีมสีเขียว + ทองอ่อนๆ ล้อกับตราสัญลักษณ์ประจำหน่วยงาน — ฟอนต์อ้างอิง "Leelawadee UI" ซึ่งเป็นฟอนต์ไทยที่มากับ
   Windows 10/11 อยู่แล้ว (ออกแบบมาสำหรับ UI โดยเฉพาะ ดูทันสมัยกว่า Tahoma/Angsana มาก) จึงไม่ต้องดาวน์โหลดไฟล์ฟอนต์
   เพิ่ม ยังคง deploy ได้แม้ไม่มีอินเทอร์เน็ตเหมือนเดิม — เครื่องที่ไม่มีฟอนต์นี้จะไล่ fallback ไปฟอนต์ระบบตามปกติ */
:root {
  --primary: #0E6B45;
  --primary-dark: #0A5236;
  --primary-light: #128F5C;
  --accent-light: #E6F6ED;
  --accent-border: #BEE5CE;
  --gold: #B8892F;
  --gold-light: #F7EFDC;
  --text: #1f2937;
  --text-muted: #64748b;
  --danger: #B3261E;
  --success: #1D8A4E;
  --warning: #8A5A00;
  --bg: #F3F8F5;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(15, 42, 30, 0.08);
  --shadow-md: 0 6px 20px rgba(15, 42, 30, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Leelawadee UI", "Segoe UI Variable Text", "Segoe UI", "Noto Sans Thai", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C7D6CD; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #A8BDB1; }

.topbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 10px rgba(10, 82, 54, 0.25);
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 20px;
  position: relative;
}
.topbar .brand-group { display: flex; align-items: center; gap: 10px; }
.topbar .brand-logo {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: white; object-fit: cover;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.35);
}
.topbar .brand { font-weight: 700; font-size: 16px; line-height: 1.25; }
.topbar .brand small { display: block; font-weight: 400; font-size: 11px; color: #bfe4cd; }

/* กล่องผู้ใช้ (มุมขวา) บนจอกว้าง (>768px, นอกเงื่อนไข media query ด้านล่างที่ทับ width:100% ให้อยู่แล้วบนมือถือ) —
   ดัน margin-left:auto ให้ชิดขวาเสมอ กันปัญหาเมนูของบทบาทที่มีลิงก์เยอะ (เช่นผู้ดูแลระบบ) ล้นบรรทัดแรกจนกล่องผู้ใช้
   ต้องตกไปขึ้นบรรทัดที่ 2 ของ .topbar-inner (flex-wrap) แล้วเกาะชิดซ้ายใต้โลโก้แทนที่จะชิดขวาแบบตอนอยู่บรรทัดเดียว
   กับเมนู — margin อัตโนมัติทำให้ชิดขวาสุดของบรรทัดตัวเองเสมอไม่ว่าจะขึ้นบรรทัดใหม่หรือไม่ */
.topbar .user-box { margin-left: auto; }

/* แถวเมนูหลัก — ลิงก์เดี่ยวและปุ่มเปิดเมนูย่อย ('จัดการ'/'ระบบ') ใช้หน้าตาปุ่มแบบเดียวกันหมด (pill) เพื่อความ
   สม่ำเสมอ ไอคอนหน้าป้ายชื่อช่วยให้กวาดสายตาหาเมนูที่ต้องการได้เร็วกว่าอ่านตัวหนังสือล้วนๆ */
.topbar nav { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; position: relative; }
/* ตั้งใจใช้ตัวเลือกลูกตรง (>) เท่านั้น — ป้องกันไม่ให้กฎสีของลิงก์เมนูหลัก (ตัวหนังสือสีขาวโปร่งแสงบนพื้นเขียว)
   ไปทับกฎสีของลิงก์ใน .dropdown-menu ที่ซ้อนอยู่ลึกกว่า (นาว > details > div.dropdown-menu > a) ซึ่งอยู่บนพื้นขาว
   — ถ้าเผลอใช้ตัวเลือกลูกหลานทั่วไป (space) จะได้ตัวหนังสือสีขาวบนพื้นขาวมองไม่เห็นในเมนูย่อย */
.topbar nav > a,
.topbar nav > details > summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.topbar nav > a svg, .topbar nav > details > summary svg:not(.chevron) { width: 16px; height: 16px; flex-shrink: 0; }
.topbar nav summary::-webkit-details-marker { display: none; }
.topbar nav summary::marker { content: ""; }
.topbar nav > a:hover, .topbar nav > details > summary:hover { background: rgba(255, 255, 255, 0.12); color: white; }
.topbar nav > a.active, .topbar nav > details > summary.active {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
/* ตัวเลขจำนวนงานค้าง แปะท้ายป้ายเมนู (เช่น "งานของฉัน") — วงกลมแดงเล็กๆ แบบตัวเลขแจ้งเตือนทั่วไป */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.topbar .chevron { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.75; transition: transform 0.15s; }
.nav-dropdown[open] > summary .chevron, .user-menu[open] > summary .chevron { transform: rotate(180deg); }
.nav-dropdown[open] > summary { background: rgba(255, 255, 255, 0.2); color: white; }

.nav-dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  min-width: 200px;
  z-index: 40;
}
.dropdown-menu a, .dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.dropdown-menu a svg, .dropdown-menu button svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-muted); }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--accent-light); color: var(--primary); }
.dropdown-menu a:hover svg, .dropdown-menu button:hover svg { color: var(--primary); }
.dropdown-menu a.active { background: var(--accent-light); color: var(--primary); font-weight: 700; }
.dropdown-menu a.active svg { color: var(--primary); }
.dropdown-menu button:hover { color: var(--danger); }
.dropdown-menu button:hover svg { color: var(--danger); }

/* เมนูผู้ใช้งาน (มุมขวา) — avatar วงกลม + ชื่อ/บทบาท พับเป็นดรอปดาวน์เดียวกัน แทนปุ่ม "ออกจากระบบ" ลอยเดี่ยวๆ เดิม */
.user-menu { position: relative; }
.user-menu summary {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer; list-style: none; user-select: none;
  transition: background 0.15s;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::marker { content: ""; }
.user-menu summary:hover { background: rgba(255, 255, 255, 0.18); }
.user-menu[open] summary { background: rgba(255, 255, 255, 0.18); }
.user-menu .user-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 700;
}
.user-menu .user-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; line-height: 1; }
.user-menu .user-name { font-size: 13px; font-weight: 600; color: white; }
.user-menu .badge { background: rgba(255, 255, 255, 0.22); color: white; font-size: 10.5px; padding: 1px 8px; }
.user-menu .dropdown-menu { right: 0; left: auto; min-width: 190px; }

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  border-radius: 6px;
  width: 36px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  order: 2;
}

.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

@media (min-width: 601px) {
  .container { padding: 24px; }
}

@media (max-width: 768px) {
  .nav-toggle { display: inline-block; }
  .topbar .brand-group { order: 1; flex: 1; }
  .topbar nav {
    order: 3;
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    border-top: 1px solid rgba(255,255,255,0.25);
    padding-top: 10px;
  }
  .topbar.nav-open nav { display: flex; }
  .topbar nav > a, .topbar nav > details > summary { border-radius: 8px; padding: 10px 12px; }
  /* บนมือถือให้เมนูย่อยกางออกในแนวตั้งแทนกล่องลอย (ใช้ <details> ตัวเดิม ไม่ต้องมี JS เพิ่ม) */
  .nav-dropdown .dropdown-menu {
    position: static;
    box-shadow: none;
    background: transparent;
    padding: 2px 0 2px 30px;
    min-width: 0;
  }
  .nav-dropdown .dropdown-menu a { color: rgba(255,255,255,0.8); padding: 8px 10px; }
  .nav-dropdown .dropdown-menu a:hover, .nav-dropdown .dropdown-menu a.active { background: rgba(255,255,255,0.12); color: white; }
  .nav-dropdown .dropdown-menu a.active svg { color: white; }
  .topbar .user-box {
    order: 4;
    width: 100%;
    display: none;
    border-top: 1px solid rgba(255,255,255,0.25);
    padding-top: 10px;
  }
  .topbar.nav-open .user-box { display: block; }
  .user-menu, .user-menu summary { width: 100%; }
  .user-menu summary { justify-content: space-between; padding: 8px 12px; }
  .user-menu .dropdown-menu { position: static; box-shadow: none; background: transparent; padding: 2px 0 0; }
  .user-menu .dropdown-menu a, .user-menu .dropdown-menu button { color: rgba(255,255,255,0.8); }
  .user-menu .dropdown-menu a:hover, .user-menu .dropdown-menu button:hover { background: rgba(255,255,255,0.12); color: white; }
  .user-menu .dropdown-menu a svg, .user-menu .dropdown-menu button svg { color: inherit; }
}

/* ปุ่มลอย "แชทบอทเจ้าหน้าที่" — แสดงทุกหน้าที่ล็อกอินแล้ว (สร้างจาก js/api.js::renderStaffChatFab() ต่อท้าย
   renderTopbar() จึงไม่ต้องแก้ทีละหน้า) กดแล้วเปิดระบบแชทบอทของกรมที่ดินเองที่ https://bi.dol.go.th/chatbot/login
   ในแท็บใหม่ — ใช้โทนฟ้า/ฟ้าอมเขียวแยกจากปุ่ม "คุยกับเจ้าหน้าที่" ของประชาชน (โทนส้ม ใน track.html) ให้ไม่สับสนกัน
   ว่าเป็นคนละฟีเจอร์ วางไว้ต่ำกว่า .modal-backdrop (z-index 50) เพื่อไม่ให้ลอยทับหน้าต่าง modal ที่เปิดอยู่ */
#staffChatFabWrap {
  position: fixed; right: 20px; bottom: 20px; z-index: 35;
  display: flex; align-items: center; gap: 10px;
}
#staffChatFabLabel {
  background: #0891B2; color: #fff; font-size: 13px; font-weight: 700; padding: 10px 16px;
  border-radius: 999px; box-shadow: var(--shadow-md); cursor: pointer; white-space: nowrap;
  animation: staffFabLabelIn 0.4s ease-out;
}
#staffChatFabLabel:hover { background: #0A6E88; }
#staffChatFab {
  position: relative; flex-shrink: 0;
  width: 58px; height: 58px; border-radius: 50%; border: 3px solid #0891B2; cursor: pointer;
  background: #fff; padding: 0;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
  animation: staffFabPop 0.5s ease-out;
}
#staffChatFab:hover { transform: scale(1.07); }
#staffChatFab:active { transform: scale(0.94); }
#staffChatFab img { width: 40px; height: 40px; object-fit: contain; pointer-events: none; }
#staffChatFab .staff-chat-fab-ring {
  position: absolute; inset: -3px; border-radius: 50%; border: 3px solid #0891B2;
  animation: staffFabPing 2.4s cubic-bezier(0,0,0.2,1) infinite; pointer-events: none;
}
/* กล่องยืนยันก่อนออกจากระบบ — กดไอคอน/ป้ายแล้วไม่พาไปที่ลิงก์ทันที แต่ถามให้เลือกก่อน "เปิด" (ไปตามลิงก์
   ในแท็บใหม่) หรือ "ปิด" (ยกเลิก ปิดกล่องนี้กลับไปเหมือนเดิม) กันพลาดกดโดนแล้วหลุดออกจากระบบไปที่อื่นโดยไม่ตั้งใจ */
.staff-chat-fab-confirm {
  display: none;
  position: absolute; bottom: calc(100% + 14px); right: 0;
  width: 230px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-md);
  padding: 14px;
}
.staff-chat-fab-confirm.open { display: block; animation: staffFabConfirmIn 0.18s ease-out; }
.staff-chat-fab-confirm::after {
  content: ""; position: absolute; top: 100%; right: 24px;
  border: 7px solid transparent; border-top-color: #fff;
}
.staff-chat-fab-confirm-text { font-size: 13px; color: var(--text); line-height: 1.5; margin-bottom: 6px; }
.staff-chat-fab-confirm-hint { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; }
.staff-chat-fab-confirm-actions { display: flex; gap: 8px; }
.staff-chat-fab-confirm-actions button {
  flex: 1; border: none; border-radius: 8px; padding: 8px 0; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
#staffChatFabOpenBtn { background: #0891B2; color: #fff; }
#staffChatFabOpenBtn:hover { background: #0A6E88; }
#staffChatFabCloseBtn { background: #EEF2F1; color: var(--text-muted); }
#staffChatFabCloseBtn:hover { background: #E2E8E6; }
@keyframes staffFabLabelIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes staffFabPop { 0% { transform: scale(0); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes staffFabPing { 0% { transform: scale(1); opacity: 0.6; } 75%, 100% { transform: scale(1.5); opacity: 0; } }
@keyframes staffFabConfirmIn { from { opacity: 0; transform: translateY(6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 480px) { #staffChatFabLabel { display: none; } } /* จอแคบมาก: เหลือแค่ไอคอนกันบังเนื้อหา */
@media print { #staffChatFabWrap { display: none !important; } }

/* กระดิ่งแจ้งเตือน "ข้อความจากประชาชน" — วางเหนือปุ่มแชทบอทเจ้าหน้าที่ (มุมขวาล่างเดียวกัน) ใช้โทนสีทอง (var(--gold))
   ของระบบแทนโทนฟ้าของปุ่มแชทบอท ให้เห็นชัดว่าเป็นคนละฟีเจอร์กัน ซ่อนตัวเอง ([hidden]) เมื่อไม่มีข้อความค้างตอบ */
#notifBellBtn {
  position: fixed; right: 20px; bottom: 92px; z-index: 36;
  width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--gold); cursor: pointer;
  background: #fff; padding: 0; color: var(--gold);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
#notifBellBtn[hidden] { display: none; }
#notifBellBtn:hover { transform: scale(1.07); }
#notifBellBtn:active { transform: scale(0.94); }
#notifBellBtn img { width: 36px; height: 36px; pointer-events: none; object-fit: contain; }
.notif-bell-badge {
  position: absolute; top: -4px; right: -4px; min-width: 21px; height: 21px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
}
.notif-bell-panel {
  display: none;
  position: fixed; right: 20px; bottom: 154px; z-index: 36;
  width: 380px; max-width: calc(100vw - 40px); max-height: 70vh;
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-md);
  flex-direction: column; overflow: hidden;
}
.notif-bell-panel.open { display: flex; animation: staffFabConfirmIn 0.18s ease-out; }
.notif-bell-head { background: var(--primary); color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.notif-bell-head b { font-size: 14px; }
.notif-bell-count { background: rgba(255, 255, 255, 0.22); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.notif-bell-head button { margin-left: auto; background: transparent; border: none; color: #fff; font-size: 19px; cursor: pointer; line-height: 1; opacity: 0.85; }
.notif-bell-list { overflow-y: auto; padding: 8px; }
.notif-msg { border: 1px solid var(--accent-border); border-radius: 11px; padding: 11px 12px; margin-bottom: 8px; }
.notif-msg:last-child { margin-bottom: 0; }
.notif-msg-top { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; flex-wrap: wrap; }
.notif-msg-code { font-weight: 800; font-size: 13.5px; color: var(--primary-dark); text-decoration: none; }
.notif-msg-code:hover { color: var(--primary-light); }
.notif-msg-who { font-size: 12.5px; color: var(--text-muted); }
.notif-age { margin-left: auto; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.notif-age.new { background: var(--accent-light); color: var(--success); }
.notif-age.warn { background: var(--gold-light); color: var(--warning); }
.notif-age.late { background: #FDECEA; color: var(--danger); }
.notif-msg-text {
  font-size: 15px; line-height: 1.6; font-weight: 700; color: var(--primary-dark);
  background: var(--accent-light); border-radius: 8px; padding: 8px 10px;
  margin-bottom: 9px; word-break: break-word;
}
.notif-reply-row { display: flex; gap: 6px; }
.notif-reply-row textarea {
  flex: 1; border: 1px solid var(--accent-border); border-radius: 9px; padding: 7px 9px;
  font-family: inherit; font-size: 13px; resize: none; height: 52px;
}
.notif-reply-row textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.notif-reply-row button {
  align-self: flex-end; background: var(--primary); color: #fff; border: none; border-radius: 9px;
  padding: 9px 14px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.notif-reply-row button:hover { background: var(--primary-dark); }
.notif-mark-read-link {
  display: block; margin-top: 7px; background: none; border: none; padding: 0;
  font-size: 11.5px; font-family: inherit; color: var(--text-muted); text-decoration: underline;
  cursor: pointer; text-align: left;
}
.notif-mark-read-link:hover { color: var(--text); }
.notif-bell-foot { border-top: 1px solid #EDF2EF; padding: 9px 14px; font-size: 12px; flex-shrink: 0; }
.notif-bell-foot a { color: var(--primary); font-weight: 700; text-decoration: none; }
@media (max-width: 480px) {
  .notif-bell-panel { right: 10px; left: 10px; width: auto; bottom: 148px; }
}
@media print { #notifBellWrap { display: none !important; } }

.card {
  background: white;
  border: 1px solid #E7EEE9;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-card {
  background: white;
  border: 1px solid #E7EEE9;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-card .value { font-size: 26px; font-weight: 700; color: var(--primary); }
.kpi-card .label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.kpi-card.warn { border-left-color: var(--warning); }
.kpi-card.warn .value { color: var(--warning); }
.kpi-card.danger { border-left-color: var(--danger); }
.kpi-card.danger .value { color: var(--danger); }

/* การ์ดจัดอันดับ (top จังหวัด/สำนักงาน/ช่างรังวัดที่มีงานค้างมากที่สุด) ใน Dashboard ผู้บริหาร —
   3 คอลัมน์บนจอกว้าง ย่อเหลือ 1 คอลัมน์บนมือถือ เหมือน .kpi-grid ด้านบน */
/* auto-fit แทนที่จะกำหนดตายตัวเป็น 3 คอลัมน์ เพราะการ์ด "5 อันดับจังหวัด" อาจถูกซ่อนไปเมื่อกรองเหลือจังหวัดเดียว
   (ดู renderRankings ใน dashboard.html) — ถ้าตายตัว 3 คอลัมน์ พอเหลือการ์ดแค่ 2 ใบจะเหลือที่ว่างเปล่าด้านขวา */
.rank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; align-items: start; margin-bottom: 18px; }
@media (max-width: 640px) { .rank-grid { grid-template-columns: 1fr; } }

.ranked-list { display: flex; flex-direction: column; gap: 12px; }
.ranked-row { display: flex; gap: 10px; align-items: flex-start; }
.ranked-rank {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #DFE8E2; color: #445064;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.ranked-rank.rank-1 { background: #FBE1DE; color: var(--danger); }
.ranked-rank.rank-2 { background: var(--gold-light); color: var(--warning); }
.ranked-rank.rank-3 { background: var(--accent-light); color: var(--primary); }
.ranked-body { flex: 1; min-width: 0; }
.ranked-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ranked-label { font-size: 13px; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranked-value { font-size: 13px; font-weight: 700; color: var(--text); flex-shrink: 0; }
.ranked-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.ranked-track { height: 6px; background: #EDF2EF; border-radius: 4px; margin-top: 5px; overflow: hidden; }
.ranked-fill { height: 100%; background: var(--primary-light); border-radius: 4px; }
.ranked-row:nth-child(1) .ranked-fill { background: var(--danger); }
.ranked-row:nth-child(2) .ranked-fill { background: var(--warning); }

h1 { font-size: 20px; color: var(--primary); margin: 0 0 4px 0; font-weight: 700; }
h2 { font-size: 16px; color: var(--primary); margin: 0 0 12px 0; font-weight: 700; }
.subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; background: var(--primary); color: white; padding: 9px 10px; font-weight: 600; white-space: nowrap; }
th:first-child { border-top-left-radius: 6px; }
th:last-child { border-top-right-radius: 6px; }
td { padding: 8px 10px; border-bottom: 1px solid #EDF2EF; }
tr:hover td { background: var(--accent-light); }
tr.clickable { cursor: pointer; }

/* ตารางหลายคอลัมน์ (เช่น cases.html ที่มี 11 คอลัมน์) มักกว้างเกินการ์ด (.container กว้างสุด 1100px) แม้บนจอ
   เดสก์ท็อปทั่วไป จึงต้องเลื่อนแนวนอนภายในกล่องนี้ (overflow-x) ปัญหาที่พบคือผู้ใช้จำนวนมากไม่รู้ว่าเลื่อนดูส่วนที่
   เหลือได้ — เห็นแค่ขอบขวาของตารางถูกตัดพอดีกับกล่อง เข้าใจผิดว่าเนื้อหาหายไป/แสดงไม่ครบ (ไม่ใช่บั๊ก แค่ขาด
   สัญญาณบอกว่าเลื่อนได้) แก้โดย (1) เงาไล่สีที่ขอบขวา/ซ้าย — เทคนิค CSS ล้วนๆ ไม่ต้องใช้ JavaScript (ใช้
   background-attachment: local/scroll ผสมกัน) จะปรากฏเฉพาะตอนยังมีเนื้อหาให้เลื่อนดูอีกในทิศทางนั้นๆ เท่านั้น พอ
   เลื่อนไปสุดขอบเงาจะหายไปเอง เป็นสัญญาณภาพที่คุ้นตาว่า "ยังมีต่อ เลื่อนดูได้" (2) scrollbar แสดงตลอดและมีสีเห็น
   ชัดเจน แทนที่จะพึ่ง scrollbar ของแต่ละเบราว์เซอร์/OS ที่บางระบบซ่อนไว้จนกว่าจะเอาเมาส์ไปชี้ ทำให้มองไม่เห็นเลยว่า
   เลื่อนได้ */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -1px;
  position: relative;
  background:
    linear-gradient(to right, white 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to right, rgba(255, 255, 255, 0), white 70%) 100% 0,
    linear-gradient(to right, rgba(15, 42, 30, 0.18), rgba(15, 42, 30, 0)),
    linear-gradient(to left, rgba(15, 42, 30, 0.18), rgba(15, 42, 30, 0)) 100% 0;
  background-repeat: no-repeat;
  background-color: white;
  background-size: 24px 100%, 24px 100%, 10px 100%, 10px 100%;
  background-attachment: local, local, scroll, scroll;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) #E7EEE9;
}
.table-scroll::-webkit-scrollbar { height: 9px; }
.table-scroll::-webkit-scrollbar-track { background: #E7EEE9; border-radius: 999px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 999px; }
@media (max-width: 700px) {
  .table-scroll table { min-width: 620px; }
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
  background: #DFE8E2;
  color: #445064;
}
.badge.status-RECEIVED, .badge.status-WAITING_ASSIGNMENT { background: var(--accent-light); color: var(--primary); }
.badge.status-ASSIGNED, .badge.status-APPOINTED, .badge.status-IN_SURVEY { background: var(--gold-light); color: var(--warning); }
.badge.status-WAITING_DOCUMENT, .badge.status-WAITING_ANNOUNCEMENT, .badge.status-ON_HOLD { background: #F3E8FD; color: #6b21a8; }
.badge.status-PENDING_REVIEW, .badge.status-PENDING_APPROVAL, .badge.status-SURVEY_DONE { background: #DCEBFD; color: #1d4ed8; }
.badge.status-COMPLETED, .badge.status-CLOSED { background: #DCF3E4; color: var(--success); }
.badge.status-CANCELLED, .badge.status-POSTPONED, .badge.status-REWORK_REQUIRED, .badge.status-SURVEY_SKIPPED { background: #FBE1DE; color: var(--danger); }
.badge.status-RE_APPOINTMENT_NEEDED { background: #F3E8FD; color: #6b21a8; }
/* จำนวนสถานะงานทั้งหมด (dashboard.html) — กริดการ์ดเล็กๆ หนึ่งช่องต่อหนึ่งสถานะ ใช้ badge สีเดียวกับที่ใช้ทั่วระบบ
   (.badge.status-* ด้านบน) คู่กับตัวเลขจำนวน auto-fill ให้ปรับจำนวนคอลัมน์ตามความกว้างจอเองโดยไม่ต้องกำหนด
   breakpoint ตายตัว (เหมือน .rank-grid) */
.status-count-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 4px; }
.status-count-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid #E7EEE9; border-radius: var(--radius); padding: 10px 14px;
  background: white;
}
.status-count-item .value { font-size: 19px; font-weight: 700; color: var(--text); }
/* ป้ายระดับสถานะทั่วไป (เขียว/ส้ม/แดง) — ใช้กับตัวชี้วัดที่ไม่ใช่สถานะเรื่องโดยตรง เช่น เกณฑ์งานค้างต่อช่าง
   ในหน้าโปรไฟล์ช่างรังวัด (surveyor-profile.html) สีชุดเดียวกับ .badge.status-* ด้านบนเพื่อความหมายตรงกันทั้งระบบ */
.badge.level-ok { background: #DCF3E4; color: var(--success); }
.badge.level-warn { background: var(--gold-light); color: var(--warning); }
.badge.level-danger { background: #FBE1DE; color: var(--danger); }

.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select {
  padding: 7px 10px;
  border: 1px solid #CBD5C9;
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  /* จำกัดความกว้างสูงสุดไว้ไม่ให้ <select> ขยายตามความยาวข้อความของตัวเลือกที่ยาวที่สุด (เช่น ชื่อประเภทงาน
     ที่มีบางรายการยาวมาก) มิฉะนั้นจะดันให้แถบตัวกรองล้นขอบจอในหน้าจอมือถือ แม้จะตั้ง flex-wrap ไว้แล้วก็ตาม */
  max-width: 100%;
}
.filters select {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .filters input, .filters select { flex: 1 1 100%; max-width: 100%; }
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 0 3px rgba(14, 107, 69, 0.15);
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 2px rgba(10,82,54,0.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: white; border: 1px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--accent-light); }
.btn-success { background: var(--success); color: white; box-shadow: 0 1px 2px rgba(29,138,78,0.25); }
.btn-success:hover { background: #146C3E; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; }
.btn-icon svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #334155; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #CBD5C9;
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.combo-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 60;
  background: white;
  border: 1px solid #CBD5C9;
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  margin-top: 2px;
}
.combo-item { padding: 9px 11px; font-size: 13px; cursor: pointer; }
.combo-item:hover { background: var(--accent-light); }
.combo-add { color: var(--primary); font-weight: 600; border-top: 1px solid #E9EEF3; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 55%, #073523 100%);
}
.login-box {
  background: white;
  border-radius: 14px;
  padding: 36px 34px;
  width: 360px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.login-logo img { width: 76px; height: 76px; border-radius: 50%; box-shadow: 0 4px 14px rgba(15,42,30,0.2); }
.login-box h1 { text-align: center; }
.login-box .subtitle { text-align: center; }
.login-box .btn-primary { width: 100%; margin-top: 6px; }
@media (max-width: 480px) {
  .login-wrap { padding: 16px; }
  .login-box { padding: 28px 20px; }
}

/* เครดิตผู้พัฒนา — วางไว้ใต้กล่อง login บนพื้นเขียวไล่เฉด ให้เด่นแต่ไม่แย่งซีนฟอร์มเข้าสู่ระบบ */
.dev-credit {
  margin-top: 22px;
  text-align: center;
  animation: dev-credit-fade 0.8s ease-out;
}
.dev-credit .dc-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 2px;
}
.dev-credit .dc-name {
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: linear-gradient(90deg, #FFE9A8 0%, #FFD447 45%, #F2B705 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(255, 212, 71, 0.45);
}
.dev-credit .dc-slogan {
  margin-top: 3px;
  font-size: 12.5px;
  font-style: italic;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 1px;
}
@keyframes dev-credit-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }
.hint-box {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11.5px;
  color: #334155;
  margin-top: 16px;
  line-height: 1.6;
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  padding: 8px 0 8px 18px;
  border-left: 2px solid #DFE8E2;
  position: relative;
  font-size: 13px;
}
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.timeline .ts { color: var(--text-muted); font-size: 11.5px; }

/* ข้อความจากประชาชน (case.html) — จำกัดความสูงด้วย scroll แทนปล่อยยาวไม่จำกัด เผื่อเรื่องหนึ่งมีการโต้ตอบกัน
   หลายรอบ จะได้ไม่ดันส่วนอื่นของหน้า (ประวัติสถานะ ฯลฯ) ให้ต้องเลื่อนหาไกลเกินไป */
.messages-summary-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--gold-light); color: var(--warning); white-space: nowrap;
}
.messages-summary-badge.all-done { background: #DCF3E4; color: var(--success); }
.msg-filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.msg-filter-btn {
  border: 1px solid #CBD5C9; background: white; color: var(--text-muted); font-size: 12.5px;
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-family: inherit;
}
.msg-filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.msg-filter-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.messages-scroll { max-height: 480px; overflow-y: auto; padding-right: 4px; }
.msg-item {
  padding: 12px; margin-bottom: 10px; background: #FAFCFB; border: 1px solid #EEF2EF; border-radius: 8px;
}
.msg-item:last-child { margin-bottom: 0; }

/* ข้อความแบบฟองแชท 2 ฝั่ง — ฝั่งประชาชน (ซ้าย โทนเทา) กับฝั่งเจ้าหน้าที่ (ขวา โทนเขียวหลักของระบบ) ให้แยกออกจากกัน
   เด่นชัดเหมือนแอปแชททั่วไป แทนข้อความตัวเล็กสีเดียวกันทั้งหมดแบบเดิม */
.chat-row { display: flex; flex-direction: column; margin-bottom: 10px; }
.chat-row:last-child { margin-bottom: 0; }
.chat-row.citizen { align-items: flex-start; }
.chat-row.staff { align-items: flex-end; }
.chat-sender { font-size: 11.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 3px; padding: 0 3px; }
.chat-row.staff .chat-sender { color: var(--primary-dark); }
.chat-bubble {
  max-width: 88%; padding: 10px 13px; border-radius: 15px; font-size: 14px; font-weight: 600;
  line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.chat-bubble.citizen {
  background: #E9EEF3; color: #1E293B; border-bottom-left-radius: 4px;
}
.chat-bubble.staff {
  background: var(--primary); color: #fff; border-bottom-right-radius: 4px;
}
.chat-time { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; padding: 0 3px; }

.action-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; font-size: 13.5px; }
.info-grid .k { color: var(--text-muted); }
@media (max-width: 600px) { .info-grid { grid-template-columns: 1fr; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  padding: 16px;
}
.modal {
  background: white; border-radius: 14px; padding: 22px; width: 380px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.modal h3 { margin-top: 0; font-size: 15px; color: var(--primary); }

/* ปฏิทินนัดรังวัด (calendar.html) */
.cal-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-month-label { font-size: 15.5px; font-weight: 700; color: var(--primary); min-width: 140px; text-align: center; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: #DFE8E2; border: 1px solid #DFE8E2; border-radius: 8px; overflow: hidden; }
.cal-weekday { background: var(--primary); color: white; text-align: center; padding: 8px 4px; font-size: 12px; font-weight: 600; }
.cal-day { background: white; min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day.other-month { background: #F7FAFD; }
.cal-day .cal-daynum { font-size: 12.5px; font-weight: 600; color: #334155; }
.cal-day.today .cal-daynum {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--primary); color: white;
}
.cal-chip {
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block; max-width: 100%;
  padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600;
  background: var(--accent-light); color: var(--primary);
}
.cal-chip:hover { filter: brightness(0.95); }
.cal-chip.unassigned { background: var(--gold-light); color: var(--warning); }
.cal-more { font-size: 11px; color: var(--text-muted); cursor: pointer; }
.cal-more:hover { text-decoration: underline; }
@media (max-width: 700px) {
  .cal-day { min-height: 58px; padding: 3px; }
  .cal-daynum { font-size: 11px; }
  .cal-weekday { font-size: 10px; padding: 5px 1px; }
  .cal-chip { font-size: 9.5px; padding: 1px 4px; }
}

/* การ์ด "วันนี้ช่างรังวัดออกไปรังวัด" */
.today-out-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.today-out-card { background: var(--bg); border: 1px solid #DFE8E2; border-radius: var(--radius); padding: 12px 14px; }
.today-out-card .to-name { font-weight: 700; font-size: 13.5px; color: var(--primary); margin-bottom: 8px; }
.today-out-card .to-case { font-size: 12.5px; padding: 4px 0; cursor: pointer; }
.today-out-card .to-case:hover { color: var(--primary); text-decoration: underline; }

.empty-state { text-align: center; padding: 40px 0; color: var(--text-muted); font-size: 13.5px; }
.loading { text-align: center; padding: 30px 0; color: var(--text-muted); font-size: 13px; }

/* ---- การ์ดรายการงาน (my-work.html) ---- */
.work-card { cursor: pointer; transition: box-shadow 0.15s, transform 0.15s; margin-bottom: 12px; }
.work-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.wc-top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; }
.wc-code { font-weight: 700; font-size: 15px; color: var(--primary); }
.wc-badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.wc-appt { margin-top: 12px; padding-top: 12px; border-top: 1px solid #EDF2EF; font-size: 13px; color: var(--text-muted); }
.wc-appt strong { color: var(--text); font-weight: 600; }

/* ---- ยืนยันตัวตน 2 ชั้น (2FA) — หน้า account.html และหน้า login.html ---- */
.qr-box {
  display: flex;
  justify-content: center;
  padding: 14px;
  background: white;
  border: 1px solid #DFE8E2;
  border-radius: var(--radius);
  max-width: 260px;
}
.qr-box img { width: 100%; max-width: 220px; height: auto; image-rendering: pixelated; }
.mfa-secret-box {
  font-family: "Courier New", monospace;
  font-size: 14px;
  letter-spacing: 1px;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 9px 12px;
  word-break: break-all;
  max-width: 320px;
}
.backup-codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-width: 420px;
}
@media (max-width: 480px) { .backup-codes-grid { grid-template-columns: 1fr; } }
/* ---- ตารางรายการงานรังวัด cases.html ---- */
/* เซลล์ "เช็คลิสต์" สูงไม่เท่ากันทุกแถว (ป้ายข้อความยาวบางป้ายตัดขึ้นบรรทัดใหม่) ถ้าปล่อยตามค่าเริ่มต้นของเบราว์เซอร์
   (vertical-align: middle) เนื้อหาเซลล์อื่นในแถวเดียวกัน (สถานะ/ความพึงพอใจ/จัดการ ซึ่งมีแค่บรรทัดเดียว) จะลอยขึ้นลง
   กึ่งกลางแถวไม่ตรงกันระหว่างแถว ดูเบียดเบียน/ไม่เป็นระเบียบ — บังคับชิดขอบบนของเซลล์แทน ให้ทุกแถวเริ่มเนื้อหาที่
   ระดับเดียวกันเสมอ ตั้งใจ scope เฉพาะตารางนี้ (ผ่าน .cases-table) ไม่ใช้กับตารางอื่นในระบบ เพราะบางตาราง (เช่น
   surveyors.html) มีรูปโปรไฟล์วงกลมในเซลล์ที่ตั้งใจให้จัดกึ่งกลางแถวไว้อยู่แล้ว การเปลี่ยนที่นั่นจะดูแปลกไป */
.cases-table td { vertical-align: top; }
/* แถวไอคอนวงกลมของคอลัมน์ "เช็คลิสต์" — แทนป้ายข้อความเต็มแบบเดิม (ที่เคยเป็นคอลัมน์กว้างสุดในตาราง จนดันคอลัมน์
   ขวาสุด "จัดการ" ถูกตัดครึ่งไปบางส่วน) ด้วยวงกลมไอคอนเล็กๆ 4 อัน กระชับและสวยงามขึ้นตามที่ผู้ใช้ระบบขอให้ออกแบบใหม่
   (เขียว=เสร็จ/ครบ, แดง=ยังไม่เสร็จ/รอ — ใช้สีแดงแทนส้มเดิมตามที่ผู้ใช้ระบบขอ เพื่อให้เด่นชัดสะดุดตากว่า สีนี้ scope
   เฉพาะไอคอนเช็คลิสต์ในคอลัมน์นี้เท่านั้น ไม่กระทบป้ายสถานะ .badge.status-* ที่ใช้สีส้ม/เหลืองทั่วระบบ, เทา=ยังไม่ระบุ)
   รายละเอียดเต็มดูได้จาก tooltip เมื่อชี้เมาส์ค้าง (title) */
.checklist-icons { display: flex; gap: 5px; align-items: center; }
.ci-badge {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: default;
}
.ci-badge svg { width: 14px; height: 14px; }
.ci-badge.ci-pos { background: #DCF3E4; color: var(--success); }
.ci-badge.ci-neg { background: #FBE1DE; color: var(--danger); }
.ci-badge.ci-unset { background: #DFE8E2; color: #445064; }

/* แถบเครื่องมือเหนือตารางรายการงาน — แสดงจำนวนรายการทั้งหมด + ตัวเลือกจำนวนรายการต่อหน้า */
.table-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; font-size: 13px; color: var(--text-muted); }
.page-size-label { display: flex; align-items: center; gap: 6px; }
.page-size-label select {
  padding: 5px 8px; border: 1px solid #CBD5C9; border-radius: 7px;
  font-size: 13px; font-family: inherit; background: white;
}
/* แถบเปลี่ยนหน้าใต้ตาราง — ซ่อนอัตโนมัติเมื่อมีหน้าเดียว (ดูฟังก์ชัน renderCasesPagination ใน cases.html) */
.table-pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; font-size: 13.5px; color: var(--text-muted); }
.table-pagination button:disabled { opacity: 0.45; cursor: not-allowed; }

.backup-code-chip {
  font-family: "Courier New", monospace;
  font-size: 14px;
  letter-spacing: 0.5px;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}

.avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.avatar-circle.large { width: 84px; height: 84px; font-size: 32px; }

/* หัวข้อโปรไฟล์ช่างรังวัด (surveyor-profile.html) — รูป + ชื่อ/รายละเอียดวางเรียงกัน */
.profile-header { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-header .info h2 { margin: 0 0 4px 0; color: var(--primary); font-size: 19px; }
.profile-header .info .sub { color: var(--text-muted); font-size: 13.5px; }

/* แถบสัดส่วนเช็คลิสต์ความคืบหน้ารวม (surveyor-profile.html) — เขียว=เสร็จ/ครบ, ส้ม=ยังไม่เสร็จ/รอ, เทา=ยังไม่ระบุ */
.stat-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: #DFE8E2; margin-top: 4px; }
.stat-bar span { height: 100%; }
.stat-bar .seg-pos { background: var(--success); }
.stat-bar .seg-neg { background: var(--warning); }
.stat-bar .seg-unset { background: #B7C2D0; }
.stat-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); margin-top: 8px; flex-wrap: wrap; }
.stat-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

/* เช็คลิสต์ความคืบหน้าภาคสนาม (ผลการรังวัด / ขึ้นรูป / ข้างเคียง / ปิดประกาศ) */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 640px) { .checklist-grid { grid-template-columns: 1fr; } }

.checklist-item {
  background: var(--bg);
  border: 1px solid #DFE8E2;
  border-radius: var(--radius);
  padding: 12px 14px;
}
.checklist-item .ci-label { font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 8px; }

.segmented { display: flex; border: 1px solid #CBD5C9; border-radius: 7px; overflow: hidden; }
.seg-btn {
  flex: 1;
  border: none;
  background: white;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: #64748b;
  border-right: 1px solid #CBD5C9;
  transition: background 0.15s;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: #F1F5F9; }
.seg-btn.active.pos { background: var(--success); color: white; }
.seg-btn.active.neg { background: var(--text-muted); color: white; }
.seg-btn:disabled { cursor: default; }

/* คลาสเสริม (ไม่กระทบ .checklist-grid เดิมที่ case.html ใช้) — บีบเป็น 4 คอลัมน์ในแนวนอนเดียว สำหรับแสดงเช็คลิสต์
   แบบย่อในการ์ดรายการงาน (my-work.html) ที่มีการ์ดจำนวนมากต่อหน้า ไม่อยากให้แต่ละใบสูงเกินไป */
.checklist-grid-compact { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.checklist-grid-compact .checklist-item { padding: 8px 10px; }
.checklist-grid-compact .ci-label { font-size: 11.5px; margin-bottom: 6px; }
.checklist-grid-compact .seg-btn { padding: 5px 6px; font-size: 11px; }
@media (max-width: 780px) { .checklist-grid-compact { grid-template-columns: repeat(2, 1fr); } }

/* รูปภาพประกอบข้อมูลแปลง — ใช้ thumbnail ขนาดกะทัดรัดคงที่ (ไม่ยืดเต็มคอลัมน์เหมือนเดิม) เพื่อไม่ให้เปลือง
   พื้นที่แนวตั้งเมื่อมีรูปจำนวนมาก (สูงสุด 10 รูป) — flex-wrap ทำให้จำนวนต่อแถวปรับตามความกว้างจอเองโดยไม่ต้อง
   กำหนด breakpoint ตายตัว คลิกที่รูปเพื่อดูขนาดเต็มใน lightbox (ดู #photoLightbox ใน case.html) */
.photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-slot {
  position: relative;
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  border: 1px solid #DFE8E2;
  border-radius: 8px;
  overflow: hidden;
  background: #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-slot .photo-remove {
  position: absolute; top: 2px; right: 2px;
  background: rgba(15,23,42,0.65); color: white; border: none;
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 1;
}
.photo-slot.empty {
  border: 2px dashed #CBD5C9;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}
.photo-slot.empty:hover { border-color: var(--primary); color: var(--primary); }

/* Lightbox ดูรูปภาพขนาดเต็ม (#photoLightbox ใน case.html) — ทับ .modal-backdrop (z-index 50) เพราะเปิดจาก
   ภายในหน้าเดียวกัน ไม่ได้เปิดพร้อม modal อื่นอยู่แล้ว แต่ตั้ง z-index สูงกว่าไว้กันเหนียว */
.photo-lightbox-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 60;
  padding: 24px;
}
.photo-lightbox-backdrop img {
  max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow-md);
  display: block;
  cursor: default;
}
.photo-lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: rgba(255,255,255,0.15); color: white; border: none;
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 20px; line-height: 1;
}
.photo-lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* วิดีโอประกอบข้อมูลแปลง (case.html) — แสดงเป็นรายการแนวตั้ง (ไม่ใช่กริดสี่เหลี่ยมแบบรูปภาพ) เพราะมีจำนวนน้อยกว่า
   มาก (ไม่เกิน 2 ไฟล์) และ <video controls> ต้องการพื้นที่แนวนอนมากกว่ารูปขนาดย่อ */
.video-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.video-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #DFE8E2;
  border-radius: var(--radius);
  padding: 10px;
  background: #F8FAF9;
  flex-wrap: wrap;
}
.video-item video { width: 220px; max-width: 100%; max-height: 160px; border-radius: 6px; background: #000; display: block; }
.video-item .video-meta { flex: 1; min-width: 120px; font-size: 12.5px; color: var(--text-muted); }
.video-add-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed #CBD5C9;
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.video-add-slot:hover { border-color: var(--primary); color: var(--primary); }

.location-link {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--primary); font-size: 13px; font-weight: 600; text-decoration: none;
}
.location-link:hover { text-decoration: underline; }

/* ---- หน้าติดตามงานสำหรับประชาชน (track.html) — ไม่ต้องล็อกอิน ---- */
.track-wrap {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 55%, #073523 100%);
  padding: 24px 16px 40px;
}
.track-header { text-align: center; color: white; margin-bottom: 20px; }
.track-header img { width: 64px; height: 64px; border-radius: 50%; box-shadow: 0 4px 14px rgba(0,0,0,0.25); margin-bottom: 10px; }
.track-header h1 { color: white; font-size: 19px; margin: 0 0 4px 0; }
.track-header .subtitle { color: #cfe9d9; margin: 0; }
.track-container { max-width: 480px; margin: 0 auto; }
.track-card {
  background: white;
  border-radius: 14px;
  padding: 26px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  margin-bottom: 16px;
}
.track-card .btn-primary { width: 100%; }
.track-back { text-align: center; margin-top: 10px; }
.track-back a { color: white; font-size: 13px; text-decoration: underline; cursor: pointer; }

.stage-bar { display: flex; align-items: flex-start; margin: 6px 0 20px; }
.stage-step { flex: 1; text-align: center; position: relative; }
.stage-step .dot {
  width: 26px; height: 26px; border-radius: 50%; background: #DFE8E2; color: #64748b;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  margin: 0 auto 6px; position: relative; z-index: 2;
}
.stage-step .line {
  position: absolute; top: 13px; left: -50%; width: 100%; height: 3px; background: #DFE8E2; z-index: 1;
}
.stage-step:first-child .line { display: none; }
.stage-step .lbl { font-size: 10.5px; color: var(--text-muted); line-height: 1.3; }
.stage-step.done .dot { background: var(--success); color: white; }
.stage-step.done .line { background: var(--success); }
.stage-step.current .dot { background: var(--primary); color: white; box-shadow: 0 0 0 4px var(--accent-light); }
.stage-step.current .lbl { color: var(--primary); font-weight: 700; }
.stage-bar.cancelled .stage-step .dot { background: #FBE1DE; color: var(--danger); }
.stage-bar.cancelled .stage-step .line { background: #FBE1DE; }

.track-result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.track-case-code { font-family: "Courier New", monospace; font-weight: 700; font-size: 15px; color: var(--primary); letter-spacing: 0.5px; }

/* คะแนนความพึงพอใจแบบหน้ายิ้ม 5 ระดับ (แสดงในหน้าติดตามงานเมื่องานเสร็จสิ้นแล้ว) */
.smiley-rating { display: flex; justify-content: space-between; gap: 6px; margin: 12px 0 4px; }
.smiley-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 2px; border: 2px solid transparent; border-radius: 10px; background: #f8fafc;
  cursor: pointer; font-size: 24px; transition: transform .15s, border-color .15s, background .15s;
}
.smiley-btn:hover { transform: translateY(-2px); background: var(--accent-light); }
.smiley-btn.selected { border-color: var(--primary); background: var(--accent-light); }
.smiley-btn .lbl { font-size: 9.5px; color: var(--text-muted); font-weight: 600; line-height: 1.2; }

@media print {
  .track-wrap { background: white !important; padding: 0; }
  .track-header { color: var(--text); }
  .track-header h1 { color: var(--text); }
  .track-card { box-shadow: none; border: 1px solid #e2e8f0; }
  #searchCard, .track-back, #messageFormBox, #satisfactionSection { display: none !important; }
}
