/* TBN หน้าตาใหม่ (13 พ.ย. 2569) — แนวเดียวกับวิดเจ็ตมือถือ: การ์ดใส มน เงานุ่ม · หัวข้อตัวหนาไม่มีเชิง · ปุ่มมีมิติ กดแล้วรู้สึก
   ไฟล์นี้โหลดต่อจาก style.css (ทุกหน้า) — แก้หน้าตาทั้งเว็บที่เดียว ลบไฟล์นี้ = กลับหน้าตาเดิม */
:root {
  --radius: 20px;
  --radius-sm: 12px;
  --card-bg: color-mix(in srgb, var(--surface) 86%, transparent);
  --card-line: color-mix(in srgb, var(--ink) 6%, transparent);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.18), 0 10px 28px rgba(0, 0, 0, 0.22);
  --lift: 0 8px 22px rgba(0, 0, 0, 0.28);
}
:root[data-theme="light"] {
  --card-line: rgba(255, 255, 255, 0.9);
  --shadow-card: 0 1px 2px rgba(30, 45, 60, 0.04), 0 10px 28px rgba(30, 45, 60, 0.07);
  --lift: 0 8px 22px rgba(30, 45, 60, 0.12);
}

/* ---------- ตัวหนังสือ ---------- */
h1 { font-family: var(--font); font-weight: 700; letter-spacing: -0.02em; font-size: 1.8rem; line-height: 1.25; }
h2 { font-weight: 700; letter-spacing: -0.01em; }
.page-head h1 { margin-bottom: 0.4rem; }

/* ---------- การ์ด ---------- */
.card {
  background: var(--card-bg); border: 1px solid var(--card-line); border-radius: 22px; box-shadow: var(--shadow-card);
}
.card.login { border-radius: 26px; }
a.card, .project-card, .folder-tile, .person { transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease); }
a.card:hover, .project-card:hover, .folder-tile:hover { transform: translateY(-2px); box-shadow: var(--lift); }

/* ---------- ปุ่ม: มน มีมิติ ชี้แล้วลอย กดแล้วยุบ ---------- */
.btn { border-radius: 12px; min-height: 42px; padding: 9px 16px; letter-spacing: 0.005em; transition: transform 0.12s var(--ease), box-shadow 0.15s var(--ease), background 0.15s, border-color 0.15s, filter 0.15s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn-primary {
  border: 0; color: var(--on-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #fff) 0%, var(--accent) 100%);
  box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 75%, #fff) 0%, var(--accent) 100%); box-shadow: 0 10px 22px rgba(var(--accent-rgb), 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn:not(.btn-primary):not(.btn-danger):not(.btn-ghost):hover { box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.15); }
.btn-ghost:hover { transform: none; }

/* ---------- ช่องกรอก: พื้นนุ่ม ขอบบาง โฟกัสแล้วเรืองแสง ---------- */
input:not([type=checkbox]):not([type=radio]), select, textarea {
  border-radius: 12px; border-color: var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); padding: 10px 13px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.16); background: var(--surface); }
label { font-weight: 600; }

/* ---------- แถบบน + เมนูข้าง ---------- */
.topbar { box-shadow: 0 1px 0 var(--line); }
.sidenav a { border-radius: 12px; transition: background 0.15s, color 0.15s, transform 0.12s; }
.sidenav a:hover { transform: translateX(2px); }
.sidenav a.active, .sidenav a.active:hover { box-shadow: inset 3px 0 0 var(--nav-red, var(--accent)); transform: none; }

/* ---------- ตาราง ---------- */
.table-wrap { border-radius: 18px; border-color: var(--card-line); background: var(--card-bg); box-shadow: var(--shadow-card); }
.table th { background: transparent; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); padding-top: 12px; }
.table th, .table td { padding-left: 14px; padding-right: 14px; }
.table td { padding-top: 11px; padding-bottom: 11px; }

/* ---------- ป้าย / แท็บ / แจ้งเตือน ---------- */
.pill { border-radius: 999px; font-weight: 600; }
.flash { border-radius: 14px; box-shadow: var(--shadow-card); }
.tabs a, .cal-seg a { border-radius: 9px; }

