/* ===== ฟอนต์ไทย Sarabun (เก็บไฟล์ไว้ในเครื่อง ไม่พึ่ง CDN ภายนอก กันปัญหาเน็ตโรงเรียน/ออฟไลน์ทำให้ฟอนต์ตกมาเป็น sans-serif ที่ไม่รองรับภาษาไทย) ===== */
@font-face {
  font-family: 'Sarabun';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/sarabun-400-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: 'Sarabun';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/sarabun-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Sarabun';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/sarabun-500-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: 'Sarabun';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/sarabun-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Sarabun';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/sarabun-600-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: 'Sarabun';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/sarabun-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Sarabun';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/sarabun-700-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

@font-face {
  font-family: 'Sarabun';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/sarabun-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --c-primary: #1d6fb8;
  --c-primary-d: #15578f;
  --c-bg: #f0f4f8;
  --c-card: #fff;
  --c-border: #dde3ea;
  --c-text: #243140;
  --c-muted: #6b7886;
  --c-danger: #c0392b;
  --c-ok: #2e7d32;
  --c-warn: #e08600;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0, 0, 0, .09);
}

*,
*::before,
*::after {
  box-sizing: border-box
}

body {
  margin: 0;
  font-family: 'Sarabun', 'Leelawadee UI', 'Tahoma', sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 15px;
  line-height: 1.6;
}

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

a:hover {
  text-decoration: underline
}

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

/* ===== Topbar (หน้า login ที่ยังไม่ล็อกอิน) ===== */
.topbar {
  background: var(--c-primary);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 200;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 14px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand:hover {
  text-decoration: none
}

/* ===== App shell: sidebar + top header (ผู้ใช้ที่ล็อกอินแล้ว) ===== */
.app-shell {
  display: flex;
  min-height: 100vh
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 250px;
  background: var(--c-primary-d);
  color: #eaf2fb;
  z-index: 220;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .24s ease;
  box-shadow: 4px 0 20px rgba(0, 0, 0, .22);
}

.sidebar.open {
  transform: translateX(0)
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 35, .45);
  z-index: 210;
}

.sidebar-backdrop.open {
  display: block
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-brand a {
  color: #fff;
  font-weight: 700;
  font-size: 16px
}

.sidebar-brand a:hover {
  text-decoration: none
}

.sidebar-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #d9e9f6;
  font-size: 14px;
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, .1);
  text-decoration: none;
  color: #fff
}

.sidebar-nav a.active {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-weight: 600
}

.nav-icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0
}

.sidebar-section-label {
  margin: 16px 12px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .5);
}

/* --- เมนูจัดกลุ่ม พับ/กางได้ ---------------------------------------------
   ใช้ <details>/<summary> เพื่อให้พับกางได้แม้ปิด JavaScript
   และได้ความหมายสำหรับโปรแกรมอ่านหน้าจอมาให้เองโดยไม่ต้องประกาศ aria เพิ่ม */
.nav-group {
  margin-top: 6px
}

.nav-group+.nav-group {
  margin-top: 2px
}

.nav-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #cfe3f3;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  /* ซ่อนสามเหลี่ยมมาตรฐาน ใช้ chevron ของเราแทน */
}

.nav-group-head::-webkit-details-marker {
  display: none
}

.nav-group-head::marker {
  content: ''
}

.nav-group-head:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff
}

.nav-group-head:focus-visible {
  outline: 2px solid #7cc0ff;
  outline-offset: -2px;
}

.nav-group-head>span {
  flex: 1;
  min-width: 0
}

.nav-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .7;
  transition: transform .18s ease;
}

.nav-group[open]>.nav-group-head>.nav-chevron {
  transform: rotate(180deg)
}

/* กลุ่มที่มีหน้าปัจจุบันอยู่ข้างใน — ทำเครื่องหมายให้รู้ว่าตัวเองอยู่ส่วนไหนของระบบ */
.nav-group-current>.nav-group-head {
  color: #fff
}

.nav-group-current>.nav-group-head>.nav-icon {
  color: #7cc0ff
}

/* เมนูย่อยเยื้องเข้า และมีเส้นตั้งบอกว่าอยู่ใต้กลุ่มไหน */
.nav-group-body {
  margin: 2px 0 6px 21px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, .14);
}

.nav-group-body a {
  font-size: 13.5px;
  padding: 9px 10px
}

.nav-group-body .nav-icon {
  width: 17px;
  height: 17px
}

@media (prefers-reduced-motion: reduce) {
  .nav-chevron {
    transition: none
  }
}

/* --- Top header --- */
.topheader {
  position: sticky;
  top: 0;
  z-index: 150;
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow);
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.sidebar-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
}

.sidebar-toggle span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--c-text)
}

.search-panel {
  flex: 1;
  min-width: 0;
  max-width: 420px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-panel .search-icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--c-muted);
  pointer-events: none;
}

.search-panel input[type=search] {
  width: 100%;
  padding: 8px 10px 8px 34px;
  border: 1px solid var(--c-border);
  border-radius: 20px;
  background: var(--c-bg);
  font-size: 14px;
}

.search-panel input[type=search]:focus {
  background: #fff
}

.user-info {
  position: relative;
  margin-left: auto;
  flex-shrink: 0
}

.user-info-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 10px;
}

.user-info-btn:hover {
  background: var(--c-bg)
}

.user-info .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info .user-meta {
  text-align: left;
  line-height: 1.3
}

.user-info .user-meta b {
  display: block;
  font-size: 13px;
  color: var(--c-text)
}

.user-info .user-meta small {
  display: block;
  font-size: 11px;
  color: var(--c-muted)
}

.user-info .chevron {
  width: 16px;
  height: 16px;
  color: var(--c-muted);
  transition: transform .18s ease
}

.user-info.open .chevron {
  transform: rotate(180deg)
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 250px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  padding: 14px;
  z-index: 160;
}

.user-info.open .user-dropdown {
  display: block
}

.user-dropdown-head {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--c-border)
}

.user-dropdown-head b {
  display: block;
  font-size: 14px
}

.user-dropdown-head span {
  display: block;
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 2px
}

