/* ─────────────────────────────────────────────────────────────
   ชั้นงานออกแบบ (โหลดต่อจาก app.css)
   app.css = โครงและคอมโพเนนต์พื้นฐาน · ไฟล์นี้ = ผิว แสง การเคลื่อนไหว และคอมโพเนนต์ใหม่
   ───────────────────────────────────────────────────────────── */
:root {
  --r: 18px;
  --glow: 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent), 0 18px 44px -22px color-mix(in srgb, var(--brand) 60%, transparent);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --aurora-1: rgba(164, 79, 201, .13);
  --aurora-2: rgba(246, 185, 31, .10);
}
:root[data-theme="dark"] { --aurora-1: rgba(164, 79, 201, .20); --aurora-2: rgba(246, 185, 31, .07); }

/* พื้นหลังแบบแสงเหนือ อยู่กับที่ ไม่เลื่อนตามเนื้อหา */
body { background:
  radial-gradient(900px 520px at 100% -10%, var(--aurora-1), transparent 60%),
  radial-gradient(700px 480px at -10% 110%, var(--aurora-2), transparent 60%), var(--bg); background-attachment: fixed; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent; }
::selection { background: color-mix(in srgb, var(--brand) 30%, transparent); }
h1 { letter-spacing: -.015em; }
.page-head h1 { font-size: 27px; }

/* ── การ์ดและแสงไล่ตามเมาส์ ── */
.card { border-radius: var(--r); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), var(--shadow); }
.spot { position: relative; isolation: isolate; }
.spot::before { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1; opacity: 0; pointer-events: none; transition: opacity .25s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%); }
.spot:hover::before { opacity: 1; }