/* ---------- เปิดหน้า: การ์ดค่อยๆ ลอยขึ้น (ไม่กระตุก) ---------- */
@media (prefers-reduced-motion: no-preference) {
  main.page > .card, main.page > section, main.page > .page-head, main.page > div > .card {
    animation: tbn-rise 0.32s var(--ease) both;
  }
  main.page > :nth-child(2) { animation-delay: 0.03s; }
  main.page > :nth-child(3) { animation-delay: 0.06s; }
  main.page > :nth-child(4) { animation-delay: 0.09s; }
  main.page > :nth-child(n+5) { animation-delay: 0.12s; }
}
@keyframes tbn-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- เมนูซ้าย (คอม): แผงลอยมุมมน แยกจากขอบจอ ---------- */
@media (min-width: 1024px) {
  .sidenav { top: calc(var(--topbar-h) + 10px); bottom: 12px; left: 12px; width: calc(var(--side-w) - 18px); border-radius: 22px; border: 1px solid var(--card-line);
    background: color-mix(in srgb, var(--nav-bg) 88%, transparent); box-shadow: var(--shadow-card); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
  .sidenav a { padding: 8px 11px; border-radius: 12px; }
  .sidenav a.active, .sidenav a.active:hover { background: var(--surface); box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.14); color: var(--ink); font-weight: 600; }
  .sidenav a.active .ico { color: var(--accent); }
}

/* ---------- มือถือ: แถบล่างแบบแอป ---------- */
.tabbar { display: none; }
@media (max-width: 1023.98px) {
  .tabbar {
    display: flex; position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); height: 62px;
    justify-content: space-around; align-items: center; border-radius: 22px; border: 1px solid var(--card-line);
    background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: 0 12px 30px rgba(30, 45, 60, 0.16);
    -webkit-backdrop-filter: saturate(170%) blur(16px); backdrop-filter: saturate(170%) blur(16px);
  }
  .tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-size: 0.66rem; font-weight: 600; text-decoration: none; -webkit-tap-highlight-color: transparent; cursor: pointer; }
  .tabbar .tab .ico { width: 22px; height: 22px; }
  .tabbar .tab.on { color: var(--accent); }
  .tabbar .tab:active { transform: scale(0.94); }
  /* เว้นที่ให้แถบล่าง + ยกปุ่มลอยอื่นขึ้นเหนือแถบ */
  body:has(.tabbar) main.page { padding-bottom: calc(96px + env(safe-area-inset-bottom)) !important; }
  .pomo-fab, .ally-fab { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
  .pomo-panel { bottom: calc(146px + env(safe-area-inset-bottom)) !important; }
  .ally-panel, .up-panel { bottom: calc(204px + env(safe-area-inset-bottom)) !important; }
  .tb-toast, .pd-toast { bottom: calc(88px + env(safe-area-inset-bottom)) !important; }
  .drive-menu { bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
  .nav-toggle:checked ~ .tabbar, body:has(.impersonate-bar) .tabbar { display: none; }
}
body.ally-app .tabbar, body.focus-app .tabbar { display: none !important; }

/* Needs you: ⋯ เลื่อนตรวจ / ส่งต่อ (14 พ.ย. 2569) */
.desk-acts { position: relative; flex-wrap: wrap; justify-content: flex-end; }
.desk-more > summary { list-style: none; cursor: pointer; }
.desk-more > summary::-webkit-details-marker { display: none; }
.desk-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 280px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.desk-pop form { margin: 0; }
.desk-pop-row { display: flex; gap: 6px; align-items: flex-end; }
.desk-pop-row label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 0.74rem; color: var(--muted); }
.desk-pop-row input, .desk-pop-row select { width: 100%; padding: 6px 8px; font-size: 0.85rem; }
.desk-pop > form:not(.desk-pop-row) > .btn { width: 100%; justify-content: center; }
.desk-pop-row .btn { flex: none; }
.desk-snoozed { padding: 8px 4px 0; }
@media (max-width: 640px) { .desk-pop { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(90px + env(safe-area-inset-bottom)); width: auto; } }
/* หน้างาน: เลื่อนตรวจ / ส่งต่อ */
.rv-later { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; }
.rv-later form { margin: 0; }
.rv-row { display: flex; gap: 6px; align-items: center; }
.rv-row input[type=date], .rv-row select { padding: 5px 8px; font-size: 0.85rem; max-width: 170px; }
.decide-pass .pass-note { width: 100%; min-height: 40px; resize: vertical; margin: 6px 0 8px; font-size: 0.9rem; }