.user-dropdown .year-switcher {
  margin-bottom: 10px
}

.user-dropdown .year-switcher label {
  display: block;
  font-size: 11px;
  color: var(--c-muted);
  margin-bottom: 3px
}

.user-dropdown .year-switcher select {
  width: 100%;
  font-size: 13px;
  padding: 6px 8px
}

.user-dropdown-logout {
  display: block;
  text-align: center;
  margin-top: 8px;
  padding: 9px;
  border-radius: 8px;
  background: var(--c-bg);
  color: var(--c-danger);
  font-weight: 600;
  font-size: 13px;
}

.user-dropdown-logout:hover {
  background: #fdecea;
  text-decoration: none
}

.user-dropdown-item {
  display: block;
  text-align: center;
  margin-top: 8px;
  padding: 9px;
  border-radius: 8px;
  background: var(--c-bg);
  color: var(--c-text);
  font-weight: 600;
  font-size: 13px;
}

.user-dropdown-item:hover {
  background: var(--c-border);
  text-decoration: none
}

@media (min-width: 1024px) {
  .sidebar {
    transform: none;
    box-shadow: none;
    border-right: 1px solid rgba(255, 255, 255, .08)
  }

  .sidebar-backdrop {
    display: none !important
  }

  .sidebar-close {
    display: none
  }

  .app-main {
    margin-left: 250px
  }

  .sidebar-toggle {
    display: none
  }

  .search-panel {
    max-width: 360px
  }
}

/* ===== Layout ===== */
.container {
  max-width: 1200px;
  margin: 14px auto;
  padding: 0 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .container {
    margin: 22px auto;
    padding: 0 20px
  }
}

/* หน้าที่ล็อกอินแล้ว (มี sidebar) ให้เนื้อหาเต็มพื้นที่ข้าง sidebar แทนที่จะบีบกึ่งกลางแคบๆ */
.app-main .container {
  max-width: none;
  margin-left: 0;
  margin-right: 0
}

.footer {
  text-align: center;
  color: var(--c-muted);
  padding: 16px 12px;
  font-size: 12px
}

/* ===== Cards ===== */
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

@media (min-width: 768px) {
  .card {
    padding: 20px;
    margin-bottom: 18px
  }
}

.page-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 12px
}

@media (min-width: 768px) {
  .page-title {
    font-size: 22px
  }
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--c-primary-d);
  border-bottom: 2px solid var(--c-border);
  padding-bottom: 6px;
  margin: 20px 0 12px;
}

.section-title:first-child {
  margin-top: 0
}

@media (min-width: 768px) {
  .section-title {
    font-size: 17px;
    margin: 26px 0 14px
  }
}

.muted {
  color: var(--c-muted)
}

/* ===== Grid (mobile-first: stack, then flex on ≥640px) ===== */
.row {
  display: flex;
  flex-direction: column;
  gap: 0
}

@media (min-width: 640px) {
  .row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 14px
  }
}

.col {
  width: 100%;
  min-width: 0
}

@media (min-width: 640px) {
  .col {
    flex: 1;
    min-width: 180px
  }
}

/* ===== Forms ===== */
label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 14px
}

input:not([type]),
input[type=text],
input[type=password],
input[type=number],
input[type=date],
input[type=tel],
input[type=email],
input[type=search],
input[type=url],
input[type=time],
input[type=month],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  /* ≥16px prevents iOS auto-zoom */
  background: #fff;
  color: var(--c-text);
  -webkit-appearance: none;
  appearance: none;
}

/* ปฏิทินไทย (flatpickr): ช่อง input ที่แสดงผล พ.ศ. ให้ผู้ใช้ */
input[data-thai-date]~input.flatpickr-input,
input[data-thai-date][data-thai-date] {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='16' height='16' fill='none' stroke='%236b7886' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

.flatpickr-current-month .cur-year[readonly] {
  background: transparent
}

@media (min-width: 768px) {

  input:not([type]),
  input[type=text],
  input[type=password],
  input[type=number],
  input[type=date],
  input[type=tel],
  input[type=email],
  input[type=search],
  input[type=url],
  input[type=time],
  input[type=month],
  select,
  textarea {
    font-size: 14px;
    padding: 8px 10px
  }
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(29, 111, 184, .14);
}

.field {
  margin-bottom: 12px
}

.inline-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px
}

.inline-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  margin: 0;
  cursor: pointer;
  padding: 5px 0;
  min-height: 36px;
}

.inline-checks input[type=checkbox],
.inline-checks input[type=radio] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.help {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 3px
}

.required::after {
  content: " *";
  color: var(--c-danger)
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--c-primary);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
  text-decoration: none;
  transition: background .15s;
}

.btn:hover {
  background: var(--c-primary-d);
  text-decoration: none;
  color: #fff
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-height: 34px
}

.btn-light {
  background: #eef2f7;
  color: var(--c-text)
}

.btn-light:hover {
  background: #e0e6ee;
  color: var(--c-text)
}

.btn-ok {
  background: var(--c-ok)
}

.btn-ok:hover {
  background: #1f5f23
}

.btn-danger {
  background: var(--c-danger)
}

.btn-danger:hover {
  background: #a02f24
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--c-primary);
  color: var(--c-primary)
}

.btn-outline:hover {
  background: var(--c-primary);
  color: #fff
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center
}

/* ===== Tables ===== */
.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 480px;
}

table.tbl th,
table.tbl td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  font-size: 14px;
}

table.tbl th {
  background: #eef3f8;
  font-weight: 600;
  color: var(--c-primary-d);
  white-space: nowrap;
}

table.tbl tr:last-child td {
  border-bottom: none
}

table.tbl tr:hover td {
  background: #f8fafc
}

/* Hide non-essential columns on small screens */
@media (max-width: 639px) {
  .hide-sm {
    display: none !important
  }
}

/* Show subtitle only on mobile (hides once the full column appears) */
@media (min-width: 640px) {
  .hide-md {
    display: none !important
  }
}

/* ===== Alerts / Badges ===== */
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 14px
}

.alert-success {
  background: #e6f4ea;
  color: #1e5128;
  border: 1px solid #b6dcc0
}

