/* ==========================================================================
   layout.css — โครงหน้าเว็บ: แถบเมนูด้านซ้าย (Sidebar) + พื้นที่เนื้อหาด้านขวา
   ใช้คู่กับ index.html (ลิงก์ผ่าน <link rel="stylesheet" href="layout.css">)
   แก้ความกว้างแถบเมนูที่ตัวแปร --sb-width
   ========================================================================== */

/* สาเหตุที่แถบเมนูไม่เลื่อนตาม: overflow-x:hidden บน html/body ทำให้ position:sticky ใช้ไม่ได้
   ใช้ clip แทน (กันเนื้อหาล้นด้านข้างเหมือนกัน แต่ไม่สร้าง scroll container) */
html, body{ overflow-x: clip; overflow-y: visible; }

.app{ --sb-width: 252px; --sb-gap: 20px; max-width: none; width: 100%; margin: 0; }   /* เต็มความกว้างจอ */

.app-shell{
  display: grid;
  grid-template-columns: var(--sb-width) minmax(0, 1fr);
  gap: var(--sb-gap);
  align-items: start;
}
.app-main{ min-width: 0; }              /* กันตารางกว้างดันหน้าจนล้น */
.app-main > .view > h2.section-title:first-child{ margin-top: 4px; }

/* ---------- แถบเมนูด้านซ้าย ---------- */
.masthead{
  position: sticky; top: 20px;
  display: flex; flex-direction: column; align-items: stretch; flex-wrap: nowrap;
  gap: 18px; margin-bottom: 0; padding: 18px 14px;
  min-height: calc(100dvh - 40px); max-height: calc(100dvh - 40px); overflow-y: auto;   /* สูงเต็มจอ */
  border-bottom: 1px solid var(--line);   /* คืนเส้นขอบล่างของการ์ด (เดิมเป็นเส้นคั่นหัวเว็บ) */
}
.masthead-title{ gap: 12px; padding: 0 4px; }
.masthead-title h1{ font-size: 1.05rem; line-height: 1.35; }
.masthead-sub{ font-size: .76rem; line-height: 1.5; }

.stub-nav{ flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 6px; flex: 1; }

/* ชื่อผู้ใช้ไว้บนสุด → เมนูหลัก → เมนูจัดการ/ออกจากระบบ */
#user-badge{ order: 0; margin: 0 0 8px; padding: 9px 14px; border-radius: 12px; text-align: left; overflow-wrap: anywhere; }
.stub{ order: 1; width: 100%; text-align: left; padding: 10px 14px; border-radius: 12px; }
.lock-btn{ order: 2; width: 100%; margin-left: 0; text-align: left; border-radius: 12px; }
#lock-toggle{ order: 3; margin-top: auto; }   /* ดันปุ่มออกจากระบบลงล่างสุดของแถบ */
#lock-change{ order: 4; text-align: left; padding-left: 14px; }

/* ---------- จอแคบ: แถบเมนูกลับไปอยู่ด้านบนแบบแถว ---------- */
@media (max-width: 1100px){
  .board-row{ grid-template-columns: 1fr; }
  .work-grid, .calc-wrap{ grid-template-columns: 1fr; }
  .receipt{ position: static; }
}
@media (max-width: 900px){
  .app-shell{ grid-template-columns: 1fr; }
  .masthead{ position: static; min-height: 0; max-height: none; overflow: visible; margin-bottom: 4px; }
  .stub-nav{ flex-direction: row; flex-wrap: wrap; align-items: center; }
  .stub, .lock-btn{ width: auto; }
  #user-badge{ order: 0; margin: 0; }
  #lock-toggle{ margin-top: 0; }
  .stub-nav{ flex: none; }
}

/* ---------- แถบแยกการใช้งานบนหน้า (Tabs) — เมนู Lastchaos ---------- */
.page-tabs{
  display: flex; align-items: flex-end; gap: 24px; flex-wrap: wrap;
  margin: 0 0 18px; padding: 0 6px; border-bottom: 1px solid var(--line);
}
.page-tabs-title{ padding: 0 0 12px; font-size: 1.15rem; font-weight: 700; color: var(--ink); letter-spacing: .2px; }
.page-tabs-bar{ display: flex; gap: 4px; flex-wrap: wrap; }
.page-tab{
  font: 500 .9rem 'Kanit', sans-serif; color: var(--ink-dim); cursor: pointer;
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 8px 16px 11px; margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.page-tab:hover{ color: var(--ink); }
.page-tab.active{ color: var(--accent-ink, var(--accent)); border-bottom-color: var(--accent); font-weight: 600; }
.page-tab:focus-visible{ outline: 2px solid rgba(59,111,212,.55); outline-offset: 2px; border-radius: 6px; }
