/* หลังบ้าน: แถบเมนูซ้าย + พื้นที่ทำงาน — จอแคบเมนูย้ายไปด้านบนเลื่อนแนวนอน */
body.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: var(--ink); text-decoration: none; }
.brand .mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; overflow: hidden; color: #fff; font-weight: 700;
  background: linear-gradient(140deg, var(--brand), var(--brand-2)); }
.brand .mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand b { display: block; font-size: 15.5px; line-height: 1.25; }
.brand small { color: var(--muted); font-size: 12px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; }
.side nav a:hover { background: var(--surface-2); color: var(--ink); }
.side nav a.on { background: var(--brand-soft); color: var(--brand); }
.side nav a .n { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: 11.5px; padding: 0 7px; line-height: 19px; }
.side .me { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.side .me div { min-width: 0; flex: 1; }
.side .me b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { padding: 28px clamp(16px, 3vw, 36px) 64px; max-width: 1280px; width: 100%; }
body:not(.app) main { margin: 0 auto; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.head h1 { font-size: 24px; margin: 0; }
.head p { margin: 2px 0 0; color: var(--muted); }
.head .tools { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.head .tools label { min-width: 170px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--muted); }
.kpi .ic svg { width: 22px; height: 22px; }
.kpi b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi.ok .ic { background: var(--ok-soft); color: var(--ok); } .kpi.warn .ic { background: var(--warn-soft); color: var(--warn); }
.kpi.bad .ic { background: var(--bad-soft); color: var(--bad); } .kpi.info .ic { background: var(--info-soft); color: var(--info); }
.kpi.violet .ic { background: var(--violet-soft); color: var(--violet); }
.notice { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); margin-bottom: 16px; font-weight: 500; }

/* ปฏิทิน: ช่องมุมมน เว้นระยะ อ่านง่ายแบบ heatmap */
.cal { border-collapse: separate; border-spacing: 3px; font-size: 12px; padding: 6px; }
.cal th, .cal td { border: 0; padding: 0; text-align: center; background: none !important; }
.cal th { color: var(--muted); font-weight: 500; padding: 4px 0; min-width: 38px; line-height: 1.2; }
.cal th b { display: block; font-size: 13px; color: var(--ink); }
.cal th.we b { color: var(--bad); }
.cal th.today b { color: #fff; background: var(--brand); border-radius: 8px; width: 26px; margin: 1px auto 0; }
.cal td.name { position: sticky; left: 0; z-index: 1; text-align: left; padding: 4px 12px 4px 4px; min-width: 200px; background: var(--surface) !important; }
.cal td.d { height: 40px; min-width: 38px; border-radius: 8px; cursor: pointer; font-variant-numeric: tabular-nums; font-weight: 500; transition: transform .1s; }
.cal td.d:hover { transform: scale(1.08); }
.cal td.d small { display: block; font-size: 10px; opacity: .8; }
.cal td.present { background: var(--ok-soft) !important; color: var(--ok); }
.cal td.late { background: var(--warn-soft) !important; color: var(--warn); }
.cal td.absent { background: var(--bad-soft) !important; color: var(--bad); }
.cal td.leave, .cal td.half_leave { background: var(--info-soft) !important; color: var(--info); }
.cal td.work_on_off { background: var(--violet-soft) !important; color: var(--violet); }
.cal td.off, .cal td.holiday { background: var(--surface-2) !important; color: var(--off); }
.cal td.future { background: var(--surface-2) !important; opacity: .55; }
.cal td.flag { box-shadow: inset 0 0 0 2px var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }

.photo { width: 68px; height: 68px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.linkbox { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all; background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px; }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; }
.listrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.listrow:last-of-type { border-bottom: 0; }

/* หน้าเข้าสู่ระบบ: แผงแบรนด์ + มือถือจำลอง + การ์ดฟอร์ม */
main:has(> .auth) { padding: 0; max-width: none; }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(380px, 1fr); }
.auth .art { position: relative; overflow: hidden; color: #fff; padding: 36px clamp(24px, 4vw, 64px); display: flex; flex-direction: column; gap: 28px;
  background: radial-gradient(60% 50% at 85% 20%, rgba(52, 211, 153, .45), transparent 70%), radial-gradient(50% 60% at 0% 100%, rgba(6, 182, 212, .35), transparent 70%), linear-gradient(150deg, #065f46 0%, #064e3b 45%, #022c22 100%); }
.auth .art::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .18;
  background-image: radial-gradient(rgba(255,255,255,.7) 1px, transparent 1px); background-size: 22px 22px;
  mask-image: linear-gradient(180deg, #000, transparent 85%); -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%); }
.art > * { position: relative; }
.art-top { display: flex; align-items: center; gap: 10px; font-size: 18px; flex-wrap: wrap; }
.logo-mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, #34d399, #06b6d4); box-shadow: 0 6px 20px rgba(52,211,153,.4); }
.logo-mark svg { width: 20px; height: 20px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); }
.art-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(24px, 4vw, 56px); align-items: center; }
.kicker { display: inline-block; font-size: 13px; letter-spacing: .04em; color: #a7f3d0; margin-bottom: 14px; }
.auth .art h1 { font-size: clamp(34px, 4.2vw, 58px); line-height: 1.15; margin: 0 0 18px; font-weight: 700; }
.auth .art h1 span { white-space: nowrap; }
.grad { background: linear-gradient(90deg, #6ee7b7, #67e8f9 60%, #fde68a); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pitch p { margin: 0; opacity: .85; max-width: 46ch; font-size: 16px; line-height: 1.65; }
.feats { margin: 28px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; max-width: 440px; }
.feats li { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(6px); }
.feats svg { flex: none; width: 20px; height: 20px; color: #6ee7b7; }
.feats b { font-size: 14px; margin-right: 6px; } .feats small { opacity: .72; font-size: 13px; }
.art-foot { margin: 0; font-size: 12.5px; opacity: .6; }

/* มือถือจำลอง: แชตกลุ่ม LINE ทยอยขึ้น */
.stage { position: relative; padding: 24px 40px 24px 0; }
.phone { width: 270px; height: 540px; border-radius: 40px; background: #0b1512; padding: 12px; position: relative;
  box-shadow: 0 0 0 2px rgba(255,255,255,.12), 0 40px 80px -20px rgba(0,0,0,.6), 0 0 120px rgba(52,211,153,.25); rotate: -3deg; animation: bob 6s ease-in-out infinite; }
.notch { position: absolute; top: 12px; left: 50%; translate: -50% 0; width: 90px; height: 22px; border-radius: 0 0 14px 14px; background: #0b1512; z-index: 2; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 30px 12px 10px; background: #1f2d3a; border-radius: 30px 30px 0 0; color: #fff; font-size: 13px; }
.chat-head small { display: block; opacity: .6; font-size: 11px; }
.chat-head .av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #06c755; font-size: 11px; font-weight: 700; }
.pchat { height: calc(100% - 68px); background: #8ca6c3; border-radius: 0 0 30px 30px; padding: 12px 10px; display: flex; flex-direction: column; gap: 9px; overflow: hidden; }
.pb { max-width: 82%; padding: 8px 11px; border-radius: 16px; font-size: 12.5px; line-height: 1.45; color: #111; background: #fff;
  opacity: 0; transform: translateY(10px) scale(.96); animation: pop .45s cubic-bezier(.2,.9,.3,1.3) var(--d) forwards; }
.pb i { display: block; font-style: normal; font-size: 10.5px; color: #4b5563; margin-bottom: 2px; }
.pb.in { border-top-left-radius: 4px; }
.pb.bot { border-top-left-radius: 4px; background: #ecfdf5; box-shadow: inset 3px 0 0 #10b981; }
.pb.bot i { color: #047857; font-weight: 600; }
.pb.out { align-self: flex-end; background: #06c755; color: #fff; border-top-right-radius: 4px; font-weight: 600; }
.float { position: absolute; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 16px; color: #0f1f1a;
  background: rgba(255,255,255,.96); box-shadow: 0 20px 40px -12px rgba(0,0,0,.45); font-size: 13px; animation: bob 5s ease-in-out infinite; }
.float small { display: block; color: #5f6f69; font-size: 11.5px; }
.float.f1 { left: -64px; bottom: 120px; animation-delay: -2s; }
.float.f2 { right: 0; top: 70px; flex-direction: column; gap: 0; align-items: flex-start; }
.float.f2 b { font-size: 24px; color: #047857; line-height: 1.1; }
.pdot { width: 10px; height: 10px; border-radius: 50%; } .pdot.ok { background: #10b981; box-shadow: 0 0 0 4px rgba(16,185,129,.2); }
@keyframes pop { to { opacity: 1; transform: none; } }
@keyframes bob { 50% { translate: 0 -8px; } }
@media (prefers-reduced-motion: reduce) { .phone, .float { animation: none; } .pb { animation: none; opacity: 1; transform: none; } }

/* การ์ดฟอร์ม */
.auth-side { display: grid; place-items: center; padding: 32px clamp(16px, 4vw, 56px);
  background: radial-gradient(80% 50% at 100% 0%, var(--brand-soft), transparent 70%), var(--bg); }
.auth-card { width: min(100%, 420px); display: grid; gap: 16px; padding: 32px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(15,31,26,.04), 0 24px 60px -24px rgba(6,78,59,.35); }
.card-head h2 { font-size: 26px; margin: 0 0 4px; } .card-head p { margin: 0; }
.auth-card input { padding: 12px 14px; border-radius: 12px; }
.auth-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.cta { justify-content: center; padding: 13px; font-size: 16px; border-radius: 12px; border: 0; background: linear-gradient(135deg, #059669, #0d9488); box-shadow: 0 10px 24px -8px rgba(5,150,105,.6); transition: transform .15s, box-shadow .15s; }
.cta:hover { transform: translateY(-1px); box-shadow: 0 14px 28px -8px rgba(5,150,105,.7); }
.alt { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.alt a { color: var(--brand); font-weight: 600; }
.hint { margin: 0; font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--muted); }

@media (max-width: 1240px) { .stage { display: none; } .art-main { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth .art { padding: 24px 16px 32px; gap: 20px; }
  .feats, .art-foot { display: none; }
  .auth .art h1 { font-size: 34px; margin-bottom: 10px; }
  .pitch p { font-size: 14.5px; }
  .auth-side { padding: 24px 16px 40px; }
  .auth-card { padding: 24px 20px; }
}

@media (max-width: 900px) {
  body.app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; z-index: 5; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand small, .side .me div { display: none; }
  .side nav { flex-direction: row; }
  .side nav a { white-space: nowrap; padding: 8px 10px; }
  .side .me { border: 0; padding: 0; }
  .split, .auth { grid-template-columns: minmax(0, 1fr); }
}

/* แชตจำลองกลุ่ม LINE */
.chat { height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px;
  background: color-mix(in srgb, #8fb3d9 22%, var(--surface-2)); }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 86%; }
.msg small { display: block; font-size: 11.5px; color: var(--muted); margin: 0 4px 2px; }
.msg p { margin: 0; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; line-height: 1.5; font-size: 14.5px; }
.msg.bot p { background: var(--surface); border-top-left-radius: 4px; box-shadow: var(--shadow); }
.msg.bot .avatar { background: #06c755; color: #fff; }
.msg.me { align-self: flex-end; }
.msg.me small { text-align: right; }
.msg.me p { background: #06c755; color: #fff; border-bottom-right-radius: 4px; }
.chatbar { display: flex; gap: 8px; }
.chatbar button { padding: 9px 14px; }
.chip { cursor: pointer; }