.alert-danger {
  background: #fdecea;
  color: #7a231b;
  border: 1px solid #f3c0bb
}

.alert-info {
  background: #e7f1fb;
  color: #13456f;
  border: 1px solid #bcd9f4
}

/* ===== Toast (แจ้งเตือนลอย บันทึก/ลบ/แก้ไข) ===== */
.toast-container {
  position: fixed;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 480px) {
  .toast-container {
    left: auto;
    width: 340px
  }
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  background: #fff;
  border: 1px solid var(--c-border);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: auto;
}

.toast-show {
  opacity: 1;
  transform: translateY(0)
}

.toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.toast-success .toast-icon {
  background: var(--c-ok)
}

.toast-danger .toast-icon {
  background: var(--c-danger)
}

.toast-warning .toast-icon {
  background: var(--c-warn)
}

.toast-info .toast-icon {
  background: var(--c-primary)
}

.toast-msg {
  flex: 1;
  line-height: 1.5;
  word-break: break-word
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--c-muted);
  padding: 0 2px;
}

.toast-close:hover {
  color: var(--c-text)
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap
}

.badge-draft {
  background: #eceff3;
  color: #5a6673
}

.badge-submitted {
  background: #fff2d8;
  color: #8a5a00
}

.badge-certified {
  background: #e0f2e2;
  color: #1e5128
}

/* ภาวะโภชนาการ (น้ำหนักตามเกณฑ์ส่วนสูง) */
.badge-good {
  background: #e0f2e2;
  color: #1e5128
}

.badge-warn {
  background: #fff2d8;
  color: #8a5a00
}

.badge-bad {
  background: #fde4e1;
  color: #9b261b
}

.badge-muted {
  background: #eceff3;
  color: #5a6673
}

/* แถบกระจายภาวะโภชนาการ (stacked) */
.dist-bar {
  display: flex;
  width: 100%;
  height: 18px;
  border-radius: 99px;
  overflow: hidden;
  background: #eef1f4
}

.dist-bar>span {
  display: block;
  height: 100%
}

.dist-seg-good {
  background: #43a047
}

.dist-seg-warn {
  background: #f0a500
}

.dist-seg-bad {
  background: #e2503e
}

.dist-seg-muted {
  background: #c2cad3
}

.dist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  font-size: 13px
}

.dist-legend>div {
  display: flex;
  align-items: center;
  gap: 6px
}

.dist-legend .dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block
}

.inline-measure {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: nowrap
}

.inline-measure input {
  width: 64px;
  padding: 5px 6px;
  font-size: 13px
}

/* แบ่งหน้า (pagination) */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 14px
}

.pager .pager-current {
  background: var(--c-primary);
  color: #fff;
  pointer-events: none
}

.pager .is-disabled {
  opacity: .45;
  pointer-events: none
}

.pager .pager-gap {
  padding: 0 4px;
  color: var(--c-muted)
}

/* ===== Dashboard stats ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px
}

@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px
  }
}

.stat {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow)
}

.stat .n {
  font-size: 26px;
  font-weight: 700;
  color: var(--c-primary)
}

/* การ์ดตัวเลขที่กดเข้าไปดูรายชื่อได้ (drill down) — ต้องดูเหมือนการ์ดเดิม ไม่ใช่ลิงก์ขีดเส้นใต้ */
a.stat {
  display: block;
  color: inherit;
  text-decoration: none
}

a.stat:hover {
  border-color: var(--c-primary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12)
}

.stat .l {
  color: var(--c-muted);
  font-size: 13px
}

@media (min-width: 768px) {
  .stat {
    padding: 18px
  }

  .stat .n {
    font-size: 30px
  }

  .stat .l {
    font-size: 14px
  }
}

/* ===== Login ===== */
.login-wrap {
  max-width: 420px;
  margin: 5vh auto;
  padding: 0 12px
}

.login-wrap .card {
  padding: 22px
}

@media (min-width: 480px) {
  .login-wrap {
    margin: 8vh auto
  }

  .login-wrap .card {
    padding: 28px
  }
}

/* ===== Public landing page ===== */
.public-login-link {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
}

.public-login-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .13);
  text-decoration: none
}

.landing-body {
  --landing-blue: #1d6fb8;
  --landing-blue-dark: #15578f;
  --landing-mist: #e8f1f9;
  --landing-ink: #16232f;
  --landing-paper: #f7f9fc;
  background: var(--landing-paper);
  color: var(--landing-ink);
}

.landing-body .topbar {
  position: relative;
  background: #15578f;
  box-shadow: none
}

.landing-body .topbar-inner {
  max-width: 1180px;
  height: 64px
}

.landing-body .brand {
  font-size: 19px;
  letter-spacing: .01em
}

.landing-body .container {
  max-width: none;
  margin: 0;
  padding: 0
}

.landing-body .footer {
  background: #0d3f66;
  color: rgba(255, 255, 255, .72);
  padding: 24px 16px
}

.landing-page {
  overflow: hidden
}

.landing-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 70px;
  align-items: center;
  max-width: 1180px;
  min-height: 650px;
  margin: 0 auto;
  padding: 70px 20px 88px;
}

.landing-hero::before {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  right: -240px;
  top: -210px;
  border-radius: 50%;
  background: #dceaf7;
  z-index: -1;
}

.landing-hero::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  left: -80px;
  bottom: 24px;
  border: 28px solid #e3eef9;
  border-radius: 50%;
  z-index: -1;
}

.eyebrow,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--landing-blue);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.eyebrow span {
  width: 28px;
  height: 2px;
  background: #ef9d3f
}

.hero-copy h1 {
  margin: 18px 0 22px;
  font-size: 47px;
  line-height: 1.14;
  letter-spacing: -.035em;
  font-weight: 500
}

.hero-copy h1 strong {
  color: var(--landing-blue);
  font-weight: 800
}

.hero-lead {
  max-width: 690px;
  color: #55636f;
  font-size: 18px;
  line-height: 1.85;
  margin: 0
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px
}

.landing-btn-primary,
.landing-btn-secondary {
  min-height: 48px;
  padding: 11px 23px;
  border-radius: 999px;
  font-weight: 700
}

