:root {
  --bg: #f2f5f4;
  --card: #ffffff;
  --ink: #111827;
  --ink-deep: #0b2b29;
  --ink-2: #374151;
  --ink-3: #4b5563;
  --muted: #6b7280;
  --line: #dde4e2;
  --line-soft: #eef2f1;
  --teal: #0d9488;
  --teal-700: #0f766e;
  --teal-900: #134e4a;
  --mint: #2dd4bf;
  --mint-soft: #ccfbf1;
  --mint-text: #99f6e4;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 24px -16px rgba(16, 24, 40, 0.14);
  --shadow-float: 0 1px 2px rgba(16, 24, 40, 0.05), 0 12px 28px -16px rgba(16, 24, 40, 0.18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Poppins, 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ── แถบเมนูลอย ── */
.nav-holder { position: sticky; top: 0; z-index: 5; padding: 14px 24px 0; }
/* ม่านสีพื้นหลังแถบ: เนื้อหาที่เลื่อนผ่านจะจางหายก่อนถึงขอบบน ไม่โผล่ในช่องว่างเหนือแถบ */
.nav-holder::before { content: ''; position: absolute; inset: 0 0 -18px; z-index: -1; pointer-events: none; background: linear-gradient(var(--bg) 45%, rgba(242, 245, 244, 0)); }
.nav {
  max-width: 1200px; margin: 0 auto; min-height: 66px; padding: 10px 10px 10px 24px;
  background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9), 0 0 0 1px rgba(19, 78, 74, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 24px -18px rgba(19, 78, 74, 0.25);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  transition: box-shadow 0.25s, background 0.25s;
}
.nav-holder.scrolled .nav {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9), 0 0 0 1px rgba(19, 78, 74, 0.08), 0 2px 4px rgba(16, 24, 40, 0.05), 0 18px 36px -18px rgba(19, 78, 74, 0.42);
}
.nav img { height: 30px; width: auto; display: block; }
.nav .spacer { flex: 1; }
.tag { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; color: var(--teal-700); background: var(--mint-soft); border-radius: 999px; padding: 4px 10px; }
.nav .tag { display: inline-flex; align-items: center; gap: 7px; margin-left: 4px; padding: 5px 12px 5px 10px; font-size: 11px; letter-spacing: 0.12em; color: #fff; background: var(--teal-900); }
.nav .tag::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: var(--mint); }
.navbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 46px; height: 46px; padding: 0 14px;
  border: 0; border-radius: 999px; background: var(--bg); color: var(--ink-2); font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.navbtn:hover { background: var(--mint-soft); color: var(--teal-900); }
.navbtn:active { transform: scale(0.95); }
.navbtn:has(span) { padding: 0 18px 0 14px; }
.navbtn.out:hover { background: #fee2e2; color: var(--danger); }
.nav-sep { width: 1px; height: 26px; margin: 0 4px; background: var(--line); }
.me { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 18px 0 5px; border-radius: 999px; background: var(--teal-900); color: #fff; box-shadow: 0 8px 18px -12px rgba(19, 78, 74, 0.8); }
.me .avatar { width: 36px; height: 36px; border-radius: 999px; background: linear-gradient(135deg, #5eead4, var(--mint)); color: var(--teal-900); display: grid; place-items: center; font-weight: 700; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35); }
.me .who { line-height: 1.2; }
.me .who b { display: block; font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { font-size: 11px; color: var(--mint-text); }
/* ปุ่มเปลี่ยนรหัสผ่านอยู่ท้ายแคปซูลชื่อผู้ใช้ */
.me:has(.me-btn) { padding-right: 5px; }
.me-btn { display: grid; place-items: center; width: 36px; height: 36px; margin-left: 4px; padding: 0; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: #fff; transition: background 0.15s, color 0.15s, transform 0.15s; }
.me-btn:hover { background: var(--mint); color: var(--teal-900); }
.me-btn:active { transform: scale(0.92); }
.me-btn:focus-visible { outline: 2px solid #5eead4; outline-offset: 2px; }

/* ── ปุ่ม ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 22px; border-radius: 999px; border: 0; font-size: 14px; font-weight: 600; text-decoration: none; }
.btn-dark { background: var(--ink-deep); color: #fff; }
.btn-dark:hover { background: var(--teal-900); }
.btn-line { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px #9aa8a5; }
.btn-line:hover { background: #e9eeec; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ── หน้ารวม ── */
main.home { padding-top: 56px; padding-bottom: 56px; display: flex; flex-direction: column; gap: 44px; }
.status { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: #115e59; background: #fff; border-radius: 999px; padding: 6px 14px 6px 10px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06); }
.status i { width: 8px; height: 8px; border-radius: 999px; background: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18); }
/* แถวป้ายบนหัวหน้ารวม: สถานะเข้าสู่ระบบ + จำนวนคนที่กำลังใช้งานแอป */
.status-row { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 8px; }
.status.live { color: var(--ink-2); text-decoration: none; transition: box-shadow 0.15s, color 0.15s; }
.status.live b { font-weight: 700; color: var(--teal-900); font-variant-numeric: tabular-nums; }
.status.live i { background: #0ea5e9; box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18); }
.status.live.idle i { background: #9aa8a5; box-shadow: 0 0 0 4px rgba(154, 168, 165, 0.2); animation: none; }
a.status.live:hover { color: var(--teal-900); box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.45), 0 6px 14px -10px rgba(19, 78, 74, 0.45); }
/* กล่อง "กำลังใช้งาน" ในการ์ดนาฬิกา (มุมขวาบนข้างเวลา) — แสดงแทนป้ายแคปซูลเมื่อการ์ดแสดงอยู่ */
.hp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.hp-live {
  flex: none; min-width: 112px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 12px 16px 14px; border-radius: 22px; color: #fff; text-decoration: none;
  background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}
.hp-live b { font-family: Poppins, sans-serif; font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 6px; }
.hp-live-tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 999px; background: rgba(94, 234, 212, 0.16); color: #5eead4; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; }
.hp-live-tag i { width: 7px; height: 7px; border-radius: 999px; background: #5eead4; animation: ping-mint 2s ease-out infinite; }
.hp-live-sub { font-size: 12px; font-weight: 500; color: var(--mint-text); white-space: nowrap; }
.hp-live.idle b { color: rgba(255, 255, 255, 0.55); }
.hp-live.idle .hp-live-tag { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.6); letter-spacing: 0.02em; }
.hp-live.idle .hp-live-tag i { background: rgba(255, 255, 255, 0.5); animation: none; }
a.hp-live:hover { background: rgba(255, 255, 255, 0.14); box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.45), 0 14px 22px -14px rgba(0, 0, 0, 0.5); transform: translateY(-2px); }
a.hp-live:focus-visible { outline-color: #fff; }
@keyframes ping-mint { 0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0.6); } 70%, 100% { box-shadow: 0 0 0 7px rgba(94, 234, 212, 0); } }
/* การ์ดแสดง (>980px) = ใช้กล่องในการ์ด ซ่อนป้ายแคปซูล · การ์ดถูกซ่อน = ใช้ป้ายแคปซูล */
@media (min-width: 981px) { .status.live { display: none !important; } }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); gap: 32px; align-items: stretch; }
.hero-main { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.hero-panel { position: relative; overflow: hidden; padding: 28px; border-radius: 32px; background: var(--teal-900); color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 22px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 24px 44px -22px rgba(19, 78, 74, 0.65); animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.hero-panel::before { content: ''; position: absolute; right: -90px; top: -110px; width: 280px; height: 280px; border-radius: 999px; background: var(--teal-700); opacity: 0.55; }
.hero-panel::after { content: ''; position: absolute; left: -60px; bottom: -80px; width: 180px; height: 180px; border-radius: 999px; background: var(--mint); opacity: 0.1; }
.hero-panel > * { position: relative; }
/* นาฬิกาเป็นจุดเด่น: วัน → เวลาตัวใหญ่ → วันที่ */
.hp-top { display: flex; flex-direction: column; }
.hp-label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--mint-text); }
.hp-top .hp-label { font-size: 14px; letter-spacing: 0; color: #5eead4; }
.hp-clock { margin: 6px 0 8px -3px; font-family: Poppins, sans-serif; font-size: 72px; font-weight: 700; line-height: 0.95; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; color: #fff; }
.hp-date { font-size: 15px; font-weight: 500; line-height: 1.4; color: var(--mint-soft); }
/* จำนวนแอป: แถวเดียว ไม่มีกรอบซ้อน — ข้อความซ้าย แถบแบ่งช่องขวา */
.hp-stats { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.hp-stat-text { font-size: 14px; font-weight: 500; color: var(--mint-soft); white-space: nowrap; }
.hp-stat-text b { font-family: Poppins, sans-serif; font-size: 18px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.hp-stat-text small { font-size: 13px; color: #5eead4; }
.hp-segs { flex: 1; max-width: 160px; display: flex; gap: 4px; }
.hp-segs i { flex: 1; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); }
.hp-segs i.on { background: #5eead4; animation: seg-on 0.4s ease backwards; animation-delay: calc(0.4s + var(--i, 0) * 90ms); }
@keyframes seg-on { from { background: rgba(255, 255, 255, 0.14); } }
.hp-apps { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.hp-apps > * { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.09); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); color: rgba(255, 255, 255, 0.45); }
.hp-apps a { background: var(--mint); color: var(--teal-900); box-shadow: none; transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1), background 0.2s, box-shadow 0.3s, opacity 0.2s; }
/* ชี้เมาส์: ไอคอนเด้งขึ้น เป็นสีขาวมีวงเรืองมินต์ ไอคอนอื่นจางลง และชื่อแอปขึ้นข้างหัวข้อ */
.hp-apps a:hover, .hp-apps a:focus-visible { transform: translateY(-5px) scale(1.12); background: #fff; box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.28), 0 14px 22px -10px rgba(0, 0, 0, 0.55); }
.hp-apps a:active { transform: translateY(-1px) scale(0.96); transition-duration: 0.1s; }
.hp-apps a svg { transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1); }
.hp-apps a:hover svg { transform: scale(1.08) rotate(-6deg); }
.hp-apps:hover a:not(:hover) { opacity: 0.55; }
.hp-apps > div { transition: background 0.2s, color 0.2s; }
.hp-apps > div:hover { background: rgba(255, 255, 255, 0.14); color: rgba(255, 255, 255, 0.7); }
.hp-apps-head { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.hp-apps-head span { padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 12px; font-weight: 600; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transform: translateX(-6px); transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.hp-apps-head span.on { opacity: 1; transform: none; }
.hp-apps-head span.dim { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); color: var(--mint-soft); font-weight: 500; }
.hp-apps a:focus-visible { outline-color: #fff; }
.hp-none { margin-top: 8px; font-size: 13px; line-height: 1.6; color: var(--mint-soft); }
.hero h1 { font-size: clamp(32px, 5vw, 56px); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; color: var(--ink-deep); overflow-wrap: anywhere; }
.hero h1 span { color: var(--teal); }

/* ── ลูกเล่นเคลื่อนไหวของหน้ารวม (ปิดทั้งหมดเมื่อผู้ใช้ตั้งค่าลดการเคลื่อนไหว — ดูท้ายไฟล์) ── */
/* แสงสีลอยช้าๆ หลังเนื้อหา */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; width: 620px; height: 620px; border-radius: 999px; will-change: transform; }
.aurora i:nth-child(1) { left: -160px; top: -180px; background: radial-gradient(closest-side, rgba(45, 212, 191, 0.3), rgba(45, 212, 191, 0)); animation: drift-a 22s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { right: -200px; top: 120px; background: radial-gradient(closest-side, rgba(14, 165, 233, 0.16), rgba(14, 165, 233, 0)); animation: drift-b 28s ease-in-out infinite alternate; }
.aurora i:nth-child(3) { left: 30%; bottom: -320px; background: radial-gradient(closest-side, rgba(13, 148, 136, 0.2), rgba(13, 148, 136, 0)); animation: drift-c 26s ease-in-out infinite alternate; }
/* ลูกบอลเด้งในพื้นหลัง — ตำแหน่งขยับด้วย balls.js */
.aurora .ball { position: absolute; left: 0; top: 0; border-radius: 999px; opacity: 0.55; will-change: transform; box-shadow: inset -10px -14px 26px rgba(19, 78, 74, 0.12), 0 18px 30px -18px rgba(19, 78, 74, 0.35); }
@keyframes drift-a { to { transform: translate(180px, 120px) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-220px, 160px) scale(0.9); } }
@keyframes drift-c { to { transform: translate(140px, -180px) scale(1.2); } }

/* ส่วนหัวค่อยๆ ลอยขึ้นทีละชิ้น */
.hero-main > * { animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.hero-main > :nth-child(2) { animation-delay: 0.08s; }
.hero-main > :nth-child(3) { animation-delay: 0.16s; }
.hero-panel { animation-delay: 0.12s; }

/* ข้อความไล่สีวิ่ง */
.hero h1 span.shine { color: transparent; background: linear-gradient(90deg, var(--teal) 0%, #2dd4bf 25%, #0ea5e9 50%, #2dd4bf 75%, var(--teal) 100%) 0 0 / 300% 100%; -webkit-background-clip: text; background-clip: text; padding: 0.12em 0; animation: shine 9s linear infinite; }
@keyframes shine { to { background-position: -300% 0; } }

/* จุดสถานะเต้นเป็นคลื่น */
.status i { animation: ping 2.2s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); } 70%, 100% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); } }
.status.live:not(.idle) i { animation: ping-blue 2.2s ease-out infinite; }
@keyframes ping-blue { 0% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.5); } 70%, 100% { box-shadow: 0 0 0 9px rgba(14, 165, 233, 0); } }

/* การ์ดสรุป: วงกลมลอย แสงตามเมาส์ นาฬิกากะพริบ ทางลัดเด้งเข้าทีละอัน */
.hero-panel { background: radial-gradient(280px circle at var(--mx, 70%) var(--my, 0%), rgba(94, 234, 212, 0.2), rgba(94, 234, 212, 0) 70%), var(--teal-900); }
.hero-panel::before { animation: bob-a 11s ease-in-out infinite alternate; }
.hero-panel::after { animation: bob-b 13s ease-in-out infinite alternate; }
@keyframes bob-a { to { transform: translate(-36px, 30px) scale(1.12); } }
@keyframes bob-b { to { transform: translate(44px, -28px) scale(1.25); } }
.hp-clock i { font-style: normal; margin: 0 0.02em; animation: blink 2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.hp-apps > * { animation: pop 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) backwards; animation-delay: calc(0.35s + var(--i, 0) * 55ms); }
@keyframes pop { from { opacity: 0; transform: scale(0.5) translateY(8px); } }

/* การ์ดแอปลอยขึ้นไล่กัน + ไอคอนเอียงเมื่อชี้ */
.grid.intro > .card { animation: rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: calc(var(--i, 0) * 55ms); }
.card .tile { transition: transform 0.3s cubic-bezier(0.2, 1.3, 0.4, 1); }
a.card:hover .tile { transform: rotate(-8deg) scale(1.1); }
.card.feat { position: relative; overflow: hidden; }
.card.feat::after { content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%; pointer-events: none; background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0)); transform: skewX(-18deg); animation: sheen 6s ease-in-out infinite; }
@keyframes sheen { 0%, 55% { left: -60%; } 100% { left: 130%; } }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 12px; }
.search { position: relative; flex: 1 1 340px; max-width: 520px; }
.search svg { position: absolute; left: 20px; top: 18px; color: var(--muted); }
.search input { width: 100%; height: 56px; padding: 0 20px 0 52px; border: 0; border-radius: 999px; background: #fff; font-size: 16px; box-shadow: var(--shadow-float); }
.search input::placeholder { color: #9ca3af; }
/* ตัวกรองแผนก: ป้ายแยกชิ้นอยู่แถวของตัวเองใต้ช่องค้นหา — ขึ้นหลายแถวได้โดยไม่มีกรอบใหญ่ครอบ */
.chips { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 16px;
  border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.75); color: var(--ink-2);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.chips button:hover { background: #fff; color: var(--teal-900); box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.45), 0 6px 14px -10px rgba(19, 78, 74, 0.45); }
.chips button:active { transform: scale(0.97); }
.chips button b {
  min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--line-soft); color: var(--ink-3); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: background 0.15s, color 0.15s;
}
.chips button:hover b { background: var(--mint-soft); color: var(--teal-700); }
.chips button[aria-pressed='true'] { background: var(--teal-900); color: #fff; font-weight: 600; box-shadow: 0 8px 18px -10px rgba(19, 78, 74, 0.7); }
.chips button[aria-pressed='true'] b { background: rgba(255, 255, 255, 0.16); color: var(--mint-text); }
.chips button.none:not([aria-pressed='true']) { background: transparent; color: var(--ink-3); box-shadow: none; outline: 1px dashed #b8c4c1; outline-offset: -1px; }
.chips button.none:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
@media (max-width: 640px) {
  /* จอแคบ: เลื่อนซ้าย-ขวาแถวเดียว ไม่กินความสูงจอ */
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -24px; padding: 2px 24px 6px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips button { flex: none; }
}

.notice { padding: 14px 18px; border-radius: 16px; background: #fef3c7; color: #78350f; font-size: 14px; }

.group { display: flex; flex-direction: column; gap: 16px; }
.group-head { display: flex; align-items: baseline; gap: 10px; }
.group-head h2 { font-size: 20px; font-weight: 700; color: var(--ink-deep); letter-spacing: -0.01em; }
.group-head span { font-size: 13px; font-weight: 500; color: var(--muted); }
.group-head::after { content: ''; flex: 1; height: 1px; background: var(--line); align-self: center; }
.group.no-access .group-head h2 { color: var(--ink-3); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(264px, 1fr)); gap: 16px; }

.card { display: flex; flex-direction: column; gap: 16px; min-height: 236px; padding: 22px; border-radius: 24px; background: var(--card); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s; }
/* ชี้เมาส์: การ์ดลอยขึ้น มีขอบเขียวบาง ๆ และแสงนุ่มตามตำแหน่งเมาส์ (--mx/--my ตั้งจาก home.js) */
a.card { position: relative; overflow: hidden; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s; }
a.card > * { position: relative; }
a.card::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s; background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%), rgba(45, 212, 191, 0.2), rgba(45, 212, 191, 0) 65%); }
a.card:hover::before, a.card:focus-visible::before { opacity: 1; }
a.card:hover { transform: translateY(-6px); box-shadow: inset 0 0 0 1.5px rgba(13, 148, 136, 0.4), 0 2px 4px rgba(16, 24, 40, 0.04), 0 28px 44px -20px rgba(19, 78, 74, 0.42); }
a.card:active { transform: translateY(-2px) scale(0.985); transition-duration: 0.1s; }
a.card .tile { transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1), box-shadow 0.3s; }
a.card:hover .tile { transform: scale(1.08) rotate(-5deg); box-shadow: 0 12px 20px -10px rgba(19, 78, 74, 0.55); }
a.card h3 { transition: color 0.2s; }
a.card:not(.feat):hover h3 { color: var(--teal-700); }
a.card .role i { transition: box-shadow 0.3s; }
a.card:hover .role i { box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.3); }
a.card.feat::before { background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%), rgba(94, 234, 212, 0.26), rgba(94, 234, 212, 0) 65%); }
a.card.feat:hover { box-shadow: inset 0 0 0 1.5px rgba(94, 234, 212, 0.45), 0 2px 4px rgba(16, 24, 40, 0.06), 0 30px 48px -20px rgba(19, 78, 74, 0.75); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tile { flex: none; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: var(--teal); }
.tile.sales { background: #0369a1; }
.tile.hr { background: #b45309; }
.role { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 5px 12px 5px 10px; background: var(--bg); color: var(--ink-2); }
.role i { width: 7px; height: 7px; border-radius: 999px; background: var(--teal); }
.card h3 { font-size: 19px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.card .en { font-size: 12px; color: var(--muted); font-family: Poppins, sans-serif; }
.card .desc { font-size: 14px; line-height: 1.6; color: var(--ink-3); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; font-size: 14px; font-weight: 600; }
.card-foot small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.go { flex: none; width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; background: var(--ink-deep); color: #fff; transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1), background 0.2s, box-shadow 0.3s; }
a.card:hover .go { transform: translate(3px, -3px) scale(1.08); background: var(--teal); box-shadow: 0 10px 18px -8px rgba(13, 148, 136, 0.7); }

.card.feat { background: var(--teal-900); color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 18px 36px -18px rgba(19, 78, 74, 0.6); }
.card.feat .tile { background: var(--mint); color: var(--teal-900); }
.card.feat .role { background: rgba(255, 255, 255, 0.14); color: #fff; }
.card.feat .role i { background: #5eead4; }
.card.feat .en, .card.feat .card-foot small { color: var(--mint-text); }
.card.feat .desc { color: var(--mint-soft); }
.card.feat .go { background: var(--mint); color: var(--teal-900); }
a.card.feat:hover .go { background: #fff; }

.card.off { background: var(--bg); box-shadow: inset 0 0 0 1.5px #b8c4c1; color: var(--ink-3); }
.card.off .tile { background: #e1e7e5; color: var(--ink-3); }
.card.off .role { background: #e1e7e5; color: var(--ink-3); }
.card.off h3 { color: var(--ink-2); }
.card.off .card-foot { font-weight: 500; font-size: 13px; color: var(--ink-3); }

.empty { padding: 56px 24px; text-align: center; border-radius: 24px; box-shadow: inset 0 0 0 1.5px #b8c4c1; color: var(--ink-3); }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }

/* ── ฟอร์ม / กล่องโต้ตอบ ── */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .field .label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.input, .field select { width: 100%; height: 52px; padding: 0 18px; border: 0; border-radius: 16px; background: var(--bg); font-size: 15px; }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 44px; }
.input:focus, .field select:focus { outline: none; background-color: #fff; box-shadow: inset 0 0 0 1.5px var(--teal), 0 0 0 5px rgba(13, 148, 136, 0.14); }
.hint { font-size: 12px; color: var(--muted); }
.error { padding: 12px 16px; border-radius: 14px; background: #fee2e2; color: #991b1b; font-size: 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--teal); }

dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 28px; background: #fff; color: var(--ink); box-shadow: 0 30px 60px -20px rgba(11, 43, 41, 0.45); }
dialog::backdrop { background: rgba(11, 43, 41, 0.45); backdrop-filter: blur(3px); }
dialog form { display: flex; flex-direction: column; gap: 18px; padding: 28px; }
dialog h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink-deep); }
dialog .sub { font-size: 14px; color: var(--muted); margin-top: -10px; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.access-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 14px; }
.access-list .field label { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.access-list .field select { height: 46px; border-radius: 14px; }
.mini { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px; background: var(--mint-soft); color: #115e59; }
.mini.plain { background: #e1e7e5; color: var(--ink-3); }

/* ── กล่องเพิ่ม/แก้ไขผู้ใช้: หัว-ท้ายอยู่กับที่ เนื้อหาเลื่อนตรงกลาง ── */
dialog.sheet { width: min(680px, calc(100vw - 32px)); overflow: hidden; }
dialog.sheet form { padding: 0; gap: 0; max-height: calc(100vh - 32px); }
.dlg-head { display: flex; align-items: center; gap: 14px; padding: 22px 20px 20px 28px; border-bottom: 1px solid var(--line-soft); }
.dlg-avatar { flex: none; width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; background: var(--teal-900); color: #5eead4; font-size: 22px; font-weight: 700; }
.dlg-heading { flex: 1; min-width: 0; }
.dlg-heading h2 { font-size: 22px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-heading p { margin-top: 2px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-head .iconbtn { flex: none; color: var(--ink-3); }
.dlg-body { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 28px; }
.dlg-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 16px 28px; border-top: 1px solid var(--line-soft); background: #fafcfb; }
.sec { display: flex; flex-direction: column; gap: 14px; }
.sec-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; color: var(--teal-700); }
.sec-title::before { content: ''; width: 4px; height: 14px; border-radius: 999px; background: var(--mint); }
.sec-count { font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--mint-soft); color: #115e59; }
.input:disabled { color: var(--muted); cursor: not-allowed; }

.switch.opt { align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--bg); transition: background 0.15s, box-shadow 0.15s; }
.switch.opt .track { order: 2; margin-left: auto; }
.switch.opt:has(input:checked) { background: #ecfdf8; box-shadow: inset 0 0 0 1.5px #99e6d8; }
.switch.opt:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.opt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-text b { font-size: 14px; font-weight: 600; color: var(--ink); }
.opt-text span { font-size: 12px; line-height: 1.5; color: var(--muted); }

.acc-list { display: flex; flex-direction: column; gap: 8px; }
.acc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 10px 10px 10px 12px; border-radius: 18px; box-shadow: inset 0 0 0 1.5px var(--line-soft); transition: background 0.15s, box-shadow 0.15s; }
.acc-row.on { background: #ecfdf8; box-shadow: inset 0 0 0 1.5px #99e6d8; }
.acc-tile { flex: none; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: #e1e7e5; color: var(--ink-3); transition: background 0.15s, color 0.15s; }
.acc-row.on .acc-tile { background: var(--teal); color: #fff; }
.acc-name { flex: 1 1 180px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.acc-name b { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.acc-row.on .acc-name b { color: var(--ink); }
.acc-sel { flex: 0 1 200px; }
.acc-sel select { height: 44px; border-radius: 14px; font-size: 14px; color: var(--muted); }
.acc-row.on .acc-sel select { background-color: #fff; color: var(--ink); font-weight: 600; }
@media (max-width: 520px) {
  .dlg-head { padding-left: 20px; }
  .dlg-body { padding: 20px; }
  .dlg-foot { padding: 14px 20px; }
  .acc-sel { flex-basis: 100%; }
}

/* ── หน้าเข้าสู่ระบบ ── */
.login { min-height: 100vh; padding: 16px; display: flex; gap: 16px; }
.login aside { position: relative; overflow: hidden; flex: 0 0 47%; padding: 44px; border-radius: 32px; background: var(--teal-900); color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login aside::before { content: ''; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 999px; background: var(--teal-700); opacity: 0.55; }
.login aside > * { position: relative; }
.login .brand { display: flex; align-items: center; gap: 12px; }
.login .brand img { width: 168px; height: auto; }
.login .brand .tag { background: #5eead4; color: var(--teal-900); }
.login .tiles { display: grid; grid-template-columns: repeat(5, 72px); gap: 12px; }
.login .tiles div { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.09); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); color: var(--mint-text); }
.login .tiles div:first-child { background: var(--mint); color: var(--teal-900); box-shadow: none; }
.login .pitch h1 { font-size: clamp(38px, 4.4vw, 60px); font-weight: 700; line-height: 1.08; letter-spacing: -0.035em; }
.login .pitch h1 span { display: inline-block; margin-top: 10px; font-size: 0.56em; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; color: #5eead4; }
/* บรรทัดเดียวทุกความกว้างที่แผงนี้แสดง (>860px): ย่อตัวอักษรตามความกว้างแผง (47vw − padding) · จอแคบกว่า 1100px ลด padding แผงให้ตัวอักษรไม่เล็กเกิน */
.login .pitch p { margin-top: 18px; font-size: clamp(13px, calc((47vw - 104px) / 32), 16px); line-height: 1.7; color: var(--mint-soft); white-space: nowrap; }
@media (max-width: 1100px) {
  .login aside { padding: 28px; }
  .login .pitch p { font-size: clamp(10px, calc((47vw - 72px) / 32), 14px); }
}
.points { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.points li { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500; color: #fff; background: rgba(255, 255, 255, 0.09); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
.points svg { color: #5eead4; }

.login main { flex: 1; display: grid; place-items: center; padding: 24px 8px; }
.login-card { width: min(460px, 100%); padding: 44px 40px 36px; border-radius: 32px; background: #fff; display: flex; flex-direction: column; gap: 22px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 32px 64px -32px rgba(19, 78, 74, 0.28); animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.login .mobile-logo { display: none; height: 34px; width: auto; align-self: flex-start; }
.login-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.eyebrow { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 6px 12px 6px 10px; border-radius: 999px; background: var(--bg); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--teal-700); }
.eyebrow i { width: 7px; height: 7px; border-radius: 999px; background: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18); }
.login-head h2 { font-size: 36px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15; color: var(--ink-deep); }
.login-head p { font-size: 15px; color: var(--muted); }
.login-card .field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }

.fld { position: relative; display: flex; align-items: center; height: 58px; border-radius: 18px; background: #f5f7f6; box-shadow: inset 0 0 0 1.5px transparent; transition: background 0.15s, box-shadow 0.15s; }
.fld:hover { background: #eff3f1; }
.fld:focus-within { background: #fff; box-shadow: inset 0 0 0 1.5px var(--teal), 0 0 0 5px rgba(13, 148, 136, 0.14); }
.fld > svg { flex: none; margin-left: 18px; color: #7b8a87; transition: color 0.15s; }
.fld:focus-within > svg { color: var(--teal); }
.fld input { flex: 1; min-width: 0; height: 100%; padding: 0 14px; border: 0; background: transparent; font-size: 16px; outline: none; }
/* เบราว์เซอร์ทาพื้นทึบสี่เหลี่ยมทับช่องตอนเติม/แนะนำรหัสอัตโนมัติ และไม่ยอมให้ตั้ง background ทับ
   ทางเดียวที่ทำให้พื้นของกรอบมุมโค้งยังเห็นอยู่คือหน่วงการเปลี่ยนสีพื้นไว้นานจนไม่เกิดขึ้นจริง */
.fld input:-webkit-autofill,
.fld input:-webkit-autofill:hover,
.fld input:-webkit-autofill:focus,
.fld input:-webkit-autofill:active,
.input:-webkit-autofill,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  transition: background-color 600000s 0s, color 600000s 0s !important;
}
.eye { flex: none; width: 46px; height: 46px; margin-right: 6px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.eye:hover { background: #e6ebe9; color: var(--ink-2); }

.switch { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { flex: none; position: relative; width: 44px; height: 26px; border-radius: 999px; background: #8a9895; transition: background 0.2s; }
.switch .track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25); transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
.switch input:checked + .track { background: var(--teal); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--teal); outline-offset: 3px; }
.switch small { margin-left: 4px; padding: 2px 8px; border-radius: 999px; background: var(--bg); font-size: 12px; color: var(--muted); }

.cta { position: relative; display: flex; align-items: center; justify-content: center; height: 60px; padding: 0 64px; border: 0; border-radius: 999px; background: var(--ink-deep); color: #fff; font-size: 16px; font-weight: 600; box-shadow: 0 14px 28px -14px rgba(11, 43, 41, 0.7); transition: transform 0.15s, background 0.15s, box-shadow 0.15s; }
.cta:hover { background: var(--teal-900); transform: translateY(-1px); box-shadow: 0 18px 32px -14px rgba(11, 43, 41, 0.75); }
.cta:active { transform: translateY(0); }
.cta-go { position: absolute; right: 8px; top: 8px; width: 44px; height: 44px; border-radius: 999px; background: var(--mint); color: var(--teal-900); display: grid; place-items: center; transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
.cta:hover .cta-go { transform: translateX(3px); }
.cta:disabled { opacity: 0.7; cursor: default; transform: none; }
.cta.busy .cta-go svg { display: none; }
.cta.busy .cta-go::after { content: ''; width: 18px; height: 18px; border-radius: 999px; border: 2.4px solid rgba(19, 78, 74, 0.25); border-top-color: var(--teal-900); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login .help { font-size: 13px; color: var(--muted); text-align: center; }

/* ── หน้าจัดการผู้ใช้ ── */
main.admin { padding-top: 40px; padding-bottom: 48px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink-deep); }
.page-head p { margin-top: 6px; color: var(--ink-3); }
.panel { background: #fff; border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; }
.panel-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-tools .search { flex: 1 1 260px; max-width: 340px; }
.panel-tools .search svg { left: 16px; top: 14px; }
.panel-tools .search input { height: 44px; padding: 0 16px 0 42px; background: var(--bg); box-shadow: none; font-size: 14px; }
.legend { margin-left: auto; font-size: 13px; color: var(--muted); }
.scroll { overflow-x: auto; }
table { width: 100%; min-width: 1060px; border-collapse: collapse; font-size: 13px; }
th { padding: 14px 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; line-height: 1.3; }
th:first-child, td:first-child { text-align: left; padding-left: 20px; }
td { padding: 12px 4px; text-align: center; border-top: 1px solid var(--line-soft); }
tbody tr:hover { background: #f7faf9; }
.person { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.person .avatar { flex: none; width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; background: var(--mint-soft); color: #115e59; }
.person.off .avatar { background: #e1e7e5; color: var(--ink-3); }
.person b { display: block; font-size: 14px; font-weight: 600; }
.person span { font-size: 12px; color: var(--muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; white-space: nowrap; background: #dcfce7; color: #166534; }
.pill.top { background: var(--teal-900); color: #fff; }
.pill.view { background: #e0f2fe; color: #075985; }
.none { color: #9aa8a5; font-size: 18px; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; color: #166534; }
.state i { width: 8px; height: 8px; border-radius: 999px; background: #16a34a; }
.state.off { color: var(--ink-3); }
.state.off i { background: #9aa8a5; }
.iconbtn { width: 44px; height: 44px; border: 0; border-radius: 999px; background: transparent; color: var(--teal-700); display: inline-grid; place-items: center; }
.iconbtn:hover { background: var(--bg); }

@media (max-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-panel { display: none; }
}
@media (max-width: 860px) {
  .login { flex-direction: column; }
  .login aside { display: none; }
  .login .mobile-logo { display: block; }
  .login main { padding: 0; }
  .login-card { padding: 32px 22px 28px; border-radius: 28px; }
  .nav { padding-left: 16px; border-radius: 28px; }
  .me .who { display: none; }
  .me { padding: 0 4px; }
  .navbtn span { display: none; }
  .navbtn:has(span) { padding: 0 14px; }
  .nav-sep { display: none; }
  main.home { padding-top: 36px; gap: 32px; }
  .legend { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  /* ยกเว้น input: transition ของมันคือตัวกันพื้นทึบตอนเติมรหัสอัตโนมัติ (ดูด้านบน) */
  *:not(input) { transition: none !important; animation: none !important; }
}

/* ── แท็กแผนกบนการ์ดแอป ── */
/* ป้าย "กำลังพัฒนา" บนการ์ดแอป (inDevelopment ใน apps.ts) */
.dev-badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; line-height: 1; padding: 6px 12px 6px 10px; border-radius: 999px; background: #fef3c7; color: #92400e; box-shadow: inset 0 0 0 1px #fcd34d; }
.dev-badge i { width: 7px; height: 7px; border-radius: 999px; background: #f59e0b; }
.card.feat .dev-badge { background: rgba(251, 191, 36, 0.18); color: #fde68a; box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.4); }
.card.off .dev-badge { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px #b8c4c1; }
.card.off .dev-badge i { background: var(--ink-3); }

.dept-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dept-tags span { font-size: 12px; font-weight: 500; line-height: 1; padding: 6px 10px; border-radius: 999px; background: var(--bg); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.card.feat .dept-tags span { background: rgba(255, 255, 255, 0.12); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.card.off .dept-tags span { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px #b8c4c1; }

/* ── หน้าจัดการ: แถบ + แผนกและแท็กแอป ── */
.tabs { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; background: #fff; border-radius: 999px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05); }
.tabs button { height: 44px; padding: 0 20px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 500; }
.tabs button[aria-selected='true'] { background: var(--teal-900); color: #fff; font-weight: 600; }
.dept-view { display: flex; flex-direction: column; gap: 24px; }

/* ── หน้าจัดการ: ประวัติการใช้งาน ── */
.audit-filter { flex: 0 1 260px; }
.audit-filter select { height: 44px; font-size: 14px; border-radius: 999px; }
.audit-error { margin: 16px 20px 0; }
table.audit-table { min-width: 880px; }
.audit-table th, .audit-table td { text-align: left; padding-left: 12px; padding-right: 12px; vertical-align: top; }
.audit-table th:first-child, .audit-table td:first-child { padding-left: 20px; }
.audit-when { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.audit-when b { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-deep); }
.audit-when span, .audit-ip span { font-size: 12px; color: var(--muted); }
.audit-who { font-weight: 600; color: var(--ink-deep); white-space: nowrap; }
.audit-detail { color: var(--ink-2); line-height: 1.5; min-width: 280px; }
.audit-target { display: inline-block; margin-right: 8px; font-weight: 600; color: var(--ink-deep); }
.audit-ip { white-space: nowrap; }
.audit-ip b { display: block; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.audit-empty { padding: 40px 20px !important; color: var(--muted); text-align: center !important; }
.audit-more { display: flex; justify-content: center; padding: 16px; border-top: 1px solid var(--line-soft); }
.ev { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; white-space: nowrap; background: #e1e7e5; color: var(--ink-2); }
.ev.ok { background: #dcfce7; color: #166534; }
.ev.bad { background: #fee2e2; color: #991b1b; }
.ev.warn { background: #fef3c7; color: #92400e; }
.ev.info { background: #e0f2fe; color: #075985; }
.ev.admin { background: var(--teal-900); color: #fff; }
.dept-panel { padding: 24px; display: flex; flex-direction: column; gap: 18px; overflow: visible; }
.dept-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink-deep); }
.dept-head p { margin-top: 4px; font-size: 14px; color: var(--muted); }
.dept-add { display: flex; flex-wrap: wrap; gap: 10px; }
.dept-add .input { flex: 1 1 240px; max-width: 420px; }
.dept-add .btn { height: 52px; }
.dept-list, .tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dept-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.dept-list .input { flex: 1 1 200px; max-width: 420px; height: 46px; border-radius: 14px; font-weight: 500; }
.dept-used { font-size: 13px; color: var(--muted); white-space: nowrap; }
.dept-list .iconbtn { margin-left: auto; }
.iconbtn.danger { color: var(--danger); }
.iconbtn.danger:hover { background: #fee2e2; }
.dept-empty { padding: 20px 0 !important; color: var(--muted); font-size: 14px; }
.tag-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.tag-app { flex: 0 0 240px; min-width: 0; }
.tag-app b { display: block; font-size: 15px; font-weight: 600; }
.tag-app span { font-size: 12px; color: var(--muted); font-family: Poppins, sans-serif; }
.tag-chips { flex: 1 1 320px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag-off { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-3); font-size: 13px; font-weight: 500; box-shadow: inset 0 0 0 1.5px #b8c4c1; transition: background 0.15s, color 0.15s; }
.tag-off::before { content: '+'; font-weight: 700; }
/* ปุ่มลัด "ทุกฝ่าย" — ติด/เอาออกทุกแผนกของแอปนั้น */
.tag-all { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--mint-soft); color: var(--teal-700); font-size: 13px; font-weight: 600; transition: background 0.15s, color 0.15s; }
.tag-all:hover { background: #b6f3e8; }
.tag-all[aria-pressed='true'] { background: var(--teal); color: #fff; }
.tag-all[aria-pressed='true']::before { content: '✓'; font-weight: 700; }
.tag-off:hover { background: #e9eeec; }
/* แท็กที่ติดอยู่: [‹] ชื่อ [›] — ลูกศรเลื่อนลำดับ, ลากสลับได้, กดชื่อ = เอาออก */
.tag-on { display: inline-flex; align-items: center; min-height: 40px; padding: 0 4px; border-radius: 999px; background: var(--teal-900); color: #fff; cursor: grab; transition: opacity 0.15s, box-shadow 0.15s; }
.tag-on.solo { padding: 0 8px; cursor: default; }
.tag-on button { border: 0; background: transparent; color: inherit; }
.tag-name { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 6px; font-size: 13px; font-weight: 600; }
.tag-name::before { content: '✓'; font-weight: 700; }
.tag-move { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; opacity: 0.8; transition: background 0.15s, opacity 0.15s; }
.tag-move:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); opacity: 1; }
.tag-move:disabled { opacity: 0.25; cursor: default; }
.tag-on.dragging { opacity: 0.45; }
.tag-on.drop { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--mint); }
@media (max-width: 860px) {
  .tag-app { flex-basis: 100%; }
  .dept-used { display: none; }
}

/* แถบ "กำลังใช้งาน" (presence.js) */
.presence-sum { font-size: 14px; color: var(--ink-2); }
.presence-sum b { color: var(--teal-900); }
table.presence-table { min-width: 760px; }
.presence-table .ev.ok::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #16a34a; margin-right: 6px; vertical-align: 1px; }
.presence-who b { display: block; }
.presence-who span { font-size: 12px; color: var(--muted); }

/* ── หน้าเข้าสู่ระบบ: ยืนยันตัวตน 2 ชั้น ── */
.mfa-steps { display: flex; flex-direction: column; gap: 14px; padding-left: 20px; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.mfa-steps li::marker { font-weight: 700; color: var(--teal-700); }
.mfa-qr { display: block; width: 200px; height: 200px; margin: 12px 0 8px; padding: 8px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-soft); image-rendering: pixelated; }
.mfa-alt { display: block; font-size: 12px; color: var(--muted); }
.mfa-alt code { display: inline-block; margin-top: 4px; padding: 4px 8px; border-radius: 8px; background: var(--bg); font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-deep); word-break: break-all; user-select: all; }
#mfa-code { font-size: 22px; font-weight: 600; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.linkbtn { border: 0; padding: 0; background: none; font: inherit; color: var(--teal-700); text-decoration: underline; cursor: pointer; }
.mini.mfa { background: #e0f2fe; color: #075985; }
.mfa-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 14px 16px; border-radius: 18px; background: var(--bg); }
.mfa-row .btn { height: 40px; padding: 0 16px; font-size: 13px; }
.mfa-trust-note { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.mfa-actions { display: flex; flex-wrap: wrap; gap: 8px; }