/* ── ปุ่ม ── */
.btn { border-radius: 12px; transition: transform .14s var(--ease), box-shadow .2s, background .2s, border-color .2s, filter .2s; }
.btn.primary, .btn.gold { position: relative; overflow: hidden; }
.btn.primary::after, .btn.gold::after { content: ""; position: absolute; inset: 0; translate: -120% 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .32) 50%, transparent 65%); transition: translate .6s var(--ease); pointer-events: none; }
.btn.primary:hover::after, .btn.gold:hover::after { translate: 120% 0; }
.btn.primary { background: linear-gradient(135deg, #9a3fc4, #6a1f8b 60%, #581572); box-shadow: 0 8px 22px -10px #7b2a9e, inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn.gold { background: linear-gradient(135deg, #ffd24d, #f6b91f); box-shadow: 0 8px 22px -10px #c98a00, inset 0 1px 0 rgba(255, 255, 255, .5); font-weight: 600; }
.btn.gold:hover { border-color: transparent; filter: brightness(1.05); }
.btn.glass { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .28); color: #fff; backdrop-filter: blur(8px); }
.btn.glass:hover { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .5); box-shadow: none; }
.chip { letter-spacing: .01em; }

/* ── แถบข้างและแถบบน ── */
.side { background: radial-gradient(600px 300px at 0 0, rgba(164, 79, 201, .45), transparent 70%), linear-gradient(180deg, #3f0f55, #22082f); border-right: 1px solid rgba(255, 255, 255, .06); }
.nav-h { font-size: 11px; font-weight: 600; letter-spacing: .08em; opacity: .5; padding: 14px 12px 4px; }
.nav { position: relative; transition: background .18s, color .18s, transform .18s var(--ease); }
.nav:hover { transform: translateX(2px); }
.nav.on { background: linear-gradient(90deg, rgba(246, 185, 31, .22), rgba(255, 255, 255, .08)); box-shadow: inset 3px 0 0 var(--gold), 0 8px 20px -14px #000; }
.nav .badge { box-shadow: 0 0 0 3px rgba(246, 185, 31, .25); animation: badgePulse 2.4s ease-in-out infinite; }
@keyframes badgePulse { 50% { box-shadow: 0 0 0 7px rgba(246, 185, 31, 0); } }
.side-foot { border: 1px solid rgba(255, 255, 255, .08); transition: background .2s; }
.side-foot:hover { background: rgba(255, 255, 255, .12); }
.avatar { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4); }
.avatar.sm { width: 30px; height: 30px; font-size: 13px; background: linear-gradient(135deg, #a44fc9, #6a1f8b); }
.top { background: color-mix(in srgb, var(--surface) 62%, transparent); backdrop-filter: blur(16px) saturate(1.4); position: relative; z-index: 15; }
.search-btn { border-radius: 14px; transition: border-color .2s, box-shadow .2s; }
.search-btn:hover { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.live { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px; border-radius: 99px; font-size: 12px; font-weight: 600; color: var(--good-ink); background: var(--good-soft); white-space: nowrap; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: livePing 1.8s ease-out infinite; }
@keyframes livePing { to { box-shadow: 0 0 0 8px transparent; } }
.live.off { color: var(--crit-ink); background: var(--crit-soft); }
.live.off i { background: var(--crit); animation: none; }

/* ── การเปลี่ยนหน้า ── */
::view-transition-old(root) { animation: vtOut .16s ease both; }
::view-transition-new(root) { animation: vtIn .26s var(--ease) both; }
@keyframes vtOut { to { opacity: 0; } }
@keyframes vtIn { from { opacity: 0; transform: translateY(8px); } }
.list > *, .tiles > *, .pipe > * { animation: riseIn .45s var(--ease) both; }
.list > :nth-child(2), .tiles > :nth-child(2), .pipe > :nth-child(2) { animation-delay: 40ms; }
.list > :nth-child(3), .tiles > :nth-child(3), .pipe > :nth-child(3) { animation-delay: 80ms; }
.list > :nth-child(4), .tiles > :nth-child(4), .pipe > :nth-child(4) { animation-delay: 120ms; }
.list > :nth-child(5), .pipe > :nth-child(5) { animation-delay: 160ms; }
.list > :nth-child(6), .pipe > :nth-child(6) { animation-delay: 200ms; }
.list > :nth-child(n+7), .pipe > :nth-child(n+7) { animation-delay: 240ms; }
@keyframes riseIn { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.skel { border-radius: var(--r); background: linear-gradient(100deg, var(--bg-2) 30%, color-mix(in srgb, var(--surface) 70%, var(--bg-2)) 50%, var(--bg-2) 70%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── แดชบอร์ด: แถบต้อนรับ ── */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: 30px 32px; border-radius: 26px; color: #fff; overflow: hidden;
  background: radial-gradient(520px 300px at 88% 10%, rgba(246, 185, 31, .42), transparent 65%), radial-gradient(460px 320px at 0% 120%, #c261ea, transparent 60%), linear-gradient(135deg, #5a1675, #7b2a9e 55%, #40105a);
  box-shadow: 0 30px 60px -34px #5a1675, inset 0 1px 0 rgba(255, 255, 255, .22); animation: riseIn .5s var(--ease) both; }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background: linear-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px) 0 0 / 100% 34px, linear-gradient(90deg, rgba(255, 255, 255, .07) 1px, transparent 1px) 0 0 / 34px 100%;
  mask-image: radial-gradient(520px 300px at 85% 30%, #000, transparent 75%); }
.hero.spot::before { background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .16), transparent 70%); }
.hero .eyebrow { font-size: 13px; opacity: .78; letter-spacing: .02em; }
.hero h1 { font-size: clamp(26px, 3vw, 38px); font-weight: 700; margin: 4px 0 6px; }
.hero p { margin: 0 0 18px; font-size: 16px; opacity: .92; }
.hero p b { color: var(--gold); font-size: 1.15em; }
.hero-ring { position: relative; width: 168px; text-align: center; }
.hero-ring svg { width: 148px; height: 148px; rotate: -90deg; display: block; margin: 0 auto; }
.ring-bg, .ring-fg { fill: none; stroke-width: 9; }
.ring-bg { stroke: rgba(255, 255, 255, .16); }
.ring-fg { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset 1.2s var(--ease); filter: drop-shadow(0 0 6px rgba(246, 185, 31, .6)); }
.ring-val { position: absolute; inset: 0 0 auto; height: 148px; display: grid; place-content: center; }
.ring-val b { font-size: 32px; line-height: 1.1; }
.ring-val span { font-size: 12px; opacity: .8; }
.ring-cap { font-size: 12px; opacity: .78; margin-top: 6px; }
.tile { transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.tile:hover { transform: translateY(-3px); box-shadow: var(--glow); border-color: transparent; }
.tile .val { font-size: 40px; letter-spacing: -.02em; }
.tile .glyph { background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--gold) 22%, var(--brand-soft))); }
.lv:hover { box-shadow: var(--glow); border-color: transparent; }
.lv .step { text-transform: none; letter-spacing: .02em; }
.feed { display: grid; gap: 2px; margin-top: 10px; }
.feed-i { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; color: inherit; text-decoration: none; transition: background .15s, transform .15s var(--ease); }
.feed-i:hover { background: var(--brand-soft); transform: translateX(2px); }
.feed-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-i > .grow { min-width: 0; }
.feed-ic { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.feed-ic svg.ic { width: 15px; height: 15px; }
.feed-ic.return, .feed-ic.cancel { background: var(--crit-soft); color: var(--crit-ink); }
.feed-ic.issue, .feed-ic.receive { background: var(--good-soft); color: var(--good-ink); }
.grid-2 + .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* ── แถวเอกสาร ── */
.doc-row { border-left: 3px solid transparent; }
.doc-row[data-status="pending"] { border-left-color: var(--gold); }
.doc-row[data-status="returned"] { border-left-color: var(--crit); }
.doc-row[data-status="done"] { border-left-color: var(--good); }
.doc-row:hover { box-shadow: var(--glow); border-color: transparent; border-left-color: var(--brand); }
.doc-row.picked { background: color-mix(in srgb, var(--brand) 9%, var(--surface)); border-color: var(--brand); }
.doc-row > .grow > .grow { min-width: 0; }
.pick { width: 24px; height: 24px; flex: none; border-radius: 8px; border: 2px solid var(--line-2); background: var(--surface); cursor: pointer; display: grid; place-items: center; padding: 0; color: transparent; transition: background .15s, border-color .15s, transform .15s var(--ease); }
.pick svg.ic { width: 14px; height: 14px; stroke-width: 3; }
.pick:hover { border-color: var(--brand); transform: scale(1.1); }
.pick[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
#bulk-bar { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; z-index: 25; display: flex; align-items: center; gap: 12px; min-width: min(460px, calc(100vw - 24px)); padding: 10px 12px 10px 20px; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, #5a1675, #3a0d52); box-shadow: 0 24px 50px -18px #000, inset 0 1px 0 rgba(255, 255, 255, .2); animation: riseIn .3s var(--ease) both; }
#bulk-bar b { font-size: 22px; color: var(--gold); }
.bulk-list { display: grid; gap: 4px; max-height: 240px; overflow: auto; }
.bulk-list > div { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; }
.bulk-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-list i { width: 16px; height: 16px; border-radius: 50%; flex: none; border: 2px solid var(--line-2); }
.bulk-list .run i { border-color: color-mix(in srgb, var(--brand) 25%, transparent); border-top-color: var(--brand); animation: sp .7s linear infinite; }
.bulk-list .ok i { border-color: var(--good); background: var(--good); }
.bulk-list .err i { border-color: var(--crit); background: var(--crit); }
.bulk-list em { font-style: normal; font-size: 12px; color: var(--crit-ink); }

/* ── บอร์ดตามขั้นตอน ── */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; scroll-snap-type: x proximity; align-items: flex-start; }
.col { flex: 0 0 286px; scroll-snap-align: start; display: grid; gap: 8px; padding: 10px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 55%, transparent); border: 1px solid var(--line); animation: riseIn .4s var(--ease) both; }
.col header { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px; font-weight: 600; font-size: 13.5px; }
.col header::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); flex: none; }
.col[data-kind="returned"] header::before { background: var(--crit); }
.col[data-kind="done"] header::before { background: var(--good); }
.col header b { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: var(--bg-2); font-size: 12px; display: grid; place-items: center; }
.kcard { display: grid; gap: 7px; padding: 12px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; box-shadow: var(--shadow); transition: transform .16s var(--ease), box-shadow .16s, border-color .16s; }
.kcard:hover { transform: translateY(-2px) rotate(-.3deg); box-shadow: var(--glow); border-color: transparent; }
.kcard .t { font-weight: 600; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard .m { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg button svg.ic { width: 16px; height: 16px; vertical-align: -3px; }

/* ── หน้าเอกสาร ── */
.viewer-bar { border-radius: 16px; box-shadow: 0 12px 30px -16px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .12); max-width: calc(100% - 20px); }
.viewer-bar .sep { width: 1px; height: 18px; background: var(--line-2); margin: 0 4px; }
.page { border-radius: 3px; transition: box-shadow .25s; }
.page:not(.ready) { background: linear-gradient(100deg, #fff 30%, #f1ecf6 50%, #fff 70%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
.page::after { content: attr(data-no); position: absolute; left: 50%; bottom: -15px; translate: -50% 0; font-size: 10.5px; font-weight: 600; line-height: 1; color: var(--ink-3); }
.panel { background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 94%, var(--brand))); }
.st.done .b { box-shadow: 0 4px 12px -4px var(--brand); }
.alert { border: 1px solid color-mix(in srgb, currentColor 14%, transparent); }

/* ── โมดัล / ท็อสต์ / ฉลอง ── */
.overlay { background: rgba(18, 7, 28, .55); backdrop-filter: blur(8px) saturate(1.2); }
.modal { border-radius: 24px; box-shadow: 0 40px 90px -30px #000, inset 0 1px 0 rgba(255, 255, 255, .08); }
.toast { position: relative; overflow: hidden; border-radius: 16px; background: color-mix(in srgb, var(--ink) 92%, var(--brand)); }
.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--gold); transform-origin: left; animation: toastBar 4.2s linear forwards; }
.toast.err::after { background: rgba(255, 255, 255, .7); animation-duration: 6s; }
@keyframes toastBar { to { transform: scaleX(0); } }
.celebrate { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; pointer-events: none; transition: opacity .35s; }
.celebrate.out { opacity: 0; }
.celebrate > div { display: grid; justify-items: center; gap: 4px; padding: 30px 44px; border-radius: 28px; color: #fff; text-align: center; background: linear-gradient(135deg, rgba(90, 22, 117, .94), rgba(58, 13, 82, .94)); backdrop-filter: blur(10px); box-shadow: 0 40px 80px -30px #000, inset 0 1px 0 rgba(255, 255, 255, .2); animation: modalIn .4s cubic-bezier(.2, 1.4, .4, 1) both; }
.celebrate svg { width: 84px; height: 84px; fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 6px; }
.celebrate circle { stroke: var(--gold); stroke-dasharray: 214; stroke-dashoffset: 214; animation: drawLine .6s var(--ease) .1s forwards; }
.celebrate path { stroke: #fff; stroke-dasharray: 46; stroke-dashoffset: 46; animation: drawLine .4s var(--ease) .55s forwards; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
.celebrate b { font-size: 21px; }
.celebrate span { opacity: .82; font-size: 14px; }
.keys { display: grid; gap: 6px; }
.keys h4 { margin: 10px 0 2px; font-size: 12px; color: var(--ink-3); letter-spacing: .06em; font-weight: 600; }
.keys > div { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.keys > div > span { min-width: 92px; }
kbd { font: 600 12px ui-monospace, "Cascadia Mono", monospace; padding: 3px 8px; border-radius: 7px; background: var(--bg-2); border: 1px solid var(--line-2); border-bottom-width: 2px; }

/* ── หน้าเข้าสู่ระบบ ── */
.login-form form { padding: 30px; border-radius: 26px; background: color-mix(in srgb, var(--surface) 78%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow-lg); backdrop-filter: blur(14px); animation: riseIn .5s var(--ease) both; }
.login-hero h1 { text-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.drop { transition: border-color .2s, background .2s, transform .2s var(--ease), box-shadow .2s; }
.drop:hover { box-shadow: var(--glow); }
.org-node { border-radius: 16px; }
.org-node:hover { box-shadow: var(--glow); }

/* ── จอเล็ก ── */
@media (max-width: 900px) {
  .nav-h, .keys-btn, .live span { display: none; }
  .live { padding: 0 9px; }
  .nav:hover { transform: none; }
  .hero { grid-template-columns: 1fr; padding: 22px 20px; border-radius: 22px; }
  .hero-ring { display: grid; grid-template-columns: 96px 1fr; align-items: center; width: auto; text-align: left; gap: 0 14px; }
  .hero-ring svg { width: 96px; height: 96px; }
  .ring-val { width: 96px; height: 96px; inset: 0 auto auto 0; }
  .ring-val b { font-size: 22px; }
  .ring-val span { display: none; }
  .grid-2 + .grid-2 { grid-template-columns: 1fr; }
  #bulk-bar { bottom: calc(66px + env(safe-area-inset-bottom)); }
  .viewer-bar { gap: 0; }
  .viewer-bar .sep { margin: 0 2px; }
  .col { flex-basis: 250px; }
}
@media (max-width: 599px) {
  .login-form form { padding: 20px; }
  .hero h1 { font-size: 24px; }
  .tile .val { font-size: 30px; }
}
a.btn { text-decoration: none; }
@media (max-width: 900px) {
  .nav.on { background: rgba(255, 255, 255, .13); box-shadow: inset 0 -3px 0 var(--gold); }
}
/* จอกว้างปานกลาง: แถวเอกสารเหลือชื่อเรื่องกับสถานะ เพื่อไม่ให้เบียดกัน */
@media (min-width: 600px) and (max-width: 900px) {
  .doc-row { grid-template-columns: minmax(0, 1fr) auto; }
  .doc-row > :nth-child(2), .doc-row > :last-child { display: none; }
  .doc-row > :nth-child(3) { max-width: 260px; overflow: hidden; }
  .doc-row .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
}

/* ── วางลายเซ็นและข้อความแบบแยกชิ้น ── */
.stamp.text { outline-width: 1.5px; outline-color: color-mix(in srgb, var(--brand) 70%, transparent); background: rgba(164, 79, 201, .05); }
.stamp.text .stamp-h { width: 16px; height: 16px; right: -8px; bottom: -8px; border-width: 2px; }
.stamp.flash { animation: stampFlash .9s ease 2; }
@keyframes stampFlash { 50% { outline-color: var(--gold); outline-width: 4px; box-shadow: 0 0 0 8px rgba(246, 185, 31, .25); } }
.add-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.st-list { display: grid; gap: 6px; }
.st-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.st-row .input { height: 36px; min-width: 0; }
.st-ic { width: 28px; height: 28px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.st-ic svg.ic { width: 15px; height: 15px; }
.stamp .stamp-x, .stamp .stamp-h { opacity: 0; transition: opacity .15s; }
.stamp:hover .stamp-x, .stamp:hover .stamp-h, .stamp.sel .stamp-x, .stamp.sel .stamp-h { opacity: 1; }
.stamp:not(.sel):not(:hover) { outline-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.stamp.sel { z-index: 3; outline-style: solid; }
.stamp.text .stamp-x { width: 18px; height: 18px; right: -9px; top: -9px; font-size: 12px; }
@media (hover: none) { .stamp.sel .stamp-x, .stamp.sel .stamp-h { opacity: 1; } }

/* ═════════════════════════════════════════════════════════════
   ตัวอักษร · โลโก้ · หน้าเข้าสู่ระบบแบบสามมิติ
   ═════════════════════════════════════════════════════════════ */
body { font-family: "Anuphan Variable", "Leelawadee UI", "Segoe UI", system-ui, sans-serif; font-size: 15.5px; letter-spacing: .005em; }
h1, h2, h3, .hero h1, .tile .val, .lv .pending { font-family: inherit; }
h1, h2 { font-weight: 700; letter-spacing: -.012em; }
.btn, .chip, .nav, .seg button { letter-spacing: .008em; }
.tile .val, .lv .pending, .ring-val b { font-weight: 700; font-variant-numeric: tabular-nums; }

.logo { width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(145deg, #b05ad6, #6a1f8b 55%, #4a1263); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 18px -8px #4a1263; }
.logo svg { width: 30px; height: 30px; fill: none; filter: drop-shadow(0 2px 2px rgba(40, 10, 60, .3)); }
.splash { height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 18px; }
.splash .logo { width: 64px; height: 64px; border-radius: 20px; animation: splashPulse 1.4s ease-in-out infinite; }
.splash .logo svg { width: 46px; height: 46px; }
.splash i { width: 120px; height: 4px; border-radius: 9px; background: linear-gradient(90deg, transparent, var(--brand), var(--gold), transparent) 0 0 / 200% 100%; animation: shimmer 1.1s linear infinite; }
@keyframes splashPulse { 50% { transform: scale(1.07); box-shadow: 0 0 0 14px color-mix(in srgb, var(--brand) 12%, transparent); } }
.tilt { transform: perspective(1200px) rotateX(calc(var(--rx, 0) * 4deg)) rotateY(calc(var(--ry, 0) * 5deg)); transition: transform .3s ease-out; }
.docv.focus { grid-template-columns: 1fr; }
.docv.focus .panel { display: none; }

/* ── หน้าเข้าสู่ระบบ ── */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, .85fr); }
.auth-hero { position: relative; overflow: hidden; isolation: isolate; color: #fff; padding: 36px 48px 40px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 8px;
  background: radial-gradient(900px 600px at 78% 8%, #b65fe0 0%, transparent 58%), radial-gradient(700px 520px at 6% 100%, rgba(246, 185, 31, .5), transparent 60%), linear-gradient(150deg, #3c0e54, #6d2390 52%, #2a093c); }
.auth-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .55;
  background: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px) 0 0 / 100% 44px, linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px) 0 0 / 44px 100%;
  mask-image: radial-gradient(70% 60% at 55% 45%, #000, transparent 78%); }
.auth-hero .brand { font-size: 17px; }
.auth-hero .brand small { display: block; font-weight: 400; font-size: 12.5px; opacity: .75; }
.auth-copy h1 { font-size: clamp(30px, 3.5vw, 50px); line-height: 1.18; text-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.auth-copy h1 em { font-style: normal; background: linear-gradient(90deg, #ffe08a, #f6b91f); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-copy p { font-size: 16.5px; opacity: .86; max-width: 50ch; margin: 12px 0 0; }
.auth-copy .flow-demo { margin-top: 18px; }

/* ฉากสามมิติ: กองเอกสารลอย ลายเซ็นเขียนตัวเอง ตราอนุมัติ และสายการเสนอ 5 ขั้น */
.scene { perspective: 1300px; display: grid; place-items: center; min-height: 420px; }
.stage { position: relative; width: 270px; height: 356px; transform-style: preserve-3d;
  transform: rotateX(calc(16deg - var(--py, 0) * 12deg)) rotateY(calc(-24deg + var(--px, 0) * 18deg)) rotateZ(3deg);
  transition: transform .35s ease-out; animation: stageFloat 6s ease-in-out infinite alternate; }
@keyframes stageFloat { to { translate: 0 -16px; } }
.orb { position: absolute; inset: -70px; border-radius: 50%; background: radial-gradient(circle, rgba(246, 185, 31, .55), transparent 62%); filter: blur(26px); transform: translateZ(-170px); }
.sheet { position: absolute; inset: 0; border-radius: 16px; background: linear-gradient(180deg, #fff, #f6f0fb); box-shadow: 0 40px 70px -30px rgba(20, 5, 35, .75), inset 0 0 0 1px rgba(255, 255, 255, .8); }
.sheet.s3 { transform: translate3d(52px, -34px, -110px); opacity: .32; }
.sheet.s2 { transform: translate3d(27px, -18px, -55px); opacity: .62; }
.sheet.s1 { padding: 24px 24px 20px; display: grid; align-content: start; gap: 15px; transform-style: preserve-3d; }
.sheet.s1::after { content: ""; position: absolute; right: 0; top: 0; width: 46px; height: 46px; border-radius: 0 16px 0 14px; background: linear-gradient(225deg, #6d2390 50%, #e7d6f2 50%); box-shadow: -4px 4px 10px -4px rgba(40, 10, 60, .35); }
.sh-head { display: flex; align-items: center; gap: 12px; }
.sh-head > i { width: 40px; height: 40px; border-radius: 50%; background: conic-gradient(from 210deg, #7b2a9e, #f6b91f, #7b2a9e); flex: none; }
.sh-head div { display: grid; gap: 7px; flex: 1; }
.sh-head b { height: 9px; border-radius: 9px; background: #7b2a9e; width: 70%; }
.sh-head b + b { width: 44%; background: #d9c3e8; height: 7px; }
.sh-lines { display: grid; gap: 8px; }
.sh-lines i { height: 7px; border-radius: 9px; background: #e6daf0; }
.sh-sign { position: relative; margin-top: 6px; padding-left: 86px; transform: translateZ(26px); }
.sh-sign svg { width: 136px; display: block; overflow: visible; }
.sh-sign path { fill: none; stroke: #1d3fae; stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: 330; stroke-dashoffset: 330; animation: sigDraw 7s ease-in-out infinite; }
@keyframes sigDraw { 0%, 12% { stroke-dashoffset: 330; opacity: 1; } 42%, 90% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }
.sh-sign i, .sh-sign span { display: block; height: 6px; border-radius: 9px; background: #cdb7de; margin: 6px 0 0 auto; width: 120px; }
.sh-sign span { width: 84px; background: #e6daf0; margin-right: 18px; }
.sh-stamp { position: absolute; left: 22px; bottom: 34px; padding: 3px 12px; border: 3px solid #d03b3b; border-radius: 9px; color: #d03b3b; font-weight: 700; font-size: 17px; letter-spacing: .04em; rotate: -13deg; transform: translateZ(40px); opacity: 0; animation: stampPop 7s cubic-bezier(.2, 1.5, .4, 1) infinite; }
@keyframes stampPop { 0%, 46% { opacity: 0; scale: 2.2; } 54%, 90% { opacity: .92; scale: 1; } 100% { opacity: 0; scale: 1; } }
.fchip { position: absolute; display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 99px; font-size: 13.5px; font-weight: 600; white-space: nowrap; color: #fff;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .35); backdrop-filter: blur(10px); box-shadow: 0 16px 30px -16px rgba(0, 0, 0, .6); animation: chipBob 5s ease-in-out infinite alternate; }
.fchip svg.ic { width: 15px; height: 15px; color: var(--gold); }
.fchip.c1 { left: -118px; top: 34px; transform: translateZ(90px); }
.fchip.c2 { right: -128px; top: 150px; transform: translateZ(120px); animation-delay: -1.6s; }
.fchip.c3 { left: -96px; bottom: 44px; transform: translateZ(70px); animation-delay: -3.1s; }
@keyframes chipBob { to { translate: 0 -12px; } }
.chain { position: absolute; left: 50%; bottom: -74px; display: flex; gap: 22px; transform: translateX(-50%) translateZ(60px); }
.chain::before { content: ""; position: absolute; left: 16px; right: 16px; top: 50%; height: 2px; background: rgba(255, 255, 255, .28); }
.chain i { position: relative; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #4a1263; border: 2px solid rgba(255, 255, 255, .4); color: transparent; animation: nodeLit 7s ease infinite; animation-delay: calc(var(--i) * .75s); }
.chain svg.ic { width: 15px; height: 15px; stroke-width: 2.8; }
@keyframes nodeLit { 0%, 6% { background: #4a1263; color: transparent; scale: 1; border-color: rgba(255, 255, 255, .4); box-shadow: none; }
  12% { scale: 1.22; } 16%, 80% { background: var(--gold); color: #3a2500; scale: 1; border-color: #fff; box-shadow: 0 0 18px rgba(246, 185, 31, .8); }
  92%, 100% { background: #4a1263; color: transparent; border-color: rgba(255, 255, 255, .4); box-shadow: none; } }

.auth-side { display: grid; place-items: center; padding: 32px; position: relative; }
.auth-card { width: min(420px, 100%); display: grid; gap: 18px; padding: 34px; border-radius: 28px; background: color-mix(in srgb, var(--surface) 82%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, .5); backdrop-filter: blur(16px); animation: riseIn .55s var(--ease) both; }
.auth-card h2 { font-size: 30px; margin: 2px 0; }
.auth-card .eyebrow { font-size: 12.5px; font-weight: 600; color: var(--brand-ink); letter-spacing: .04em; }
.in-wrap { position: relative; display: flex; align-items: center; }
.in-wrap > svg.ic { position: absolute; left: 14px; color: var(--ink-3); pointer-events: none; }
.in-wrap .input { height: 48px; padding-left: 44px; border-radius: 14px; }
.in-wrap:focus-within > svg.ic { color: var(--brand); }
.in-eye { position: absolute; right: 6px; width: 38px; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--ink-3); cursor: pointer; display: grid; place-items: center; }
.in-eye:hover { background: var(--brand-soft); color: var(--brand-ink); }
.caps { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--warn-ink); }
.caps svg.ic { width: 14px; height: 14px; }
.auth-card .btn.big { height: 52px; border-radius: 15px; font-size: 16.5px; }
.demo summary { cursor: pointer; font-size: 13px; color: var(--ink-2); padding: 4px 0; }
.demo .demo-list { margin-top: 8px; }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 12.5px; color: var(--ink-3); }
.auth-note svg.ic { width: 15px; height: 15px; }

@media (max-width: 1100px) { .fchip.c2 { right: -90px; } .fchip.c1 { left: -86px; } .fchip.c3 { left: -70px; } }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 24px 22px 26px; grid-template-rows: auto auto auto; }
  .scene { min-height: 300px; }
  .stage { scale: .62; }
  .auth-copy p, .auth-copy .flow-demo { display: none; }
  .auth-copy h1 { font-size: 26px; }
  .auth-side { padding: 20px 14px 32px; margin-top: -22px; }
  .auth-card { padding: 24px 20px; border-radius: 24px; }
  .tilt { transform: none; }
}
/* เว้นที่ใต้กองเอกสารให้สายการเสนอ 5 ขั้น และย่อฉากเมื่อจอเตี้ย */
.scene { padding-bottom: 96px; }
@media (max-height: 800px) and (min-width: 901px) {
  .scene { min-height: 330px; padding-bottom: 70px; }
  .stage { scale: .8; }
  .auth-copy .flow-demo { display: none; }
  .auth-copy h1 { font-size: clamp(28px, 3vw, 40px); }
}
@media (max-width: 900px) { .scene { padding-bottom: 54px; } }

/* ── แถบปิดทับ / ทะเบียนหนังสือ ── */
.stamp.cover { background: #fff; outline-color: var(--crit); z-index: 1; animation: none; }
.stamp.cover img { height: 100%; opacity: 0; }
.stamp.text, .stamp.sign { z-index: 2; }
.tbl.rec tbody tr { cursor: pointer; transition: background .15s; }
.tbl.rec tbody tr:hover { background: var(--brand-soft); }
.tbl.rec td { white-space: nowrap; }
.tbl.rec td:nth-child(2) { white-space: normal; min-width: 220px; }
/* ปุ่มหลักในแผงดำเนินการ: ข้อความยาว (ชื่อตำแหน่งถัดไป) ให้ขึ้นบรรทัดใหม่แทนการล้น */
.actions-bar .btn.big { white-space: normal; height: auto; min-height: 48px; padding: 9px 14px; line-height: 1.3; text-align: center; }

/* ── แบบอักษรหนังสือราชการ สำหรับข้อความที่ประทับลงบนเอกสาร ── */
@font-face { font-family: "TH SarabunIT9"; src: url("/fonts/THSarabunIT9.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "TH SarabunIT9"; src: url("/fonts/THSarabunIT9-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

/* ── ปฏิทินการปฏิบัติงานแทน ── */
.alert.warn { background: var(--warn-soft); color: var(--warn-ink); }
.cal { display: grid; gap: 10px; }
.cal-g { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-h span { text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 2px 0; }
.cal-d { min-height: 78px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-d.out { opacity: .4; }
.cal-d.past .cal-e { opacity: .55; }
.cal-d.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-n { font-size: 12.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cal-d.today .cal-n { color: var(--brand-ink); }
.cal-e { font-size: 11.5px; line-height: 1.3; padding: 2px 6px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 599px) { .cal-d { min-height: 56px; padding: 4px; } .cal-e { font-size: 10px; padding: 1px 4px; } }

/* ── ลากย้ายตำแหน่งในผังองค์กร ── */
.org-node[draggable="true"] { cursor: grab; }
.org-node.dragging { opacity: .45; cursor: grabbing; }
.org-node.drop { border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 45%, transparent), var(--shadow-lg); transform: scale(1.04); }
.org-root-drop { display: none; align-items: center; justify-content: center; gap: 8px; margin: 0 0 18px; padding: 14px; border: 2px dashed var(--line-2); border-radius: 14px; color: var(--ink-2); font-size: 13.5px; position: sticky; left: 0; }
.org-wrap.dnd .org-root-drop { display: flex; }
.org-root-drop.drop { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, transparent); color: var(--ink); }

/* ── ประกาศผู้ปฏิบัติงานแทน (แถบใต้แถบบน) ── */
.ann { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center; gap: 12px; width: calc(100% - 48px); margin: 12px 24px 0; padding: 8px 14px 8px 8px; text-align: left; cursor: pointer; color: var(--ink);
  border-radius: 18px; border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  background: linear-gradient(100deg, color-mix(in srgb, var(--gold) 20%, var(--surface)), color-mix(in srgb, var(--brand) 9%, var(--surface)) 60%, var(--surface));
  box-shadow: 0 14px 30px -20px color-mix(in srgb, var(--gold) 80%, #000), inset 0 1px 0 rgba(255, 255, 255, .5); animation: riseIn .5s var(--ease) both; transition: transform .2s var(--ease), box-shadow .2s; }
.ann:hover { transform: translateY(-1px); box-shadow: 0 18px 34px -18px color-mix(in srgb, var(--gold) 90%, #000); }
.ann::before { content: ""; position: absolute; inset: 0; z-index: -1; translate: -110% 0; background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .55) 50%, transparent 60%); animation: annSweep 5.5s ease-in-out infinite; }
@keyframes annSweep { 0%, 55% { translate: -110% 0; } 100% { translate: 110% 0; } }
.ann-ic { position: relative; flex: none; width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; color: #3a2500; background: linear-gradient(135deg, #ffd95e, #f6b91f); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6); }
.ann-ic svg.ic { animation: annShake 3.2s ease-in-out infinite; transform-origin: 30% 60%; }
.ann-ic::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 0 0 rgba(246, 185, 31, .7); animation: annPing 2.4s ease-out infinite; }
@keyframes annPing { to { box-shadow: 0 0 0 12px rgba(246, 185, 31, 0); } }
@keyframes annShake { 0%, 78%, 100% { rotate: 0deg; } 82% { rotate: -14deg; } 88% { rotate: 10deg; } 94% { rotate: -6deg; } }
.ann-track { flex: 1; min-width: 0; display: grid; align-items: center; }
.ann-item { grid-area: 1 / 1; display: flex; align-items: center; gap: 12px; min-width: 0; opacity: 0; translate: 0 16px; pointer-events: none; transition: opacity .45s, translate .45s var(--ease); }
.ann-item.on { opacity: 1; translate: 0 0; }
.ann-tx { flex: 1; min-width: 0; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ann-pos { color: var(--ink-3); font-size: 13px; }
.ann-n { flex: none; font-size: 12px; color: var(--ink-2); padding: 3px 9px; border-radius: 99px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.chip.gold { background: color-mix(in srgb, var(--gold) 30%, var(--surface)); color: var(--gold-ink); }
.ann-pp { display: inline-flex; align-items: center; gap: 0; flex: none; }
.avatar.off { background: linear-gradient(135deg, #b9afc4, #8a7f96); filter: saturate(.4); position: relative; }
.avatar.off::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--crit); border: 2px solid var(--surface); }
.ann-pp .avatar:last-child { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--good) 70%, transparent); }
.ann-flow { width: 30px; height: 2px; margin: 0 7px 0 5px; border-radius: 2px; background: linear-gradient(90deg, transparent 0 20%, var(--brand) 20% 40%, transparent 40% 60%, var(--brand) 60% 80%, transparent 80%) 0 0 / 20px 100% repeat-x; animation: annFlow .9s linear infinite; position: relative; }
.ann-flow::after { content: ""; position: absolute; right: -2px; top: 50%; width: 7px; height: 7px; border-top: 2px solid var(--brand); border-right: 2px solid var(--brand); translate: 0 -50%; rotate: 45deg; }
@keyframes annFlow { to { background-position: 20px 0; } }
.ann-pp.big .avatar { width: 46px; height: 46px; font-size: 18px; }
.ann-pp.big .ann-flow { width: 44px; }
.ann-list { display: grid; gap: 10px; }
.ann-card { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); animation: riseIn .4s var(--ease) both; }
.ann-card:nth-child(2) { animation-delay: 60ms; }
.ann-card:nth-child(3) { animation-delay: 120ms; }
.ann-card:nth-child(n+4) { animation-delay: 180ms; }
@media (max-width: 900px) {
  .ann { width: calc(100% - 24px); margin: 10px 12px 0; gap: 10px; }
  .ann-tx { white-space: normal; font-size: 13.5px; line-height: 1.35; }
  .ann-item { gap: 9px; }
  .ann-item .chip, .ann-item .ann-pp { display: none; }
  .ann-card { flex-direction: column; align-items: flex-start; }
}

/* ── ป้ายแผนกของเรื่อง: ให้ผู้อนุมัติเห็นทันทีว่าเรื่องมาจากแผนกใด ── */
.chip.dept { background: color-mix(in srgb, var(--brand) 11%, var(--surface)); color: var(--brand-ink, var(--brand)); border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent); font-weight: 600; max-width: 100%; }
.chip.dept svg.ic { width: 13px; height: 13px; flex: none; }
.dept-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.kcard .chip.dept { margin: 6px 0 2px; }
.chip.dept { white-space: normal; height: auto; min-height: 24px; line-height: 1.3; padding-block: 3px; text-align: left; border-radius: 12px; }
.doc-row .dept-line > span { min-width: 0; }