.landing-btn-primary {
  background: var(--landing-blue);
  box-shadow: 0 9px 22px rgba(29, 111, 184, .2)
}

.landing-btn-primary:hover {
  background: var(--landing-blue-dark)
}

.landing-btn-secondary {
  background: transparent;
  color: var(--landing-blue);
  border: 1px solid #a8c9e3
}

.landing-btn-secondary:hover {
  background: var(--landing-mist);
  color: var(--landing-blue);
  border-color: var(--landing-blue)
}

.hero-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 42px;
  padding-top: 22px;
  border-top: 1px solid #dde6ee
}

.hero-trust div {
  min-width: 115px
}

.hero-trust b,
.hero-trust span {
  display: block
}

.hero-trust b {
  font-size: 14px;
  color: var(--landing-ink)
}

.hero-trust span {
  color: #71828f;
  font-size: 12px;
  margin-top: 2px
}

.login-panel {
  position: relative;
  background: #fff;
  border: 1px solid #d7e4ef;
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 28px 60px rgba(21, 87, 143, .14);
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid #eaf2f9;
  border-radius: 17px;
  pointer-events: none
}

.login-panel>* {
  position: relative
}

.login-panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px
}

.login-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  color: var(--landing-blue);
  background: var(--landing-mist);
  flex: 0 0 auto
}

.login-mark svg,
.privacy-icon svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round
}

.login-panel-head p {
  color: #7c8b96;
  font-size: 11px;
  margin: 0 0 2px
}

.login-panel-head h2 {
  font-size: 20px;
  line-height: 1.3;
  margin: 0
}

.login-panel label {
  color: #324a5c;
  font-size: 13px;
  font-weight: 600
}

.login-panel input {
  border-color: #d4e0ea;
  background: #fbfdfe;
  min-height: 46px
}

.login-panel input::placeholder {
  color: #a2aeb8
}

.login-panel input:focus {
  border-color: var(--landing-blue);
  box-shadow: 0 0 0 3px rgba(29, 111, 184, .12)
}

.login-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 5px;
  background: var(--landing-blue);
  border-radius: 10px;
  font-weight: 700
}

.login-submit:hover {
  background: var(--landing-blue-dark)
}

.login-submit svg {
  width: 19px;
  height: 19px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round
}

.login-help {
  color: #7e8d99;
  font-size: 11px;
  text-align: center;
  margin: 15px 0 0
}

.landing-section {
  padding: 90px 20px
}

.section-heading {
  max-width: 730px;
  margin: 0 auto 42px;
  text-align: center
}

.section-heading h2,
.workflow-copy h2 {
  font-size: clamp(22.5px, 3vw, 33px);
  line-height: 1.25;
  margin: 12px 0 14px;
  letter-spacing: -.025em
}

.section-heading p,
.workflow-copy>p {
  color: #66767f;
  font-size: 16px;
  line-height: 1.8;
  margin: 0
}

.form-guide {
  background: #eef4fa
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  max-width: 1120px;
  margin: 0 auto
}

.guide-card {
  position: relative;
  background: rgba(255, 255, 255, .88);
  border: 1px solid #dbe7f1;
  border-radius: 17px;
  padding: 28px;
  min-height: 220px;
  transition: transform .18s ease, box-shadow .18s ease
}

.guide-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(21, 87, 143, .08)
}

.guide-number {
  display: inline-flex;
  color: var(--landing-blue);
  background: var(--landing-mist);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em
}

.guide-card h3 {
  margin: 19px 0 9px;
  font-size: 18px
}

.guide-card p {
  color: #61707c;
  font-size: 14px;
  line-height: 1.75;
  margin: 0
}

.workflow-section {
  display: grid;
  grid-template-columns: .9fr 1.1fr;
  gap: 80px;
  max-width: 1120px;
  margin: 0 auto;
  align-items: center
}

.workflow-copy {
  max-width: 470px
}

.workflow-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px
}

.workflow-list li {
  display: flex;
  gap: 14px;
  min-height: 135px;
  padding: 21px;
  background: #fff;
  border: 1px solid #dfe7ef;
  border-radius: 15px
}

.workflow-list li>span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  color: #fff;
  background: var(--landing-blue);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800
}

.workflow-list b {
  font-size: 15px
}

.workflow-list p {
  color: #6c7c86;
  font-size: 13px;
  line-height: 1.6;
  margin: 5px 0 0
}

.campaigns-section {
  background: #eef4fa
}

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  max-width: 1120px;
  margin: 0 auto
}

.campaign-card {
  display: block;
  background: #fff;
  border: 1px solid #dbe7f1;
  border-radius: 17px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .18s ease, box-shadow .18s ease
}

.campaign-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(21, 87, 143, .12)
}

.campaign-card img {
  display: block;
  width: 100%;
  height: auto
}

.campaign-card-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 16px 20px
}

.campaign-card-label span {
  flex: none;
  color: var(--landing-blue);
  background: var(--landing-mist);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  white-space: nowrap
}

.campaign-card-label b {
  font-size: 15px;
  font-weight: 700
}

.privacy-banner {
  display: flex;
  align-items: center;
  gap: 19px;
  max-width: 1120px;
  margin: 0 auto 90px;
  padding: 30px 34px;
  color: #fff;
  background: #0e4a75;
  border-radius: 20px;
  box-shadow: 0 18px 45px rgba(14, 74, 117, .18)
}

.privacy-icon {
  display: grid;
  place-items: center;
  width: 55px;
  height: 55px;
  flex: 0 0 auto;
  color: #bcdcf0;
  background: rgba(255, 255, 255, .09);
  border-radius: 15px
}

.privacy-icon svg {
  width: 31px;
  height: 31px
}

.privacy-banner h2 {
  font-size: 18px;
  margin: 0 0 5px
}

.privacy-banner p {
  color: #d2e6f2;
  font-size: 13px;
  line-height: 1.7;
  margin: 0
}

.privacy-banner a {
  flex: 0 0 auto;
  color: #fff;
  border-bottom: 1px solid #8cc0e0;
  font-size: 13px;
  font-weight: 700
}