/* ลงยอดขาย: ใบกำกับภาษี — เฉพาะเข้าบัญชีบริษัท · ติ๊กขอแล้วค่อยโชว์ช่องกรอก */
.sl-tax { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.sl-tax-on { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.sl-tax-on input { width: 18px; height: 18px; }
.sl-tax-fields { display: none; flex-direction: column; gap: 10px; }
.sl-tax:has(input[name=tax_invoice]:checked) .sl-tax-fields { display: flex; }
.sl-form:has(input[name=account][value=leo]:checked) .sl-tax { display: none; }
.sl-form .sl-tax-on { flex-direction: row; justify-content: flex-start; text-align: left; }
.sl-form .sl-tax-on input { flex: none; margin: 0; }
@media (max-width: 640px) { .sl-tax .row2 { grid-template-columns: 1fr; display: grid; } }
/* สถานะบิล (ยอดเข้าบัญชีบริษัท) */
.tag.sl-bill { white-space: nowrap; margin-left: 4px; }
.tag.sl-bill.is-todo { background: var(--amber-soft); color: var(--amber); }
.tag.sl-bill.is-done { background: var(--green-soft); color: var(--green); }
.sl-bill-tabs b { font-weight: 700; margin-left: 2px; }
.sl-tax legend { font-weight: 600; padding: 0 4px; }
.sl-paste { display: none; flex-direction: column; gap: 6px; }
.sl-tax:has(input[name=tax_req]:checked) .sl-paste { display: flex; }
.sl-paste textarea { width: 100%; min-height: 96px; }
.sl-paste-st { margin: 0; color: var(--muted); }
.sl-paste-st.is-ok { color: var(--green); }
.sl-paste-st.is-warn { color: var(--red-ink, var(--red)); }
/* ยังไม่ติ๊กขอใบกำกับ = ไม่ต้องโชว์ช่องกรอก (เหลือแค่ติ๊ก "ออกบิลแล้ว") */

/* คอมเมนต์รอบก่อน (กล่องคอมเมนต์แก้งาน) */
.rv-prev { margin: 4px 0 10px; }
.rv-prev > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.rv-prev > summary::-webkit-details-marker { display: none; }
.rv-prev[open] > summary { margin-bottom: 8px; }
.rv-prev-round { border: 1px solid var(--border, #e5e7eb); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2, rgba(0,0,0,.02)); }
.rv-prev-round h4 { margin: 0 0 6px; font-size: 14px; }
.rv-prev-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rv-prev-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.rv-prev-thumb { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: rgba(0,0,0,.06); }
.rv-prev-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rv-prev .rv-where { color: var(--muted, #6b7280); font-size: 12px; margin-right: 4px; }

/* โอที (หน้าแรกพนักงาน + หน้า /ot) */
.ot-card { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.ot-card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.ot-card > summary::-webkit-details-marker { display: none; }
.ot-card p { margin: 0; }
.ot-card.is-ok { border-color: var(--green, #16a34a); }
.ot-card.is-run { border-color: var(--brand, #f97316); }
.ot-form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ot-in { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ot-list > li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line, #e5e7eb); }
.ot-list > li:first-child { border-top: 0; }
.ot-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.ot-acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ot-approve { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ot-approve label { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.ot-edit > summary { list-style: none; }
.ot-edit > summary::-webkit-details-marker { display: none; }
.ot-edit[open] > form { margin-top: 8px; }
.ot-approve select, .ot-approve input[type=time] { width: auto; min-width: 0; }

/* Needs you: ชื่องานต้องมีที่อย่างน้อย ~220px · ไม่พอ = ปุ่มลงบรรทัดใหม่ (กันชื่อบีบเหลือตัวละ 1 บรรทัด — 17 พ.ย. 2569) */
.desk-list > li { flex-wrap: wrap; }
.desk-main { flex: 1 1 220px; min-width: min(100%, 220px); }
.desk-acts { margin-left: auto; }
@media (max-width: 520px) { .desk-main { flex-basis: 100%; } }
.desk-undo-grp { margin-left: auto; display: inline-flex; gap: 6px; }
.desk-undo { font-size: 0.78rem; padding: 4px 10px; }
.desk-needs .desk-h { display: flex; align-items: center; gap: 8px; }
/* แถบล่างจอ: กว้างตามข้อความ (เดิมบีบเหลือครึ่งจอบนมือถือ) */
.toast { width: max-content; }
