/* ============================================================
   layout.css — โครงหน้าเว็บกลาง (กลับมาใช้หน้าตาเดิม)
   แถบบนสีน้ำเงินเข้ม (โลโก้ + ชื่อบริษัท | ชื่อผู้ใช้ + ออกจากระบบ) + เส้นฟ้า
   ใต้แถบบนมีแถบหัวโมดูล (ชื่อโมดูล + เมนูย่อย + ปุ่มกลับ)  เนื้อหากลางจอกว้าง ~1150px ไม่มีเมนูข้าง
   มือถือ: เมนูย่อยเป็นแถวเลื่อนแนวนอนอยู่ใต้แถบบน (หน้าไม่เลื่อนไปด้านข้าง)
   ============================================================ */

.mod-marketing { --mc: var(--mod-marketing); }
.mod-hr { --mc: var(--mod-hr); }
.mod-stock { --mc: var(--mod-stock); }
.mod-accounting { --mc: var(--mod-accounting); }
.mod-me { --mc: var(--mod-me); }
.mod-admin { --mc: var(--mod-admin); }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--navy); color: #fff; padding: .6rem 1rem; border-radius: 0 0 10px 0; z-index: 200; }
.skip-link:focus { left: 0; }

.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
/* หน้าแผนที่: ให้แผนที่กินพื้นที่ที่เหลือใต้แถบทั้งหมด ไม่ให้หน้าเลื่อน */
.app:has(.map-page) { height: 100vh; height: 100dvh; min-height: 0; }

/* ---------- แถบบน (ขาวโปร่ง + เบลอ) ---------- */
.topbar { background: rgba(255, 255, 255, .82); -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid rgba(213, 219, 232, .7); position: sticky; top: 0; z-index: 40; }
.topbar-in { height: 56px; max-width: var(--page-w); margin: 0 auto; padding: 0 1rem; display: flex; align-items: center; gap: 1rem; }
.topbar .brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--navy-dark); text-decoration: none; font-weight: 800; font-size: 1rem; min-width: 0; white-space: nowrap; letter-spacing: -.01em; }
.topbar .brand:hover { color: var(--navy); }
.topbar .brand img { width: 32px; height: 32px; border-radius: 9px; background: #fff; flex: none; display: block; box-shadow: 0 0 0 1px var(--line); }
.topbar .top-right { display: flex; align-items: center; gap: .5rem; min-width: 0; margin-left: auto; }
.topbar .top-right form { margin: 0; }
.topbar .who { display: inline-flex; align-items: center; gap: .5rem; color: var(--text-2); font-size: .82rem; white-space: nowrap; min-width: 0; padding-right: .3rem; }
.who-av { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--navy) 0%, var(--sky) 100%); color: #fff; font-style: normal; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: .85rem; }
.who-t { overflow: hidden; text-overflow: ellipsis; max-width: 16rem; }
.btn-top { display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 .85rem; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--navy); font: inherit; font-size: .85rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background var(--ease), border-color var(--ease); }
.btn-top:hover, .btn-top.active { background: var(--sky-soft); border-color: var(--sky); color: var(--navy-dark); }
.btn-top:focus-visible { box-shadow: var(--focus); }

/* สลับส่วนงาน (เดสก์ท็อป) */
.modswitch { display: flex; gap: 2px; padding: 3px; background: #EBEFF7; border-radius: 12px; }
.modswitch a { display: inline-flex; align-items: center; gap: .4rem; padding: .32rem .8rem; border-radius: 9px; text-decoration: none; font-size: .86rem; font-weight: 600; color: var(--gray-text); white-space: nowrap; transition: background var(--ease), color var(--ease), box-shadow var(--ease); }
.modswitch a .ico { width: 1.05rem; height: 1.05rem; }
.modswitch a:hover { color: var(--navy-dark); background: rgba(255, 255, 255, .6); }
.modswitch a.active { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(23, 44, 116, .14); }
.modswitch a.active .ico { color: var(--logo-blue); }

/* ---------- แถบเมนูย่อยของโมดูล ---------- */
.modband { background: transparent; border-bottom: 1px solid var(--line); }
.modband-in { max-width: var(--page-w); margin: 0 auto; padding: .5rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; }
.modband .modtitle { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: .95rem; color: var(--navy-dark); white-space: nowrap; }
.modband .modtitle .ico-wrap { width: 28px; height: 28px; border-radius: 9px; background: var(--sky-soft); color: var(--mc, var(--logo-blue)); display: inline-flex; align-items: center; justify-content: center; }
.modband .modtitle .ico-wrap .ico { width: 16px; height: 16px; }
.subnav { display: flex; flex-wrap: wrap; gap: .15rem; flex: 1 1 auto; min-width: 0; align-items: center; }
.subnav a { padding: .3rem .75rem; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: .85rem; color: var(--gray-text); border: 0; white-space: nowrap; position: relative; transition: background var(--ease), color var(--ease); }
.subnav a:hover { background: var(--gray-bg); color: var(--navy-dark); }
.subnav a.active { background: var(--sky-soft); color: var(--navy); }
.subnav a.feature:not(.active)::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--sky); margin-left: .35rem; vertical-align: middle; }
.btn-back { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .82rem; padding: .25rem .65rem; border-radius: 8px; border: 0; background: transparent; white-space: nowrap; margin-left: auto; transition: var(--ease); }
.btn-back:hover { background: var(--gray-bg); color: var(--navy-dark); }
.btn-back .ico { width: 1em; height: 1em; }