@media (max-width: 900px) {
  .landing-hero {
    grid-template-columns: 1fr;
    gap: 45px;
    padding-top: 55px
  }

  .hero-copy {
    text-align: center
  }

  .hero-lead {
    margin-left: auto;
    margin-right: auto
  }

  .eyebrow,
  .hero-actions,
  .hero-trust {
    justify-content: center
  }

  .login-panel {
    width: min(100%, 510px);
    margin: 0 auto
  }

  .guide-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .workflow-section {
    grid-template-columns: 1fr;
    gap: 40px
  }

  .workflow-copy {
    max-width: 700px;
    text-align: center;
    margin: 0 auto
  }

  .privacy-banner {
    margin-left: 20px;
    margin-right: 20px
  }
}

@media (max-width: 620px) {
  .landing-body .topbar-inner {
    height: 58px
  }

  .landing-body .brand {
    font-size: 17px
  }

  .landing-hero {
    min-height: 0;
    padding: 42px 16px 65px
  }

  .landing-hero::before {
    width: 360px;
    height: 360px;
    right: -260px;
    top: -180px
  }

  .hero-copy h1 {
    font-size: 38px;
    margin-top: 14px
  }

  .hero-lead {
    font-size: 15px;
    line-height: 1.75
  }

  .hero-actions {
    flex-direction: column
  }

  .hero-actions .btn {
    width: 100%
  }

  .hero-trust {
    gap: 14px
  }

  .hero-trust div {
    flex: 1;
    min-width: 90px
  }

  .login-panel {
    padding: 25px 21px;
    border-radius: 19px
  }

  .landing-section {
    padding: 68px 16px
  }

  .section-heading {
    margin-bottom: 30px
  }

  .section-heading h2,
  .workflow-copy h2 {
    font-size: 21.75px
  }

  .guide-grid,
  .workflow-list,
  .campaign-grid {
    grid-template-columns: 1fr
  }

  .guide-card {
    min-height: 0;
    padding: 23px
  }

  .workflow-section {
    padding-left: 16px;
    padding-right: 16px
  }

  .workflow-list li {
    min-height: 0
  }

  .privacy-banner {
    align-items: flex-start;
    flex-wrap: wrap;
    margin: 0 16px 68px;
    padding: 24px
  }

  .privacy-banner div {
    flex: 1;
    min-width: 190px
  }

  .privacy-banner a {
    margin-left: 74px
  }
}

/* ===== Household members table ===== */
.members-tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.members-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 700px
}

.members-tbl th,
.members-tbl td {
  border: 1px solid var(--c-border);
  padding: 4px 5px
}

.members-tbl th {
  background: #eef3f8;
  font-size: 11px;
  text-align: center;
  white-space: nowrap
}

.members-tbl td:first-child {
  text-align: center;
  background: #f8fafc;
  font-weight: 600;
  min-width: 34px
}

.members-tbl input,
.members-tbl select {
  padding: 5px 4px;
  font-size: 13px;
  font-family: inherit
}

.members-tbl input[type=checkbox] {
  width: auto;
  height: auto
}

/* ===== Sticky save toolbar ===== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap
}

.sticky-toolbar {
  position: sticky;
  bottom: 0;
  background: #fff;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .1);
  z-index: 50;
  margin-top: 4px;
}

/* ===== Photo grid ===== */
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px
}

.photo-item {
  text-align: center
}

.photo-thumb {
  max-width: 140px;
  width: 140px;
  height: 100px;
  object-fit: cover;
  border: 1px solid var(--c-border);
  border-radius: 6px
}

.private-note {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7e6;
  color: #6f4b00;
  font-size: 13px
}

/* ===== Map and role dashboards ===== */
.dashboard-welcome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
  padding: 25px 28px;
  color: #fff;
  background: linear-gradient(120deg, #15578f, #1d7fb8);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(21, 87, 143, .2)
}

.dashboard-welcome span {
  color: #cfe7f8;
  font-size: 12px;
  font-weight: 600
}

.dashboard-welcome h1 {
  margin: 3px 0;
  font-size: 25px
}

.dashboard-welcome p {
  margin: 0;
  color: #e3f1fa;
  font-size: 13px
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px
}

.dashboard-welcome .btn {
  border: 1px solid rgba(255, 255, 255, .45)
}

.dashboard-stats {
  grid-template-columns: repeat(4, 1fr)
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, .75fr) minmax(500px, 1.25fr);
  gap: 18px
}

.progress-overview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  min-height: 225px
}

.progress-ring {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  width: 150px;
  height: 150px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--c-primary) calc(var(--progress) * 3.6deg), #e7edf2 0)
}

.progress-ring::after {
  content: "";
  position: absolute;
  inset: 13px;
  background: #fff;
  border-radius: 50%
}

.progress-ring b,
.progress-ring span {
  position: relative;
  z-index: 1
}

.progress-ring b {
  color: var(--c-primary);
  font-size: 29px;
  line-height: 1.2
}

.progress-ring span {
  color: var(--c-muted);
  font-size: 11px
}

.progress-legend {
  display: grid;
  gap: 12px;
  font-size: 13px
}

.progress-legend div {
  display: flex;
  align-items: center;
  gap: 7px
}

.progress-legend b {
  min-width: 28px
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%
}

.dot-draft {
  background: #84909d
}

.dot-submitted {
  background: #e4a12f
}

.dot-certified {
  background: #3d9951
}

.dot-missing {
  background: #dfe5ea
}

.mini-progress {
  display: inline-block;
  vertical-align: middle;
  width: 70px;
  height: 6px;
  overflow: hidden;
  margin-right: 5px;
  background: #e8edf1;
  border-radius: 99px
}

.mini-progress span {
  display: block;
  height: 100%;
  background: var(--c-primary);
  border-radius: inherit
}

.tbl small {
  color: var(--c-muted);
  font-size: 10px
}

.page-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px
}

.page-heading-row .page-title {
  margin-bottom: 2px
}

.page-heading-row p {
  margin: 0
}

.map-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px
}

.map-summary>div {
  display: flex;
  flex-direction: column;
  padding: 14px 17px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius)
}

