/* ระบบบันทึกผลการเรียน · ธีมเขียวขาว วิทยาลัยเทคโนโลยีอีสานเหนือ */
:root {
  --green: #0F5535;      /* เขียวเข้มจากโลโก้ */
  --green-2: #1A6A45;
  --green-dark: #0A3B25;
  --lime: #73BF43;       /* เขียวอ่อนจากโลโก้ (ใช้เป็นพื้น ไม่ใช้เป็นสีตัวอักษรบนขาว) */
  --mint: #EAF5E2;
  --mint-2: #F6FAF3;
  --line: #D4E6C8;
  --line-2: #EEF3EA;
  --ink: #1B2A22;
  --muted: #44544B;
  --field: #A9BBAF;
  --red: #B42318;  --red-bg: #FDECEA;
  --amber: #8A4A06; --amber-bg: #FFF8EF; --amber-line: #F2C894;
  --blue: #1D4E89; --blue-bg: #E8F0FA;
  --radius: 14px;
  --font: 'Sarabun', 'Leelawadee UI', Tahoma, sans-serif;
  --font-head: 'Prompt', 'Sarabun', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--mint-2); }
a { color: var(--green); }
a:hover { color: var(--green-dark); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.3; margin: 0 0 .5em; }
.h1 { font-size: 28px; color: var(--green); }
.h2 { font-size: 21px; }
.h3 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.skip { position: absolute; left: -999px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: #fff; padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid #9CCB7C; outline-offset: 2px; }

/* ---- โครงหน้า ---- */
.shell { display: flex; min-height: 100vh; }
.side { width: 264px; flex: 0 0 264px; background: var(--green); color: #E6F3DE; padding: 18px 14px 28px; display: flex; flex-direction: column; gap: 2px; }
.side-head { display: flex; flex-direction: column; gap: 10px; padding: 0 6px 6px; position: relative; }
.side-logo { width: 148px; height: 74px; object-fit: contain; background: #fff; border-radius: 37px; }
.side-title { color: #fff; font-family: var(--font-head); font-size: 17px; font-weight: 600; }
.side-close { display: none; position: absolute; right: 0; top: 0; width: 44px; height: 44px; border: 0; background: transparent; color: #fff; font-size: 20px; cursor: pointer; }
.side-user { margin: 10px 2px 6px; background: var(--green-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.side-user-name { color: #fff; font-weight: 600; }
.side-user-role { color: #CFE8C2; font-size: 14px; }
.side-user label { color: #CFE8C2; font-size: 13px; }
.side-user select { width: 100%; height: 40px; border: 0; border-radius: 8px; padding: 0 8px; font: inherit; font-size: 15px; color: var(--ink); }
.side-group { font-size: 13px; color: #A9D594; letter-spacing: .03em; padding: 14px 12px 4px; }
.side-link { display: block; padding: 10px 12px; border-radius: 10px; color: #E6F3DE; text-decoration: none; }
.side-link:hover { background: var(--green-2); color: #fff; }
.side-link.on { background: #fff; color: var(--green); font-weight: 700; }
.side-menu { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.side-ico { flex: 0 0 auto; opacity: .9; }
.side-top { display: flex; align-items: center; gap: 10px; }
.side-sec > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: #fff; font-weight: 600; user-select: none; }
.side-sec > summary::-webkit-details-marker { display: none; }
.side-sec > summary:hover { background: var(--green-2); }
.side-sec > summary:focus-visible { outline: 3px solid #A9D594; outline-offset: 1px; }
.side-sec > summary span:first-of-type { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.side-count { font-size: 12px; font-weight: 600; color: #A9D594; background: rgba(255,255,255,.08); border-radius: 999px; padding: 1px 8px; }
.side-chev { flex: 0 0 auto; transition: transform .15s; color: #A9D594; }
.side-sec[open] > summary .side-chev { transform: rotate(90deg); }
.side-sec[open] > summary { background: rgba(255,255,255,.06); }
.side-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px 21px; padding-left: 10px; border-left: 1px solid rgba(169,213,148,.35); }
.side-sub .side-link { padding: 8px 10px; font-size: 15px; }
@media (prefers-reduced-motion: reduce) { .side-chev { transition: none; } }
.side-logout { margin-top: 14px; border-top: 1px solid var(--green-2); border-radius: 0; padding-top: 14px; }
.main-col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-title { font-family: var(--font-head); font-size: 19px; font-weight: 600; color: var(--green); flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-meta { color: var(--muted); font-size: 15px; white-space: nowrap; }
.menu-btn { display: none; width: 44px; height: 44px; border: 1px solid var(--field); background: #fff; border-radius: 10px; color: var(--green); cursor: pointer; align-items: center; justify-content: center; }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1400px; width: 100%; }
.foot { padding: 16px 28px 24px; color: var(--muted); font-size: 13px; }

@media (max-width: 960px) {
  .side { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; overflow-y: auto; width: 288px; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .side-close { display: block; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 14px; }
  .topbar-meta { display: none; }
  .content { padding: 16px 14px 40px; }
}

.icon-btn { position: relative; width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid var(--field); border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--green); background: #fff; }
.icon-btn:hover { background: var(--mint); }
.bell-count { position: absolute; top: -7px; right: -7px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.bell-count[hidden] { display: none; }
.bell.ring svg { animation: ring .9s ease-in-out 2; }
@keyframes ring { 0%,100% { transform: rotate(0); } 25% { transform: rotate(14deg); } 75% { transform: rotate(-14deg); } }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 40; max-width: 360px; background: var(--green); color: #fff; border-radius: 14px; padding: 14px 18px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast a { color: #fff; font-weight: 700; }
.toast[hidden] { display: none; }
.notif-unread td { background: #F4FAEF; font-weight: 600; }

/* ---- ส่วนประกอบ ---- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px; }
.card > :last-child { margin-bottom: 0; }
.card.narrow { max-width: 560px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 15px; }
.stat-value { font-family: var(--font-head); font-size: 32px; font-weight: 600; color: var(--green); }
.stat.warn { background: var(--amber-bg); border-color: var(--amber-line); }
.stat.warn .stat-label, .stat.warn .stat-value { color: var(--amber); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--green); background: var(--green); color: #fff; font: inherit; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--green-dark); color: #fff; }
.btn-outline { background: #fff; color: var(--green); }
.btn-outline:hover { background: var(--mint); color: var(--green-dark); }
.btn-danger { background: #fff; color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled], .btn:disabled { background: #C9D3CC; border-color: #C9D3CC; color: var(--muted); cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--green); font: inherit; text-decoration: underline; cursor: pointer; }

.form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .label { font-weight: 600; font-size: 15px; }
.hint { color: var(--muted); font-size: 14px; }
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=email], input[type=tel], select, textarea {
  width: 100%; min-height: 44px; border: 1px solid var(--field); border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 16px; color: var(--ink); background: #fff;
}
textarea { min-height: 88px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--green); vertical-align: middle; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

.table-wrap { overflow-x: auto; border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { background: var(--mint); color: var(--green); text-align: left; font-weight: 700; padding: 10px 12px; white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:hover td { background: #FBFDF9; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .ctr { text-align: center; }
.tbl tr.warn td { background: var(--amber-bg); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 13px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge-ok { background: #E3F1D8; color: var(--green); }
.badge-neutral { background: #F1F2F0; color: var(--muted); }
.badge-warn { background: #FDECD8; color: var(--amber); }
.badge-bad { background: var(--red-bg); color: var(--red); }
.badge-info { background: var(--blue-bg); color: var(--blue); }

.alert { border-radius: 12px; padding: 12px 16px; border: 1px solid; }
.alert-success { background: #EAF5E2; border-color: #9CCB7C; color: #183F27; }
.alert-error { background: var(--red-bg); border-color: #F3B3AC; color: #7A1A12; }
.alert-info { background: var(--blue-bg); border-color: #B7CDE9; color: #183C66; }
.alert-warn { background: var(--amber-bg); border-color: var(--amber-line); color: #6B3905; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; }
.pager a, .pager .current { min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; padding: 0 10px; }
.pager .current { background: var(--green); color: #fff; border-color: var(--green); }
.pager .muted { margin-left: 8px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; border-bottom: 3px solid transparent; color: var(--muted); }
.tabs a.on { color: var(--green); border-bottom-color: var(--green); font-weight: 700; }

/* ---- ตารางกรอกคะแนน ---- */
.sheet td { padding: 6px 6px; }
.cell { width: 70px; min-height: 40px; text-align: center; padding: 4px; }
.cell.bad { border: 2px solid var(--red); background: var(--red-bg); color: #7A1A12; font-weight: 700; }
.cell.saving { border-color: var(--lime); }
.grade { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 32px; border-radius: 8px; font-weight: 700; background: #E3F1D8; color: var(--green); }
.grade.zero { background: var(--red-bg); color: #7A1A12; }
.grade.none { background: #F1F2F0; color: var(--muted); font-weight: 400; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
.save-state { font-size: 14px; color: var(--muted); }
.save-state.ok { color: var(--green); }
.save-state.err { color: var(--red); }

/* ---- เช็คชื่อ / โฮมรูม ---- */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; min-width: 52px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 8px; border: 1px solid var(--field); border-radius: 10px; background: #fff; cursor: pointer; font-size: 15px; white-space: nowrap; }
.seg input:focus-visible + span { outline: 3px solid #9CCB7C; outline-offset: 1px; }
.seg input:checked + span.s-present { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.seg input:checked + span.s-late { background: var(--lime); border-color: var(--lime); color: #0B2E1D; font-weight: 700; }
.seg input:checked + span.s-absent { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.seg input:checked + span.s-sick, .seg input:checked + span.s-personal, .seg input:checked + span.s-activity { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }
.person { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.person-name { font-weight: 600; font-size: 17px; }

/* ---- หน้าเข้าสู่ระบบ ---- */
body.bare { background: #fff; }
.bare-alert { max-width: 420px; margin: 16px auto 0; }
.login { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login-brand { flex: 1 1 480px; background: var(--green); color: #fff; padding: 56px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.login-brand img { width: 220px; height: 110px; object-fit: contain; background: #fff; border-radius: 55px; }
.login-brand h1 { font-size: 40px; margin: 0; }
.login-brand p { color: #D9EED0; font-size: 19px; margin: 12px 0 0; }
.login-form { flex: 1 1 400px; display: flex; align-items: center; justify-content: center; padding: 40px 20px; background: var(--mint-2); }
.login-form form { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 36px 32px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 700px) { .login-brand { padding: 28px 20px; gap: 18px; } .login-brand h1 { font-size: 28px; } .login-brand img { width: 160px; height: 80px; } }

@media print {
  .side, .topbar, .foot, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { border: 0; padding: 0; }
}

/* รายการ ชื่อ–ค่า (ระเบียนประวัติ) */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 18px; margin: 0; }
.kv > div { min-width: 0; }
.kv dt { font-size: 13px; color: var(--muted, #5b6b62); }
.kv dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
/* จอเล็ก: ฟอร์มเรียงช่องเดียว (กันช่องที่กำหนด span 2 ดันคอลัมน์จนแคบ) */
@media (max-width: 640px) { .form > .field { grid-column: 1 / -1 !important; } }

/* =====================================================================
   v2.8 · ปรับหน้าตาให้กระชับ (เมนูข้างแคบลง ค้นหาเมนู บทบาทมุมขวาบน
   หัวหน้าเดียว ปุ่ม 3 ระดับ ตารางแน่นขึ้น หัวตารางติดบน แบ่งหน้า)
   ===================================================================== */
:root { --side-w: 236px; }
.h1 { font-size: 23px; }
.h2 { font-size: 19px; }
.h3 { font-size: 17px; }
.page-title { margin: 0; }

/* เมนูข้าง */
.side { width: var(--side-w); flex: 0 0 var(--side-w); padding: 12px 10px 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.side-head { flex-direction: row; align-items: center; gap: 10px; padding: 0 4px 8px; }
.side-logo { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; object-position: left center; flex: 0 0 46px; }
.side-title { font-size: 15px; line-height: 1.25; }
.side-search { padding: 2px 2px 6px; position: sticky; top: -12px; background: var(--green); z-index: 1; padding-top: 8px; }
.side-search input { min-height: 36px; height: 36px; border: 0; border-radius: 9px; font-size: 14px; padding: 4px 10px; background: rgba(255,255,255,.95); }
.side-empty { color: #CFE8C2; font-size: 14px; padding: 6px 12px; margin: 0; }
.side-menu { margin-top: 0; gap: 1px; }
.side-link { padding: 7px 10px; font-size: 14.5px; border-radius: 8px; }
.side-sec > summary { padding: 8px 10px; gap: 9px; border-radius: 8px; }
.side-sec > summary span:first-of-type { font-size: 14.5px; }
.side-sub { margin: 1px 0 4px 18px; padding-left: 8px; }
.side-sub .side-link { padding: 6px 9px; font-size: 14px; }
.side-link mark { background: #FFE58A; color: #0A3B25; border-radius: 3px; padding: 0 1px; }

/* แถบบน */
.topbar { padding: 8px 22px; gap: 10px; min-height: 58px; }
.topbar-crumb { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-meta { font-size: 14px; }
.icon-btn { width: 38px; height: 38px; flex-basis: 38px; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 8px 3px 3px; border: 1px solid var(--field); border-radius: 999px; background: #fff; color: var(--ink); min-height: 38px; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: var(--mint); }
.um-av { width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: 0 0 30px; }
.um-txt { display: flex; flex-direction: column; line-height: 1.15; max-width: 190px; }
.um-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.um-role { font-size: 12px; color: var(--green); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.um-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 270px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 28px rgba(10,59,37,.16); padding: 8px; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 80px); overflow-y: auto; }
.um-head { display: flex; flex-direction: column; padding: 6px 8px 8px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.um-roles { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 6px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.um-roles > span { padding: 0 8px 2px; }
.um-role-btn, .um-link { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 14.5px; color: var(--ink); text-decoration: none; cursor: pointer; }
.um-role-btn:hover, .um-link:hover { background: var(--mint); color: var(--green-dark); }
.um-role-btn.on { background: var(--mint); color: var(--green); font-weight: 700; }
/* ✓ ของบทบาทที่ใช้อยู่แสดงในข้อความปุ่มแล้ว (layout_main) */
.um-out { color: var(--red); }

/* เนื้อหา */
.content { padding: 18px 22px 40px; gap: 16px; }
.card { padding: 16px 18px; border-radius: 14px; }
.stat { padding: 12px 14px; border-radius: 12px; }
.stat-value { font-size: 26px; }
.grid { gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.alert { padding: 10px 14px; }

/* ปุ่ม 3 ระดับ: หลัก (.btn) · รอง (.btn-outline) · เบา (.btn-ghost) */
.btn { min-height: 38px; padding: 0 14px; border-radius: 9px; font-size: 14.5px; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13.5px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--green); }
.btn-ghost:hover { background: var(--mint); color: var(--green-dark); }

/* ช่องกรอก */
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=email], input[type=tel], select, textarea { min-height: 38px; padding: 6px 10px; font-size: 15px; border-radius: 9px; }
textarea { min-height: 76px; }
.form { gap: 12px; }
.field { gap: 4px; }
.field label, .label { font-size: 14px; }
/* แถบตัวกรองบรรทัดเดียว */
form.row { gap: 8px; }
form.row > input:not([type=checkbox]):not([type=radio]):not([type=hidden]), form.row > select { width: auto; max-width: 260px; min-height: 34px; height: 34px; padding: 3px 9px; font-size: 14.5px; }
form.row > label:not(.check):not(.sr) { font-size: 14px; color: var(--muted); }
form.row > .btn { min-height: 34px; }

/* ตาราง: แถวแน่นขึ้น หัวตารางติดบนเมื่อเลื่อน */
.table-wrap { max-height: calc(100vh - 150px); overflow: auto; border: 1px solid var(--line-2); }
table.tbl { font-size: 14.5px; }
.tbl th { padding: 7px 10px; }
.tbl thead { position: sticky; top: 0; z-index: 2; }
.tbl thead th { box-shadow: inset 0 -1px 0 var(--line); }
.tbl td { padding: 6px 10px; }
.tbl thead th.sticky-col, .tbl th.sticky-col { z-index: 3; }
.tbl td .btn-sm, .tbl td .btn { min-height: 30px; }

/* ส่วนเพิ่มข้อมูลแบบพับได้ (สร้างโดย app.js จากหัวข้อที่ขึ้นต้นด้วย "เพิ่ม") */
.fold-head { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.fold-head::before { content: '+'; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; background: var(--green); color: #fff; font-weight: 700; flex: 0 0 24px; }
.fold-open .fold-head::before { content: '−'; }
.fold-closed > :not(.fold-keep) { display: none !important; }

/* แบ่งหน้า */
.pager { gap: 4px; margin-top: 10px; font-size: 14px; }
.pager a, .pager .current { min-width: 34px; height: 34px; padding: 0 8px; }
.pager .pp { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.pager .pp select { width: auto; min-height: 32px; height: 32px; padding: 2px 6px; font-size: 14px; }

@media (max-width: 960px) {
  .side { position: fixed; inset: 0 auto 0 0; height: 100%; width: min(300px, 86vw); z-index: 30; padding-bottom: 40px; }
  .side.open { box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { padding: 8px 12px; }
  .um-txt { display: none; }
  .user-menu > summary { padding: 3px; }
  .content { padding: 14px 12px 36px; }
  .table-wrap { max-height: none; }
  .tbl thead { position: static; }
}
@media print {
  .user-menu { display: none !important; }
  .table-wrap { max-height: none !important; overflow: visible !important; }
}
/* ฟอร์มค้นหา/กรอง (method=get) เรียงบรรทัดเดียว ปุ่มอยู่ท้ายแถว */
form.form[method=get], form.form[method=GET] { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
form.form[method=get] > .field, form.form[method=GET] > .field { flex: 1 1 170px; max-width: 300px; }
form.form[method=get] > .field:has(> .btn:only-child), form.form[method=get] > .btn { flex: 0 0 auto; }
form.form[method=get] input:not([type=checkbox]):not([type=radio]), form.form[method=get] select { min-height: 36px; height: 36px; padding: 3px 9px; }
form.form[method=get] .btn { min-height: 36px; }
.tbl td .btn-sm { min-height: 28px; padding: 0 9px; }
.tbl td { line-height: 1.4; }

/* v2.9: การ์ดตัวกรอง · เมนู ⋯ · ตารางเป็นการ์ดบนมือถือ · ตัวเลือกแบบการ์ด · แถบขั้นตอน */
.stat-filter { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-filter .stat { text-decoration: none; color: inherit; transition: box-shadow .12s, border-color .12s; }
.stat-filter .stat:hover { border-color: var(--green-2); }
.stat-filter .stat.on { border: 2px solid var(--green); box-shadow: 0 0 0 3px var(--mint); }
.stat.ok .stat-value { color: var(--green); }
.stat.bad { background: var(--red-bg); border-color: #F3B3AC; }
.stat.bad .stat-label, .stat.bad .stat-value { color: var(--red); }
.stat-filter .stat-value { font-size: 24px; }
details.more { position: relative; }
details.more > summary { list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
.more-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 180px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 22px rgba(10,59,37,.14); padding: 6px; display: flex; flex-direction: column; }
.more-pop a { padding: 7px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: 14px; white-space: nowrap; }
.more-pop a:hover { background: var(--mint); }
.choice-group { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 0 0 12px; }
.choice-group > legend { font-weight: 700; padding: 0 6px; }
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--field); border-radius: 10px; padding: 10px 12px; cursor: pointer; background: #fff; }
.choice:hover { border-color: var(--green-2); }
.choice input { margin-top: 3px; }
.choice:has(input:checked) { border: 2px solid var(--green); background: var(--mint-2); }
.choice strong { display: block; font-size: 15px; }
.choice small { color: var(--muted); display: block; line-height: 1.35; }
.choice .tag { font-size: 12px; color: var(--amber); }
.steps { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 4px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.steps li { padding: 2px 8px; border-radius: 999px; background: #F1F2F0; color: var(--muted); white-space: nowrap; }
.steps li.done { background: #E3F1D8; color: var(--green); }
.steps li.now { background: var(--amber-bg); color: var(--amber); font-weight: 700; border: 1px solid var(--amber-line); }
.steps li + li::before { content: '›'; margin-right: 6px; color: var(--field); }
.form-help { background: var(--blue-bg); border: 1px solid #B7CDE9; color: #183C66; border-radius: 10px; padding: 10px 14px; font-size: 14.5px; }
.form-help ol { margin: 4px 0 0; padding-left: 20px; }
.kv-masked { letter-spacing: .5px; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .tbl-cards thead { display: none; }
  .tbl-cards, .tbl-cards tbody, .tbl-cards tr, .tbl-cards td { display: block; width: 100%; }
  .tbl-cards tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 8px 10px; background: #fff; }
  .tbl-cards td { border: 0; padding: 4px 0; text-align: left !important; display: flex; gap: 10px; }
  .tbl-cards td::before { content: attr(data-label); flex: 0 0 92px; color: var(--muted); font-size: 13px; }
  .tbl-cards td[data-label=""]::before { display: none; }
  .table-wrap:has(.tbl-cards) { border: 0; overflow: visible; max-height: none; }
}
.term-block { border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
.term-block > summary { cursor: pointer; padding: 2px 0; }
.term-block[open] > summary { margin-bottom: 8px; }

/* v2.12: ฟอร์มระเบียนประวัติ — ช่องที่ต้องกรอก · แถบความครบ · เมนูขั้นตอน · รูปถ่าย */
.field.need > label::after { content: ' *'; color: var(--red); }
.field.need input, .field.need select { border-color: #F3B3AC; background: #FFF8F7; }
.req-meter { height: 8px; background: #EEF2EC; border-radius: 99px; overflow: hidden; }
.req-meter > span { display: block; height: 100%; background: var(--green); width: 0; transition: width .2s; }
.step-nav { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0; background: var(--bg, #F6F8F5); }
.step-nav a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; text-decoration: none; color: var(--ink); font-size: 14px; }
.step-nav a:hover { border-color: var(--green-2); }
.photo-box { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.photo-frame { width: 150px; height: 200px; border: 2px dashed var(--line); border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fafbf9; color: var(--muted); font-size: 13px; text-align: center; }
.photo-frame img, .photo-frame video, .photo-frame canvas { width: 100%; height: 100%; object-fit: cover; }
.cam-wrap { position: relative; width: 240px; height: 320px; border-radius: 12px; overflow: hidden; background: #000; }
.cam-wrap video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-wrap .guide { position: absolute; inset: 12% 18% 22%; border: 2px dashed rgba(255,255,255,.8); border-radius: 50% 50% 45% 45%; pointer-events: none; }
.photo-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.photo-card { border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; }
.photo-card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; }

/* v2.14 — เมนูบัญชีผู้ใช้ · ปุ่มออกจากระบบตรึงล่างเมนู */
.side-user-switch { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; min-height: 40px; border: 0; border-radius: 8px; padding: 6px 10px; background: rgba(255,255,255,.12); color: #fff; font: inherit; font-size: 14.5px; text-align: left; cursor: pointer; }
.side-user-switch:hover, .side-user-switch:focus-visible { background: rgba(255,255,255,.22); }
.side-user-chg { font-size: 12.5px; color: #CFE8C2; white-space: nowrap; }
.side-logout { position: sticky; bottom: -20px; z-index: 2; background: var(--green); margin: auto -10px -20px; padding: 14px 20px 18px; border-top: 1px solid var(--green-2); }
.um-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 8px 4px; }
.um-chip { font-size: 12.5px; background: #F1F5F2; color: var(--ink); border-radius: 999px; padding: 2px 9px; }
.um-chip.lead { background: #F7F1DF; color: #5A4A1A; }
.um-out { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 9px; font-weight: 600; }
.um-acts { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.um-acts a { flex: 1 1 auto; text-align: center; font-size: 13.5px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; text-decoration: none; color: var(--ink); }
.um-acts a:hover { background: var(--mint); }
.um-acts a.um-out { color: #fff; background: var(--red, #B3261E); border-color: transparent; font-weight: 600; margin: 0; padding: 6px 10px; border-top: 0; }

/* v2.14 — บุคลากรและโครงสร้าง */
.pp-tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 0 0 14px; border-bottom: 2px solid var(--line); }
.pp-tabs > a { padding: 10px 16px; font-weight: 700; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.pp-tabs > a.on { color: var(--green); border-bottom-color: var(--green); }
.pp-tabs > a:hover { color: var(--green-dark); }
.pp-tabs-x { margin-left: auto; display: flex; gap: 12px; font-size: 13.5px; }
.pp-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.pp-filter input[type=search] { flex: 1 1 220px; min-width: 180px; }
.pp-filter select { flex: 0 1 auto; max-width: 230px; }
.pp-bulk { position: sticky; top: 64px; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; margin-bottom: 10px; background: #FFF8E1; border: 1px solid #F0D98A; border-radius: 10px; }
.pp-bulk select { max-width: 260px; }
.pp-chip { display: inline-block; font-size: 12.5px; line-height: 1.5; background: var(--mint, #EEF5E9); color: var(--green-dark); border-radius: 999px; padding: 1px 9px; margin: 1px 0; white-space: nowrap; }
.pp-chip.lead { background: #F7F1DF; color: #5A4A1A; font-weight: 600; }
.pp-chip.nomenu { background: #F2F3F2; color: #6B746F; }
.pp-tbl tr.pp-off td { opacity: .6; }
.pp-name { font-weight: 600; }
.pp-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(10, 30, 20, .35); }
.pp-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(620px, 100vw); background: #fff; box-shadow: -10px 0 30px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.pp-dhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 16px 20px 10px; border-bottom: 1px solid var(--line-2); }
.pp-x { font-size: 20px; text-decoration: none; color: var(--muted); padding: 2px 8px; border-radius: 8px; }
.pp-x:hover { background: var(--mint); }
.pp-dtabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line-2); }
.pp-dtabs a { padding: 9px 12px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.pp-dtabs a.on { color: var(--green); border-bottom-color: var(--green); }
.pp-dbody { flex: 1 1 auto; overflow-y: auto; padding: 14px 20px 20px; }
.pp-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 12px; }
.pp-form .field { margin-bottom: 10px; }
.pp-rsearch { width: 100%; margin-bottom: 8px; }
.pp-rgroup { border: 1px solid var(--line); border-radius: 10px; padding: 4px 0 2px; margin: 0 0 10px; }
.pp-rgroup legend { font-weight: 700; color: var(--green); padding: 0 6px; margin-left: 8px; font-size: 14px; }
.pp-rrow { display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-top: 1px solid var(--line-2); }
.pp-rrow:first-of-type { border-top: 0; }
.pp-rrow.on { background: #F2F8EE; }
.pp-rrow > label:first-child { display: flex; gap: 8px; align-items: flex-start; margin: 0; flex: 1; cursor: pointer; font-weight: 600; }
.pp-rrow > label:first-child input { width: auto; margin-top: 4px; }
.pp-rrow small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.pp-tag { font-size: 11px; font-weight: 600; color: #6B746F; background: #F2F3F2; border-radius: 999px; padding: 0 6px; }
.pp-lead { display: flex; align-items: center; gap: 4px; font-size: 12.5px; white-space: nowrap; color: #5A4A1A; background: #F7F1DF; border-radius: 999px; padding: 2px 9px; margin: 0; cursor: pointer; }
.pp-lead input { width: auto; margin: 0; }
.pp-lead.off { opacity: .35; pointer-events: none; }
.pp-dfoot { position: sticky; bottom: -20px; background: #fff; display: flex; gap: 8px; padding: 12px 0 4px; border-top: 1px solid var(--line-2); margin-top: 6px; }
@media (max-width: 760px) { .pp-tabs-x { margin-left: 0; width: 100%; padding: 6px 4px; } .pp-bulk { top: 56px; } }
.pp-bulk[hidden] { display: none; }
.tl-grp td { background: #EEF4EE; }
.badge-back { background: #F2ECF9; color: #6B3FA0; }
/* ตารางมาตรฐาน (ใช้ได้ทั้งหน้าตาเดิมและ ESARNTECH CONNECT) */
.dt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; }
.dt-search { display: flex; gap: 6px; align-items: center; flex: 1 1 280px; min-width: 0; }
.dt-count { margin-right: auto; }
a.dt-sort { color: inherit; text-decoration: none; white-space: nowrap; }
a.dt-sort span { font-size: 10px; opacity: .6; }
@media print { .dt-bar { display: none !important; } }

/* ESARNTECH CONNECT: จุดสลับบทบาทเดียวใน Sidebar */
.side-role-picker{width:100%;min-width:0}
.side-role-picker > summary{list-style:none}
.side-role-picker > summary::-webkit-details-marker{display:none}
.side-role-picker[open] > summary{background:rgba(255,255,255,.23)}
.side-role-options{display:flex;flex-direction:column;gap:4px;margin-top:7px;padding:6px;background:rgba(0,0,0,.12);border-radius:8px;max-height:270px;overflow-y:auto}
.side-role-choice{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%;border:0;border-radius:7px;background:transparent;color:#fff;font:inherit;font-size:13px;line-height:1.4;text-align:left;padding:9px 10px;cursor:pointer;overflow-wrap:anywhere}
.side-role-choice:hover,.side-role-choice:focus-visible{background:rgba(255,255,255,.15);outline-offset:1px}
.side-role-choice.active{background:#dff3e6;color:#12563a;font-weight:700}

/* v2.29 เมนู "จัดการ ▾" ในแถว */
details.row-menu { position: relative; display: inline-block; }
details.row-menu > summary { list-style: none; cursor: pointer; white-space: nowrap; }
details.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu-pop { position: fixed; z-index: 60; min-width: 200px; max-width: min(92vw, 360px); max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 6px; background: #fff; border: 1px solid var(--line, #DCE9E0); border-radius: 10px; box-shadow: 0 10px 28px rgba(16, 24, 20, .16); text-align: left; }
.row-menu-pop > a, .row-menu-pop > button, .row-menu-pop form > button, .row-menu-pop form > .btn { display: flex; width: 100%; justify-content: flex-start; text-align: left; border: 0; background: transparent; color: var(--ink, #1d2b22); min-height: 38px; padding: 6px 10px; border-radius: 7px; font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; box-shadow: none; }
.row-menu-pop > a:hover, .row-menu-pop button:hover, .row-menu-pop > a:focus-visible, .row-menu-pop button:focus-visible { background: var(--green-bg, #EAF5EE); }
.row-menu-pop form { display: block; margin: 0; }
.row-menu-pop .danger, .row-menu-pop .btn-danger { color: var(--red, #B42318) !important; }
.row-menu-pop hr { border: 0; border-top: 1px solid var(--line, #DCE9E0); margin: 2px 0; }
.row-acts { display: inline-flex; gap: 6px; align-items: center; flex-wrap: nowrap; justify-content: flex-end; }
@media (max-width: 760px) {
  .tbl-cards td .row-acts { justify-content: flex-start; flex-wrap: wrap; }
  .card select, .card input:not([type=checkbox]):not([type=radio]), .card textarea { max-width: 100%; }
  .table-wrap > table.tt { min-width: 720px; }
  .tbl-mob td:not(.tc-long), .tbl-mob th:not(.tc-long) { white-space: nowrap; }
  .tbl-mob .tc-long { min-width: 14em; }
  .tbl-cards-auto td > .tc-v { flex: 1 1 auto; min-width: 0; }
  .tbl-cards-auto td:empty { display: none; }
  .tbl-cards td { overflow-wrap: anywhere; }
}

/* หน้ากำหนดช่องที่นักศึกษาแก้ได้ */
.reg-edit-fields fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0 0 8px; }
.reg-edit-fields legend { font-weight: 600; padding: 0 5px; }
.reg-edit-fields .reg-field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 12px; }
.reg-edit-fields .reg-field-grid label { display: flex; align-items: center; gap: 7px; font-weight: 400; font-size: 14px; margin: 0; }
.reg-edit-fields .reg-field-grid input { flex-shrink: 0; }
.reg-edit-fields .reg-locked { opacity: .78; background: rgba(130,130,130,.05); }

/* ช่องที่ซ่อนด้วย hidden ต้องหายจริง แม้ .field จะเป็น flex */
.field[hidden], .form [hidden] { display: none !important; }

/* ---- เลือกภาษา ไทย / ລາວ / English (v2.40) ---- */
.lang-sw{display:inline-flex;border:1px solid #bfd6c7;border-radius:999px;overflow:hidden;background:#fff;flex:0 0 auto}
.lang-sw a{padding:5px 10px;font-size:13px;color:#0b5d3b;text-decoration:none;line-height:1.3;font-family:"Sarabun","Noto Sans Lao","Leelawadee UI",sans-serif}
.lang-sw a+a{border-left:1px solid #dbe9e0}
.lang-sw a.on{background:#0b5d3b;color:#fff;font-weight:600}
.lang-sw .lang-short{display:none}
.lang-top{margin-right:6px}
.lang-login{display:flex;width:max-content;margin:0 0 12px auto}
@media (max-width:900px){.lang-top .lang-long{display:none}.lang-top .lang-short{display:inline}.lang-top a{padding:5px 7px}}
.lang-side{display:none;margin:6px 0 4px;background:rgba(255,255,255,.95)}
@media (max-width:600px){.lang-top{display:none}.lang-side{display:inline-flex}}

/* v2.69 · ปุ่มดู/พิมพ์ (สีฟ้า) */
.btn.btn-view, .cx a.btn.btn-view, .cx .btn.btn-view { background: #fff; color: var(--blue, #1D4E89); border: 1px solid #BFD3EC; }
.btn.btn-view:hover { background: var(--blue-bg, #EAF2FB); }