.wrap { width: 100%; max-width: var(--page-w); margin: 0 auto; padding: 1.1rem 1rem 3rem; flex: 1; }
.wrap.narrow { max-width: 680px; }

/* ---------- แถบเมนูล่าง (มือถือ) ---------- */
.tabbar { display: none; }

/* ---------- มือถือ ---------- */
@media (max-width: 900px) { .modswitch { display: none; } .who-t { display: none; } }
@media (max-width: 760px) {
  .topbar-in { padding: 0 .8rem; gap: .4rem; height: 52px; }
  .topbar .brand img { width: 30px; height: 30px; }
  .topbar .hide-sm { display: none; }
  .btn-top { height: 32px; padding: 0 .7rem; font-size: .8rem; }
  .modband-in { padding: 0; gap: 0; }
  .modband .modtitle { order: 1; flex: 1 1 auto; min-width: 0; height: 42px; padding: 0 .9rem; overflow: hidden; text-overflow: ellipsis; }
  .modband .btn-back { order: 2; margin: 0 .6rem 0 0; padding: 0; width: 34px; height: 34px; justify-content: center; }
  .modband .btn-back span { display: none; }
  .subnav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: .35rem; padding: .3rem .8rem .55rem; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav a { flex: none; background: var(--gray-bg); padding: .4rem .9rem; border-radius: var(--radius-pill); }
  .subnav a.active { background: var(--navy); color: #fff; }
  .wrap { padding: .9rem .85rem calc(5.4rem + env(safe-area-inset-bottom)); }
  .page-head { display: block; }
  .page-head p { text-align: left; }
  .tabbar { display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 60; padding: 6px; gap: 2px; background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 8px 28px rgba(23, 44, 116, .18); }
  .tabbar a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .4rem .1rem; border-radius: 14px; text-decoration: none; color: var(--muted); font-size: .68rem; font-weight: 600; transition: background var(--ease), color var(--ease); }
  .tabbar a .ico { width: 1.35rem; height: 1.35rem; }
  .tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .tabbar a.active { background: var(--navy); color: #fff; box-shadow: 0 4px 12px rgba(37, 69, 160, .35); }
}

/* ---------- หน้า login ---------- */
.login-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(155deg, #1B2260 0%, #262F7A 48%, #2A61A6 100%); }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 24px; padding: 1.8rem 1.4rem 1.4rem; box-shadow: 0 24px 60px rgba(8, 12, 50, .45); }
.login-card img.logo { display: block; width: 190px; max-width: 65%; margin: 0 auto .6rem; }
.login-card h1 { text-align: center; font-size: 1.2rem; margin: .2rem 0 .4rem; }
.login-card .lead { text-align: center; color: var(--muted); margin-bottom: 1rem; }
.login-card label.field { margin: .9rem 0 .3rem; font-size: 1.05rem; }
.login-card input { min-height: 52px; }
.login-card .btn-big { min-height: 64px; border-radius: 14px; }

/* ---------- ส่วนหัวหน้า (หัวข้อ + ประโยคช่วย) ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .1rem 1.2rem; margin-bottom: var(--s-4); }
.page-head h1 { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: 0; }
.page-head p { font-size: var(--fs-sm); }
.page-head .ico-title { color: var(--mc, var(--logo-blue)); }
.hero-link { display: flex; align-items: center; gap: 1rem; background: linear-gradient(105deg, var(--navy) 0%, #2B5AA0 100%); color: #fff; border-radius: var(--radius); padding: 1.05rem 1.3rem; text-decoration: none; box-shadow: var(--shadow); margin-bottom: 1.1rem; }
.hero-link:hover { color: #fff; box-shadow: var(--shadow-lg); }
.hero-link .hero-ico { flex: none; width: 52px; height: 52px; border-radius: 14px; background: rgba(255, 255, 255, .14); display: inline-flex; align-items: center; justify-content: center; }
.hero-link .big { font-size: 1.2rem; font-weight: 700; }
.hero-link .go { margin-left: auto; background: var(--sky); color: var(--navy-dark); padding: .6rem 1.1rem; border-radius: 12px; font-weight: 700; white-space: nowrap; }
@media (max-width: 560px) { .hero-link { flex-wrap: wrap; } .hero-link .go { margin-left: 0; width: 100%; text-align: center; } }
.no-print { }
@media print {
  .topbar, .modband, .tabbar, .no-print, .flash, .skip-link { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  body { background: #fff; font-size: 12pt; }
}