.map-summary b {
  color: var(--c-primary);
  font-size: 24px;
  line-height: 1.2
}

.map-summary span {
  color: var(--c-muted);
  font-size: 12px;
  margin-top: 3px
}

.map-filter-card {
  margin-bottom: 12px
}

.map-filter-card .field {
  margin-bottom: 0
}

.map-filter-actions {
  display: flex;
  gap: 7px;
  max-width: 260px
}

.map-shell {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  margin-bottom: 20px;
  background: #dfe8e2;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  box-shadow: var(--shadow)
}

.student-map {
  width: 100%;
  height: min(68vh, 720px);
  min-height: 560px
}

.student-map .leaflet-popup {
  width: 290px
}

.visit-detail-map .leaflet-popup {
  width: 220px
}

.student-map .leaflet-popup-content-wrapper,
.visit-detail-map .leaflet-popup-content-wrapper {
  width: 100%;
  max-width: 100%
}

.student-map .leaflet-popup-content,
.visit-detail-map .leaflet-popup-content {
  max-width: calc(100% - 26px)
}

.map-empty {
  position: absolute;
  z-index: 500;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(420px, calc(100% - 30px));
  padding: 22px;
  text-align: center;
  background: rgba(255, 255, 255, .94);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .13)
}

.map-empty span {
  color: var(--c-muted);
  font-size: 13px
}

.student-map-marker {
  background: none;
  border: 0
}

.student-map-marker span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  background: var(--marker-color);
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .38);
  transform: rotate(-45deg)
}

.student-map-marker svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(45deg)
}

.map-popup {
  min-width: 235px;
  font-family: 'Sarabun', 'Leelawadee UI', 'Tahoma', sans-serif;
  color: var(--c-text)
}

.map-popup-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px
}

.map-popup-head b,
.map-popup-head span {
  display: block
}

.map-popup-head b {
  font-size: 14px
}

.map-popup-head span {
  color: var(--c-muted);
  font-size: 12px
}

.map-student-photo,
.map-student-placeholder {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover
}

.map-student-placeholder {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--c-primary);
  font-weight: 700
}

.map-home-photo {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  object-fit: cover
}

.map-no-photo {
  display: grid;
  place-items: center;
  height: 72px;
  color: var(--c-muted);
  background: #eef2f0;
  border-radius: 8px;
  font-size: 12px
}

.map-popup p {
  margin: 9px 0;
  font-size: 12px;
  line-height: 1.55
}

.map-status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px
}

.map-status-draft {
  color: #5a6673;
  background: #eceff3
}

.map-status-submitted {
  color: #8a5a00;
  background: #fff2d8
}

.map-status-certified {
  color: #1e5128;
  background: #e0f2e2
}

.map-popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 10px
}

.map-popup-actions a {
  padding: 7px;
  text-align: center;
  color: #fff;
  background: var(--c-primary);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600
}

.map-popup-actions a:first-child {
  color: var(--c-primary);
  background: #eaf2fb
}

.student-profile-card {
  display: flex;
  align-items: center;
  gap: 17px
}

.student-profile-photo,
.student-profile-placeholder {
  width: 78px;
  height: 78px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover
}

.student-profile-placeholder {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--c-primary);
  font-size: 28px;
  font-weight: 700
}

.student-profile-card h2 {
  margin: 0 0 2px;
  font-size: 20px
}

.student-profile-card p {
  margin: 0;
  color: var(--c-muted);
  font-size: 13px
}

.student-profile-card .badge {
  margin-left: auto
}

.visit-detail-map {
  width: 100%;
  height: 400px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: #e7ece9
}

.visit-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 13px
}

.visit-photo-grid .photo-item {
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--c-border);
  border-radius: 10px
}

.visit-photo-grid img {
  width: 100%;
  height: 180px;
  object-fit: cover
}

.visit-photo-grid span {
  display: block;
  padding: 8px 10px;
  color: var(--c-muted);
  font-size: 12px
}

@media (max-width: 639px) {
  .dashboard-welcome {
    align-items: flex-start;
    flex-direction: column;
    padding: 21px
  }

  .dashboard-actions {
    width: 100%
  }

  .dashboard-actions .btn {
    flex: 1
  }

  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr)
  }

  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr)
  }

  .dashboard-grid>* {
    min-width: 0
  }

  .progress-overview {
    gap: 20px
  }

  .progress-ring {
    width: 125px;
    height: 125px
  }

  .map-summary {
    grid-template-columns: repeat(2, 1fr)
  }

  .map-filter-card .field {
    margin-bottom: 10px
  }

  .map-filter-actions {
    max-width: none
  }

  .map-shell,
  .student-map {
    min-height: 480px
  }

  .student-map {
    height: 66vh
  }

  .student-profile-card {
    align-items: flex-start;
    flex-wrap: wrap
  }

  .student-profile-card .badge {
    margin-left: 0
  }

  .visit-detail-map {
    height: 320px
  }
}

@media (min-width: 640px) and (max-width: 980px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr)
  }

  .dashboard-grid>* {
    min-width: 0
  }
}

/* ===== HERO OBEC CARE ===== */
.hero-welcome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 15px;
  padding: 27px 30px;
  color: #fff;
  background: linear-gradient(120deg, #15578f, #1d7fb8);
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(21, 87, 143, .2)
}

.hero-welcome h1 {
  margin: 4px 0;
  font-size: 29px
}

.hero-welcome p {
  margin: 0;
  color: #e3f1fa
}

.hero-welcome .eyebrow {
  color: #cfe7f8;
  letter-spacing: .04em
}

.hero-docs,
.doc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px
}

.hero-docs .btn {
  border-color: rgba(255, 255, 255, .45)
}

.doc-links a {
  color: var(--c-primary);
  font-size: 12px;
  font-weight: 600
}

.workflow-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 15px;
  padding: 15px 20px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 13px;
  box-shadow: var(--shadow)
}

.workflow-strip>div {
  display: flex;
  align-items: center;
  gap: 9px
}

.workflow-strip b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  color: #fff;
  background: #2e8062;
  border-radius: 50%
}

.workflow-strip span {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2
}

