
/* RUS Shared Sidebar v53 — authoritative menu layout for every system */
:root{--rus-sidebar-w:300px;--rus-topbar-h:64px}
.sidebar{
  position:fixed!important;top:var(--rus-topbar-h)!important;bottom:0!important;left:0!important;
  width:var(--rus-sidebar-w)!important;background:#fff!important;border-right:1px solid #dce4ef!important;
  overflow-y:auto!important;overflow-x:hidden!important;padding:14px 8px 28px!important;z-index:55!important;
  scrollbar-gutter:stable!important
}
.sidebar .nav-section{padding:0 4px!important}
.sidebar .nav-section .label{font-size:14.5px!important;color:#1e3a66!important;font-weight:800!important;letter-spacing:0!important;text-transform:none!important;line-height:1.35!important;padding:14px 8px 6px!important}
#navSystems{width:100%!important}
#navSystems .nav-parent{
  display:flex!important;align-items:center!important;gap:10px!important;width:100%!important;min-width:0!important;
  border:0!important;background:transparent!important;text-align:left!important;padding:10px 10px!important;
  border-radius:9px!important;color:#42516a!important;font-family:inherit!important;cursor:pointer!important
}
#navSystems .nav-parent .ico{width:22px!important;min-width:22px!important;display:flex!important}
#navSystems .nav-parent .ico svg{width:20px!important;height:20px!important}
#navSystems .nav-parent .txt{flex:1!important;min-width:0!important;text-align:left!important;white-space:normal!important;overflow-wrap:anywhere!important;line-height:1.35!important}
#navSystems .nav-parent .chev{width:16px!important;height:16px!important;flex:0 0 16px!important;transition:transform .18s ease!important}
#navSystems .nav-parent.open .chev{transform:rotate(90deg)!important}
#navSystems .nav-parent.open,#navSystems .nav-parent.current-sys{background:#eaf3ff!important;color:#123e78!important;font-weight:600!important}

#navSystems .submenu{display:none!important;max-height:none!important;overflow:visible!important;background:#f4f7fc!important;padding:5px 4px 8px!important;border-radius:0 0 9px 9px!important}
#navSystems .submenu.open{display:block!important}
#navSystems .nav-group2{
  position:relative!important;display:flex!important;align-items:flex-start!important;gap:7px!important;
  width:100%!important;min-width:0!important;border:0!important;background:transparent!important;
  text-align:left!important;padding:9px 8px!important;border-radius:7px!important;color:#284e7f!important;
  font-family:inherit!important;font-size:12.5px!important;line-height:1.4!important;cursor:pointer!important
}
#navSystems .nav-group2 .g-cn{flex:1!important;min-width:0!important;white-space:normal!important;overflow-wrap:anywhere!important}
#navSystems .nav-group2 .g-chev{width:16px!important;height:16px!important;flex:0 0 16px!important;margin-top:1px!important;transition:transform .18s ease!important}
#navSystems .nav-group2.open .g-chev{transform:rotate(90deg)!important}
#navSystems .nav-group2:hover{background:#eaf1fb!important}
#navSystems .nav-group2.active-step{background:#fff!important;color:#173d75!important;font-weight:700!important;box-shadow:0 1px 5px rgba(30,60,90,.08)!important;border-left:3px solid #2458a6!important;padding-left:7px!important}

#navSystems .subsub{display:none!important;padding:2px 0 4px 8px!important;margin:0!important}
#navSystems .subsub.open{display:block!important}
#navSystems .nav-leaf{
  display:flex!important;align-items:flex-start!important;gap:8px!important;width:100%!important;min-width:0!important;
  text-decoration:none!important;color:#31507e!important;font-family:inherit!important;font-size:12px!important;
  line-height:1.4!important;padding:7px 8px 7px 12px!important;border-radius:7px!important;white-space:normal!important
}
#navSystems .nav-leaf .bullet{width:5px!important;height:5px!important;border-radius:50%!important;background:#9fb0c7!important;flex:0 0 5px!important;margin-top:6px!important}
#navSystems .nav-leaf .cn{flex:1!important;min-width:0!important;overflow-wrap:anywhere!important}
#navSystems .nav-leaf:hover{background:#edf3fb!important}
#navSystems .nav-leaf.active{background:#fff!important;color:#173d75!important;font-weight:700!important;border-left:3px solid #2b62b0!important;padding-left:9px!important}
#navSystems .nav-leaf.active .bullet{background:#2b62b0!important}

@media(min-width:1051px){
  body:has(.sidebar) .content{margin-left:var(--rus-sidebar-w)!important}
}
@media(max-width:1050px) and (min-width:761px){
  :root{--rus-sidebar-w:270px}
  body:has(.sidebar) .content{margin-left:var(--rus-sidebar-w)!important}
}
@media(max-width:760px){
  .sidebar{display:none!important}
  body:has(.sidebar) .content{margin-left:0!important}
}


