/* =====================================================================
   Login v2 — split screen: story panel (teal → indigo + lifecycle illustration + live stats) | sign-in card
   Mobile: app-like gradient header + bottom card. Requires app.css tokens.
   ===================================================================== */
.login-body { background: #f4f7f9; overflow-x: hidden; }
.login { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(480px, .88fr); min-height: 100vh; min-height: 100dvh; }

/* ---------- Story panel ---------- */
.login-cover { position: relative; overflow: hidden; color: #fff; background: var(--grad-hero); isolation: isolate; }
.login-cover::before { content: ''; position: absolute; inset: 0; z-index: -1; background-image: var(--pattern); background-size: 64px 64px; opacity: .085;
  mask-image: radial-gradient(120% 90% at 100% 0%, #000 0%, rgba(0, 0, 0, .45) 55%, transparent 100%); -webkit-mask-image: radial-gradient(120% 90% at 100% 0%, #000 0%, rgba(0, 0, 0, .45) 55%, transparent 100%); }
.login-cover::after { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, .10) 0%, transparent 38%), linear-gradient(0deg, rgba(4, 20, 40, .38) 0%, transparent 42%); }
.lc-content { position: relative; height: 100%; display: flex; flex-direction: column; gap: 18px; padding: 34px 52px 30px; }
.lc-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.lc-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.lc-brand img { width: 52px; height: 52px; border-radius: 16px; background: #fff; padding: 4px; object-fit: contain; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .45); flex-shrink: 0; }
.lc-brand b { display: block; font-size: 17px; font-weight: 700; letter-spacing: -.005em; line-height: 1.3; }
.lc-brand span { display: block; font-size: 13px; color: rgba(255, 255, 255, .78); }
.lc-mobile-lang { display: none; }
.lc-hero { max-width: 640px; animation: fade-up .8s var(--ease-out) both .05s; }
.lc-kicker { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 13px; border-radius: 999px; background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .24); backdrop-filter: blur(10px); font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.lc-kicker i { color: #fde68a; }
.lc-hero h1 { color: #fff; font-size: clamp(30px, 2.9vw, 44px); line-height: 1.24; font-weight: 700; letter-spacing: -.02em; margin: 16px 0 10px; text-wrap: balance; }
.lc-hero p { font-size: 16px; color: rgba(255, 255, 255, .86); max-width: 560px; line-height: 1.65; margin: 0; }

.lc-illus { position: relative; width: min(100%, 640px, calc(36vh * 560 / 300)); aspect-ratio: 560 / 300; margin: 0 auto 0 0; flex-shrink: 0; animation: fade-up .9s var(--ease-out) both .2s; }
.lc-illus svg { width: 100%; height: 100%; overflow: visible; }
.lc-illus .lg-dash { animation: lg-dash 1.6s linear infinite; }
.lc-illus .lg-orbit { transform-origin: 484px 150px; animation: lg-spin 18s linear infinite; }
.lc-illus .lg-doc { filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .25)); }
@keyframes lg-dash { to { stroke-dashoffset: -22; } }
@keyframes lg-spin { to { transform: rotate(360deg); } }
.lc-node { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #fff; color: var(--brand); font-size: 20px; box-shadow: 0 0 0 5px rgba(255, 255, 255, .16), 0 10px 22px -8px rgba(0, 0, 0, .45); z-index: 1; }
.lc-node em { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); font-style: normal; font-size: 12px; font-weight: 600; white-space: nowrap; color: #fff; padding: 2px 9px; border-radius: 999px; background: rgba(4, 30, 40, .35); backdrop-filter: blur(6px); }
.lc-node:nth-of-type(odd) i { color: #4f46e5; }
.lc-node.lc-node-ai, .lc-node.lc-node-src { width: 0; height: 0; background: none; box-shadow: none; }
.lc-node.lc-node-ai em { top: 58px; background: linear-gradient(135deg, rgba(99, 102, 241, .6), rgba(13, 148, 136, .55)); border: 1px solid rgba(255, 255, 255, .3); }
.lc-node.lc-node-src em { top: 0; }

/* ลูกศรอยู่ใน .lc-item เดียวกับชิปถัดไป → ขึ้นบรรทัดใหม่แล้วไม่มีลูกศรค้างท้าย/ต้นบรรทัด */
.lc-steps { max-width: 700px; overflow: hidden; }
.lc-steps .lc-track { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; margin-left: -14px; }
.lc-steps .lc-track > .lc-item:first-child { margin-left: 14px; }
.lc-steps .lc-item { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
.lc-steps .lc-chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.lc-steps .lc-chip i { font-size: 14px; color: #99f6e4; }
.lc-steps .is-ai .lc-chip { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .35); }
.lc-steps .is-ai .lc-chip i { color: #fde68a; }
.lc-steps .lc-arrow { font-size: 10px; width: 10px; display: inline-flex; justify-content: center; color: rgba(255, 255, 255, .45); }

.lc-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.lc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; max-width: 700px; }
.lc-stats > div { padding: 13px 15px 12px; border-radius: 18px; background: rgba(255, 255, 255, .11); border: 1px solid rgba(255, 255, 255, .2); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3); box-shadow: 0 20px 40px -24px rgba(0, 0, 0, .5); min-width: 0; }
.lc-stats i { font-size: 22px; color: #99f6e4; }
.lc-stats b { display: block; font-size: 27px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; margin-top: 6px; }
.lc-stats span { display: block; font-size: 12.5px; color: rgba(255, 255, 255, .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-stats .lc-live { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.lc-stats .lc-live .live-dot { align-self: flex-start; background: rgba(16, 185, 129, .18); color: #a7f3d0; }
.lc-stats .lc-live small { font-size: 12.5px; color: rgba(255, 255, 255, .8); }
.lc-announce { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: rgba(4, 20, 40, .3); border: 1px solid rgba(255, 255, 255, .14); backdrop-filter: blur(10px); font-size: 13.5px; max-width: 700px; }
.lc-announce i { color: #fcd34d; font-size: 18px; flex-shrink: 0; }
.lc-marquee { overflow: hidden; white-space: nowrap; flex: 1; mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.lc-marquee span { display: inline-block; padding-left: 100%; animation: marquee 22s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* ---------- Sign-in panel ---------- */
.login-panel { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; padding: 24px 40px 20px; background: #f6f8fa; overflow-y: auto; }
.login-panel::before { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgba(15, 31, 46, .055) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, #000, transparent 55%); -webkit-mask-image: linear-gradient(180deg, #000, transparent 55%); pointer-events: none; }
.lp-top { position: relative; display: flex; justify-content: space-between; align-items: center; }
.lp-help { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); font-weight: 600; }
.lp-help:hover { color: var(--brand-ink); }
.lp-card { position: relative; width: 100%; max-width: 448px; margin: 0 auto; animation: fade-up .7s var(--ease-out) both .1s; }
.lp-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.lp-logo { width: 54px; height: 54px; border-radius: 17px; background: #fff; padding: 5px; box-shadow: 0 14px 30px -16px color-mix(in srgb, var(--brand) 70%, transparent), 0 0 0 1px var(--line); flex-shrink: 0; }
.lp-logo img { width: 100%; height: 100%; object-fit: contain; }
.lp-brand-text b { display: block; font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.lp-brand-text span { display: block; font-size: 13px; color: var(--brand-ink); font-weight: 500; }
.lp-card h2 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.lp-sub { color: var(--muted); margin: 4px 0 18px; font-size: 14.5px; }
.lp-portal { width: 100%; margin: 0 0 10px; }
.lp-portal button { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-form { display: flex; flex-direction: column; gap: 14px; }
.lp-input .input { height: 50px; border-radius: 14px; font-size: 15px; background: #fff; }
.lp-input > i:first-child { font-size: 19px; }
.lp-input .input-addon { right: 7px; }
.lp-remember { align-self: flex-start; }
.lp-submit { height: 52px; border-radius: 15px; font-size: 16px; margin-top: 2px; }
.lp-submit i { transition: transform .25s var(--ease); }
.lp-submit:hover i { transform: translateX(4px); }
.lp-error { margin-bottom: 14px; }
.lp-error.shake { animation: shake .5s var(--ease); }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
.lp-caps { color: var(--amber-ink); }
.lp-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.lp-divider::before, .lp-divider::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }
.lp-divider span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lp-demo-group + .lp-demo-group { margin-top: 10px; }
.lp-demo-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.lp-demo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lp-demo-btn { display: flex; align-items: center; gap: 9px; min-height: 52px; padding: 7px 9px; border-radius: 13px; border: 1px solid var(--line); background: #fff; text-align: left; transition: .2s var(--ease); min-width: 0; box-shadow: var(--sh-xs); }
.lp-demo-btn .ld-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); font-size: 18px; flex-shrink: 0; transition: .2s; }
.lp-demo-btn .ld-text { min-width: 0; line-height: 1.25; }
.lp-demo-btn b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12.5px; font-weight: 600; color: var(--ink); overflow: hidden; line-height: 1.3; overflow-wrap: anywhere; }
.lp-demo-btn[hidden], .lp-demo-legend [hidden] { display: none !important; }
.lp-demo-btn small { display: block; font-size: 11.5px; color: var(--muted); font-family: var(--font-num); }
.lp-demo-btn:hover { border-color: color-mix(in srgb, var(--tone) 50%, transparent); transform: translateY(-2px); box-shadow: 0 10px 20px -14px var(--tone); }
.lp-demo-btn.picked { background: var(--tone); border-color: transparent; }
.lp-demo-btn.picked .ld-ico { background: rgba(255, 255, 255, .2); color: #fff; }
.lp-demo-btn.picked b, .lp-demo-btn.picked small { color: #fff; }
.lp-demo-note { display: flex; align-items: center; gap: 6px; margin: 10px 0 0; font-size: 12px; color: var(--muted-2); }
.lp-foot { position: relative; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted-2); }
.lp-foot span { display: inline-flex; align-items: center; gap: 6px; }
.lp-foot i { color: var(--emerald); }

@media (min-width: 1024px) {
  .login-cover { position: sticky; top: 0; height: 100vh; height: 100dvh; }
  .login-panel { height: 100vh; height: 100dvh; }
}
@media (min-width: 1024px) and (max-height: 860px) {
  .lc-content { padding: 26px 46px 22px; gap: 14px; }
  .lc-hero h1 { margin: 12px 0 8px; font-size: clamp(28px, 2.6vw, 38px); }
  .lc-hero p { font-size: 15px; }
  .lc-stats b { font-size: 24px; }
  .lp-brand { margin-bottom: 12px; }
  .lp-card h2 { font-size: 25px; }
  .lp-sub { margin-bottom: 14px; }
  .lp-form { gap: 11px; }
  .lp-input .input { height: 46px; }
  .lp-submit { height: 48px; }
  .lp-divider { margin: 16px 0 10px; }
  .lp-demo-btn { min-height: 44px; }
}
@media (min-width: 1024px) and (max-width: 1280px) {
  .login { grid-template-columns: minmax(0, 1fr) 460px; }
  .lc-content { padding-inline: 36px; }
  .login-panel { padding-inline: 28px; }
}

/* ---------- Mobile: app-style gradient header + bottom card ---------- */
@media (max-width: 1023px) {
  .login { grid-template-columns: 1fr; }
  .login-cover { min-height: 0; }
  .lc-content { padding: calc(14px + env(safe-area-inset-top)) 18px 52px; gap: 10px; }
  .lc-brand img { width: 44px; height: 44px; border-radius: 14px; }
  .lc-brand b { font-size: 14.5px; }
  .lc-brand span { font-size: 12px; }
  .lc-mobile-lang { display: inline-flex; background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .22); }
  .lc-mobile-lang a { color: rgba(255, 255, 255, .8); }
  .lc-mobile-lang a.active { background: #fff; color: var(--brand-ink); }
  .lc-kicker { display: none; }
  .lc-hero h1 { font-size: 21px; margin: 4px 0 0; line-height: 1.32; }
  .lc-hero p { display: none; }
  .lc-illus { width: 100%; margin: -4px auto 0; }
  .lc-node { width: 30px; height: 30px; font-size: 15px; box-shadow: 0 0 0 4px rgba(255, 255, 255, .16), 0 8px 16px -8px rgba(0, 0, 0, .45); }
  .lc-node em { font-size: 10.5px; padding: 1px 7px; top: calc(100% + 5px); }
  .lc-node.lc-node-ai em { top: 34px; }
  .lc-steps .lc-track { flex-wrap: nowrap; }
  .lc-steps { overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px; mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .lc-steps::-webkit-scrollbar { display: none; }
  .lc-bottom { display: none; }
  .login-panel { margin-top: -34px; border-radius: 28px 28px 0 0; padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -18px 40px -22px rgba(4, 20, 40, .45); z-index: 2; overflow: visible; background: #fff; }
  .login-panel::before { display: none; }
  .login-panel::after { content: ''; position: absolute; top: 9px; left: 50%; width: 42px; height: 5px; margin-left: -21px; border-radius: 3px; background: var(--line-2); }
  .lp-top { display: none; }
  .lp-card { margin: 14px auto 6px; }
  .lp-brand { display: none; }
  .lp-card h2 { font-size: 24px; }
  .lp-sub { margin-bottom: 14px; font-size: 14px; }
  .lp-input .input { height: 52px; font-size: 16px; }
  .lp-demo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lp-foot { justify-content: center; text-align: center; margin-top: 12px; }
}
@media (max-width: 380px) {
  .lp-portal button { padding: 6px 8px; font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .lc-illus .lg-dash, .lc-illus .lg-orbit { animation: none; }
}
@media (max-width: 1023px) {
  .lc-steps .lc-chip { height: 26px; padding: 0 9px; font-size: 11.5px; }
  .lc-brand b, .lc-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lc-brand > div { min-width: 0; }
}
/* brand text sizing fix (span inside b) + compact demo grid with group legend */
.lc-brand b span { display: inline; font-size: inherit; color: inherit; }
.lc-brand > div > span > span { display: inline; font-size: inherit; }
.lp-demo-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: -2px 0 10px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.lp-demo-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lp-demo-legend span::before { content: ''; width: 8px; height: 8px; border-radius: 3px; background: var(--g, #0d9488); }
.lp-demo-legend i { display: none; }
.lg-exec, .grp-exec { --g: #f59e0b; } .lg-staff, .grp-staff { --g: #0d9488; } .lg-branch, .grp-branch { --g: #6366f1; }
.lp-demo-btn { position: relative; }
.lp-demo-btn::after { content: ''; position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 2px; background: var(--g); opacity: .85; }
.lp-divider span[data-tip] { cursor: help; }
@media (min-width: 1024px) and (max-height: 960px) {
  .lp-brand { margin-bottom: 10px; }
  .lp-logo { width: 46px; height: 46px; border-radius: 14px; }
  .lp-portal { margin-bottom: 12px; }
}
/* English copy is longer — tighten the story panel */
html[lang=en] .lc-hero h1 { font-size: clamp(28px, 2.4vw, 38px); }
html[lang=en] .lc-hero p { font-size: 15px; }
@media (min-width: 1024px) and (max-height: 960px) { html[lang=en] .lc-illus { width: min(100%, 600px, calc(31vh * 560 / 300)); } }
/* ชิปบัญชีทดลองแบบแนวตั้ง: ไอคอน + username ด้านบน · ชื่อบทบาท (จากฐานข้อมูล ยาวได้) เต็มความกว้าง 2 บรรทัด */
.lp-demo-btn { flex-direction: column; align-items: stretch; gap: 5px; min-height: 0; padding: 8px 10px 9px; }
.lp-demo-btn .ld-top { display: flex; align-items: center; gap: 7px; min-width: 0; }
.lp-demo-btn .ld-ico { width: 26px; height: 26px; border-radius: 8px; font-size: 15px; }
.lp-demo-btn .ld-top small { font-size: 11.5px; color: var(--muted); font-family: var(--font-num); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-demo-btn .ld-text { display: block; }
.lp-demo-btn b { font-size: 12.5px; line-height: 1.32; overflow-wrap: break-word; }
.lp-demo-btn.picked .ld-top small { color: rgba(255, 255, 255, .8); }
@media (min-width: 1024px) and (max-height: 960px) { .lp-demo-btn { padding: 6px 9px 7px; gap: 3px; } .lp-demo-btn .ld-ico { width: 24px; height: 24px; } .lp-demo-grid { gap: 6px; } .lp-divider { margin: 14px 0 10px; } .lp-sub { margin-bottom: 12px; } .lp-form { gap: 10px; } }
/* ---------- All-in-one: ชิปรูปแบบองค์กร (โรงเรียน · เขตพื้นที่การศึกษา · ส่วนราชการ · องค์กร/บริษัท) + ป้ายโปรไฟล์ปัจจุบัน ---------- */
.lc-kickers { display: flex; flex-wrap: wrap; gap: 8px; }
.lc-kicker-org { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .34); }
.lc-kicker-org i { color: #a5f3fc; }
.lc-profiles { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 16px; }
.lc-prof-label { display: flex; flex-basis: 100%; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: rgba(255, 255, 255, .78); margin: 0 0 1px; }
.lc-prof-label i { color: #fde68a; font-size: 14px; }
.lc-prof { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .18); color: rgba(255, 255, 255, .9); }
.lc-prof i { font-size: 16px; color: #99f6e4; }
.lc-prof.on { background: #fff; color: var(--brand-ink); border-color: #fff; box-shadow: 0 10px 22px -12px rgba(0, 0, 0, .55); }
.lc-prof.on i { color: var(--brand); }
@media (min-width: 1024px) and (max-height: 860px) { .lc-profiles { margin-top: 12px; } .lc-prof { height: 28px; } }
@media (max-width: 1023px) {
  .lc-profiles { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 8px -18px 0; padding: 0 18px; mask-image: linear-gradient(90deg, #000 88%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .lc-profiles::-webkit-scrollbar { display: none; }
  .lc-prof-label { display: none; }
  .lc-prof { height: 26px; font-size: 11.5px; padding: 0 10px 0 8px; flex-shrink: 0; }
  /* โปรไฟล์ขององค์กรนี้ขึ้นก่อนเสมอ (ไม่ถูกตัด/จางใต้ mask ขอบขวา) — ชิปที่เหลือเลื่อนดูได้ */
  .lc-prof.on { order: -1; }
  .lc-kickers { display: none; }
}