.workflow-strip small {
  color: var(--c-muted);
  font-weight: 400
}

.workflow-strip i {
  color: #97aaa2;
  font-size: 27px;
  font-style: normal
}

.hero-stats {
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr))
}

.stat-attention {
  border-color: #efc7a4;
  background: #fff9f3
}

.stat-attention .n {
  color: #b95718
}

.hero-table {
  min-width: 1050px
}

/* ===== กราฟแท่งสัดส่วนผลคัดกรอง (hero_risk_report.php) — CSS ล้วน ไม่พึ่งไลบรารีกราฟ ===== */
.risk-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  color: var(--c-muted)
}

.risk-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px
}

.risk-row {
  margin-bottom: 10px
}

.risk-label {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: baseline;
  margin-bottom: 3px
}

.risk-bar {
  display: flex;
  height: 24px;
  overflow: hidden;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: var(--c-bg)
}

.risk-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap
}

a.risk-seg:hover {
  filter: brightness(1.1);
  text-decoration: underline
}

.risk-normal {
  background: var(--c-ok)
}

.risk-risk {
  background: var(--c-warn)
}

.risk-problem {
  background: var(--c-danger)
}

.hero-actions {
  min-width: 250px
}

.assessment-count {
  display: inline-block;
  padding: 3px 7px;
  color: #315c4d;
  background: #edf6f2;
  border-radius: 99px;
  font-size: 11px
}

.badge-danger {
  color: #8f241b;
  background: #fde4e1
}

.alert-warning,
.alert-error {
  background: #fff5df;
  color: #725000;
  border: 1px solid #edd39c
}

.text-danger {
  color: #a53127 !important;
  font-weight: 600
}

.student-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
  padding: 20px 23px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 13px
}

.student-head h1 {
  margin: 5px 0 1px;
  font-size: 24px
}

.student-head p {
  margin: 0;
  color: var(--c-muted)
}

.back-link {
  color: var(--c-primary);
  font-size: 12px;
  font-weight: 700
}

.screening-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.1fr) minmax(350px, 1.25fr) minmax(190px, .8fr);
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--c-border)
}

.screening-row .field {
  margin: 0
}

.risk-options {
  display: flex;
  gap: 5px
}

.risk-choice {
  flex: 1;
  padding: 8px 7px;
  text-align: center;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer
}

.risk-choice input {
  width: auto
}

.risk-normal:has(input:checked) {
  color: #236034;
  background: #e5f5e8;
  border-color: #90c99c
}

.risk-risk:has(input:checked) {
  color: #775000;
  background: #fff2d8;
  border-color: #e4bd6e
}

.risk-problem:has(input:checked) {
  color: #8f241b;
  background: #fde4e1;
  border-color: #e9a69f
}

.check-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 9px 0;
  padding: 12px 14px;
  background: #f8faf9;
  border: 1px solid var(--c-border);
  border-radius: 9px
}

.check-card input {
  width: auto;
  margin-top: 3px
}

.check-card span {
  display: grid;
  gap: 2px
}

.check-card small {
  color: var(--c-muted)
}

.check-danger {
  background: #fff7f5;
  border-color: #efc3bd
}

.no-screen-card {
  border-left: 4px solid #85928c
}

.nine-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px
}

.nine-grid .check-card {
  margin: 0
}

.form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  box-shadow: 0 -3px 18px rgba(0, 0, 0, .09);
  z-index: 30
}

.sdq-head,
.sdq-row {
  display: grid;
  grid-template-columns: minmax(330px, 1fr) repeat(3, 105px);
  gap: 6px;
  align-items: center
}

.sdq-head {
  padding: 9px 8px;
  color: #fff;
  background: #315c4d;
  border-radius: 8px 8px 0 0;
  font-size: 12px;
  text-align: center
}

.sdq-head span:first-child {
  text-align: left
}

.sdq-row {
  min-height: 56px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--c-border)
}

.sdq-row:nth-child(odd) {
  background: #f8faf9
}

.sdq-row label,
.eq-row label {
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer
}

.sdq-row label span,
.eq-row label span {
  display: none
}

.sdq-row input,
.eq-row input {
  width: 18px;
  height: 18px
}

/* --- MD-SST (11 มิติ, 55 ตัวชี้วัด, มาตราส่วน 0-3) --- */
.mdsst-dim {
  padding: 16px 0;
  border-top: 1px solid var(--c-border)
}

.mdsst-dim:first-of-type {
  border-top: none;
  padding-top: 6px
}

.mdsst-head,
.mdsst-row {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) repeat(4, 88px);
  gap: 6px;
  align-items: center
}

.mdsst-head {
  padding: 9px 8px;
  color: #fff;
  background: #315c4d;
  border-radius: 8px 8px 0 0;
  font-size: 11px;
  text-align: center
}

.mdsst-head span:first-child {
  text-align: left
}

.mdsst-row {
  min-height: 48px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--c-border);
  font-size: 13.5px
}

.mdsst-row:nth-child(even) {
  background: #f8faf9
}

.mdsst-row label {
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer
}

.mdsst-row input {
  width: 18px;
  height: 18px
}

.mdsst-dim .field {
  margin-top: 8px
}

@media(max-width:980px) {

  .mdsst-head,
  .mdsst-row {
    grid-template-columns: minmax(220px, 1fr) repeat(4, 58px)
  }
}

@media(max-width:639px) {
  .mdsst-head {
    display: none
  }

  .mdsst-row {
    grid-template-columns: 1fr repeat(4, 1fr);
    gap: 4px;
    padding: 10px 5px
  }

  .mdsst-row>div {
    grid-column: 1/-1
  }
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 15px
}

.score-grid>div {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 10px
}

.score-grid span,
.score-grid b {
  display: block
}

.score-grid span {
  color: var(--c-muted);
  font-size: 12px
}

.score-grid b {
  margin: 3px 0;
  font-size: 19px
}

.scorebar {
  height: 6px;
  overflow: hidden;
  background: #e8eeeb;
  border-radius: 99px
}

.scorebar i {
  display: block;
  height: 100%;
  background: #2e8062
}

.score-total {
  color: #fff !important;
  background: #315c4d !important
}