/* v56: clarify Master ownership and keep System Status out of Master concept */
#navSystems .nav-group2[data-master-role="shared"],
#navSystems .nav-group2[data-master-role="system"]{font-weight:800!important}

/* ── v57 (F079) — เมนูที่อยู่นอก #navSystems ────────────────────────────────
   ทุกกฎด้านบนผูกกับ `#navSystems` แต่ `#roleMenu` ("งานของฉัน") ที่ rus-nav.js
   แทรกไว้บนสุดเป็น .nav-section พี่น้องกัน จึงไม่โดนกฎเลย
   ผลคือ <svg> ที่ไม่มี width/height ตกไปใช้ค่า default ของ browser (300×150)
   → icon ระเบิดเต็มการ์ดบน 300 หน้าที่ไม่มี <style> .nav-parent .ico svg ของตัวเอง
   ใช้ .sidebar (class) ไม่ใช่ ID → specificity ต่ำกว่า #navSystems เสมอ
   กฎเดิมของเมนูระบบจึงชนะอยู่ ไม่กระทบของที่ทำงานถูกอยู่แล้ว */
.sidebar .nav-parent{
  display:flex!important;align-items:center!important;gap:10px!important;
  width:100%!important;min-width:0!important;border:0!important;background:transparent!important;
  text-align:left!important;padding:10px!important;border-radius:9px!important;
  color:#42516a!important;font-family:inherit!important;cursor:pointer!important;text-decoration:none!important
}
.sidebar .nav-parent .ico{
  width:22px!important;min-width:22px!important;height:22px!important;
  display:flex!important;align-items:center!important;justify-content:center!important
}
.sidebar .nav-parent .ico svg{width:20px!important;height:20px!important;flex:0 0 20px!important}
.sidebar .nav-parent .txt{
  flex:1!important;min-width:0!important;text-align:left!important;
  white-space:normal!important;overflow-wrap:anywhere!important;line-height:1.35!important
}
.sidebar .nav-parent:hover{background:#edf3fb!important}
.sidebar .nav-parent.current{background:#eaf3ff!important;color:#123e78!important;font-weight:600!important}

/* ตาข่ายกันพลาด: svg ใน sidebar ที่ไม่ได้ระบุ width มาในแท็ก ห้ามโตเกินขนาดแถว
   (ถ้ามีใครเพิ่มเมนูใหม่แล้วลืม .ico อีก จะได้ไม่ระเบิดซ้ำรอบนี้) */
.sidebar svg:not([width]){max-width:22px!important;max-height:22px!important}

/* ── v58 (F081) — role ที่เห็นระบบเดียว ────────────────────────────────────
   ไม่ต้องมีปุ่มพับ/กางหัวข้อระบบ เพราะไม่มีระบบอื่นให้สลับไป — rus-nav.js ติด
   .sec-flat ให้เมื่อนับแล้วเหลือ section ระบบเดียวที่ไม่ถูกซ่อน
   (admin/executive ที่เห็น 9 ระบบ ไม่โดนกฎนี้ ยังพับได้เหมือนเดิมตาม F073) */
.nav-section.sec-flat > .sec-toggle{display:none!important}
.nav-section.sec-flat > .sec-body{display:block!important}

/* ชื่อระบบยังต้องเห็นอยู่ ไม่งั้นไม่รู้ว่ากำลังดูเมนูของระบบไหน — แสดงเป็นหัวข้อ
   แทนปุ่ม ใช้หน้าตาเดียวกับ .label ของ section อื่นให้กลมกลืน */
.nav-section.sec-flat::before{
  content:attr(data-label-text);
  display:block;font-size:14.5px;color:#1e3a66;font-weight:800;letter-spacing:0;text-transform:none;line-height:1.35;padding:14px 8px 6px
}


/* ── v60 (F108) — ยุบเมนูแล้วเหลือแถบไอคอน ไม่ใช่หายไปทั้งแถบ ────────────
   v59 (F106) ทำให้ปุ่มยุบใช้งานได้ครั้งแรก แต่ยุบแล้ว sidebar หายหมด
   Sarawit ทักว่าควรเหลือไอคอนไว้ให้กดข้ามหน้าได้โดยไม่ต้องกางกลับทุกครั้ง
   → ยุบ = หด `--rus-sidebar-w` เหลือแถบแคบ โชว์เฉพาะไอคอน ซ่อนข้อความ

   ⚠️ ต้องใส่ !important แทบทุกบรรทัด เพราะกฎด้านบนในไฟล์นี้เองผูก !important ไว้หมด
   (นั่นคือสาเหตุที่ปุ่มยุบไม่เคยทำงานเลยก่อน F106) */

.sidebar{transition:width .18s ease}

#app.collapsed{--rus-sidebar-w:68px}
#app.collapsed .sidebar{
  width:68px!important;
  padding:14px 6px 28px!important;
  overflow-x:hidden!important
}

/* ข้อความหายหมด เหลือแต่ไอคอน — ใช้ปุ่มกางกลับเมื่อต้องอ่านชื่อ */
#app.collapsed .sidebar .txt,
#app.collapsed .sidebar .cn,
#app.collapsed .sidebar .g-cn,
#app.collapsed .sidebar .chev,
#app.collapsed .sidebar .g-chev,
#app.collapsed .sidebar .sec-div,
#app.collapsed .sidebar .nav-section > .label{display:none!important}

/* ไอคอนมาอยู่กลางแถบ */
#app.collapsed .sidebar .nav-parent,
#app.collapsed .sidebar .sec-toggle{
  justify-content:center!important;
  padding:10px 0!important;
  gap:0!important
}
#app.collapsed .sidebar .nav-parent .ico{margin:0!important}

