/* ===== ฟอนต์ Prompt (เก็บในเครื่อง ใช้ได้โดยไม่ต้องต่ออินเทอร์เน็ต) ===== */
@font-face { font-family: 'Prompt'; font-weight: 400; font-display: swap; src: url(../vendor/fonts/prompt-thai-400-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-weight: 500; font-display: swap; src: url(../vendor/fonts/prompt-thai-500-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-weight: 600; font-display: swap; src: url(../vendor/fonts/prompt-thai-600-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-weight: 700; font-display: swap; src: url(../vendor/fonts/prompt-thai-700-normal.woff2) format('woff2'); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: 'Prompt'; font-weight: 400; font-display: swap; src: url(../vendor/fonts/prompt-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2212; }
@font-face { font-family: 'Prompt'; font-weight: 500; font-display: swap; src: url(../vendor/fonts/prompt-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2212; }
@font-face { font-family: 'Prompt'; font-weight: 600; font-display: swap; src: url(../vendor/fonts/prompt-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2212; }
@font-face { font-family: 'Prompt'; font-weight: 700; font-display: swap; src: url(../vendor/fonts/prompt-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2190-2212; }

:root {
  --navy-900: #4a0510; --navy-800: #8c0b1b; --navy-700: #b80f25; --navy-600: #d4142e;
  --blue: #d4142e; --blue-600: #a80f24; --blue-soft: #fdeaec; --blue-line: #f3c3c9;
  --bg: #f6f2f2; --card: #fff; --ink: #1d0f11; --muted: #7a6668; --line: #eadede;
  --green: #1fa34a; --green-soft: #dcf5e4; --orange: #f39200; --orange-soft: #fff1db;
  --red: #e53935; --red-soft: #fde4e4; --cyan: #ff3347;
  --radius: 14px; --shadow: 0 1px 2px #3a06100d, 0 6px 18px #3a06100f;
  --font: 'Prompt', 'Leelawadee UI', 'Noto Sans Thai', Tahoma, sans-serif;
  --top: 64px; --side: 244px;
}
* { box-sizing: border-box; }
html, body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }
svg.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }

/* ===== ปุ่ม / ฟอร์ม ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 9px 16px;
  border-radius: 10px; cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s; }
.btn:hover { background: #fdf5f5; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-600); }
.btn.navy { background: linear-gradient(180deg, var(--navy-600), var(--navy-800)); border-color: var(--navy-800); color: #fff; }
.btn.navy:hover { filter: brightness(1.12); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.outline { border-color: var(--blue-line); color: var(--blue); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 12px; font-size: 13.5px; border-radius: 8px; }
.btn.lg { padding: 13px 22px; font-size: 17px; border-radius: 12px; }
.btn.block { width: 100%; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 0; display: inline-grid; place-items: center; cursor: pointer; color: #fff; }
.icon-btn.edit { background: var(--blue); } .icon-btn.del { background: var(--red); } .icon-btn.key { background: var(--orange); }
.icon-btn:hover { filter: brightness(1.1); }

input, select, textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid #d4142e2e; border-color: var(--blue); }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field input, .field select, .field textarea { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.input-icon input { padding-left: 38px; width: 100%; }
.muted { color: var(--muted); font-size: 13.5px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.pill.in, .pill.ok { background: var(--green-soft); color: #13803a; }
.pill.out, .pill.bad { background: var(--red-soft); color: #c62828; }
.pill.warn { background: var(--orange-soft); color: #b45f00; }
.pill.mute { background: #eef1f6; color: #475467; }
.pill.blue { background: var(--blue-soft); color: var(--blue); }

/* สวิตช์เปิด/ปิด */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px #0003; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ===== หน้าเข้าสู่ระบบ ===== */
.login-page { isolation: isolate; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.login-page::before { content: ''; position: fixed; inset: -20px; background: url(../assets/building.jpg) center 30%/cover no-repeat; filter: contrast(1.05) saturate(1.15); z-index: -2; }
.login-page::after { content: ''; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(160deg, #fff6f670 0%, #fde3e640 45%, #7a0a1780 100%); }
.login-card { width: min(400px, 100%); background: #ffffffee; backdrop-filter: blur(6px); border-radius: 22px; padding: 30px 28px 24px;
  box-shadow: 0 20px 50px #8c0b1b40, 0 2px 6px #8c0b1b1a; text-align: center; }
.login-card .logo { width: 116px; height: auto; display: block; margin: 0 auto 8px; }
.login-card h1 { font-size: 22px; margin: 0; color: var(--navy-800); }
.login-card .sub { color: var(--muted); font-size: 14.5px; margin: 2px 0 22px; }
.login-card .field { text-align: left; }
.login-card .input-icon input { padding: 12px 42px 12px 40px; border-radius: 12px; background: #fffafa; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; display: grid; }
.login-card .btn.navy { font-size: 18px; padding: 12px; border-radius: 12px; margin-top: 4px; }
.login-card .forgot { display: inline-block; margin-top: 14px; font-size: 14.5px; }
.login-err { background: var(--red-soft); color: #b42318; border-radius: 10px; padding: 9px 12px; font-size: 14px; margin-bottom: 12px; text-align: left; }
.login-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-foot a { font-weight: 500; }
.login-foot .scan-big { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; font-size: 18px; font-weight: 700; color: #c8102e; background: #fff; border: 2px solid #c8102e; border-radius: 12px; text-decoration: none; }
.login-foot .scan-big:hover { background: #fdeaec; }
.login-foot .scan-big svg { width: 24px; height: 24px; }
.login-foot span { text-align: center; }
.motto { position: fixed; top: 18px; right: 24px; color: var(--navy-800); font-weight: 600; font-style: italic; font-size: 18px; opacity: .8; }

/* ===== โครงหน้าระบบ ===== */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: var(--top); z-index: 30; display: flex; align-items: center; gap: 12px; padding: 0 18px 0 14px;
  background: linear-gradient(90deg, var(--navy-900), var(--navy-700)); color: #fff; box-shadow: 0 2px 10px #0003; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo-wrap { width: 46px; height: 46px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex: none; overflow: hidden; }
.brand .logo-wrap img { width: 42px; height: 42px; object-fit: contain; }
.brand .name { font-weight: 600; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .name small { display: block; font-weight: 400; font-size: 12px; opacity: .75; }
.burger { border: 0; background: none; color: #fff; padding: 6px; cursor: pointer; display: grid; border-radius: 8px; }
.burger:hover { background: #ffffff1f; }
.topbar .spacer { flex: 1; }
.top-clock { font-variant-numeric: tabular-nums; opacity: .85; font-size: 14px; white-space: nowrap; }
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #fff; cursor: pointer; padding: 4px 6px; border-radius: 10px; text-align: left; }
.user-btn:hover { background: #ffffff1a; }
.user-btn .av { width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--navy-700); display: grid; place-items: center; flex: none; }
.user-btn b { display: block; font-weight: 500; font-size: 15px; line-height: 1.2; }
.user-btn small { opacity: .75; font-size: 12px; }
.dropdown { position: fixed; z-index: 90; background: #fff; color: var(--ink); border-radius: 16px; box-shadow: 0 18px 44px #8c0b1b40;
  width: min(300px, calc(100vw - 16px)); padding: 8px; display: none; }
.dropdown.show { animation: dd-in .16s ease-out; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.drop-me { display: flex; gap: 12px; align-items: center; padding: 10px 10px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.drop-me .av { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; background: #fdeaec; color: #c8102e; }
.drop-me .av svg { width: 24px; height: 24px; }
.drop-me b { display: block; font-size: 16px; line-height: 1.3; }
.drop-me small { display: block; font-size: 13px; opacity: .75; line-height: 1.4; }
.drop-me small.u { opacity: .55; font-size: 12px; }
.dropdown button { min-height: 44px; font: inherit; font-size: 15px; }
.dropdown button svg { width: 20px; height: 20px; flex: none; }
.dropdown #logout2 { color: #c8102e; }
body.glass-ui .dropdown { background: #1d070c; backdrop-filter: blur(18px); }
body.glass-ui .drop-me { border-bottom-color: #ffffff21; }
body.glass-ui .drop-me .av { background: #ff334733; color: #fff; }
body.glass-ui .dropdown #logout2 { color: #ff8a96; }
.dropdown.show { display: block; }
.dropdown button { display: flex; width: 100%; gap: 10px; align-items: center; border: 0; background: none; padding: 10px 12px; border-radius: 8px; cursor: pointer; text-align: left; }
.dropdown button:hover { background: var(--blue-soft); color: var(--blue); }

.sidebar { position: fixed; top: var(--top); left: 0; bottom: 0; width: var(--side); z-index: 25; background: var(--navy-800); color: #ffe1e5;
  padding: 14px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; transition: transform .22s; }
.sidebar .nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: inherit; cursor: pointer; border: 0; background: none;
  width: 100%; text-align: left; font-size: 15px; }
.sidebar .nav-item svg { width: 20px; height: 20px; flex: none; }
.sidebar .nav-item:hover { background: #ffffff14; color: #fff; }
.sidebar .nav-item.on { background: var(--blue); color: #fff; font-weight: 500; box-shadow: 0 4px 12px #d4142e66; }
.sidebar .nav-item .badge { margin-left: auto; background: var(--orange); color: #fff; border-radius: 99px; font-size: 12px; padding: 0 8px; font-weight: 600; }
.sidebar .scan-cta { background: linear-gradient(135deg, #ff3347, #d4142e); color: #fff; font-weight: 600; margin-bottom: 10px; justify-content: center; }
.sidebar .scan-cta:hover { filter: brightness(1.08); background: linear-gradient(135deg, #ff3347, #d4142e); }
.sidebar .sep { height: 1px; background: #ffffff1a; margin: 10px 6px; }
.sidebar .foot { margin-top: auto; font-size: 12px; opacity: .55; padding: 10px 8px 0; }
.backdrop { position: fixed; inset: 0; background: #8c0b1b4d; z-index: 24; display: none; }

.content { margin-left: var(--side); padding: calc(var(--top) + 22px) 26px 40px; min-height: 100vh; transition: margin .22s; }
body.side-collapsed .sidebar { transform: translateX(-100%); }
body.side-collapsed .content { margin-left: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; margin: 0; color: var(--navy-800); }
.page-head .crumb { color: var(--muted); font-size: 13.5px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; border: 1px solid #efe2e3; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card h2 { font-size: 17px; margin: 0; color: var(--navy-800); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 240px; }
.toolbar .end { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Dashboard ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat { border-radius: var(--radius); padding: 18px; color: #fff; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: #ffffff17; }
.stat .ic { width: 54px; height: 54px; border-radius: 50%; background: #ffffff2e; display: grid; place-items: center; flex: none; }
.stat .ic svg { width: 30px; height: 30px; }
.stat .k { font-size: 15px; opacity: .95; }
.stat .v { font-size: 28px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 16px; font-weight: 500; margin-left: 4px; }
.stat.blue { background: linear-gradient(135deg, #e3192f, #a00d1f); }
.stat.green { background: linear-gradient(135deg, #2b2b2b, #0d0d0d); }
.stat.orange { background: linear-gradient(135deg, #8c0b1b, #4a0510); }
.stat.red { background: linear-gradient(135deg, #ff4d5e, #d4142e); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; }
.dash-grid .card { margin-bottom: 0; }
.legend { display: flex; gap: 14px; font-size: 13.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); fill: #7a6668; font-size: 12px; }
.chart .pt { cursor: pointer; }
.chart-tip { position: fixed; pointer-events: none; background: var(--navy-800); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 13px; z-index: 50; display: none; white-space: nowrap; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.recent li:last-child { border-bottom: 0; }
.recent .nm { flex: 1; min-width: 0; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .nm small { display: block; color: var(--muted); font-size: 12px; }
.recent .tm { font-variant-numeric: tabular-nums; font-weight: 500; font-size: 14px; }
.av-sm { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; background: var(--blue-soft); }
.notice { display: flex; gap: 12px; align-items: flex-start; }
.notice .chat { width: 42px; height: 42px; border-radius: 11px; background: #06c755; color: #fff; display: grid; place-items: center; flex: none; }
.notice .bubble { background: #f8f1f1; border-radius: 4px 14px 14px 14px; padding: 10px 12px; font-size: 14px; white-space: pre-line; flex: 1; }
.notice .bubble b { display: block; margin-bottom: 2px; }
.mini-list { margin: 10px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
.mini-list li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed var(--line); }

/* ===== ตาราง ===== */
.tbl-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { background: #fbf1f2; color: var(--navy-800); font-weight: 600; text-align: left; padding: 11px 14px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #fffafa; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .c { text-align: center; }
.tbl .actions { display: flex; gap: 6px; justify-content: center; }
.tbl .empty { text-align: center; color: var(--muted); padding: 30px; }
.thumb { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: var(--blue-soft); display: block; margin: 0 auto; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; font-size: 14px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager button { min-width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer; padding: 0 8px; }
.pager button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.pager button:disabled { opacity: .45; cursor: default; }

/* แท็บ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 16px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); }

/* ===== รายงาน ===== */
.report-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.rtile { background: #fff; border: 1px solid #f0dfe1; border-radius: var(--radius); padding: 22px 12px 18px; text-align: center; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s; font-weight: 500; color: var(--navy-800); }
.rtile:hover { transform: translateY(-3px); box-shadow: 0 12px 26px #8c0b1b22; }
.rtile .ico { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 16px; display: grid; place-items: center; color: #fff; }
.rtile .ico svg { width: 36px; height: 36px; }
.rtile.on { outline: 3px solid var(--blue); }
.bar { height: 10px; background: #f4e8e9; border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.print-head { display: none; }

/* ===== กล่องโต้ตอบ ===== */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(560px, 94vw); max-height: 92vh; box-shadow: 0 30px 80px #8c0b1b55; }
dialog.modal::backdrop { background: #8c0b1b66; backdrop-filter: blur(2px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); background: #fff7f7; }
.modal-head h3 { margin: 0; font-size: 18px; color: var(--navy-800); }
.modal-body { padding: 18px 20px; overflow-y: auto; max-height: calc(92vh - 140px); }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .right { display: flex; gap: 8px; margin-left: auto; }
.photo-edit { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 8px; }
.photo-edit img { width: 104px; height: 130px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--blue-soft); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--navy-800); color: #fff; padding: 11px 20px; border-radius: 12px;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 99; box-shadow: 0 10px 30px #0004; max-width: 92vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 90; color: var(--navy-800); text-align: center; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--blue-soft); border-top-color: var(--blue); animation: spin 0.8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.set-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .lbl { width: 200px; flex: none; color: var(--ink); font-weight: 500; }
.set-row .lbl small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.set-row .val { flex: 1; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.set-row .val input:not([type=checkbox]):not([type=file]), .set-row .val select { max-width: 320px; width: 100%; }
code.link { display: block; background: #f6efef; padding: 6px 9px; border-radius: 8px; font-size: 12px; word-break: break-all; margin-top: 4px; }

/* ===== หน้าสแกน ===== */
body.scan { background: radial-gradient(ellipse at 50% 35%, #6e0712 0%, #4a0510 60%, #0a0203 100%); color: #fff; min-height: 100vh; min-height: 100dvh; overflow: hidden; }
.scan-top { position: fixed; top: 0; left: 0; right: 0; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 16px; z-index: 6;
  background: linear-gradient(90deg, #2a040aee, #8c0b1bee); border-bottom: 1px solid #ffffff1a; }
.scan-top .mode { font-weight: 600; padding: 7px 16px; border-radius: 999px; border: 0; cursor: pointer; font-size: 15px; color: #fff; }
.scan-top .mode.in { background: var(--green); } .scan-top .mode.out { background: var(--orange); }
.scan-top .mode.auto { cursor: default; display: inline-flex; align-items: center; gap: 8px; }
.scan-top .mode small { font-size: 11.5px; font-weight: 600; background: #ffffff33; padding: 1px 8px; border-radius: 999px; }
.scan-top .tbtn { border: 0; background: #ffffff1a; color: #fff; border-radius: 10px; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; flex: none; }
.scan-top .tbtn:hover { background: #ffffff33; }
.scan-top .meta { font-size: 14px; opacity: .85; text-align: right; white-space: nowrap; }
.scan-top .meta b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; opacity: 1; }
.scan-main { position: fixed; inset: 64px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4vh; padding: 16px; }
.stage { position: relative; width: min(94vw, 960px, calc((100dvh - 290px) * 16 / 9)); aspect-ratio: 16 / 9; border-radius: 22px; overflow: hidden;
  background: #1a0508; box-shadow: 0 0 0 1px #ff334733, 0 20px 60px #0008; }
.stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage video.mirror { transform: scaleX(-1); }
.stage .shade { position: absolute; inset: 0; pointer-events: none; }
.frame { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 16px; box-shadow: 0 0 0 200vmax #12030680; transition: box-shadow .2s; }
.frame i { position: absolute; width: 54px; height: 54px; border: 6px solid var(--cyan); filter: drop-shadow(0 0 8px #ff3347cc); transition: border-color .2s; }
.frame i:nth-child(1) { left: -6px; top: -6px; border-right: 0; border-bottom: 0; border-top-left-radius: 18px; }
.frame i:nth-child(2) { right: -6px; top: -6px; border-left: 0; border-bottom: 0; border-top-right-radius: 18px; }
.frame i:nth-child(3) { left: -6px; bottom: -6px; border-right: 0; border-top: 0; border-bottom-left-radius: 18px; }
.frame i:nth-child(4) { right: -6px; bottom: -6px; border-left: 0; border-top: 0; border-bottom-right-radius: 18px; }
.frame .laser { position: absolute; left: 6%; right: 6%; height: 3px; top: 10%; background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 14px var(--cyan); animation: laser 2.2s ease-in-out infinite; opacity: .85; }
@keyframes laser { 50% { top: 88%; } }
.frame .idle-ico { position: absolute; inset: 0; display: grid; place-items: center; color: #ffffffd9; }
.frame .idle-ico svg { width: 26%; height: auto; filter: drop-shadow(0 0 10px #ff334799); }
.frame.detect i { border-color: #ffffff; filter: drop-shadow(0 0 8px #ffffffcc); }
.frame.busy i { border-color: #ffb3bc; animation: pulse 0.9s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.scan-msg { text-align: center; }
.scan-msg .big { font-size: clamp(22px, 3.2vw, 34px); font-weight: 600; line-height: 1.35; text-shadow: 0 2px 10px #0008; }
.scan-msg .small { margin-top: 6px; font-size: clamp(15px, 1.8vw, 19px); color: #ffb3bc; }
.scan-msg .dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.scan-now { background: linear-gradient(135deg, #ff3347, #d4142e); color: #fff; border: 0; border-radius: 999px; padding: 12px 34px; font-size: 18px; font-weight: 600;
  cursor: pointer; box-shadow: 0 8px 24px #d4142e80; display: inline-flex; gap: 8px; align-items: center; }
.result { position: fixed; inset: 0; z-index: 8; display: none; align-items: center; justify-content: center; padding: 18px; background: #120306cc; backdrop-filter: blur(4px); }
.result.show { display: flex; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.result-card { width: min(420px, 100%); background: #fff; color: var(--ink); border-radius: 26px; padding: 22px 22px 26px; text-align: center; box-shadow: 0 30px 80px #0009;
  animation: pop .22s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.result-card .badge { display: flex; align-items: center; justify-content: center; gap: 8px; color: #fff; border-radius: 12px; padding: 10px; font-size: 20px; font-weight: 600; }
.result.pass .badge { background: var(--green); } .result.fail .badge { background: var(--red); }
.result-card .photo { width: 150px; height: 150px; border-radius: 50%; object-fit: cover; margin: 18px auto 10px; display: block; border: 5px solid #fdeaec; background: var(--blue-soft); }
.result.pass .photo { border-color: #c9efd6; }
.result-card .fail-ico { width: 130px; height: 130px; border-radius: 50%; margin: 18px auto 10px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.result-card .fail-ico svg { width: 70px; height: 70px; }
.result-card .nm { font-size: 26px; font-weight: 600; color: var(--navy-800); line-height: 1.3; }
.result-card .cls { font-size: 18px; color: var(--muted); margin-top: 2px; }
.result-card .mode-l { font-size: 15px; margin-top: 8px; font-weight: 500; }
.result-card .time { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; font-size: 40px; font-weight: 700; color: var(--navy-800); font-variant-numeric: tabular-nums; }
.result-card .time .ck { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.result.pass .time .ck { background: var(--green); } .result.fail .time .ck { background: var(--red); }
.result-card .date { color: var(--muted); font-size: 15px; }
.nocam { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 20px; background: #1a0508; z-index: 3; }
.nocam.show { display: flex; }
.setup { position: fixed; inset: 0; z-index: 10; background: radial-gradient(ellipse at 50% 20%, #6e0712, #4a0510 70%); overflow: auto; display: none; padding: 20px 14px; }
.setup.show { display: block; }
.setup-card { max-width: 520px; margin: 3vh auto; background: #fff; color: var(--ink); border-radius: 22px; padding: 24px 22px; box-shadow: 0 30px 80px #0007; }
.setup-card .hd { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.setup-card .hd img { width: 56px; }
.setup-card h1 { font-size: 21px; margin: 0; color: var(--navy-800); }
.setup-card label { color: var(--ink); font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg button { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 15px 10px; font-size: 18px; cursor: pointer; font-weight: 500; }
.seg button.on { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.setup select { width: 100%; font-size: 16px; padding: 11px; }
.cam-preview { width: 100%; aspect-ratio: 16 / 9; max-height: 26vh; background: #1a0508; border-radius: 12px; object-fit: cover; display: block; margin-top: 10px; }
.cam-preview.mirror { transform: scaleX(-1); }
.err { background: var(--red-soft); color: #b42318; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }

/* ===== จอเล็ก ===== */
@media (max-width: 1180px) {
  .stats, .report-tiles { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: 10px 0 30px #0004; }
  body.side-open .sidebar { transform: none; }
  body.side-open .backdrop { display: block; }
  .content, body.side-collapsed .content { margin-left: 0; padding: calc(var(--top) + 16px) 14px 30px; }
  .top-clock { display: none; }
  .motto { display: none; }
}
@media (max-width: 640px) {
  :root { --top: 58px; }
  .brand .name { font-size: 15px; }
  .brand .name small { display: none; }
  .brand .logo-wrap { width: 40px; height: 40px; } .brand .logo-wrap img { width: 36px; height: 36px; }
  .user-btn .who { display: none; }
  .page-head h1 { font-size: 20px; }
  .stats { gap: 10px; }
  .stat { padding: 14px 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .stat .ic { width: 42px; height: 42px; } .stat .ic svg { width: 24px; height: 24px; }
  .stat .v { font-size: 23px; } .stat .k { font-size: 13.5px; }
  .card { padding: 14px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .report-tiles { gap: 10px; }
  .set-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .set-row .lbl { width: auto; }
  .toolbar .end { margin-left: 0; }
  .toolbar > * { flex: 1 1 auto; }
  /* ตารางแบบการ์ดบนมือถือ */
  table.rt thead { display: none; }
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt tr { padding: 10px 12px; border-bottom: 1px solid var(--line); position: relative; }
  table.rt td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.rt td::before { content: attr(data-l); color: var(--muted); font-size: 13px; text-align: left; flex: none; }
  table.rt td.c, table.rt td.num { text-align: right; }
  table.rt td .thumb { margin: 0; }
  table.rt td .actions { justify-content: flex-end; }
  table.rt td.empty { display: block; text-align: center; }
  table.rt td.empty::before { content: none; }
  .scan-top .meta span { display: none; }
  .scan-top .sname { display: none; }
  .stage { width: 96vw; aspect-ratio: 3 / 4; max-height: calc(100dvh - 300px); }
}
@media (max-width: 640px) and (orientation: landscape) {
  .stage { aspect-ratio: 16 / 9; width: auto; height: calc(100dvh - 170px); }
}

/* ===== พิมพ์ / PDF ===== */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  .topbar, .sidebar, .backdrop, .no-print, .toast, .report-tiles, .toolbar { display: none !important; }
  .content { margin: 0; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 14px; }
  .print-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--navy-800); padding-bottom: 10px; margin-bottom: 14px; }
  .print-head img { width: 64px; }
  .print-head h2 { margin: 0; font-size: 20px; }
  .tbl-wrap { border: 0; overflow: visible; }
  .tbl th { background: #f6f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bar i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page-head .btn { display: none; }
}

/* ===== ธีมแดง-ขาว ดุดัน ===== */
.topbar { background: linear-gradient(100deg, #1a0306 0%, #6e0712 38%, #c8102e 100%); border-bottom: 3px solid #ff3347; }
.topbar::after, .scan-top::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(115deg, transparent 0 26px, #ffffff0c 26px 34px); }
.topbar > *, .scan-top > * { position: relative; z-index: 1; }
.sidebar { background: linear-gradient(180deg, #a50d1f, #6e0712 70%, #3d040b); color: #ffe1e5; }
.sidebar .nav-item.on { background: #fff; color: #c8102e; font-weight: 700; box-shadow: 0 6px 16px #0004; }
.sidebar .nav-item.on svg { color: #c8102e; }
.sidebar .scan-cta { background: #fff; color: #c8102e; font-weight: 700; border: 2px solid #fff; }
.sidebar .scan-cta:hover { background: #1a0306; color: #fff; border-color: #ff3347; filter: none; }
.sidebar .nav-item .badge { background: #fff; color: #c8102e; }
.page-head h1 { font-weight: 700; letter-spacing: -.2px; position: relative; padding-left: 14px; }
.page-head h1::before { content: ''; position: absolute; left: 0; top: 12%; bottom: 12%; width: 5px; border-radius: 3px; background: linear-gradient(#ff3347, #8c0b1b); }
.card { border-top: 3px solid #d4142e; }
.stats .stat, .report-tiles .rtile { border-top: 0; }
.stat { box-shadow: 0 10px 24px #8c0b1b33; }
.stat::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, transparent 0 22px, #ffffff0a 22px 30px); pointer-events: none; }
.btn.primary, .btn.navy { box-shadow: 0 4px 12px #d4142e40; font-weight: 600; }
.btn.navy { background: linear-gradient(180deg, #e3192f, #a00d1f); border-color: #a00d1f; }
.tbl th { background: #1d0f11; color: #fff; }
.tbl th:first-child { border-top-left-radius: 11px; } .tbl th:last-child { border-top-right-radius: 11px; }
.pager button.on { box-shadow: 0 4px 10px #d4142e55; }
.login-page::after { background: linear-gradient(160deg, #fff6f670 0%, #fde3e640 45%, #8c0b1b80 100%); }
.login-card { border-top: 6px solid #d4142e; }
.login-card h1 { color: #b80f25; font-weight: 700; }
.motto { color: #8c0b1b; }
body.scan { background: radial-gradient(ellipse at 50% 30%, #5a0610 0%, #1f0307 55%, #0a0203 100%); }
.scan-top { background: linear-gradient(100deg, #1a0306, #8c0b1b 60%, #c8102e); border-bottom: 3px solid #ff3347; }
.frame i { border-color: #fff; filter: drop-shadow(0 0 10px #ff3347); }
.frame.detect i { border-color: #ff3347; filter: drop-shadow(0 0 12px #ff3347); }
.scan-now { background: linear-gradient(135deg, #ff3347, #a00d1f); box-shadow: 0 8px 24px #d4142e80; }
.setup { background: radial-gradient(ellipse at 50% 20%, #6e0712, #1a0306 70%); }
.setup-card { border-top: 6px solid #d4142e; }
.class-info { display: flex; gap: 12px; align-items: center; background: #fdeaec; border-left: 5px solid #d4142e; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; color: #1d0f11; }
.class-info svg { width: 28px; height: 28px; color: #d4142e; }
@media print { .tbl th { background: #eee !important; color: #000; } .card { border-top: 0; } }

/* =====================================================================
   โครงหน้าแบบภาพออกแบบที่ 2: ส่วนหัวใหญ่ + เมนูขาวพับได้ + แถบล่างสีแดง
   ===================================================================== */
body.app { background: linear-gradient(180deg, #fff 0, #fbf3f4 320px, #f8f1f2); padding-bottom: 52px; }
.hero { position: relative; height: 190px; display: flex; align-items: center; gap: 22px; padding: 0 28px; overflow: hidden; background: #fff; border-bottom: 1px solid #f3d6da; }
.hero::before { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 54%; background: url(../assets/building.jpg) center 62% / cover no-repeat;
  filter: contrast(1.08) saturate(1.15);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18%); mask-image: linear-gradient(90deg, transparent 0, #000 18%); }
.hero::after { content: ''; position: absolute; left: -70px; top: -52px; width: 300px; height: 80px; background: linear-gradient(90deg, #c8102e, #ff3347); transform: rotate(-20deg); }
.hero > * { position: relative; z-index: 1; }
.hero-logo { width: 118px; height: auto; flex: none; }
.hero-title { border-left: 4px solid #c8102e; padding-left: 22px; min-width: 0; text-shadow: 0 0 10px #fff, 0 0 4px #fff, 0 0 2px #fff; }
.hero-title h1 { margin: 0; font-size: 40px; font-weight: 700; color: #4a0510; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-title p { margin: 4px 0 0; font-size: 19px; color: #1d0f11; font-weight: 500; }
.hero .user-menu { margin-left: auto; align-self: flex-end; margin-bottom: 14px; }
.hero .user-btn { background: #fff; color: #1d0f11; box-shadow: 0 6px 18px #0002; border-radius: 14px; padding: 8px 14px; }
.hero .user-btn:hover { background: #fff5f6; }
.hero .user-btn .av { background: #fdeaec; color: #c8102e; }
.hero .burger { display: none; color: #c8102e; background: #fff; box-shadow: 0 4px 12px #0002; }

.layout { display: grid; grid-template-columns: 252px minmax(0, 1fr); gap: 20px; padding: 18px 22px 24px; align-items: start; }
.main-area { min-width: 0; }
.side { position: sticky; top: 12px; max-height: calc(100vh - 76px); overflow-y: auto; background: #fff; border: 1px solid #f3d6da; border-radius: 18px;
  padding: 14px 12px; box-shadow: 0 10px 30px #8c0b1b14; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; scrollbar-color: #f0a3ad transparent; }
.nav-main { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; color: #1d0f11; font-weight: 600; font-size: 16px; }
.nav-main svg { width: 22px; height: 22px; }
.nav-main.on, .nav-main:hover { background: linear-gradient(90deg, #c8102e, #e8253c); color: #fff; box-shadow: 0 6px 16px #c8102e44; }
.nav-sec { margin-top: 4px; }
.sec-head { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: none; padding: 10px 6px; font-weight: 700; font-size: 15px; color: #1d0f11; cursor: pointer; border-radius: 10px; }
.sec-head:hover { background: #fff5f6; }
.sec-head > svg:first-child { color: #c8102e; }
.sec-head > svg:last-child { margin-left: auto; transition: transform .2s; color: #7a6668; }
.nav-sec.open > .sec-head > svg:last-child { transform: rotate(180deg); }
.nav-sec:not(.open) > .sec-body { display: none; }
.sec-body { display: flex; flex-direction: column; gap: 5px; padding: 2px 0 6px; }
.grade-head { display: flex; width: 100%; align-items: center; gap: 8px; border: 1px solid #f3d6da; background: #fffafa; border-radius: 10px; padding: 8px 12px;
  cursor: pointer; font-weight: 600; color: #4a0510; text-align: left; }
.grade-head small { color: #7a6668; font-weight: 400; margin-left: auto; font-size: 12.5px; }
.grade-head svg { width: 16px; height: 16px; transition: transform .2s; color: #7a6668; }
.grade.open .grade-head { background: #fdeaec; border-color: #f3c3c9; }
.grade.open .grade-head svg { transform: rotate(180deg); }
.grade:not(.open) .grade-rooms { display: none; }
.grade-rooms { display: flex; flex-direction: column; gap: 4px; padding: 5px 0 4px 10px; }
.room-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border: 1px solid #f0e2e3; border-radius: 10px; color: #1d0f11; font-size: 14.5px; background: #fff; box-shadow: 0 1px 2px #0000000a; }
.room-item svg { width: 18px; height: 18px; }
.room-item small { margin-left: auto; color: #7a6668; font-size: 12px; }
.room-item:hover { border-color: #e8253c; color: #c8102e; }
.room-item.on { background: #c8102e; color: #fff; border-color: #c8102e; }
.room-item.on small { color: #fff; }
.room-all { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: #f2eeee; color: #1d0f11; font-size: 14.5px; font-weight: 500; margin-top: 2px; }
.room-all.on, .room-all:hover { background: #fdeaec; color: #c8102e; }
.side .nav-item { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 10px; color: #1d0f11; font-size: 15px; }
.side .nav-item i { width: 30px; height: 30px; border-radius: 50%; background: #fdeaec; color: #c8102e; display: grid; place-items: center; flex: none; }
.side .nav-item i svg { width: 17px; height: 17px; }
.side .nav-item:hover { background: #fff3f4; color: #c8102e; }
.side .nav-item.on { background: #fdeaec; color: #c8102e; font-weight: 600; }
.side .nav-item .badge { margin-left: auto; background: #c8102e; color: #fff; border-radius: 99px; font-size: 12px; padding: 0 8px; font-weight: 600; }
.nav-logout { margin: 10px auto 4px; display: flex; align-items: center; gap: 10px; justify-content: center; width: 86%; padding: 10px; border: 1px solid #f3c3c9;
  background: #fff5f6; color: #1d0f11; border-radius: 12px; cursor: pointer; font-weight: 500; }
.nav-logout svg { color: #c8102e; }
.nav-logout:hover { background: #c8102e; color: #fff; }
.nav-logout:hover svg { color: #fff; }
.side-art { width: 100%; margin-top: 6px; }

.footbar { position: fixed; left: 0; right: 0; bottom: 0; height: 46px; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 0 34px;
  color: #fff; background: linear-gradient(100deg, #8c0b1b, #c8102e 40%, #e8253c); font-size: 16px; overflow: hidden; }
.footbar::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, transparent 0 40px, #ffffff12 40px 52px); pointer-events: none; }
.footbar > * { position: relative; }
.motto-f { font-weight: 600; font-size: 19px; }
.date-f { display: flex; align-items: center; gap: 8px; }
.date-f .sep { opacity: .6; margin: 0 4px; }

/* หัวข้อหน้าแบบริบบิ้นสีแดง */
.page-head h1.ribbon { display: inline-flex; align-items: center; gap: 12px; margin: 0; padding: 10px 52px 10px 18px; color: #fff; font-size: 21px; font-weight: 700;
  background: linear-gradient(90deg, #b80f25, #e8253c); clip-path: polygon(0 0, calc(100% - 28px) 0, 100% 100%, 0 100%); border-radius: 12px 0 0 12px; }
.page-head h1.ribbon::before { display: none; }
.page-head h1.ribbon svg { width: 26px; height: 26px; }

/* การ์ดและตารางโทนขาว-แดงอ่อนตามภาพ */
.card { border: 1px solid #f3d6da; border-top: 1px solid #f3d6da; border-radius: 16px; box-shadow: 0 8px 24px #8c0b1b12; }
.card-head h2 { display: flex; align-items: center; gap: 8px; color: #1d0f11; }
.card-head h2 svg { color: #c8102e; width: 22px; height: 22px; }
.tbl th { background: #fdeaec; color: #4a0510; }
.card.rb { padding: 0; overflow: hidden; }
.rb-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: #fff; font-weight: 700; font-size: 17px;
  background: linear-gradient(110deg, #b80f25 0, #e8253c 60%, #fff 60.4%); }
.rb-head svg { width: 22px; height: 22px; flex: none; }
.rb-head > span { white-space: nowrap; }
.rb-head a, .rb-head .rb-meta { margin-left: auto; color: #c8102e; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.rb-head a svg { width: 16px; height: 16px; }
.rb-head select { margin-left: auto; padding: 5px 10px; border-radius: 8px; font-size: 14px; color: #1d0f11; }
.rb-body { padding: 14px 16px; }

/* การ์ดสถิติแบบสีอ่อน */
.stat { color: #1d0f11; border: 1px solid; box-shadow: 0 6px 16px #0000000d; padding: 14px; }
.stat::after, .stat::before { display: none; }
.stat .ic { width: 58px; height: 58px; border-radius: 14px; color: #fff; box-shadow: 0 6px 14px #0002; }
.stat .k { font-weight: 600; font-size: 14.5px; }
.stat .v { font-size: 26px; }
.stat.blue { background: linear-gradient(135deg, #eaf1ff, #fff); border-color: #cfe0ff; } .stat.blue .ic { background: linear-gradient(135deg, #3b82f6, #1d4ed8); } .stat.blue .k { color: #1d4ed8; }
.stat.green { background: linear-gradient(135deg, #e9fbf0, #fff); border-color: #c6f0d6; } .stat.green .ic { background: linear-gradient(135deg, #22c55e, #15803d); } .stat.green .k { color: #15803d; }
.stat.orange { background: linear-gradient(135deg, #fff4e5, #fff); border-color: #ffdcab; } .stat.orange .ic { background: linear-gradient(135deg, #fb923c, #ea580c); } .stat.orange .k { color: #c2410c; }
.stat.red { background: linear-gradient(135deg, #fff0f1, #fff); border-color: #f9c9cf; } .stat.red .ic { background: linear-gradient(135deg, #f43f5e, #c8102e); } .stat.red .k { color: #c8102e; }

/* หน้าหลัก */
.dash2 { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr) 320px;
  grid-template-areas: "stats stats scan" "chart recent scan" "rooms table hist"; }
.dash2 .card { margin: 0; }
.d-stats { grid-area: stats; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.d-scan { grid-area: scan; } .d-chart { grid-area: chart; } .d-recent { grid-area: recent; }
.d-rooms { grid-area: rooms; } .d-table { grid-area: table; } .d-hist { grid-area: hist; }
.d-scan { display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: linear-gradient(160deg, #e8253c, #8c0b1b); box-shadow: 0 14px 30px #c8102e40; color: #fff; padding: 0 12px 12px; }
.d-scan .rb-head { background: none; padding: 14px 4px; font-size: 19px; }
.scan-prev { position: relative; flex: 1; min-height: 230px; border-radius: 14px; overflow: hidden; background: url(../assets/hero-building.jpg) center / cover;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.scan-prev::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, #2a040a26, #2a040a66); }
.scan-prev > * { position: relative; }
.scan-prev .cam svg { width: 74px; height: 74px; filter: drop-shadow(0 2px 6px #0008); }
.scan-prev p { margin: 0; font-size: 18px; font-weight: 600; text-shadow: 0 2px 6px #000a; line-height: 1.5; }
.scan-prev i { position: absolute; width: 38px; height: 38px; border: 5px solid #fff; z-index: 1; }
.scan-prev i:nth-child(1) { left: 14px; top: 14px; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.scan-prev i:nth-child(2) { right: 14px; top: 14px; border-left: 0; border-bottom: 0; border-top-right-radius: 12px; }
.scan-prev i:nth-child(3) { left: 14px; bottom: 14px; border-right: 0; border-top: 0; border-bottom-left-radius: 12px; }
.scan-prev i:nth-child(4) { right: 14px; bottom: 14px; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }
.d-scan .go { margin-top: 10px; background: #fff; color: #c8102e; font-weight: 700; border-radius: 12px; padding: 10px; display: flex; justify-content: center; align-items: center; gap: 4px; }
.d-scan:hover .go { background: #1d0f11; color: #fff; }
.grade-sel { width: 100%; margin-bottom: 12px; }
.room-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.room-btn { border: 1.5px solid #f0a3ad; border-radius: 10px; padding: 9px 6px; text-align: center; color: #1d0f11; font-weight: 600; background: #fff; }
.room-btn:hover { background: #c8102e; color: #fff; border-color: #c8102e; }
.tbl.compact th, .tbl.compact td { padding: 7px 12px; }
.tbl.compact th { position: sticky; top: 0; }

/* ห้องเรียน */
.room-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.room-tile { display: flex; flex-direction: column; gap: 4px; border: 1.5px solid #f3d6da; border-radius: 14px; padding: 12px 14px; color: #1d0f11; background: #fff; transition: .15s; }
.room-tile:hover { border-color: #c8102e; box-shadow: 0 8px 18px #c8102e22; transform: translateY(-2px); }
.room-tile > b { font-size: 20px; color: #c8102e; }
.room-tile .prog { color: #7a6668; }
.room-tile .cnt { font-size: 14px; }
.bar i { background: linear-gradient(90deg, #e8253c, #c8102e); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.chip { border: 1.5px solid #f3d6da; background: #fff; border-radius: 99px; padding: 6px 14px; cursor: pointer; }
.chip.on { background: #c8102e; color: #fff; border-color: #c8102e; }
a.btn[aria-disabled="true"] { opacity: .5; }

@media (max-width: 1320px) {
  .dash2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "stats stats" "chart recent" "scan rooms" "table hist"; }
  .hero-title h1 { font-size: 32px; }
}
@media (max-width: 1000px) {
  .d-stats { grid-template-columns: repeat(2, 1fr); }
  .dash2 { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stats" "scan" "chart" "recent" "rooms" "table" "hist"; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 290px; max-height: none; border-radius: 0 18px 18px 0; z-index: 40; transform: translateX(-105%); transition: transform .22s; }
  body.side-open .side { transform: none; }
  body.side-open .backdrop { display: block; z-index: 35; }
  .hero .burger { display: grid; }
  .hero { height: 112px; gap: 12px; padding: 0 14px; }
  .hero::before { width: 72%; opacity: 1; background-position: center 60%; }
  .hero::after { width: 160px; height: 50px; top: -34px; left: -50px; }
  .hero-logo { width: 64px; }
  .hero-title { padding-left: 12px; }
  .hero-title h1 { font-size: 22px; }
  .hero-title p { font-size: 12.5px; }
  .footbar { position: static; height: auto; padding: 10px 14px; flex-direction: column; gap: 2px; font-size: 14px; }
  .motto-f { font-size: 16px; }
  body.app { padding-bottom: 0; }
}
@media (max-width: 640px) {
  .hero { height: 92px; }
  .hero-title p { display: none; }
  .hero .user-btn .who { display: none; }
  .hero .user-menu { align-self: center; margin-bottom: 0; }
  .hero .user-btn { padding: 4px 6px; }
  .hero-logo { width: 48px; }
  .hero-title { border-left-width: 3px; padding-left: 10px; }
  .hero-title h1 { font-size: 17px; }
  .page-head h1.ribbon { font-size: 17px; padding: 8px 40px 8px 14px; }
  .room-btns { grid-template-columns: repeat(2, 1fr); }
  .rb-head { font-size: 15px; background: linear-gradient(110deg, #b80f25 0, #e8253c 66%, #fff 66.4%); }
}
@media print {
  .hero, .side, .footbar, .chips, .backdrop { display: none !important; }
  .layout { display: block; padding: 0; }
  body.app { padding: 0; background: #fff; }
}

/* หัวการ์ดริบบิ้น: ส่วนแดงยาวตามชื่อหัวข้อ */
.rb-head { background: #fff; padding: 0 14px 0 0; border-bottom: 1px solid #f3d6da; min-height: 50px; }
.rb-t { display: flex; align-items: center; gap: 10px; align-self: stretch; padding: 12px 44px 12px 16px; color: #fff; min-width: 0;
  background: linear-gradient(100deg, #b80f25, #e8253c); clip-path: polygon(0 0, calc(100% - 26px) 0, 100% 100%, 0 100%); }
.rb-t > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-scan .rb-head { border: 0; min-height: 0; background: none; padding: 0; }
.d-scan .rb-t { background: none; clip-path: none; padding: 14px 4px; }
.tbl.compact { font-size: 14px; }
.tbl.compact th, .tbl.compact td { padding: 7px 8px; }
@media (max-width: 640px) { .rb-head { background: #fff; } .rb-t { padding-right: 36px; } }

/* มาสายจากวินัยสมาร์ท */
.late-sum { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.late-sum > span:first-child { font-size: 22px; color: #c8102e; }
#winaiSet code { background: #fdeaec; padding: 1px 6px; border-radius: 6px; color: #8c0b1b; }

/* พิมพ์บัตรนักเรียน */
.cards-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; align-items: start; }
.cards-grid .card { margin-bottom: 18px; }
.card-list { display: flex; flex-direction: column; gap: 4px; max-height: 62vh; overflow-y: auto; }
.card-pick { display: flex; gap: 10px; align-items: center; text-align: left; border: 1px solid transparent; background: none; border-radius: 10px; padding: 6px 8px; cursor: pointer; }
.card-pick small { display: block; color: var(--muted); font-size: 12px; }
.card-pick:hover { background: #fff5f6; }
.card-pick.on { background: #fdeaec; border-color: #f3c3c9; color: #8c0b1b; font-weight: 600; }
.card-previews { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-previews figure { margin: 0; text-align: center; }
.card-previews canvas { width: 100%; height: auto; border-radius: 14px; box-shadow: 0 10px 26px #3a061026, 0 0 0 1px #f0dfe1; }
.card-previews figcaption { margin-top: 6px; color: var(--muted); font-size: 14px; }
.print-sheet { display: none; }
@media (max-width: 1100px) { .cards-grid, .card-previews { grid-template-columns: minmax(0, 1fr); } .card-list { max-height: 260px; } }
@media print {
  body.printing-cards > *:not(.layout) { display: none !important; }
  body.printing-cards .layout > *:not(.main-area), body.printing-cards .main-area > *:not(.print-sheet) { display: none !important; }
  body.printing-cards .print-sheet { display: block !important; }
  .print-note { font-size: 9pt; color: #666; margin-bottom: 4mm; }
  .print-cards { display: grid; grid-template-columns: repeat(2, 85.6mm); grid-auto-rows: 54mm; gap: 4mm 6mm; justify-content: center; }
  .print-cards img { width: 85.6mm; height: 54mm; outline: 0.2mm dashed #bbb; break-inside: avoid; }
}

/* ===== ระบบมาสาย ===== */
.seg-tabs { display: inline-flex; background: #f6eeef; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 10px; }
.seg-tabs button { border: 0; background: none; padding: 8px 22px; border-radius: 9px; cursor: pointer; font-weight: 600; color: #6b5a5c; }
.seg-tabs button.on { background: #c8102e; color: #fff; box-shadow: 0 4px 10px #c8102e44; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.late-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.late-row { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid #f0e2e3; border-radius: 12px; background: #fff; }
.late-row .no { width: 26px; text-align: center; color: #7a6668; font-variant-numeric: tabular-nums; }
.late-row .nm { flex: 1; min-width: 0; }
.late-row .nm small { display: block; color: #7a6668; font-size: 12.5px; }
.late-row .tm { font-variant-numeric: tabular-nums; color: #7a6668; font-size: 14px; }
.late-row.done { background: #fff7f7; border-color: #f3c3c9; }
.late-row .btn.danger { min-width: 92px; }
.late-who { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.late-who img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: #fdeaec; }
.late-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.late-type { border: 2px solid #eadede; background: #fff; border-radius: 12px; padding: 12px 8px; cursor: pointer; text-align: center; }
.late-type b { display: block; font-size: 16px; }
.late-type small { color: #7a6668; font-size: 12px; }
.late-type.warn.on { border-color: #f59e0b; background: #fff7e6; }
.late-type.bad.on { border-color: #c8102e; background: #fdeaec; }
.late-type.blue.on { border-color: #2563eb; background: #eef4ff; }
@media (max-width: 640px) {
  .late-types { grid-template-columns: 1fr; }
  .late-row { flex-wrap: wrap; }
  .late-row .nm { flex-basis: calc(100% - 90px); }
}

/* ===== หน้าโหลดเข้า (Splash) ===== */
html.splash-lock, html.splash-lock body { overflow: hidden; }
.splash { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; color: #fff; overflow: hidden;
  background: #0c0306; font-family: inherit; transition: opacity .7s ease, transform .7s ease, filter .7s ease; }
.splash.out { opacity: 0; transform: scale(1.04); filter: blur(6px); pointer-events: none; }
.splash .sp-bg { position: absolute; inset: -30px; background: url(../assets/cover.png) center / cover no-repeat;
  opacity: .38; filter: grayscale(.2) contrast(1.1); animation: sp-pan 14s ease-in-out infinite alternate; }
.splash .sp-grid { position: absolute; inset: 0; opacity: .5;
  background-image: linear-gradient(#ffffff0d 1px, transparent 1px), linear-gradient(90deg, #ffffff0d 1px, transparent 1px);
  background-size: 44px 44px; -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0, transparent 72%); mask-image: radial-gradient(circle at 50% 45%, #000 0, transparent 72%); }
.splash .sp-glow { position: absolute; inset: 0; background:
  radial-gradient(600px 380px at 50% 42%, #c8102e55, transparent 70%),
  radial-gradient(900px 500px at 50% 120%, #c8102e40, transparent 70%),
  linear-gradient(180deg, #0c0306b3, #0c030673 40%, #0c0306e6); }
.splash .sp-sweep { position: absolute; left: 0; right: 0; height: 120px; top: -120px;
  background: linear-gradient(180deg, transparent, #ff334714 60%, #ff334733 98%, #ff6b7a 100%); animation: sp-sweep 3.2s linear infinite; }
/* มุมกรอบ */
.splash .sp-c { position: absolute; width: 34px; height: 34px; border: 2px solid #ffffff59; animation: sp-in .8s ease both .1s; }
.splash .sp-c.tl { left: 22px; top: 22px; border-right: 0; border-bottom: 0; }
.splash .sp-c.tr { right: 22px; top: 22px; border-left: 0; border-bottom: 0; }
.splash .sp-c.bl { left: 22px; bottom: 22px; border-right: 0; border-top: 0; }
.splash .sp-c.br { right: 22px; bottom: 22px; border-left: 0; border-top: 0; }
.splash .sp-top, .splash .sp-bot { position: absolute; left: 70px; right: 70px; display: flex; justify-content: space-between; gap: 16px;
  font: 600 12px/1 ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: .28em; color: #ffffff8c; text-transform: uppercase; animation: sp-in .8s ease both .2s; }
.splash .sp-top { top: 34px; } .splash .sp-bot { bottom: 34px; }
.splash .sp-bot span:first-child { font-family: var(--font); letter-spacing: .06em; font-size: 14px; font-weight: 500; color: #ffffffcc; text-transform: none; }
.splash .sp-bot i { font-style: normal; color: #ff3347; margin: 0 .5em; }
.splash .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ff3347; margin-right: 10px; box-shadow: 0 0 10px #ff3347; animation: sp-blink 1.2s ease-in-out infinite; vertical-align: middle; }
.splash .sp-center { position: relative; width: min(520px, 88vw); text-align: center; }
/* โลโก้ + วงแหวน */
.splash .sp-logo { position: relative; width: 132px; height: 132px; margin: 0 auto 22px; display: grid; place-items: center; animation: sp-pop .9s cubic-bezier(.2, .9, .3, 1.25) both; }
.splash .sp-logo img { position: relative; width: 104px; height: 104px; object-fit: contain; background: #fff; border-radius: 50%; padding: 10px; box-shadow: 0 0 0 4px #c8102e, 0 0 40px #ff334799; }
.splash .ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid #ff334799; animation: sp-ring 2.2s ease-out infinite; }
.splash .ring.r2 { animation-delay: 1.1s; }
.splash .orbit { position: absolute; inset: -14px; border-radius: 50%; border: 1px dashed #ffffff33; animation: sp-spin 6s linear infinite; }
.splash .orbit i { position: absolute; top: -4px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: #fff; box-shadow: 0 0 12px #fff, 0 0 20px #ff3347; }
.splash .sp-name { margin: 0; font-size: clamp(26px, 5.4vw, 44px); font-weight: 700; letter-spacing: .01em; text-shadow: 0 4px 30px #c8102e99; animation: sp-up .8s ease both .25s; }
.splash .sp-en { margin: 6px 0 0; font: 600 11.5px/1.5 ui-monospace, Consolas, monospace; letter-spacing: .22em; text-transform: uppercase; color: #ffffff99; animation: sp-up .8s ease both .35s; }
.splash .sp-sys { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 20px 0 30px; font-size: 18px; font-weight: 600; color: #ffd6db; animation: sp-up .8s ease both .45s; }
.splash .sp-sys span { height: 2px; width: 46px; background: linear-gradient(90deg, transparent, #ff3347); }
.splash .sp-sys span:last-child { transform: scaleX(-1); }
/* แถบโหลด */
.splash .sp-bar { position: relative; height: 6px; border-radius: 99px; background: #ffffff1a; overflow: hidden; animation: sp-up .8s ease both .55s; }
.splash .sp-bar b { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #8c0b1b, #ff3347 70%, #ffb3bc); box-shadow: 0 0 16px #ff3347, 0 0 4px #fff; }
.splash .sp-bar b::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, #ffffff80, transparent); background-size: 60px 100%; background-repeat: no-repeat; animation: sp-shine 1.1s linear infinite; }
.splash .sp-meta { display: flex; justify-content: space-between; margin-top: 12px; font-size: 14px; color: #ffffffb3; animation: sp-up .8s ease both .6s; }
.splash .sp-pct { font: 700 14px ui-monospace, Consolas, monospace; letter-spacing: .12em; color: #fff; }
.splash.done .sp-msg { color: #7dffa8; }
.splash.done .sp-bar b { background: linear-gradient(90deg, #16a34a, #4ade80); box-shadow: 0 0 16px #22c55e; }
.splash.reduce *, .splash.reduce { animation: none !important; transition-duration: .2s !important; }
@keyframes sp-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sp-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes sp-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes sp-ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.55); opacity: 0; } }
@keyframes sp-spin { to { transform: rotate(360deg); } }
@keyframes sp-blink { 50% { opacity: .25; } }
@keyframes sp-sweep { to { top: 100%; } }
@keyframes sp-shine { from { background-position: -60px 0; } to { background-position: calc(100% + 60px) 0; } }
@keyframes sp-pan { from { transform: scale(1.05) translateX(-10px); } to { transform: scale(1.12) translateX(10px); } }
@media (max-width: 640px) {
  .splash .sp-top, .splash .sp-bot { left: 26px; right: 26px; font-size: 10px; letter-spacing: .18em; }
  .splash .sp-top { top: 30px; } .splash .sp-bot { bottom: 30px; flex-direction: column; align-items: center; gap: 8px; }
  .splash .sp-c { width: 24px; height: 24px; } .splash .sp-c.tl, .splash .sp-c.bl { left: 14px; } .splash .sp-c.tr, .splash .sp-c.br { right: 14px; }
  .splash .sp-c.tl, .splash .sp-c.tr { top: 14px; } .splash .sp-c.bl, .splash .sp-c.br { bottom: 14px; }
  .splash .sp-logo { width: 112px; height: 112px; } .splash .sp-logo img { width: 90px; height: 90px; }
  .splash .sp-en { font-size: 9.5px; letter-spacing: .14em; }
  .splash .sp-bot span:first-child { font-size: 13px; letter-spacing: .04em; }
}

/* ===== ปุ่มเปิด/ปิดแบบสวย (fx-toggle) ===== */
.fx-toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.fx-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.fx-toggle .tr { position: relative; width: 92px; height: 40px; border-radius: 99px; background: linear-gradient(180deg, #e7e2e3, #f6f2f3);
  box-shadow: inset 0 2px 6px #0000002e, 0 1px 0 #fff; transition: background .45s ease, box-shadow .45s ease; overflow: hidden; }
.fx-toggle .tr::before, .fx-toggle .tr::after { position: absolute; top: 0; bottom: 0; display: grid; place-items: center; font: 800 12px/1 ui-monospace, Consolas, monospace; letter-spacing: .14em; transition: opacity .35s, transform .45s; }
.fx-toggle .tr::before { content: 'ON'; left: 14px; color: #fff; opacity: 0; transform: translateX(-8px); }
.fx-toggle .tr::after { content: 'OFF'; right: 12px; color: #8a7b7d; }
.fx-toggle .kn { position: absolute; top: 4px; left: 4px; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(180deg, #fff, #f1eded);
  box-shadow: 0 3px 8px #0003, inset 0 -2px 3px #0000000f; display: grid; place-items: center; transition: transform .5s cubic-bezier(.3, 1.5, .5, 1), width .25s; }
.fx-toggle .kn::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: #c9bfc1; transition: background .4s, box-shadow .4s; }
.fx-toggle:active .kn { width: 38px; }
.fx-toggle input:checked + .tr { background: linear-gradient(135deg, #8c0b1b, #e11d34 55%, #ff4d5e); box-shadow: inset 0 2px 6px #0000004d, 0 0 0 4px #c8102e1f, 0 6px 18px #c8102e66; }
.fx-toggle input:checked + .tr::before { opacity: 1; transform: none; }
.fx-toggle input:checked + .tr::after { opacity: 0; transform: translateX(8px); }
.fx-toggle input:checked + .tr .kn { transform: translateX(52px); }
.fx-toggle input:checked:active + .tr .kn { transform: translateX(46px); }
.fx-toggle input:checked + .tr .kn::before { background: #ff3347; box-shadow: 0 0 8px #ff3347, 0 0 2px #ff3347; }
.fx-toggle input:focus-visible + .tr { outline: 3px solid #c8102e66; outline-offset: 3px; }
.fx-toggle .lb { margin-left: 12px; font-weight: 600; color: #6b5a5c; transition: color .3s; }
.fx-toggle input:checked ~ .lb { color: #c8102e; }
.splash-set { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.splash-thumb { position: relative; width: 210px; height: 118px; border-radius: 14px; overflow: hidden; background: #0c0306; flex: none;
  box-shadow: 0 8px 22px #0003; display: grid; place-items: center; color: #fff; text-align: center; }
.splash-thumb::before { content: ''; position: absolute; inset: 0; background: url(../assets/cover.png) center / cover; opacity: .4; }
.splash-thumb::after { content: ''; position: absolute; inset: 0; background: radial-gradient(160px 90px at 50% 40%, #c8102e66, transparent 70%); }
.splash-thumb > * { position: relative; z-index: 1; }
.splash-thumb img { width: 38px; height: 38px; background: #fff; border-radius: 50%; padding: 4px; box-shadow: 0 0 0 2px #c8102e, 0 0 14px #ff3347; }
.splash-thumb b { display: block; font-size: 12px; margin-top: 6px; }
.splash-thumb i { display: block; width: 120px; height: 3px; margin: 8px auto 0; border-radius: 9px; background: linear-gradient(90deg, #ff3347 64%, #ffffff26 64%); }
.splash-thumb.off { filter: grayscale(1) brightness(.7); }

/* ===== หน้าเข้าสู่ระบบ (แบบใหม่) ===== */
body.lg { margin: 0; min-height: 100vh; min-height: 100dvh; background: #12040a; isolation: isolate; position: relative; color: #fff; overflow-x: hidden; display: flex; flex-direction: column; }
.lg-bg { position: fixed; inset: 0; background: url(../assets/cover.png) center 30% / cover no-repeat; z-index: -2; animation: lg-zoom 24s ease-in-out infinite alternate; }
.lg-shade { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(520px 520px at 50% 52%, #0c030659, transparent 72%), linear-gradient(180deg, #0c030666 0%, transparent 18%, transparent 74%, #0c0306b3 100%); }
@keyframes lg-zoom { from { transform: scale(1); } to { transform: scale(1.05); } }
/* แถบบน */
.lg-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 26px; }
.lg-chip { display: inline-flex; align-items: center; gap: 10px; padding: 9px 16px; border-radius: 99px; background: #0c0306a6; backdrop-filter: blur(10px); border: 1px solid #ffffff26;
  font: 700 12px/1 ui-monospace, Consolas, monospace; letter-spacing: .24em; }
.lg-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 10px #22c55e; animation: sp-blink 1.6s ease-in-out infinite; }
.lg-clock { text-align: right; padding: 8px 16px; border-radius: 14px; background: #0c0306a6; backdrop-filter: blur(10px); border: 1px solid #ffffff26; }
.lg-clock b { display: block; font: 700 22px/1.1 ui-monospace, Consolas, monospace; letter-spacing: .06em; }
.lg-clock small { font-size: 12.5px; color: #ffffffbf; }
/* การ์ด */
.lg-main { flex: 1; display: grid; place-items: center; padding: 10px 16px 24px; }
.lg-card { position: relative; width: 100%; padding: 26px 26px 22px; border-radius: 24px; background: linear-gradient(160deg, #1c060cd9, #12040ae6);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); border: 1px solid #ffffff2e;
  box-shadow: 0 30px 70px #00000080, 0 0 0 1px #c8102e33, inset 0 1px 0 #ffffff26; animation: lg-in .7s cubic-bezier(.2, .9, .3, 1.1) both .1s; }
.lg-card::before { content: ''; position: absolute; left: 24px; right: 24px; top: -1px; height: 3px; border-radius: 0 0 6px 6px; background: linear-gradient(90deg, transparent, #ff3347, transparent); }
.lg-card.shake { animation: lg-shake .45s cubic-bezier(.36, .07, .19, .97); }
@keyframes lg-in { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes lg-shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
.lg-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.lg-logo { width: 62px; height: 62px; flex: none; object-fit: contain; background: #fff; border-radius: 50%; padding: 6px; box-shadow: 0 0 0 3px #c8102e, 0 0 22px #ff334780; }
.lg-greet { display: block; color: #ff8a96; font-weight: 600; font-size: 13.5px; }
.lg-head h1 { margin: 0; font-size: 21px; line-height: 1.25; font-weight: 700; }
.lg-head p { margin: 1px 0 0; font-size: 13.5px; color: #ffffffa6; }
.lg-err { display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 14px; border-radius: 12px; background: #ff33471f; border: 1px solid #ff334766; color: #ffb3bc; font-size: 14px; }
.lg-err svg, .lg-caps svg { width: 16px; height: 16px; flex: none; }
/* ช่องกรอก ป้ายลอย */
.lg-field { position: relative; display: block; margin-bottom: 14px; }
.lg-field .ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #ffffff80; display: grid; transition: color .2s; pointer-events: none; }
.lg-field .ic svg { width: 19px; height: 19px; }
.lg-field input { width: 100%; box-sizing: border-box; height: 56px; padding: 20px 46px 6px 46px; border-radius: 14px; border: 1.5px solid #ffffff26; background: #ffffff0f;
  color: #fff; font: inherit; font-size: 16px; outline: none; transition: border-color .2s, background .2s, box-shadow .2s; }
.lg-field input:hover { border-color: #ffffff4d; }
.lg-field input:focus { border-color: #ff3347; background: #ffffff17; box-shadow: 0 0 0 4px #ff334726; }
.lg-field em { position: absolute; left: 46px; top: 50%; transform: translateY(-50%); font-style: normal; color: #ffffff8c; font-size: 15.5px; pointer-events: none; transition: all .18s ease; }
.lg-field input:focus ~ em, .lg-field input:not(:placeholder-shown) ~ em { top: 15px; font-size: 11.5px; color: #ff8a96; letter-spacing: .02em; }
.lg-field input:focus ~ .ic, .lg-field:has(input:focus) .ic { color: #ff3347; }
.lg-field input:-webkit-autofill { -webkit-text-fill-color: #fff; -webkit-box-shadow: 0 0 0 40px #2a0b12 inset; caret-color: #fff; }
.lg-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: #ffffffa6; cursor: pointer; display: grid; place-items: center; }
.lg-eye:hover { background: #ffffff14; color: #fff; }
.lg-eye svg { width: 20px; height: 20px; }
.lg-caps { display: flex; align-items: center; gap: 6px; margin: -6px 0 12px; font-size: 13px; color: #fbbf24; }
.lg-row { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 16px; font-size: 14px; }
.lg-row a { color: #ff8a96; text-decoration: none; } .lg-row a:hover { text-decoration: underline; }
/* สวิตช์เล็ก "จำชื่อผู้ใช้" */
.lg-mini { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; color: #ffffffcc; user-select: none; }
.lg-mini input { position: absolute; opacity: 0; width: 0; height: 0; }
.lg-mini .tr { position: relative; width: 40px; height: 22px; border-radius: 99px; background: #ffffff26; transition: background .3s; }
.lg-mini .tr::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px #0005; transition: transform .35s cubic-bezier(.3, 1.5, .5, 1); }
.lg-mini input:checked + .tr { background: #22c55e; box-shadow: 0 0 12px #22c55e80; }
.lg-mini input:checked + .tr::after { transform: translateX(18px); }
.lg-mini input:focus-visible + .tr { outline: 2px solid #ff3347; outline-offset: 2px; }
/* ปุ่มเข้าสู่ระบบ: ปกติ → หมุน → ติ๊กเขียว */
.lg-btn { position: relative; width: 100%; height: 54px; border: 0; border-radius: 14px; cursor: pointer; color: #fff; font: inherit; font-size: 17px; font-weight: 700; overflow: hidden;
  background: linear-gradient(135deg, #a50d22, #e11d34 55%, #ff4d5e); box-shadow: 0 10px 26px #c8102e66, inset 0 1px 0 #ffffff40; transition: transform .15s, box-shadow .2s, background .4s; }
.lg-btn::after { content: ''; position: absolute; top: 0; bottom: 0; width: 60px; left: -80px; background: linear-gradient(90deg, transparent, #ffffff59, transparent); transform: skewX(-20deg); transition: left .6s; }
.lg-btn:hover::after { left: calc(100% + 20px); }
.lg-btn:hover { box-shadow: 0 14px 30px #c8102e88, inset 0 1px 0 #ffffff40; }
.lg-btn:active { transform: scale(.98); }
.lg-btn .spin, .lg-btn .ok { position: absolute; left: 50%; top: 50%; opacity: 0; transition: opacity .2s, transform .35s; }
.lg-btn .spin { width: 24px; height: 24px; margin: -12px 0 0 -12px; border: 3px solid #ffffff4d; border-top-color: #fff; border-radius: 50%; }
.lg-btn .ok { width: 30px; height: 30px; margin: -15px 0 0 -15px; display: grid; place-items: center; transform: scale(.4); }
.lg-btn .ok svg { width: 26px; height: 26px; stroke-width: 3; }
.lg-btn .t { transition: opacity .2s; }
.lg-btn.busy .t, .lg-btn.done .t { opacity: 0; }
.lg-btn.busy .spin { opacity: 1; animation: sp-spin .8s linear infinite; }
.lg-btn.done { background: linear-gradient(135deg, #15803d, #22c55e); box-shadow: 0 10px 26px #22c55e66; }
.lg-btn.done .ok { opacity: 1; transform: scale(1); }
.lg-btn:disabled { cursor: default; }
.lg-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: #ffffff73; font-size: 13px; }
.lg-or::before, .lg-or::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #ffffff33, transparent); }
/* ปุ่มสแกนบัตร */
.lg-scan { position: relative; display: flex; align-items: center; gap: 14px; padding: 13px 14px; border-radius: 16px; text-decoration: none; color: #fff;
  background: #ffffff0f; border: 1.5px solid #ffffff2e; transition: border-color .2s, background .2s, transform .15s; overflow: hidden; }
.lg-scan:hover { border-color: #22c55e; background: #22c55e14; }
.lg-scan:active { transform: scale(.98); }
.lg-scan .ic { position: relative; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #16a34a, #22c55e); box-shadow: 0 6px 16px #22c55e55; flex: none; }
.lg-scan .ic::after { content: ''; position: absolute; left: 8px; right: 8px; height: 2px; top: 12px; background: #fff; border-radius: 2px; box-shadow: 0 0 6px #fff; animation: lg-scanline 1.8s ease-in-out infinite; }
.lg-scan .ic svg { width: 26px; height: 26px; }
.lg-scan .tx { flex: 1; display: flex; flex-direction: column; }
.lg-scan .tx b { font-size: 17px; } .lg-scan .tx small { color: #ffffff99; font-size: 12.5px; }
.lg-scan .arr { color: #ffffff80; display: grid; transition: transform .2s; } .lg-scan:hover .arr { transform: translateX(4px); color: #22c55e; }
.lg-scan .arr svg { width: 20px; height: 20px; }
@keyframes lg-scanline { 0%, 100% { top: 11px; } 50% { top: 33px; } }
.lg-foot { display: flex; justify-content: space-between; gap: 12px; padding: 14px 26px 18px; font-size: 14px; color: #ffffffcc; text-shadow: 0 1px 6px #000c; }
.lg-foot #motto { font-weight: 600; letter-spacing: .04em; padding: 8px 16px; border-radius: 99px; background: #0c0306a6; backdrop-filter: blur(10px); border: 1px solid #ffffff26; text-shadow: none; }
.lg-foot #motto:empty { display: none; }
.lg-ver { padding: 8px 14px; border-radius: 99px; background: #0c030680; text-shadow: none; }
.lg-ver { font: 600 11.5px ui-monospace, Consolas, monospace; letter-spacing: .24em; color: #ffffff99; }
body.lg .toast { z-index: 50; }
@media (prefers-reduced-motion: reduce) { .lg-bg, .lg-card, .lg-scan .ic::after { animation: none !important; } }
/* มือถือ: รูปเป็นแบนเนอร์ด้านบน (เห็นตราโรงเรียน) การ์ดอยู่ล่าง */
@media (max-width: 720px) {
  .lg-bg { bottom: auto; height: 46vh; background-position: 86% 45%; animation: none;
    -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent); mask-image: linear-gradient(180deg, #000 70%, transparent); }
  .lg-shade { background: linear-gradient(180deg, #0c030659 0%, transparent 22%, transparent 30%, #12040a 48%); }
  .lg-top { padding: 14px 14px 0; }
  .lg-chip { font-size: 10px; letter-spacing: .16em; padding: 8px 12px; }
  .lg-clock { padding: 6px 12px; } .lg-clock b { font-size: 17px; } .lg-clock small { font-size: 11px; }
  .lg-main { place-items: end center; padding: 22vh 12px 10px; }
  .lg-card { padding: 22px 18px 18px; border-radius: 22px; }
  .lg-foot { justify-content: center; padding: 8px 14px 16px; } .lg-ver { display: none; }
}

/* หน้าโหลด: วงแหวนความคืบหน้า · จุดโหลด · ติ๊กสำเร็จ */
.splash .sp-prog { position: absolute; inset: -14px; width: calc(100% + 28px); height: calc(100% + 28px); transform: rotate(-90deg); overflow: visible; }
.splash .sp-prog circle { fill: none; stroke-width: 5; }
.splash .sp-prog .bg { stroke: #ffffff1f; }
.splash .sp-prog .fg { stroke: #ff3347; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; filter: drop-shadow(0 0 6px #ff3347); transition: stroke .4s; }
.splash.done .sp-prog .fg { stroke: #22c55e; filter: drop-shadow(0 0 8px #22c55e); }
.splash .sp-ok { position: absolute; right: -4px; bottom: -4px; width: 42px; height: 42px; border-radius: 50%; background: #22c55e; display: grid; place-items: center;
  box-shadow: 0 0 0 4px #0c0306, 0 0 22px #22c55e; transform: scale(0); transition: transform .45s cubic-bezier(.3, 1.6, .5, 1); }
.splash .sp-ok svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.splash .sp-ok path { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .4s ease .25s; }
.splash.done .sp-ok { transform: scale(1); }
.splash.done .sp-ok path { stroke-dashoffset: 0; }
.splash.done .ring { animation: none; opacity: 0; }
.splash .sp-st { display: inline-flex; align-items: center; gap: 10px; }
.splash .sp-dots { display: inline-flex; gap: 5px; }
.splash .sp-dots i { width: 7px; height: 7px; border-radius: 50%; background: #ff3347; animation: sp-dot 1s ease-in-out infinite; }
.splash .sp-dots i:nth-child(2) { background: #ff8a96; animation-delay: .15s; }
.splash .sp-dots i:nth-child(3) { background: #fbbf24; animation-delay: .3s; }
.splash.done .sp-dots i { background: #22c55e; animation: none; }
@keyframes sp-dot { 0%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-6px); opacity: 1; } }

/* ===== แถบเมนูล่างแบบกระจก (มือถือ) ===== */
.mnav { display: none; }
@media (max-width: 760px) {
  body.has-mnav { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.has-mnav .mnav { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30; height: 68px; border-radius: 24px;
    display: grid; align-items: center; justify-items: center; padding: 0 4px;
    background: linear-gradient(160deg, #3a0d16d9, #1a060cf0); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid #ffffff2e; box-shadow: 0 16px 36px #3a061059, inset 0 1px 0 #ffffff33; animation: mn-in .5s cubic-bezier(.2, .9, .3, 1.2) both; }
  body.side-open .mnav { z-index: 20; }
}
@keyframes mn-in { from { transform: translateY(120%); opacity: 0; } to { transform: none; opacity: 1; } }
.mnav .mn-it { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; color: #ffffffa6; font: inherit; font-size: 11.5px; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color .2s; }
.mnav .mn-it svg { width: 23px; height: 23px; transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.mnav .mn-it:active svg { transform: scale(.85); }
.mnav .mn-it.on { color: #fff; font-weight: 600; }
.mnav .mn-it.on svg { transform: translateY(-2px); filter: drop-shadow(0 0 6px #ff3347); }
.mnav .mn-it.on::before { content: ''; position: absolute; top: -1px; left: 50%; width: 30px; height: 3px; margin-left: -15px; border-radius: 0 0 4px 4px; background: #ff3347; box-shadow: 0 0 12px #ff3347, 0 4px 16px #ff3347; }
.mnav .mn-it.on::after { content: ''; position: absolute; top: 0; left: 50%; width: 52px; height: 36px; margin-left: -26px; background: radial-gradient(ellipse at top, #ff334759, transparent 70%); pointer-events: none; }
.mnav .mn-bd { position: absolute; top: 7px; left: calc(50% + 4px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #ff3347; color: #fff; font-size: 10.5px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #2a0a12; box-shadow: 0 0 8px #ff3347aa; }
.mnav .mn-scan { position: relative; width: 64px; height: 64px; margin-top: -34px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #16a34a, #22c55e); box-shadow: 0 0 0 6px #ffffffe6, 0 10px 26px #16a34a88; -webkit-tap-highlight-color: transparent; transition: transform .15s; }
.mnav .mn-scan:active { transform: scale(.92); }
.mnav .mn-scan svg { width: 30px; height: 30px; }
.mnav .mn-scan::after { content: ''; position: absolute; inset: -7px; border-radius: 50%; border: 2px solid #22c55e99; animation: mn-pulse 2s ease-out infinite; }
@keyframes mn-pulse { to { transform: scale(1.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mnav, .mnav .mn-scan::after { animation: none !important; } }
/* ภาพย่อในหน้าตั้งค่า */
.mnav-thumb { width: 210px; height: 64px; flex: none; border-radius: 22px; display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; justify-items: center;
  background: linear-gradient(160deg, #3a0d16, #1a060c); box-shadow: 0 8px 22px #0003, inset 0 1px 0 #ffffff33; margin-top: 14px; }
.mnav-thumb i { width: 18px; height: 18px; border-radius: 6px; background: #ffffff59; }
.mnav-thumb i:first-child { background: #fff; box-shadow: 0 -10px 12px -4px #ff3347; }
.mnav-thumb b { width: 46px; height: 46px; margin-top: -26px; border-radius: 50%; background: linear-gradient(135deg, #16a34a, #22c55e); display: grid; place-items: center; color: #fff; box-shadow: 0 0 0 4px #fff, 0 6px 14px #16a34a88; }
.mnav-thumb b svg { width: 22px; height: 22px; }
.mnav-thumb.off { filter: grayscale(1) brightness(.75); }

/* ===== แถบเมนูข้างแบบกระจก (body.glass-side) — ปิดสวิตช์ = กลับเป็นแบบเดิม ===== */
body.glass-side .side { isolation: isolate; color: #fff; border: 1px solid #ffffff2e; border-radius: 24px; padding: 14px 12px;
  background: linear-gradient(165deg, #2c0a12f0, #170509f5); box-shadow: 0 18px 40px #3a061040, inset 0 1px 0 #ffffff26; scrollbar-color: #ffffff40 transparent; }
body.glass-side .side::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: url(../assets/login-bg.jpg) 30% center / cover; opacity: .16; filter: blur(2px) saturate(1.3); pointer-events: none; }
body.glass-side .nav-main { color: #fff; }
body.glass-side .nav-main.on, body.glass-side .nav-main:hover { background: linear-gradient(90deg, #e11d34, #ff4d5e); box-shadow: 0 8px 20px #c8102e80, inset 0 1px 0 #ffffff4d; }
body.glass-side .nav-main.on { position: relative; }
body.glass-side .nav-main.on::before { content: ''; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: #fff; box-shadow: 0 0 10px #fff; }
body.glass-side .sec-head { color: #ffffff8c; font-size: 12px; letter-spacing: .14em; font-weight: 700; padding: 12px 6px 6px; }
body.glass-side .sec-head:hover { background: #ffffff0d; color: #fff; }
body.glass-side .sec-head > svg:first-child { color: #ff6b7a; width: 16px; height: 16px; }
body.glass-side .sec-head > svg:last-child { color: #ffffff80; }
body.glass-side .side .nav-item { color: #ffffffe0; font-size: 14.5px; }
body.glass-side .side .nav-item i { background: #ffffff14; color: #ff8a96; }
body.glass-side .side .nav-item:hover { background: #ffffff12; color: #fff; }
body.glass-side .side .nav-item.on { position: relative; background: linear-gradient(90deg, #e11d34d9, #ff4d5ea6); color: #fff; box-shadow: 0 8px 18px #c8102e66, inset 0 1px 0 #ffffff40; }
body.glass-side .side .nav-item.on i { background: #ffffff33; color: #fff; }
body.glass-side .side .nav-item.on::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: #fff; box-shadow: 0 0 10px #fff; }
body.glass-side .side .nav-item .badge { background: #ff3347; color: #fff; box-shadow: 0 0 10px #ff3347aa; }
body.glass-side .grade-head { background: #ffffff0d; border-color: #ffffff1f; color: #fff; }
body.glass-side .grade-head small, body.glass-side .grade-head svg { color: #ffffff99; }
body.glass-side .grade.open .grade-head { background: #ffffff1a; border-color: #ffffff33; }
body.glass-side .grade-rooms { border-left: 1px solid #ffffff26; margin-left: 12px; padding-left: 10px; }
body.glass-side .room-item { background: transparent; border-color: transparent; box-shadow: none; color: #ffffffd9; }
body.glass-side .room-item svg { color: #ff8a96; }
body.glass-side .room-item small { color: #ffffff8c; }
body.glass-side .room-item:hover { background: #ffffff12; color: #fff; border-color: transparent; }
body.glass-side .room-item.on { background: linear-gradient(90deg, #e11d34cc, #ff4d5e99); border-color: #ffffff40; color: #fff; }
body.glass-side .room-item.on svg { color: #fff; }
body.glass-side .room-all { background: #ffffff12; color: #fff; }
body.glass-side .room-all:hover, body.glass-side .room-all.on { background: #ffffff24; color: #fff; }
.rdot { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-left: auto; }
.rdot + small, .rdot + .badge { margin-left: 8px !important; }
.rdot.ok { background: #22c55e; box-shadow: 0 0 8px #22c55e; } .rdot.mid { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; } .rdot.low { background: #ff3347; box-shadow: 0 0 8px #ff3347; }
/* ช่องค้นหา */
.side-search { position: relative; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 10px 0 12px; margin-bottom: 6px; border-radius: 14px;
  background: #ffffff12; border: 1px solid #ffffff2e; transition: border-color .2s, box-shadow .2s; }
.side-search:focus-within { border-color: #ff4d5e; box-shadow: 0 0 0 4px #ff334726; }
.side-search .ic { display: grid; color: #ffffff99; } .side-search .ic svg { width: 17px; height: 17px; }
.side-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: #fff; font: inherit; font-size: 13.5px; padding: 0; }
.side-search input::placeholder { color: #ffffff80; }
.side-search:focus-within kbd { display: none; }
.side-search kbd { font: 600 10.5px Consolas, monospace; padding: 3px 6px; border-radius: 6px; background: #ffffff1f; color: #ffffffcc; white-space: nowrap; }
.side-res { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50; max-height: 360px; overflow-y: auto; padding: 6px; border-radius: 14px;
  background: #1f070de6; backdrop-filter: blur(16px); border: 1px solid #ffffff33; box-shadow: 0 18px 40px #0008; }
.side-res a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: #fff; text-decoration: none; font-size: 14px; }
.side-res a i { width: 28px; height: 28px; border-radius: 8px; background: #ffffff14; color: #ff8a96; display: grid; place-items: center; flex: none; }
.side-res a i svg { width: 15px; height: 15px; }
.side-res a small { display: block; color: #ffffff8c; font-size: 12px; }
.side-res a.sel, .side-res a:hover { background: linear-gradient(90deg, #e11d34b3, #ff4d5e80); }
.side-res .none { margin: 8px 10px; color: #ffffff99; font-size: 13.5px; }
/* การ์ดผู้ใช้ */
.side-me { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 12px 6px 4px; border-top: 1px solid #ffffff26; }
.side-me .av { position: relative; width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, #ff8a96, #e11d34); display: grid; place-items: center; flex: none; color: #fff; }
.side-me .av svg { width: 20px; height: 20px; }
.side-me .av b { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #22c55e; border: 2px solid #1d070c; }
.side-me .who { min-width: 0; } .side-me .who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-me .who small { color: #ffffff99; font-size: 12px; }
.side-me .out { margin-left: auto; width: 36px; height: 36px; flex: none; border-radius: 10px; border: 1px solid #ffffff2e; background: #ffffff0d; color: #ffffffcc; display: grid; place-items: center; cursor: pointer; }
.side-me .out:hover { background: #e11d34; color: #fff; border-color: #e11d34; }
.side-me .out svg { width: 18px; height: 18px; }
/* ภาพย่อในหน้าตั้งค่า */
.glass-sets { display: flex; flex-direction: column; gap: 18px; }
.gs-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.gs-row b { font-size: 15.5px; } .gs-row p { margin: 4px 0 10px; font-size: 13.5px; max-width: 460px; }
.gs-thumb { width: 150px; height: 96px; flex: none; border-radius: 14px; box-shadow: 0 8px 22px #0003; position: relative; overflow: hidden; }
.gs-thumb.th-side { background: linear-gradient(165deg, #2c0a12, #170509); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.gs-thumb.th-side i { height: 8px; border-radius: 4px; background: #ffffff33; width: 70%; }
.gs-thumb.th-side i.q { width: 100%; height: 12px; background: #ffffff1f; border: 1px solid #ffffff33; }
.gs-thumb.th-side i.on { width: 85%; background: linear-gradient(90deg, #e11d34, #ff4d5e); box-shadow: 0 0 8px #ff3347; }
.gs-thumb.th-side i.u { margin-top: auto; width: 50%; background: #ffffff59; }
.gs-thumb.login { background: url(../assets/cover.png) center / cover; display: grid; place-items: center; }
.gs-thumb.login span { width: 70px; height: 70px; background: #1a060cd9; clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  box-shadow: inset 0 0 0 2px #ff4d5e; }
.gs-thumb.off { filter: grayscale(1) brightness(.75); }

/* ===== หน้าเข้าสู่ระบบแบบกระจกมุมตัด (body.lg-cut) — ปิดสวิตช์ = กลับเป็นแบบเดิม ===== */
.lg-cardwrap { position: relative; width: min(410px, 100%); }
body.lg-cut .lg-cardwrap { width: min(450px, 100%); }
.lg-alt, .lg-tip, .lg-okname { display: none; }
.lg-help[hidden] { display: none; }
.lg-help { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: #0c0306b3; backdrop-filter: blur(6px); }
.lg-help .box { width: min(440px, 100%); padding: 24px 24px 20px; border-radius: 22px; background: linear-gradient(160deg, #2a0a12f2, #12040af7); border: 1px solid #ffffff33; box-shadow: 0 30px 70px #000a; animation: lg-in .4s ease both; }
.lg-help h2 { margin: 0 0 10px; font-size: 20px; }
.lg-help ol { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; color: #ffffffd9; line-height: 1.6; }
.lg-help code { background: #ffffff1f; padding: 1px 7px; border-radius: 6px; font-family: inherit; color: #fff; }
body.lg-cut .lg-card { width: 100%; border-radius: 0; border: 0; padding: 30px 30px 24px;
  clip-path: polygon(30px 0, 100% 0, 100% calc(100% - 30px), calc(100% - 30px) 100%, 0 100%, 0 30px);
  background: linear-gradient(160deg, #2a0a12eb, #12040af5) padding-box; box-shadow: none; }
body.lg-cut .lg-card.shake { animation: lg-shake .45s cubic-bezier(.36, .07, .19, .97); }
body.lg-cut .lg-cardwrap { filter: drop-shadow(0 30px 50px #000000a6) drop-shadow(0 0 1px #ff4d5e); animation: lg-in .7s cubic-bezier(.2, .9, .3, 1.1) both .1s; }
/* เส้นขอบเรืองแสง (ชั้นหลังการ์ด ใหญ่กว่า 2px) */
body.lg-cut .lg-cardwrap::before { content: ''; position: absolute; inset: -2px; z-index: -1;
  background: linear-gradient(135deg, #ff4d5e, #ffffff59 28%, #ffffff1a 55%, #ff4d5e 100%);
  clip-path: polygon(31px 0, 100% 0, 100% calc(100% - 31px), calc(100% - 31px) 100%, 0 100%, 0 31px); }
/* มุมตัดเรืองแสงด้านนอก */
body.lg-cut .lg-cardwrap::after { content: ''; position: absolute; inset: -12px; pointer-events: none;
  background:
    linear-gradient(135deg, transparent 23px, #ff4d5e 23px, #ff4d5e 25px, transparent 25px) top left / 48px 48px no-repeat,
    linear-gradient(-45deg, transparent 23px, #ff4d5e 23px, #ff4d5e 25px, transparent 25px) bottom right / 48px 48px no-repeat;
  filter: drop-shadow(0 0 6px #ff3347); }
body.lg-cut .lg-card::before { left: 50px; right: 50px; }
body.lg-cut .lg-head h1 { font-size: 22px; }
body.lg-cut .lg-head { margin-bottom: 30px; }
/* ป้ายชื่อช่องอยู่บนช่องเสมอ (อ่านง่าย) */
body.lg-cut .lg-field { margin-top: 26px; }
body.lg-cut .lg-field em, body.lg-cut .lg-field input:focus ~ em, body.lg-cut .lg-field input:not(:placeholder-shown) ~ em { top: -14px; left: 2px; transform: translateY(-50%); font-size: 13px; color: #ffffffcc; font-weight: 500; }
body.lg-cut .lg-field input { height: 52px; padding: 0 46px 0 46px; border-radius: 12px; }
body.lg-cut .lg-field input:focus { box-shadow: 0 0 0 4px #ff334722, inset 0 0 14px #ff334722; }
body.lg-cut .lg-err { margin-bottom: 0; }
body.lg-cut .lg-okname { position: absolute; right: 14px; top: 50%; transform: translateY(-50%) scale(.4); display: grid; color: #22c55e; opacity: 0; transition: opacity .2s, transform .35s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none; }
body.lg-cut .lg-okname svg { width: 20px; height: 20px; filter: drop-shadow(0 0 6px #22c55e); }
body.lg-cut .lg-okname.show { opacity: 1; transform: translateY(-50%) scale(1); }
body.lg-cut .lg-btn { border-radius: 12px; background: linear-gradient(90deg, #b30f25, #ff3347 60%, #ff7a59); }
body.lg-cut .lg-btn.done { background: linear-gradient(135deg, #15803d, #22c55e); }
body.lg-cut .lg-scan { display: none; }
body.lg-cut .lg-alt { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
body.lg-cut .lg-alt a, body.lg-cut .lg-alt button { height: 48px; border-radius: 12px; border: 1.5px solid #ffffff2e; background: #ffffff0d; color: #fff; font: inherit; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer; transition: background .2s, border-color .2s, transform .15s; }
body.lg-cut .lg-alt svg { width: 19px; height: 19px; }
body.lg-cut .lg-alt .g { border-color: #22c55e88; background: #22c55e1f; }
body.lg-cut .lg-alt .g:hover { background: #22c55e33; } body.lg-cut .lg-alt button:hover { background: #ffffff1f; }
body.lg-cut .lg-alt a:active, body.lg-cut .lg-alt button:active { transform: scale(.97); }
body.lg-cut .lg-tip { display: block; margin: 16px 0 0; text-align: center; font-size: 12.5px; color: #ffffff99; }
body.lg-cut .lg-tip b { color: #fff; }
@media (max-width: 720px) { body.lg-cut .lg-card { padding: 24px 20px 20px; } }

/* ================================================================
   ธีมกระจกทั้งระบบ (body.glass-ui) — ตามภาพตัวอย่าง 1 และ 2
   ปิดสวิตช์ "ธีมกระจก" ในหน้าตั้งค่า = กลับเป็นแบบเดิมทั้งหมด
   ================================================================ */
.gh-date, .gh-clock { display: none; }
.side-brand { display: none; }
body.glass-ui {
  --card: #ffffff12; --line: #ffffff21; --ink: #fff; --muted: #ffffffa6; --navy-900: #fff; --navy-800: #fff; --navy-700: #ffd6db;
  --bg: transparent; --blue-soft: #ffffff17; --blue-line: #ffffff2e; --green-soft: #22c55e2e; --red-soft: #ff334729; --orange-soft: #f59e0b2e;
  --shadow: 0 16px 36px #00000059; color: #fff; background: #12040a; isolation: isolate; }
body.glass-ui::before { content: ''; position: fixed; inset: -24px; z-index: -2; background: url(../assets/login-bg.jpg) center / cover; filter: blur(7px) brightness(.5) saturate(1.25); }
body.glass-ui::after { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(900px 600px at 25% 30%, #c8102e2e, transparent 70%), linear-gradient(180deg, #0c030640, #0c0306a6); }
/* กระจก */
body.glass-ui .card, body.glass-ui .stat, body.glass-ui .rtile, body.glass-ui .room-tile, body.glass-ui .late-row {
  background: linear-gradient(160deg, #ffffff1c, #ffffff0a); border: 1px solid #ffffff2e; color: #fff;
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); box-shadow: 0 16px 36px #00000052, inset 0 1px 0 #ffffff33; }
body.glass-ui .card { border-radius: 20px; }
body.glass-ui .card-head h2, body.glass-ui .card h2, body.glass-ui h1, body.glass-ui h2, body.glass-ui h3 { color: #fff; }
body.glass-ui .card-head h2 svg { color: #ff8a96; }
body.glass-ui a { color: #ff9aa5; }
body.glass-ui .muted, body.glass-ui small { color: #ffffffa6; }
/* หัวเว็บ: คอมใช้แถบข้าง (มีโลโก้แล้ว) · มือถือ/แท็บเล็ตเป็นแถบกระจกบาง */
body.glass-ui .hero { height: 76px; background: #1a060cd9; backdrop-filter: blur(16px); border-bottom: 1px solid #ffffff21; }
body.glass-ui .hero::before, body.glass-ui .hero::after { display: none; }
body.glass-ui .hero-logo { width: 54px; background: #fff; border-radius: 50%; padding: 4px; box-shadow: 0 0 0 2px #e11d34; }
body.glass-ui .hero-title { border-left-color: #ff3347; text-shadow: none; }
body.glass-ui .hero-title h1 { color: #fff; font-size: 24px; } body.glass-ui .hero-title p { color: #ffffffb3; font-size: 14px; }
body.glass-ui .hero .user-btn { background: #ffffff14; color: #fff; border: 1px solid #ffffff2e; box-shadow: none; }
body.glass-ui .hero .user-btn .av { background: #ff334733; color: #fff; }
body.glass-ui .dropdown { background: #1f070df2; border: 1px solid #ffffff2e; color: #fff; }
body.glass-ui .dropdown button { color: #fff; } body.glass-ui .dropdown button:hover { background: #ffffff14; }
@media (min-width: 1001px) { body.glass-ui .hero { display: none; } body.glass-ui .layout { padding-top: 22px; } }
body.glass-ui .side { top: 22px; max-height: calc(100vh - 44px); }
/* โลโก้บนแถบข้าง */
body.glass-ui .side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 4px 12px; }
body.glass-ui .side-brand img { width: 46px; height: 46px; flex: none; border-radius: 50%; background: #fff; padding: 4px; object-fit: contain; box-shadow: 0 0 0 2px #e11d34, 0 0 16px #ff334766; }
body.glass-ui .side-brand b { display: block; font-size: 15px; line-height: 1.25; } body.glass-ui .side-brand small { font-size: 12px; }
/* หัวหน้า = แถบกระจก + วันที่ + นาฬิกา */
body.glass-ui .page-head { position: relative; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; column-gap: 14px; min-height: 70px; padding: 10px 22px;
  border-radius: 22px; background: linear-gradient(160deg, #ffffff1c, #ffffff0a); border: 1px solid #ffffff2e; backdrop-filter: blur(18px); box-shadow: 0 16px 36px #00000052, inset 0 1px 0 #ffffff33; }
body.glass-ui .page-head h1.ribbon { grid-row: 1; background: none; clip-path: none; padding: 0; color: #fff; font-size: 22px; box-shadow: none; }
body.glass-ui .page-head h1.ribbon svg { color: #ff8a96; }
body.glass-ui .gh-date { display: block; grid-row: 2; grid-column: 1; color: #ffffffa6; font-size: 13px; }
body.glass-ui .page-head > .toolbar { grid-row: 1 / span 2; grid-column: 3; justify-self: end; }
body.glass-ui .gh-clock { display: block; grid-row: 1 / span 2; grid-column: 4; font: 700 19px ui-monospace, Consolas, monospace; letter-spacing: .04em; }
/* การ์ดสถิติ */
body.glass-ui .stat { color: #fff; }
body.glass-ui .stat .k { color: #ffffffcc !important; }
body.glass-ui .stat .v { color: #fff; }
body.glass-ui .stat .ic { box-shadow: 0 6px 16px #0005; }
/* กล่องหัวแดง (rb) */
body.glass-ui .card.rb { padding: 0; }
body.glass-ui .rb-head { background: #ffffff0d; border-bottom: 1px solid #ffffff21; }
body.glass-ui .rb-t { background: none; clip-path: none; color: #fff; padding-right: 16px; }
body.glass-ui .rb-t svg { color: #ff8a96; }
body.glass-ui .rb-head a, body.glass-ui .rb-head .rb-meta { color: #ff9aa5; }
body.glass-ui .d-scan { background: linear-gradient(160deg, #e11d34d9, #7a0a17d9); border: 1px solid #ffffff33; backdrop-filter: blur(14px); }
/* ตาราง รายการ */
body.glass-ui .tbl th { background: #ffffff14; color: #fff; border-bottom-color: #ffffff21; }
body.glass-ui .tbl td { border-bottom-color: #ffffff17; }
body.glass-ui .tbl tr:hover td { background: #ffffff0a; }
body.glass-ui .tbl-wrap { border-color: #ffffff21; background: #ffffff0a; }
body.glass-ui .tbl thead th { position: sticky; top: 0; z-index: 1; background: #3a1018; }
body.glass-ui .tbl td b, body.glass-ui .tbl td { color: #fff; }
body.glass-ui .recent li, body.glass-ui .mini-list li, body.glass-ui .set-row { border-color: #ffffff1a; }
body.glass-ui .pill.in, body.glass-ui .pill.ok { background: #22c55e33; color: #86efac; }
body.glass-ui .pill.out, body.glass-ui .pill.bad { background: #ff334733; color: #ffb3bc; }
body.glass-ui .pill.mute { background: #ffffff1f; color: #ffffffb3; }
body.glass-ui .late-row.done { background: #ff33471f; border-color: #ff334755; }
body.glass-ui .class-info { background: #ffffff12; border-left-color: #ff3347; color: #fff; }
body.glass-ui .notice .bubble { background: #ffffff14; color: #fff; }
body.glass-ui .chart text { fill: #ffffffb3; }
body.glass-ui .chart line, body.glass-ui .chart .grid { stroke: #ffffff21; }
/* ช่องกรอก ปุ่ม */
body.glass-ui input, body.glass-ui select, body.glass-ui textarea { background: #ffffff12; border-color: #ffffff2e; color: #fff; }
body.glass-ui input::placeholder, body.glass-ui textarea::placeholder { color: #ffffff73; }
body.glass-ui input:focus, body.glass-ui select:focus, body.glass-ui textarea:focus { border-color: #ff4d5e; box-shadow: 0 0 0 4px #ff334726; outline: none; }
body.glass-ui option { color: #1d0f11; background: #fff; }
body.glass-ui input[type=date], body.glass-ui input[type=time] { color-scheme: dark; }
body.glass-ui .btn { background: #ffffff14; border-color: #ffffff2e; color: #fff; }
body.glass-ui .btn:hover { background: #ffffff24; }
body.glass-ui .btn.primary, body.glass-ui .btn.navy { background: linear-gradient(135deg, #b30f25, #ff3347); border-color: #ff334799; color: #fff; box-shadow: 0 8px 20px #c8102e55; }
body.glass-ui .btn.outline { background: transparent; border-color: #ff6b7a; color: #ffb3bc; }
body.glass-ui .btn.danger { background: #e11d34; border-color: #e11d34; color: #fff; }
body.glass-ui .chip, body.glass-ui .room-btn, body.glass-ui .seg button { background: #ffffff12; border-color: #ffffff2e; color: #fff; }
body.glass-ui .chip.on, body.glass-ui .room-btn:hover { background: #e11d34; border-color: #e11d34; }
body.glass-ui .seg button.on { background: #ff334733; border-color: #ff4d5e; color: #fff; }
body.glass-ui .seg-tabs { background: #ffffff14; } body.glass-ui .seg-tabs button { color: #ffffffb3; }
body.glass-ui .tabs { border-bottom-color: #ffffff21; } body.glass-ui .tabs button { color: #ffffffa6; } body.glass-ui .tabs button.on { color: #fff; border-bottom-color: #ff3347; }
body.glass-ui .room-tile { color: #fff; } body.glass-ui .room-tile:hover { border-color: #ff4d5e; }
body.glass-ui .rtile:hover { box-shadow: 0 16px 36px #0008, 0 0 0 1px #ff4d5e; }
body.glass-ui .late-type { background: #ffffff12; border-color: #ffffff2e; color: #fff; }
body.glass-ui .pager button { background: #ffffff12; border-color: #ffffff2e; color: #fff; }
body.glass-ui .pager button.on { background: #e11d34; border-color: #e11d34; }
body.glass-ui .switch span { background: #ffffff33; }
/* กล่องโต้ตอบ */
body.glass-ui dialog.modal { background: linear-gradient(160deg, #2a0a12f7, #12040afa); color: #fff; border: 1px solid #ffffff2e; }
body.glass-ui dialog.modal::backdrop { background: #0c0306b3; }
body.glass-ui .modal-head { background: #ffffff0d; } body.glass-ui .modal-head h3 { color: #fff; }
/* แถบล่าง (คำขวัญ/วันที่) */
body.glass-ui .footbar { background: #1a060cd9; backdrop-filter: blur(14px); border-top: 1px solid #ffffff21; color: #ffffffcc; }
body.glass-ui .footbar::before { display: none; }
/* ปุ่มสามขีด (มือถือ) */
body.glass-ui .hero .burger { background: #ffffff14; color: #fff; box-shadow: none; border: 1px solid #ffffff2e; }
body.glass-ui .backdrop { background: #0c030699; }
/* การ์ดตั้งค่าแบบกระจกในธีมนี้ */
body.glass-ui .fx-toggle .lb { color: #ffffffcc; } body.glass-ui .fx-toggle input:checked ~ .lb { color: #ff9aa5; }
body.glass-ui .fx-toggle .tr { background: #ffffff21; box-shadow: inset 0 2px 6px #0006; }
@media (max-width: 1000px) {
  body.glass-ui .page-head { grid-template-columns: 1fr auto; padding: 10px 16px; border-radius: 18px; }
  body.glass-ui .page-head > .toolbar { grid-row: 3; grid-column: 1 / -1; justify-self: stretch; margin-top: 8px !important; }
  body.glass-ui .gh-clock { grid-column: 2; font-size: 16px; }
  body.glass-ui .page-head h1.ribbon { font-size: 18px; }
}
body.glass-ui .d-scan, body.glass-ui .d-scan a, body.glass-ui .scan-prev { color: #fff; }
body.glass-ui .d-scan .go { color: #c8102e; }
body.glass-ui .mnav .mn-scan { box-shadow: 0 0 0 6px #ffffff24, 0 10px 26px #16a34a88; }

/* ===== หน้าเข้าสู่ระบบ: เลื่อนเข้า / เลื่อนสลับแผง / เลื่อนออก (ตามคลิป) ===== */
.lg-panels { position: relative; display: grid; transition: height .45s cubic-bezier(.3, .9, .3, 1); }
.lg-panels.moving { overflow: hidden; }
.lg-panel { grid-area: 1 / 1; align-self: start; transition: transform .45s cubic-bezier(.3, .9, .3, 1), opacity .35s ease; }
.lg-panel:not(.on) { position: absolute; left: 0; right: 0; top: 0; pointer-events: none; opacity: 0; visibility: hidden; }
.lg-panel.out-l, .lg-panel.out-r { visibility: visible; }
.lg-panel.in-r { transform: translateX(70px); opacity: 0; transition: none; }
.lg-panel.in-l { transform: translateX(-70px); opacity: 0; transition: none; }
.lg-panel.out-l { transform: translateX(-70px); opacity: 0; }
.lg-panel.out-r { transform: translateX(70px); opacity: 0; }
.lg-ptop { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.lg-ptop small { display: block; color: #ff8a96; font-weight: 600; font-size: 13px; }
.lg-ptop h2 { margin: 0; font-size: 22px; }
.lg-back { width: 42px; height: 42px; flex: none; border-radius: 12px; border: 1.5px solid #ffffff2e; background: #ffffff0d; color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .2s, transform .15s; }
.lg-back:hover { background: #ffffff1f; } .lg-back:active { transform: scale(.94); }
.lg-back svg { width: 20px; height: 20px; }
.lg-steps { margin: 0 0 20px; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 14.5px; line-height: 1.6; color: #ffffffd9; }
.lg-steps.plain { padding-left: 18px; }
.lg-steps code, .lg-note code { background: #ffffff1f; padding: 1px 7px; border-radius: 6px; font-family: inherit; color: #fff; }
.lg-note { display: flex; gap: 12px; padding: 14px; margin-bottom: 16px; border-radius: 14px; background: #f59e0b1f; border: 1px solid #f59e0b66; }
.lg-note .ic { width: 38px; height: 38px; flex: none; border-radius: 10px; background: #f59e0b; display: grid; place-items: center; color: #fff; }
.lg-note .ic svg { width: 20px; height: 20px; }
.lg-note p { margin: 0; font-size: 14px; line-height: 1.6; color: #ffffffd9; }
/* ก่อนเริ่ม (ระหว่างหน้าโหลด) ซ่อนการ์ดไว้ */
body.lg:not(.lg-go) .lg-cardwrap { opacity: 0; }
body.lg .lg-card, body.lg-cut .lg-cardwrap { animation: none; }
/* เลื่อนเข้า: แบบปกติ = การ์ดเลื่อนขึ้น · ช่องต่าง ๆ ทยอยเข้า */
body.lg-go .lg-cardwrap { animation: lg-in .7s cubic-bezier(.2, .9, .3, 1.1) both; }
body.lg-go .lg-panel[data-p="login"] > * { animation: lg-item .55s cubic-bezier(.2, .9, .3, 1) both; }
body.lg-go .lg-panel[data-p="login"] > :nth-child(1) { animation-delay: .25s; } body.lg-go .lg-panel[data-p="login"] > :nth-child(2) { animation-delay: .3s; }
body.lg-go .lg-panel[data-p="login"] > :nth-child(3) { animation-delay: .36s; } body.lg-go .lg-panel[data-p="login"] > :nth-child(4) { animation-delay: .42s; }
body.lg-go .lg-panel[data-p="login"] > :nth-child(5) { animation-delay: .48s; } body.lg-go .lg-panel[data-p="login"] > :nth-child(6) { animation-delay: .54s; }
body.lg-go .lg-panel[data-p="login"] > :nth-child(7) { animation-delay: .6s; } body.lg-go .lg-panel[data-p="login"] > :nth-child(n+8) { animation-delay: .66s; }
@keyframes lg-item { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
/* แบบมุมตัด: มุมเริ่มกลางการ์ด แล้วเลื่อนออกไปที่มุม · การ์ดขยายตาม · แล้วช่องทยอยเข้า */
body.lg-cut.lg-go .lg-cardwrap { animation: none; }
body.lg-cut.lg-go .lg-cardwrap::after { animation: lg-corners .9s cubic-bezier(.5, 0, .2, 1) both; }
body.lg-cut.lg-go .lg-cardwrap::before { animation: lg-grow .75s cubic-bezier(.3, .9, .3, 1) both .3s; }
body.lg-cut.lg-go .lg-card { animation: lg-grow .75s cubic-bezier(.3, .9, .3, 1) both .3s; }
body.lg-cut.lg-go .lg-panel[data-p="login"] > :nth-child(1) { animation-delay: .75s; } body.lg-cut.lg-go .lg-panel[data-p="login"] > :nth-child(2) { animation-delay: .8s; }
body.lg-cut.lg-go .lg-panel[data-p="login"] > :nth-child(3) { animation-delay: .86s; } body.lg-cut.lg-go .lg-panel[data-p="login"] > :nth-child(4) { animation-delay: .92s; }
body.lg-cut.lg-go .lg-panel[data-p="login"] > :nth-child(5) { animation-delay: .98s; } body.lg-cut.lg-go .lg-panel[data-p="login"] > :nth-child(6) { animation-delay: 1.04s; }
body.lg-cut.lg-go .lg-panel[data-p="login"] > :nth-child(7) { animation-delay: 1.1s; } body.lg-cut.lg-go .lg-panel[data-p="login"] > :nth-child(n+8) { animation-delay: 1.16s; }
@keyframes lg-corners { 0% { inset: 36% 40%; opacity: 0; } 25% { inset: 36% 40%; opacity: 1; } 100% { inset: -12px; opacity: 1; } }
@keyframes lg-grow { from { opacity: 0; transform: scale(.55); } to { opacity: 1; transform: none; } }
/* เลื่อนออก (เข้าสู่ระบบสำเร็จ) */
body.lg-leave .lg-cardwrap { animation: lg-out .6s cubic-bezier(.6, 0, .4, 1) both !important; }
body.lg-leave .lg-top, body.lg-leave .lg-foot { transition: opacity .5s; opacity: 0; }
@keyframes lg-out { to { opacity: 0; transform: translateY(-40px) scale(.94); filter: blur(4px); } }
@media (prefers-reduced-motion: reduce) {
  body.lg-go .lg-cardwrap, body.lg-go .lg-panel > *, body.lg-cut.lg-go .lg-cardwrap::after, body.lg-cut.lg-go .lg-cardwrap::before, body.lg-cut.lg-go .lg-card { animation: none !important; }
  .lg-panel, .lg-panels { transition: none; }
}
/* สั่นเมื่อรหัสผิด (ต้องชนะแอนิเมชันเลื่อนเข้า) */
body.lg .lg-card.shake, body.lg-cut.lg-go .lg-card.shake { animation: lg-shake .45s cubic-bezier(.36, .07, .19, .97) both; }

/* ===== แถบเมนูล่างแบบ 3 (ร่องโค้ง + ฟองลอย ตามคลิป) ===== */
@property --nx { syntax: '<length-percentage>'; inherits: true; initial-value: 10%; }
@media (max-width: 760px) {
  body.has-mnav .mnav.v3 { display: block; justify-items: normal; align-items: normal; height: 66px; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0;
    transition: --nx .55s cubic-bezier(.45, 1.45, .5, 1); }
  body.has-mnav .mnav.v3.noanim, body.has-mnav .mnav.v3.noanim * { transition: none !important; }
}
.mnav.v3 .mn-bar { position: absolute; inset: 0; border-radius: 24px; background: linear-gradient(160deg, #3a0d16e6, #1a060cf5);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); box-shadow: inset 0 1px 0 #ffffff33;
  -webkit-mask: radial-gradient(circle at var(--nx) -6px, transparent 0 37px, #000 38.5px); mask: radial-gradient(circle at var(--nx) -6px, transparent 0 37px, #000 38.5px); }
.mnav.v3::before { content: ''; position: absolute; inset: 0; border-radius: 24px; box-shadow: 0 16px 36px #3a061066; pointer-events: none;
  -webkit-mask: radial-gradient(circle at var(--nx) -6px, transparent 0 37px, #000 38.5px); mask: radial-gradient(circle at var(--nx) -6px, transparent 0 37px, #000 38.5px); }
.mnav.v3.nobub .mn-bar, .mnav.v3.nobub::before { -webkit-mask: none; mask: none; }
.mnav.v3 .mn-row { position: relative; width: 100%; height: 100%; display: grid; align-items: center; justify-items: stretch; }
.mnav.v3 .mn-it { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none;
  color: #ffffffb3; font: inherit; font-size: 11px; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.mnav.v3 .mn-it svg { width: 23px; height: 23px; transition: opacity .2s, transform .3s; }
.mnav.v3 .mn-it:active svg { transform: scale(.85); }
.mnav.v3 .mn-it::before, .mnav.v3 .mn-it::after { display: none; }
.mnav.v3 .mn-it.on svg { opacity: 0; transform: translateY(-10px); }
.mnav.v3 .mn-it.on span { color: #fff; font-weight: 700; transform: translateY(12px); }
.mnav.v3 .mn-it span { transition: transform .35s cubic-bezier(.3, 1.4, .5, 1), color .2s; }
.mnav.v3 .mn-it.scan { color: #4ade80; }
.mnav.v3 .mn-it.scan svg { width: 34px; height: 34px; padding: 6px; border-radius: 12px; background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; box-shadow: 0 6px 14px #16a34a66; }
.mnav.v3 .mn-it.scan span { display: none; }
.mnav.v3 .mn-bd { top: 6px; }
/* ฟองลอยในร่อง */
.mnav.v3 .mn-bub { position: absolute; top: -27px; left: var(--nx); width: 56px; height: 56px; margin-left: -28px; border-radius: 50%; z-index: 2; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 35% 30%, #ff6b7a, #e11d34 55%, #9b0c20); border: 1px solid #ffffff59;
  box-shadow: 0 10px 24px #c8102e88, 0 0 0 5px #ffffff14, inset 0 2px 6px #ffffff59; pointer-events: none; }
.mnav.v3 .mn-bub svg { width: 25px; height: 25px; filter: drop-shadow(0 1px 2px #0006); }
.mnav.v3 .mn-bub.pop { animation: mn-pop .5s cubic-bezier(.3, 1.6, .5, 1); }
.mnav.v3.nobub .mn-bub { transform: scale(0); opacity: 0; transition: transform .25s, opacity .2s; }
@keyframes mn-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
/* เส้นจับด้านล่าง (เหมือนคลิป) */
.mnav.v3 .mn-home { position: absolute; left: 50%; bottom: 5px; width: 64px; height: 3px; margin-left: -32px; border-radius: 3px; background: #ffffff40; pointer-events: none; }

body.glass-ui .room-tile > b { color: #ff9aa5; }
body.glass-ui .room-tile .prog { color: #ffffffa6; }
body.glass-ui .bar { background: #ffffff21; }

/* ===== เปลี่ยนหน้าแบบนุ่มนวล ===== */
#main { --pg-dir: 1; }
#main.pg-out > * { transition: opacity .15s ease, transform .15s ease; opacity: 0; transform: translateX(calc(var(--pg-dir) * -18px)) scale(.99); }
#main.pg-in > * { animation: pg-in .5s cubic-bezier(.2, .9, .3, 1) both; }
#main.pg-in > :nth-child(1) { animation-delay: 0s; }
#main.pg-in > :nth-child(2) { animation-delay: .05s; }
#main.pg-in > :nth-child(3) { animation-delay: .1s; }
#main.pg-in > :nth-child(4) { animation-delay: .15s; }
#main.pg-in > :nth-child(5) { animation-delay: .2s; }
#main.pg-in > :nth-child(n+6) { animation-delay: .25s; }
/* หน้าหลัก: การ์ดในตารางทยอยเข้าทีละใบ */
#main.pg-in .dash2 > *, #main.pg-in .d-stats > * { animation: pg-in .5s cubic-bezier(.2, .9, .3, 1) both; }
#main.pg-in .d-stats > :nth-child(1) { animation-delay: .06s; } #main.pg-in .d-stats > :nth-child(2) { animation-delay: .1s; }
#main.pg-in .d-stats > :nth-child(3) { animation-delay: .14s; } #main.pg-in .d-stats > :nth-child(4) { animation-delay: .18s; }
#main.pg-in .dash2 > :nth-child(2) { animation-delay: .12s; } #main.pg-in .dash2 > :nth-child(3) { animation-delay: .18s; }
#main.pg-in .dash2 > :nth-child(4) { animation-delay: .24s; } #main.pg-in .dash2 > :nth-child(5) { animation-delay: .28s; }
#main.pg-in .dash2 > :nth-child(n+6) { animation-delay: .32s; }
@keyframes pg-in { from { opacity: 0; transform: translateX(calc(var(--pg-dir) * 26px)) translateY(8px); } to { opacity: 1; transform: none; } }
/* แถบข้าง: รายการที่เลือกเปลี่ยนสีแบบนุ่ม */
.side .nav-item, .side .nav-main, .room-item { transition: background .25s, color .25s, box-shadow .25s; }
/* เครื่องที่ปิดเอฟเฟกต์เคลื่อนไหว: จางเข้า-ออกอย่างเดียว */
#main.pg-soft.pg-out > * { transform: none; }
#main.pg-soft.pg-in > *, #main.pg-soft.pg-in .dash2 > *, #main.pg-soft.pg-in .d-stats > * { animation-name: pg-fade; }
@keyframes pg-fade { from { opacity: 0; } to { opacity: 1; } }

/* ===== การ์ดเวลาเข้า-ออกโรงเรียน ===== */
.tl { margin: 6px 0 18px; }
.tl-bar { position: relative; height: 34px; border-radius: 12px; overflow: hidden; background: #f2eeee; }
.tl-seg { position: absolute; top: 0; bottom: 0; display: grid; place-items: center; transition: left .35s, width .35s; }
.tl-seg span { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; text-shadow: 0 1px 2px #0004; }
.tl-seg.ok { background: linear-gradient(90deg, #16a34a, #22c55e); } .tl-seg.late { background: #f59e0b; } .tl-seg.heavy { background: #e11d34; }
.tl-seg.early { background: repeating-linear-gradient(135deg, #7a6668, #7a6668 8px, #8f7b7d 8px, #8f7b7d 16px); } .tl-seg.mix { background: #a3a3a3; }
.tl-seg.home { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.tl-mks { position: relative; height: 44px; }
.tl-mk { position: absolute; top: 4px; transform: translateX(-50%); text-align: center; white-space: nowrap; transition: left .35s; }
.tl-mk::before { content: ''; position: absolute; left: 50%; top: -10px; width: 2px; height: 10px; background: currentColor; opacity: .5; }
.tl-mk b { display: block; font-size: 13px; } .tl-mk small { font-size: 11px; color: var(--muted); }
.tl-mk.sw { color: #7c3aed; } .tl-mk.out { color: #2563eb; }
.tl-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 4px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.tbox { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); border-top-width: 4px; cursor: pointer; }
.tbox span { font-size: 14px; } .tbox small { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tbox input[type=time] { font-size: 20px; font-weight: 700; padding: 6px 10px; width: 100%; }
.tbox.in { border-top-color: #f59e0b; } .tbox.late { border-top-color: #e11d34; } .tbox.sw { border-top-color: #7c3aed; } .tbox.out { border-top-color: #2563eb; }
.tfoot { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.tfoot .btn.primary { margin-left: auto; }
.terr { color: #e11d34; font-weight: 600; font-size: 14px; }
body.glass-ui .tl-bar { background: #ffffff14; }
body.glass-ui .terr { color: #ff8a96; }
@media (max-width: 640px) { .tl-mk small { display: none; } .tl-seg span { font-size: 10.5px; } }
.tl-mks { height: 62px; }
.tl-mk:nth-child(even) { top: 26px; }
.tl-mk:nth-child(even)::before { top: -36px; height: 36px; }
body.glass-ui .tl-mk.sw { color: #c4b5fd; } body.glass-ui .tl-mk.out { color: #93c5fd; }
body.glass-ui .tl-mk small { color: #ffffffb3; }
body.glass-ui code, body.glass-ui code.link { background: #ffffff14; color: #ffffffcc; border-color: #ffffff21; }

/* ===== เมนูล่างมือถือ: แบบเรียบ อ่านง่าย (ลดแสง ลดเด้ง ลดสีที่แย่งสายตา) ===== */
@media (max-width: 760px) {
  body.has-mnav .mnav.v3 { height: 62px; transition: --nx .4s cubic-bezier(.4, 0, .2, 1); }
}
.mnav.v3 .mn-bar { background: #1c070cf2; box-shadow: none;
  -webkit-mask: radial-gradient(circle at var(--nx) -4px, transparent 0 31px, #000 32px); mask: radial-gradient(circle at var(--nx) -4px, transparent 0 31px, #000 32px); }
.mnav.v3::before { box-shadow: 0 8px 20px #0000004d;
  -webkit-mask: radial-gradient(circle at var(--nx) -4px, transparent 0 31px, #000 32px); mask: radial-gradient(circle at var(--nx) -4px, transparent 0 31px, #000 32px); }
.mnav.v3 .mn-bub { top: -22px; width: 46px; height: 46px; margin-left: -23px; background: #e11d34; border: 0; box-shadow: 0 4px 10px #0000004d; }
.mnav.v3 .mn-bub svg { width: 22px; height: 22px; filter: none; }
.mnav.v3 .mn-bub.pop { animation: mn-fadein .25s ease; }
@keyframes mn-fadein { from { opacity: .4; } to { opacity: 1; } }
.mnav.v3 .mn-it { color: #ffffff99; font-size: 11.5px; gap: 4px; }
.mnav.v3 .mn-it svg { width: 22px; height: 22px; }
.mnav.v3 .mn-it:active svg { transform: none; }
.mnav.v3 .mn-it.on span { transform: translateY(13px); font-weight: 600; }
.mnav.v3 .mn-it span { transition: transform .3s ease, color .2s; }
.mnav.v3 .mn-it.scan { color: #4ade80; }
.mnav.v3 .mn-it.scan svg { width: 22px; height: 22px; padding: 0; border-radius: 0; background: none; color: #4ade80; box-shadow: none; }
.mnav.v3 .mn-it.scan span { display: block; color: #4ade80; }
.mnav.v3 .mn-home { display: none; }
.mnav.v3 .mn-bd { top: 7px; left: calc(50% + 6px); min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; border: 0; box-shadow: none; }
.mnav.v3 .mn-bar { background: #1c070c; backdrop-filter: none; -webkit-backdrop-filter: none; }
.mnav.v3 .mn-it.on span { transform: translateY(9px); }

/* ===== ลื่นขึ้น: เอาเบลอซ้อน (backdrop-filter) ออกจากการ์ด — พื้นหลังเบลออยู่แล้ว ใช้สีโปร่งแทน เห็นเหมือนเดิมแต่วาดเร็วกว่ามาก ===== */
body.glass-ui .card, body.glass-ui .stat, body.glass-ui .rtile, body.glass-ui .room-tile, body.glass-ui .late-row, body.glass-ui .page-head {
  backdrop-filter: none; -webkit-backdrop-filter: none; background: linear-gradient(160deg, #3a121bcc, #24090fd9); }
body.glass-ui .hero, body.glass-ui .footbar, body.glass-ui .d-scan { backdrop-filter: none; -webkit-backdrop-filter: none; }
body.glass-ui .hero, body.glass-ui .footbar { background: #1a060cf2; }
body.glass-side .side { backdrop-filter: none; }
body.glass-ui::before { will-change: transform; transform: translateZ(0); }
body.glass-ui .side { contain: layout paint; }
#main { contain: layout; }

/* ===== สวิตช์เปิด/ปิดแบบคลิป: ปิด = เทาเข้ม · เปิด = เขียว ปุ่มกลมขาวเลื่อนไปขวา ===== */
.fx-toggle .tr { width: 58px; height: 32px; border-radius: 99px; background: #3a3f4b; box-shadow: inset 0 1px 3px #0006; overflow: visible; transition: background .25s ease, box-shadow .25s ease; }
.fx-toggle .tr::before, .fx-toggle .tr::after { display: none; }
.fx-toggle .kn { top: 3px; left: 3px; width: 26px; height: 26px; background: #fff; box-shadow: 0 2px 6px #0005; transition: transform .25s cubic-bezier(.4, 0, .2, 1), width .15s; }
.fx-toggle .kn::before { display: none; }
.fx-toggle:active .kn { width: 30px; }
.fx-toggle input:checked + .tr { background: #22c55e; box-shadow: 0 0 0 3px #22c55e33, 0 4px 14px #22c55e59; }
.fx-toggle input:checked + .tr .kn { transform: translateX(26px); }
.fx-toggle input:checked:active + .tr .kn { transform: translateX(22px); }
.fx-toggle input:focus-visible + .tr { outline: 3px solid #22c55e88; outline-offset: 3px; }
.fx-toggle input:checked ~ .lb, body.glass-ui .fx-toggle input:checked ~ .lb { color: #22c55e; }
body.glass-ui .fx-toggle input:checked ~ .lb { color: #4ade80; }
body.glass-ui .fx-toggle .tr { background: #3a3f4b; }
body.glass-ui .fx-toggle input:checked + .tr { background: #22c55e; }
/* สวิตช์เล็กอื่น ๆ ในระบบให้เป็นแบบเดียวกัน */
.switch span { background: #3a3f4b; transition: background .25s; }
.switch input:checked + span { background: #22c55e; box-shadow: 0 0 0 3px #22c55e33; }
body.glass-ui .toast { background: #1f070df2; color: #fff; border: 1px solid #ffffff33; }
.fx-toggle input:focus-visible + .tr { outline: 3px solid #ffffff59; }
.fx-toggle input:checked:focus-visible + .tr { outline-color: #22c55e88; }

/* ===== รายการมาสาย: แยกตามห้อง แถวละคน (สั้น อ่านง่าย) ===== */
.lt-ftog { display: none; }
.lt-grp { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; }
.lt-grp header { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: #fbf1f2; border-bottom: 1px solid var(--line); }
.lt-grp header a { display: flex; align-items: center; gap: 8px; color: var(--navy-800); text-decoration: none; font-size: 16px; }
.lt-grp header a svg { width: 18px; height: 18px; color: #c8102e; }
.lt-cnt { margin-left: auto; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: #c8102e; color: #fff; }
.lt-row { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto 46px 34px; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); }
.lt-row:first-of-type { border-top: 0; }
.lt-row .tm { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; color: var(--muted); }
.lt-row .nm { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.lt-row .nm small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-row .pill { font-size: 12px; padding: 2px 9px; }
.lt-row .cnt { text-align: center; text-decoration: none; font-weight: 700; font-size: 15px; line-height: 1.1; color: inherit; }
.lt-row .cnt small { display: block; font-size: 10.5px; font-weight: 400; color: var(--muted); }
.lt-row .icon-btn { width: 32px; height: 32px; } .lt-row .icon-btn svg { width: 16px; height: 16px; }
.lt-empty { padding: 30px 10px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }
body.glass-ui .lt-grp { border-color: #ffffff21; background: #ffffff08; }
body.glass-ui .lt-grp header { background: #ffffff12; border-bottom-color: #ffffff1a; }
body.glass-ui .lt-grp header a { color: #fff; } body.glass-ui .lt-grp header a svg { color: #ff8a96; }
body.glass-ui .lt-row { border-top-color: #ffffff14; }
@media (max-width: 760px) {
  .lt-ftog { display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 14px; margin-bottom: 10px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
  .lt-ftog svg { width: 18px; height: 18px; flex: none; } .lt-ftog svg:last-child { margin-left: auto; transition: transform .2s; }
  .lt-ftog .muted { font-weight: 400; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .lt-filters:not(.open) { display: none; }
  .lt-filters.open + * { margin-top: 4px; }
  body.glass-ui .lt-ftog { border-color: #ffffff2e; }
  .lt-row { grid-template-columns: 42px minmax(0, 1fr) auto 34px 30px; gap: 8px; padding: 9px 12px; }
  .lt-row .pill { font-size: 11px; padding: 2px 7px; }
  .lt-row .nm { font-size: 14.5px; }
}
.lt-row { grid-template-columns: 50px minmax(0, 1fr) 46px 34px; }
.lt-row .nm small.ty { font-weight: 600; }
.lt-row .nm small.warn { color: #d97706; } .lt-row .nm small.bad { color: #c8102e; } .lt-row .nm small.blue { color: #2563eb; }
body.glass-ui .lt-row .nm small.warn { color: #fbbf24; } body.glass-ui .lt-row .nm small.bad { color: #ff8a96; } body.glass-ui .lt-row .nm small.blue { color: #93c5fd; }
.lt-row .icon-btn.edit { background: transparent; border: 1.5px solid var(--line); color: var(--muted); }
.lt-row .icon-btn.edit:hover { border-color: #c8102e; color: #c8102e; }
body.glass-ui .lt-row .icon-btn.edit { border-color: #ffffff33; color: #ffffffb3; }
@media (max-width: 760px) { .lt-row { grid-template-columns: 44px minmax(0, 1fr) 34px 32px; } }
/* ===== ย่อ/ขยายกลุ่มห้อง (เลื่อนนุ่ม) ===== */
.lt-grp header { padding: 0; gap: 0; }
.lt-tg { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 11px 6px 11px 14px; border: 0; background: none; color: inherit; font: inherit; font-size: 16px; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.lt-tg svg { width: 18px; height: 18px; color: #c8102e; flex: none; }
.lt-tg b { color: var(--navy-800); }
.lt-tg .lt-cnt { margin-left: auto; }
.lt-chev { display: grid; flex: none; transition: transform .25s ease; }
.lt-chev svg { color: var(--muted); }
.lt-grp.fold .lt-chev { transform: rotate(-90deg); }
.lt-go { display: grid; place-items: center; width: 40px; align-self: stretch; color: var(--muted); border-left: 1px solid var(--line); }
.lt-go svg { width: 18px; height: 18px; }
.lt-go:hover { color: #c8102e; }
.lt-body { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .28s ease; }
.lt-body > div { overflow: hidden; min-height: 0; }
.lt-grp.fold .lt-body { grid-template-rows: 0fr; }
.lt-grp.fold header { border-bottom-color: transparent; }
.lt-all { margin-right: 4px; }
.lt-all svg { width: 15px; height: 15px; }
body.glass-ui .lt-tg b { color: #fff; } body.glass-ui .lt-tg svg { color: #ff8a96; } body.glass-ui .lt-chev svg { color: #ffffffa6; }
body.glass-ui .lt-go { border-left-color: #ffffff1a; color: #ffffffa6; }
.lt-chev { transform: rotate(180deg); }
.lt-grp.fold .lt-chev { transform: rotate(0deg); }

/* ===== ปุ่มเลือกโหมดหน้าสแกน: อัตโนมัติ / เข้า / ออก ===== */
.scan-top .mode.pick { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 7px 12px 7px 16px; white-space: nowrap; }
.scan-top .mode.pick .ml { font-size: 17px; font-weight: 700; }
.scan-top .mode.pick small { font-size: 11.5px; font-weight: 600; background: #ffffff33; padding: 2px 8px; border-radius: 99px; }
.scan-top .mode.pick svg { width: 16px; height: 16px; opacity: .85; }
.mode-pop { position: fixed; z-index: 80; width: 260px; padding: 6px; border-radius: 16px; background: #1f070df7; border: 1px solid #ffffff2e; box-shadow: 0 18px 40px #000a; color: #fff;
  animation: mp-in .16s ease-out; }
.mode-pop[hidden] { display: none; }
@keyframes mp-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.mode-pop button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 0; border-radius: 11px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.mode-pop button:hover { background: #ffffff12; }
.mode-pop button.on { background: #ffffff1c; box-shadow: inset 0 0 0 1.5px #22c55e; }
.mode-pop b { display: block; font-size: 15px; } .mode-pop small { color: #ffffffa6; font-size: 12px; }
.mode-pop .d { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.mode-pop .d.auto { background: conic-gradient(var(--green) 0 50%, var(--orange) 50% 100%); }
.mode-pop .d.in { background: var(--green); } .mode-pop .d.out { background: var(--orange); }
.mode-pop button.on::after { content: '✓'; margin-left: auto; color: #4ade80; font-weight: 700; }
@media (max-width: 640px) { .scan-top .mode.pick { padding: 6px 10px 6px 12px; gap: 6px; } .scan-top .mode.pick .ml { font-size: 15px; } }

.manual { margin-top: 14px; display: flex; justify-content: center; }
.manual input { width: min(460px, 90vw); padding: 12px 18px; border-radius: 999px; border: 1px solid #ffffff55; background: #00000040; color: #fff; font-size: 17px; text-align: center; outline: none; }
.manual input:focus { border-color: #fff; background: #00000066; }
.manual input::placeholder { color: #ffffffa0; }

/* ===== พื้นหลังปกโรงเรียน (หน้าเปิดระบบ + หน้าเข้าสู่ระบบ ใช้ชุดเดียวกัน) =====
   ภาพปกเป็นแนวตั้ง (1055×1491): จอแนวตั้ง/มือถือ = เต็มจอ เห็นตรา+ชื่อ+อาคารครบ
   จอแนวนอน = วางภาพเต็มใบทางซ้าย (ไม่ซูมจนตราถูกตัด) พื้นข้างเป็นภาพเดียวกันเบลอ ส่วนกล่องเข้าสู่ระบบ/แถบโหลดอยู่ทางขวา */
.lg-bg, .splash .sp-bg { position: fixed; inset: 0; height: auto; overflow: hidden; background: #e9ebf1; opacity: 1; filter: none; animation: none; transform: none; z-index: -2; }
.splash .sp-bg { position: absolute; z-index: 0; }
.lg-bg::before, .splash .sp-bg::before { content: ''; position: absolute; inset: -40px; background: url(../assets/cover.png) center / cover; filter: blur(34px) saturate(1.05); opacity: .85; }
.lg-bg::after, .splash .sp-bg::after { content: ''; position: absolute; inset: 0; background: url(../assets/cover.png) center top / cover no-repeat; }
@media (min-aspect-ratio: 1/1) {
  .lg-bg::after, .splash .sp-bg::after { inset: 0 auto 0 30%; transform: translateX(-50%); aspect-ratio: 1055 / 1491; width: auto; background-size: 100% 100%; background-position: center; box-shadow: none; -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 7%, #000 93%, transparent 100%); }
}
.lg-shade { background: none; }
.lg-main { padding-top: 10px; }
@media (min-aspect-ratio: 1/1) and (min-width: 900px) {
  .lg-main { justify-items: end; padding-right: max(24px, 9vw); }
}
@media (max-width: 720px) {
  .lg-bg { bottom: 0; height: auto; background-position: center; }
  .lg-main { padding: 34vh 12px 10px; }
}
/* หน้าเปิดระบบ (splash) แบบสว่างให้เข้ากับปก */
.splash { background: #e9ebf1; color: #1b2a6b; }
.splash .sp-grid, .splash .sp-glow, .splash .sp-sweep, .splash .sp-c, .splash .sp-logo, .splash .sp-name, .splash .sp-en { display: none; }
.splash .sp-top, .splash .sp-bot { color: #1b2a6b99; position: absolute; z-index: 2; }
.splash .sp-bot span:first-child { color: #1b2a6bcc; }
.splash .sp-center { position: relative; z-index: 2; width: min(440px, 90vw); padding: 24px 26px 20px; border-radius: 22px; background: #ffffffe0; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px #1b2a6b33, 0 0 0 1px #c8102e22; }
.splash .sp-sys { margin: 0 0 18px; color: #8e0b20; font-size: 18px; }
.splash .sp-sys span { background: linear-gradient(90deg, transparent, #c8102e); }
.splash .sp-bar { background: #1b2a6b1a; }
.splash .sp-meta { color: #444; } .splash .sp-pct { color: #1b2a6b; }
.splash .dot { background: #c8102e; box-shadow: 0 0 8px #c8102e99; }
@media (min-aspect-ratio: 1/1) and (min-width: 900px) { .splash .sp-center { justify-self: end; margin-right: max(24px, 9vw); } }
@media (max-aspect-ratio: 1/1), (max-width: 899px) { .splash .sp-center { align-self: end; margin-bottom: 14vh; } }
@media (min-aspect-ratio: 1/1) and (min-width: 900px) { .splash .sp-top, .splash .sp-bot { left: 52%; } }

/* แก้: เลื่อนเมาส์ไปบนแถวในธีมกระจก พื้นแถวกลายเป็นสีขาวอมชมพู ตัวหนังสือสีขาวเลยมองไม่เห็น */
body.glass-ui .tbl tbody tr:hover { background: #ffffff0f; }
.tbl tbody tr:has(td.empty):hover { background: transparent; }
body.glass-ui .tbl td.empty { color: #ffffffb3; }

/* ป้ายจำนวน (มาสาย/จำนวนนักเรียน) บนแท็บ ชิป ห้อง */
.late-bdg { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: #c8102e; color: #fff; font-size: 11.5px; font-weight: 700; line-height: 18px; text-align: center; }
.chip.on .late-bdg, .seg-tabs button.on .late-bdg { background: #fff; color: #c8102e; }
.chip small, .seg-tabs button small { opacity: .7; font-size: 11.5px; margin-left: 3px; }
.chip.on small, .seg-tabs button.on small { opacity: .9; }
body.glass-ui .seg-tabs { background: #ffffff14; }
body.glass-ui .seg-tabs button { color: #ffffffcc; }
/* ลื่นไหล: ไม่วาดรายการที่อยู่นอกจอ */
.late-row, .lt-grp { content-visibility: auto; contain-intrinsic-size: auto 64px; }

/* ===== จอแนวนอน: ใช้ปก 16:9 เต็มจอ และกล่องเข้าสู่ระบบ/แถบโหลดอยู่กลางจอ ===== */
@media (min-aspect-ratio: 1/1) {
  .lg-bg::after, .splash .sp-bg::after { inset: 0; transform: none; width: auto; aspect-ratio: auto; -webkit-mask-image: none; mask-image: none; box-shadow: none; background-size: cover; background-repeat: no-repeat; background-position: center top; }
  .lg-bg::after { background-image: url(../assets/cover-16x9-login.jpg); }   /* กล่องมีตราและชื่อโรงเรียนอยู่แล้ว จึงใช้ปกที่ไม่มีตราซ้ำ */
  .splash .sp-bg::after { background-image: url(../assets/cover-16x9.jpg); }
  .lg-bg::before, .splash .sp-bg::before { display: none; }
}
@media (min-aspect-ratio: 1/1) and (min-width: 900px) {
  .lg-main { justify-items: center; padding-right: 16px; }
  .splash .sp-center { justify-self: center; align-self: end; margin: 0 0 13vh; }
  .splash .sp-top, .splash .sp-bot { left: 70px; }
}
@media (min-aspect-ratio: 1/1) { .splash .sp-top, .splash .sp-bot { display: none; } }

/* ===== จัดหน้าจอมือถือ ===== */
@media (max-width: 640px) {
  body .hero-title h1 { white-space: normal; overflow: visible; font-size: 13.5px !important; line-height: 1.3 !important; letter-spacing: 0; }
  body .hero-title { padding-left: 8px; flex: 1 1 0; }
  .rb-head { flex-wrap: wrap; row-gap: 2px; }
  .rb-head .rb-meta { white-space: normal; padding: 0 0 6px; }
  div:has(> #rmDay) { display: flex; flex-wrap: nowrap; gap: 8px; width: 100%; }
  div:has(> #rmDay) > * { flex: 1 1 0; min-width: 0; justify-content: center; }
  div:has(> #rmDay) > #rmDay { flex: 2 1 0; }
  .toolbar > label { flex: 1 0 100%; }
  .toolbar > input[type="date"] { flex: 1 1 36%; min-width: 0; }
  .toolbar > span.muted:has(+ input[type="date"]) { flex: 0 0 auto; }
}
/* จอตั้ง: แสดงปกเต็มความกว้าง ชื่อโรงเรียนภาษาอังกฤษไม่ถูกตัด */
@media (max-aspect-ratio: 1055/1491) { .lg-bg::after { background-size: 100% auto; } }
/* แท็บเล็ตแนวตั้ง: เลื่อนกล่องเข้าสู่ระบบลง ไม่บังชื่อโรงเรียนบนปก */
@media (min-width: 721px) and (max-aspect-ratio: 1/1) { .lg-main { padding-top: 34vh; align-content: start; } }
/* จอเล็กมาก */
@media (max-width: 360px) {
  .lg-bg::after { background-position: center 52px; }
  body .hero-title h1 { font-size: 12px !important; }
  .scan-top { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .scan-top .tbtn { width: 34px; height: 34px; min-width: 0; padding: 0; }
  .scan-top img { width: 32px; height: 32px; }
}
/* iPhone ซูมหน้าเองเมื่อช่องกรอกตัวเล็กกว่า 16px */
@supports (-webkit-touch-callout: none) { input, select, textarea { font-size: 16px !important; } }