.score-total span {
  color: #dcefe7
}

.eq-grid-head,
.eq-row {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) repeat(4, 92px);
  gap: 5px;
  align-items: center
}

.eq-grid-head {
  padding: 10px 8px;
  color: #fff;
  background: #315c4d;
  border-radius: 8px 8px 0 0;
  font-size: 11px;
  text-align: center
}

.eq-grid-head span:first-child {
  text-align: left
}

.eq-row {
  min-height: 58px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--c-border)
}

.eq-row:nth-child(odd) {
  background: #f8faf9
}

.timeline {
  position: relative;
  margin-top: 15px
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 8px;
  width: 2px;
  background: #cfe0d9
}

.timeline article {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  padding-bottom: 22px
}

.timeline-dot {
  width: 18px;
  height: 18px;
  z-index: 1;
  background: #2e8062;
  border: 4px solid #dceee7;
  border-radius: 50%
}

.timeline p {
  margin: 7px 0
}

.timeline small {
  color: var(--c-muted)
}

.source-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 15px
}

.source-strip>div {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 15px 16px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 10px
}

.source-strip b {
  font-size: 13px
}

.source-strip span {
  color: var(--c-muted);
  font-size: 11px;
  padding-right: 60px
}

.source-strip i {
  position: absolute;
  right: 11px;
  top: 12px;
  padding: 3px 7px;
  border-radius: 99px;
  font-size: 9px;
  font-style: normal
}

.source-ok {
  color: #236034;
  background: #e5f5e8
}

.source-wait {
  color: #775000;
  background: #fff2d8
}

.profile-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 14px
}

.profile-summary>div {
  padding: 10px 12px;
  background: #f7faf8;
  border-radius: 8px
}

.profile-summary span,
.profile-summary b {
  display: block
}

.profile-summary span {
  color: var(--c-muted);
  font-size: 10px
}

.profile-summary b {
  margin-top: 2px;
  font-size: 13px
}

.choice-section {
  margin: 13px 0
}

.choice-section>b {
  display: block;
  margin-bottom: 7px;
  font-size: 13px
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px
}

.choice-grid label {
  padding: 7px 10px;
  background: #f7faf8;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 12px
}

.choice-grid input {
  width: auto
}

@media(max-width:980px) {
  .hero-stats {
    grid-template-columns: repeat(3, 1fr)
  }

  .screening-row {
    grid-template-columns: 1fr
  }

  .nine-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .sdq-head,
  .sdq-row {
    grid-template-columns: minmax(260px, 1fr) repeat(3, 70px)
  }

  .eq-grid-head,
  .eq-row {
    grid-template-columns: minmax(300px, 1fr) repeat(4, 70px)
  }
}

@media(max-width:639px) {
  .hero-welcome {
    align-items: flex-start;
    flex-direction: column;
    padding: 21px
  }

  .workflow-strip {
    align-items: flex-start;
    justify-content: flex-start;
    overflow-x: auto
  }

  .workflow-strip>div {
    min-width: 130px
  }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr)
  }

  .student-head {
    align-items: flex-start;
    flex-direction: column
  }

  .nine-grid {
    grid-template-columns: 1fr
  }

  .sdq-head,
  .eq-grid-head {
    display: none
  }

  .sdq-row,
  .eq-row {
    grid-template-columns: 1fr repeat(3, 1fr);
    gap: 4px;
    padding: 12px 5px
  }

  .eq-row {
    grid-template-columns: 1fr repeat(4, 1fr)
  }

  .sdq-row>div,
  .eq-row>div {
    grid-column: 1/-1
  }

  .sdq-row label span,
  .eq-row label span {
    display: block;
    font-size: 9px
  }

  .score-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .source-strip,
  .profile-summary {
    grid-template-columns: 1fr
  }
}

/* ===== Print: preserve existing visit_print.php layout ===== */
@media print {

  .topbar,
  .sidebar,
  .sidebar-backdrop,
  .topheader,
  .sticky-toolbar,
  .no-print {
    display: none !important
  }

  .app-main {
    margin-left: 0 !important
  }

  body {
    background: #fff;
    font-size: 10pt
  }

  .container {
    margin: 0;
    padding: 0
  }
}

/* ===== ระบบคะแนนพฤติกรรม ===== */
.pts {
  font-weight: 700;
  font-variant-numeric: tabular-nums
}

.pts-pos {
  color: #1e5128
}

.pts-neg {
  color: #9b261b
}

.pts-zero {
  color: #5a6673
}

.behavior-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 4px 0 12px
}

.behavior-cat-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 11px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  cursor: pointer;
  background: #fff
}

.behavior-cat-grid label:hover {
  border-color: var(--c-primary)
}

.behavior-cat-grid input {
  margin: 0
}

.behavior-cat-grid .cat-pts {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700
}

.behavior-evidence-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px
}

.behavior-evidence-thumbs a img {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--c-border)
}

.feed-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--c-border)
}

.feed-item:last-child {
  border-bottom: none
}

.feed-item .feed-pts {
  min-width: 46px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums
}

/* ===== เช็กชื่อด้วยกล้องสแกนใบหน้า ===== */
.face-stage {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr
}

@media (min-width: 860px) {
  .face-stage {
    grid-template-columns: minmax(320px, 1fr) 1fr
  }
}

.face-cam {
  position: relative;
  background: #0d1b16;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4/3
}

.face-cam video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1)
}

.scan-result {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f2f5f9;
  min-height: 52px;
  font-size: 15px
}

.scan-result.ok {
  background: #e0f2e2;
  color: #1e5128
}

.scan-result.warn {
  background: #fff2d8;
  color: #8a5a00
}

.scan-result.bad {
  background: #fde4e1;
  color: #9b261b
}

.reg-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0
}

.reg-thumbs img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--c-border)
}

.scan-log {
  max-height: 420px;
  overflow-y: auto
}

.secure-warn {
  background: #fff2d8;
  color: #8a5a00;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 14px
}

/* ตัวเลขแจ้งเตือนบนเมนูด้านข้าง — บอกจำนวนรายการที่ยังไม่อ่าน */
.sidebar-nav a .nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}