/* เมนูย่อยที่กางอยู่ ซ่อนตอนยุบ — ไม่งั้นแถบแคบจะมีจุดกลมเรียงกันอ่านไม่ออก */
#app.collapsed .sidebar .submenu,
#app.collapsed .sidebar .subsub,
#app.collapsed .sidebar .nav-leaf,
#app.collapsed .sidebar .nav-group2{display:none!important}

/* เนื้อหาขยับตามความกว้างใหม่ ไม่ใช่ชิดขอบ */
@media(min-width:1051px){
  body:has(#app.collapsed) .content,
  #app.collapsed .content{margin-left:68px!important}
}
@media(max-width:1050px) and (min-width:761px){
  body:has(#app.collapsed) .content,
  #app.collapsed .content{margin-left:68px!important}
}

/* จอเล็ก: ปกติซ่อน sidebar อยู่แล้ว — กดปุ่มแล้วเลื่อนเข้ามาเต็มความกว้างปกติ
   (จอเล็กไม่เหมาะกับแถบไอคอน กดยากและอ่านไม่ออก) */
@media(max-width:760px){
  #app.collapsed .sidebar{width:var(--rus-sidebar-w)!important}
  #app.mobile-open .sidebar{
    display:block!important;
    width:270px!important;
    padding:14px 8px 28px!important;
    box-shadow:0 0 0 100vmax rgba(15,23,42,.45)!important;
    z-index:60!important
  }
  #app.mobile-open .sidebar .txt,
  #app.mobile-open .sidebar .nav-section > .label{display:block!important}
}

/* ── โหมดพิมพ์ (UAT RPT-007) ────────────────────────────────────────────
   กฎ margin-left ด้านบนใช้ทั้ง !important และ specificity `body:has(.sidebar) .content`
   ซึ่งชนะ `.content{margin:0}` ที่หน้าเพจเขียนเอง → เนื้อหาถูกดันขวา 300px เวลาพิมพ์
   เสียกระดาษไปหนึ่งในสาม จึงต้องล้างที่นี่ด้วย specificity เท่ากัน
   ทำที่ไฟล์กลางจุดเดียว มีผลกับทุกหน้าที่ใช้เมนูร่วมกัน */
@media print {
  .sidebar, .topbar, .backdrop, .menu-toggle { display: none !important; }

  body:has(.sidebar) .content,
  #app.collapsed .content,
  body:has(#app.collapsed) .content,
  .content { margin-left: 0 !important; margin-top: 0 !important; padding-top: 0 !important; }

  /* ให้พื้นหลังหัวตารางและป้ายสถานะติดกระดาษ ไม่งั้นเบราว์เซอร์ตัดสีทิ้ง */
  thead th, .badge, .pill, .chip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  tr { break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
}

/* ── v61 (NAV-CENTRAL-1) — เมนูกลาง: ฟอนต์ + จองที่ก่อน JS ทำงาน ─────────────
   มติ: ไฟล์กลางสร้างทั้งกรอบเมนู หน้าเหลือ <aside class="sidebar" id="sidebar"></aside> เปล่า
   rus-nav.js (ensureShell) วาด .nav-section > .label + #navSystems ลงใน aside เดิม — ไม่มี container ใหม่
   ที่ว่างจองด้วย CSS ล้วน: .sidebar เป็น position:fixed กว้าง var(--rus-sidebar-w) และ .content เว้น
   margin-left เท่ากันตั้งแต่ HTML มี <aside> (body:has(.sidebar)) → JS วาดเมนูทีหลังไม่ดันเนื้อหา ไม่กระโดด
   ⚠️ ห้ามเขียนสไตล์เมนู (.sidebar .nav-* .submenu #navSystems) ลงใน <style> ของหน้า — ที่นี่ที่เดียว
      (tests/frontend/nav-central.js ตรวจ · ย้ายหน้าด้วย tests/frontend/_tools/nav-codemod.js) */
html body{font-family:Kanit,Arial,sans-serif}
.sidebar,.sidebar a,.sidebar button{font-family:inherit}
