/* NganDee — T7 พื้นฐาน mobile-first (เป้า 360–430px แล้วขยาย) กริด 4px น้ำหนักตัวอักษรสูงสุด 600
   ห้าม letter-spacing กับภาษาไทย / ไม่มีฟังก์ชัน hover-only (hover เป็นแค่สีเสริม) */
@font-face { font-family: "Noto Sans Thai"; src: url("/static/fonts/noto-sans-thai-400-700-thai.woff2") format("woff2");
  font-weight: 400 700; font-display: swap; }

:root {
  --bg: #f4f6fb; --surface: #fff; --surface-2: #f8f9fc; --line: #dfe4ee; --line-2: #c5cddc;
  --ink: #17202e; --ink-2: #3a4558; --ink-3: #566074;           /* ink-3 บนขาว 6.3:1 */
  --brand: #1e3a8a; --brand-2: #172c6b; --brand-soft: #e6ecfb;
  /* ปุ่มตามสีมาตรฐาน — ตัวอักษรขาวบนสีทุกตัว ≥ 4.5:1 */
  --c-add: #1d4ed8; --c-edit: #b45309; --c-view: #0369a1; --c-pay: #15803d;
  --c-refund: #7e22ce; --c-print: #475569; --c-del: #b91c1c;
  --ok: #166534; --ok-bg: #e7f6ec; --warn: #854d0e; --warn-bg: #fdf3d8; --err: #991b1b; --err-bg: #fdeaea; --info: #075985; --info-bg: #e3f2fb;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
  --r: 12px; --r-sm: 8px; --tap: 44px;
  --tabbar-h: 64px; --side-w: 248px; --topbar-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --shadow: 0 1px 2px rgba(23,32,46,.06), 0 4px 16px rgba(23,32,46,.06);
  --font: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font: 400 1rem/1.65 var(--font); color: var(--ink); background: var(--bg); min-height: 100vh;
  overflow-wrap: anywhere; letter-spacing: 0; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 var(--s3); font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.0625rem; }
p { margin: 0 0 var(--s3); }
a { color: var(--c-add); text-underline-offset: 3px; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right, .num { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: var(--s3) var(--s4); z-index: 100; }
.skip:focus { left: var(--s2); top: var(--s2); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- เปลือกแอป: มือถือ = topbar + tabbar ล่าง ---------- */
.testsite { background: #fde68a; color: #422006; text-align: center; font-size: .875rem; padding: var(--s1) var(--s3); }
.app { min-height: 100vh; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) var(--s4) 0;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: var(--s2); text-decoration: none; color: var(--brand); font-weight: 600; min-width: 0; min-height: var(--tap); }
.brand-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.top-tools { display: flex; align-items: center; gap: var(--s1); }
.icon-btn { position: relative; width: var(--tap); height: var(--tap); display: inline-grid; place-items: center; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); }
.count { position: absolute; top: 4px; right: 2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--c-del); color: #fff;
  font: 600 .75rem/20px var(--font); text-align: center; font-style: normal; }
.page { padding: var(--s4) var(--s4) calc(var(--tabbar-h) + var(--safe-b) + var(--s6)); max-width: 960px; margin: 0 auto; outline: none; }

.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding: 0 env(safe-area-inset-right, 0) var(--safe-b) env(safe-area-inset-left, 0);
  background: var(--surface); border-top: 1px solid var(--line-2); box-shadow: 0 -2px 12px rgba(23,32,46,.06); }
.tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; min-height: var(--tap);
  padding: var(--s1) 2px; border: 0; background: none; color: var(--ink-3); text-decoration: none; font-size: .75rem; line-height: 1.3; cursor: pointer; }
.tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar .on { color: var(--brand); font-weight: 600; box-shadow: inset 0 3px 0 var(--brand); }
.tabbar .ic { width: 26px; height: 26px; }
.side { display: none; }

/* ---------- bottom sheet (dialog) ---------- */
dialog.sheet { margin: auto 0 0; padding: 0 var(--s4) calc(var(--s4) + var(--safe-b)); width: 100%; max-width: none; max-height: 85vh; overflow: auto;
  border: 0; border-radius: var(--r) var(--r) 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -8px 32px rgba(23,32,46,.25); }
dialog.sheet::backdrop { background: rgba(15,23,42,.5); }
dialog.sheet[open] { animation: sheet-up .2s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { dialog.sheet[open] { animation: none; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: var(--s2) auto var(--s1); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; }
.sheet-nav { display: grid; gap: var(--s1); margin: var(--s2) 0 var(--s3); }
.sheet-nav a { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: var(--s2) var(--s3); border-radius: var(--r-sm); color: var(--ink); text-decoration: none; position: relative; }
.sheet-nav a:hover { background: var(--surface-2); }
.sheet-nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sheet-nav .count { position: static; margin-left: auto; }
.sheet-foot { margin: 0; }
.sheet-body { padding: var(--s2) 0 var(--s3); }
.sheet-actions { display: grid; gap: var(--s2); }

/* ---------- ปุ่ม ---------- */
.btn { min-width: var(--tap); display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap); padding: var(--s2) var(--s5);
  border: 1px solid transparent; border-radius: var(--r-sm); background: var(--c-add); color: #fff; font-weight: 600; line-height: 1.4; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(.92); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.btn-add, .btn-save { background: var(--c-add); }
.btn-edit { background: var(--c-edit); }
.btn-view { background: var(--c-view); }
.btn-pay { background: var(--c-pay); }
.btn-refund { background: var(--c-refund); }
.btn-print { background: var(--c-print); }
.btn-del, .btn-cancel { background: var(--c-del); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-sm { min-height: var(--tap); padding: var(--s1) var(--s3); font-size: .9375rem; }
.btn-block, .form-actions .btn { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.form-actions { display: grid; gap: var(--s2); margin-top: var(--s5); }

/* ---------- ฟอร์ม ---------- */
.field { display: grid; gap: var(--s1); margin-bottom: var(--s4); }
.field > label, .field > .label, legend { font-weight: 500; color: var(--ink-2); }
.req::after { content: " *"; color: var(--c-del); }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: var(--tap); padding: var(--s2) var(--s3); font-size: 1rem;
  background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-sm); }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid rgba(29,78,216,.25); outline-offset: 0; }
input[type=checkbox], input[type=radio] { width: 24px; height: 24px; accent-color: var(--brand); flex: none; }
.check { display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); }
fieldset { border: 0; margin: 0 0 var(--s4); padding: 0; min-width: 0; }
.hint { font-size: .875rem; color: var(--ink-3); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--c-del); }
.field-err { color: var(--err); font-size: .9375rem; font-weight: 500; }
.grid-2 { display: grid; gap: 0 var(--s4); }

/* ---------- การ์ด/กล่อง/ป้าย ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); margin-bottom: var(--s4); box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.page-head { display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.page-head h1 { margin: 0; }
.stack > * + * { margin-top: var(--s4); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3) var(--s4); }
.kpi b { display: block; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--ink-3); font-size: .875rem; }
.badge-row { margin-top: var(--s3); }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--s3); border-radius: 14px; font-size: .875rem; font-weight: 500; background: var(--line); color: var(--ink-2); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); } .badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err { background: var(--err-bg); color: var(--err); } .badge-info { background: var(--info-bg); color: var(--info); }
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-sm); margin-bottom: var(--s4); border: 1px solid; }
.alert .ic { margin-top: 1px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #b7e1c4; }
.alert-err { background: var(--err-bg); color: var(--err); border-color: #f2bcbc; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #ecd68f; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #b3d9ef; }
.empty { text-align: center; padding: var(--s8) var(--s4); color: var(--ink-3); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }

/* ---------- ตาราง → การ์ด (จอ < 768px) ---------- */
.tablewrap { margin-bottom: var(--s4); }
.tablewrap table { width: 100%; border-collapse: collapse; background: var(--surface); }
.tablewrap th { text-align: left; font-weight: 600; color: var(--ink-2); background: var(--surface-2); }
.tablewrap th, .tablewrap td { padding: var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; }
@media (max-width: 767.98px) {
  .tablewrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tablewrap table, .tablewrap tbody, .tablewrap tr, .tablewrap td { display: block; width: 100%; }
  .tablewrap tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s2) var(--s4); margin-bottom: var(--s3); box-shadow: var(--shadow); }
  .tablewrap td { display: flex; justify-content: space-between; gap: var(--s4); padding: var(--s2) 0; border-bottom: 1px dashed var(--line); text-align: right; }
  .tablewrap td:last-child { border-bottom: 0; }
  .tablewrap td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--ink-3); font-size: .9375rem; text-align: left; }
  .tablewrap td:not([data-label])::before, .tablewrap td[data-label=""]::before { content: none; }
  .tablewrap td.actions::before { content: none; }
  .tablewrap td.actions { display: grid; grid-template-columns: 1fr; padding-top: var(--s3); }
  .tablewrap td.actions .btn { width: 100%; }
}

/* ---------- หน้า bare / error / login ---------- */
.bare-page { max-width: 440px; margin: 0 auto; padding: calc(var(--s8) + var(--safe-t)) var(--s4) var(--s8); outline: none; }
.bare-brand { display: flex; justify-content: center; margin-bottom: var(--s6); font-size: 1.25rem; }
.errorpage { text-align: center; padding: var(--s8) 0; }
.err-code { font-size: 4.5rem; font-weight: 600; line-height: 1.1; color: var(--brand); margin: 0 0 var(--s3); font-variant-numeric: tabular-nums; }
.errorpage .actions { margin-top: var(--s6); }
.errorpage .btn { width: 100%; max-width: 320px; }

/* ---------- แท็บเล็ต ---------- */
@media (min-width: 768px) {
  .page { padding: var(--s6) var(--s6) calc(var(--tabbar-h) + var(--safe-b) + var(--s8)); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .form-actions { display: flex; justify-content: flex-end; }
  .form-actions .btn, .btn-block-m { width: auto; }
  .page-head { grid-template-columns: 1fr auto; align-items: center; }
  dialog.sheet { margin: auto; max-width: 480px; border-radius: var(--r); }
  dialog.sheet[open] { animation: none; }
  .sheet-grip { display: none; }
  .errorpage .btn { width: auto; }
}

/* ---------- เดสก์ท็อป ≥1024: แถบข้าง ---------- */
@media (min-width: 1024px) {
  .tabbar, .topbar { display: none; }
  .app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .side { display: flex; flex-direction: column; gap: var(--s2); position: sticky; top: 0; height: 100vh; padding: var(--s4); background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; }
  .side .brand { padding: var(--s2) var(--s2) var(--s3); font-size: 1.25rem; }
  .side-ctx { margin: 0 var(--s2) var(--s2); padding: var(--s2) var(--s3); background: var(--brand-soft); color: var(--brand); border-radius: var(--r-sm); font-weight: 600; font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-nav { display: grid; gap: var(--s1); }
  .side-nav a, .side-link { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); padding: var(--s2) var(--s3); width: 100%;
    border: 0; border-radius: var(--r-sm); background: none; color: var(--ink-2); text-decoration: none; cursor: pointer; text-align: left; }
  .side-nav a:hover, .side-link:hover { background: var(--surface-2); }
  .side-nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
  .side-foot { margin-top: auto; display: grid; gap: var(--s1); padding-top: var(--s3); border-top: 1px solid var(--line); }
  .side-foot form { margin: 0; }
  .side .count { position: static; margin-left: auto; }
  .page { padding: var(--s8) var(--s8) var(--s10); }
  .btn-block-m { width: auto; }
}
@media print {
  .tabbar, .side, .topbar, .skip, dialog { display: none !important; }
  body { background: #fff; } .app { display: block; } .page { padding: 0; max-width: none; }
}

/* ---------- T15 หน้า auth (login) : สองคอลัมน์บนเดสก์ท็อป / คอลัมน์เดียวบนมือถือ ---------- */
.btn-lg { min-height: 52px; font-size: 1.0625rem; }
.auth { display: block; }
.authart { display: none; }
.authform { display: flex; align-items: center; justify-content: center; }
.authbox { width: 100%; max-width: 24rem; margin: 0 auto; }
.authmark { display: flex; align-items: center; gap: var(--s2); margin: 0 0 var(--s5); color: var(--brand); font-weight: 600; font-size: 1.25rem; }
.authbox h1 { margin-bottom: var(--s1); }
.authalt { margin: var(--s4) 0 0; text-align: center; }
.authalt a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2); font-weight: 500; }
/* มือถือ: เต็มจอ ไม่มีกล่องการ์ด (ต่อกับ brand ของ layout ที่ซ่อนไว้ เพราะ authmark แสดงอยู่แล้ว) */
.bare-page:has(.auth) { max-width: none; padding: calc(var(--s6) + var(--safe-t)) var(--s5) calc(var(--s8) + var(--safe-b)); }
.bare-page:has(.auth) > .bare-brand { display: none; }
.bare-page:has(.auth) > .alert { max-width: 24rem; margin-inline: auto; }
@media (min-width: 900px) {
  .bare-page:has(.auth) { max-width: 960px; padding: var(--s8) var(--s6); min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
  .bare-page:has(.auth) > .alert { max-width: none; width: 100%; }
  .auth { display: grid; grid-template-columns: 1fr 1fr; min-height: 34rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 18px 50px -18px rgba(23,32,46,.35); }
  .authart { display: block; position: relative; overflow: hidden; background: linear-gradient(155deg, #172c6b 0%, #1e3a8a 55%, #2f5bd0 100%); color: #fff; }
  .authart-pat { position: absolute; inset: 0; width: 100%; height: 100%; fill: rgba(255,255,255,.07); stroke: rgba(255,255,255,.22); stroke-width: 3; stroke-linecap: round; }
  .authbrand { position: absolute; left: var(--s8); right: var(--s8); bottom: var(--s10); }
  .authbrand .who { display: flex; align-items: center; gap: var(--s3); margin: 0; font-size: 1.5rem; font-weight: 600; }
  .authbrand .mark { background: #fff; color: var(--brand); }
  .authbrand .tag { margin: var(--s3) 0 0; color: rgba(255,255,255,.92); line-height: 1.7; }
  .authform { padding: var(--s10) var(--s8); }
  .authmark { display: none; }
}

/* ---------- T15 หน้าเมนูเต็ม (/menu) ---------- */
.menu-list { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.menu-list a { position: relative; display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--s4);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); text-decoration: none; }
.menu-list a.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); font-weight: 600; }
.menu-list .count { position: static; margin-left: auto; }
.menu-out { margin: 0; }
@media (min-width: 768px) { .menu-list { grid-template-columns: 1fr 1fr; } }
.authbox .form-actions { display: grid; justify-content: stretch; }
.authbox .form-actions .btn { width: 100%; }

/* ---------- T26/T27 งาน: การ์ดงาน ฟอร์ม ผู้ดูแล คำเชิญ ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.badge-duty { background: var(--brand-soft); color: var(--brand); }
.badge-row.first { margin-top: 0; }
.badge-row .badge { margin: 0 var(--s1) var(--s1) 0; }
.event-list, .member-list, .invite-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.event-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--r); padding: var(--s4); box-shadow: var(--shadow); }
.event-card:hover { border-color: var(--brand); }
.event-card.is-closed { border-left-color: var(--line-2); background: var(--surface-2); }
.event-card h2 { margin: 0 0 var(--s2); font-size: 1.125rem; }
.event-link { color: var(--ink); text-decoration: none; }
.event-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }  /* แตะได้ทั้งการ์ด */
.event-link:focus-visible { outline: none; }
.event-link:focus-visible::after { outline: 3px solid #f59e0b; outline-offset: 2px; }
.event-card .badge-row { margin: 0; }
.event-meta { display: flex; align-items: flex-start; gap: var(--s2); margin: var(--s1) 0 var(--s2); color: var(--ink-3); }
.event-meta .ic { width: 20px; height: 20px; margin-top: 3px; }
.page-head > div > h1 + .event-meta { margin-top: var(--s2); }
.empty .ic { width: 48px; height: 48px; color: var(--brand); margin-bottom: var(--s2); }
.empty h2 { color: var(--ink); }
.empty .btn { margin-top: var(--s2); width: 100%; max-width: 320px; }
.kv { margin: 0; display: grid; gap: var(--s3); }
.kv > div { display: grid; gap: 0; }
.kv dt { color: var(--ink-3); font-size: .875rem; }
.kv dd { margin: 0; }
.kv .pre { white-space: pre-line; }
.card > .kv { margin-top: var(--s3); }
.shortcuts { display: grid; gap: var(--s3); }
.shortcut { display: flex; align-items: center; gap: var(--s3); min-height: 64px; padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.shortcut:hover { border-color: var(--brand); }
.shortcut .ic { width: 28px; height: 28px; color: var(--brand); }
.shortcut b { display: block; font-weight: 600; }
.shortcut small { display: block; color: var(--ink-3); font-size: .875rem; }

/* ฟอร์มยาว: ปุ่มบันทึกติดล่างบนมือถือ เหนือแถบเมนู (ไม่บังแถบ) */
.form-sticky .form-actions { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b)); z-index: 10; margin: var(--s5) calc(var(--s4) * -1) calc(var(--s4) * -1);
  padding: var(--s3) var(--s4); background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r); }
[data-kind-other][hidden] { display: none; }

/* ผู้ดูแลงาน */
.seats { width: 100%; height: 12px; accent-color: var(--brand); }
.member { margin: 0; display: grid; gap: var(--s3); }
.member-name { font-weight: 600; margin: 0 0 var(--s1); }
.member-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: flex-start; }
.member-actions form { margin: 0; }
.inline-edit { flex: 1 1 100%; }
.inline-edit > summary { list-style: none; cursor: pointer; display: inline-flex; width: auto; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit[open] > summary { margin-bottom: var(--s3); }
.inline-form { padding: var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.invite { margin: 0; }
.linkbox { margin: var(--s2) 0 var(--s3); font-size: .9375rem; color: var(--ink-2); background: var(--surface-2) !important; }
.invite-actions form { margin: 0; }
.invite-actions .btn { flex: 1 1 calc(50% - var(--s2)); }
.invite-actions [hidden] { display: none; }
.qr-body { display: grid; justify-items: center; gap: var(--s2); padding: var(--s3) 0; }
.qr-body img { background: #fff; padding: var(--s2); border: 1px solid var(--line); border-radius: var(--r-sm); width: min(240px, 70vw); height: auto; }

/* หน้า join */
.join { text-align: center; padding: var(--s6) var(--s4); }
.join h1 { margin-bottom: var(--s3); }
.join-ic { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto var(--s3); border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.join-ic .ic { width: 28px; height: 28px; }
.join-ic-err { background: var(--err-bg); color: var(--err); }
.join-kicker { margin-bottom: var(--s1); }
.join .alert { text-align: left; }
.join .btn-block { margin-top: var(--s3); }

@media (min-width: 768px) {
  .event-list { grid-template-columns: 1fr 1fr; }
  .shortcuts { grid-template-columns: 1fr 1fr; }
  .form-sticky .form-actions { position: static; margin: var(--s5) 0 0; padding: 0; background: none; border: 0; }
  .member { grid-template-columns: 1fr auto; align-items: start; }
  .member-actions { justify-content: flex-end; }
  .inline-edit { flex-basis: auto; }
  .invite-actions .btn { flex: 0 0 auto; }
  .join { max-width: 480px; margin: var(--s8) auto 0; }
}
@media (min-width: 1024px) {
  .event-list { grid-template-columns: repeat(3, 1fr); }
}
.member-list, .invite-list { margin-bottom: var(--s5); }
section > h2 { margin-top: var(--s2); }
.invite-actions form { flex: 1 1 100%; }
.invite-actions form .btn { width: 100%; }
@media (max-width: 767.98px) {
  .form-sticky .form-actions { grid-template-columns: 2fr 1fr; }
}
@media (min-width: 768px) {
  .invite-actions form { flex: 0 0 auto; }
  .invite-actions form .btn { width: auto; }
}
.member .badge-row, .invite .badge-row { margin-bottom: var(--s2); } .member .badge-row { margin-bottom: 0; }

/* ---------- T15/T16 หน้า auth อื่น ๆ + บัญชี + แอดมิน ---------- */
.authcard { margin-top: 0; }
.authcard h1 { margin-bottom: var(--s2); }
.bare-page:has(.prose) { max-width: 760px; }
.prose h2 { margin-top: var(--s6); font-size: 1.125rem; }
.prose ul { padding-left: var(--s6); margin: 0 0 var(--s3); }
.prose li { margin-bottom: var(--s2); }
.consent { align-items: flex-start; }
.consent input { margin-top: 2px; }
.consent-form { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--line); }
.quick { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px dashed var(--line-2); display: grid; gap: var(--s2); }
.quick-h { display: flex; gap: var(--s2); align-items: center; margin: 0; color: var(--warn); font-weight: 500; }
.quick form { margin: 0; }
.otp { font-size: 1.5rem; text-align: center; font-variant-numeric: tabular-nums; min-height: 56px; }
.otp-boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 8px repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.otp-boxes .otp-box:nth-child(4) { grid-column: 5; }
.otp-box { width: 100% !important; min-width: 0; min-height: 56px !important; padding: 0 !important; text-align: center; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.otp-box:not(:placeholder-shown) { border-color: var(--line-2); background: var(--surface-2); }
.secret { display: block; padding: var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 1.0625rem; word-break: break-all; user-select: all; }
.inline-form-row { margin: 0 0 var(--s3); }
.card h3 { margin-top: var(--s5); }
.tabs { display: flex; gap: var(--s1); overflow-x: auto; margin: 0 0 var(--s4); padding-bottom: var(--s1); border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tabs a { flex: none; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s4); color: var(--ink-2); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); font-weight: 600; border-bottom-color: var(--brand); }
.searchbar { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); margin-bottom: var(--s3); }
.act-form { display: grid; gap: var(--s2); margin: 0 0 var(--s2); }
.tablewrap td input[type=text], .tablewrap td input[type=number] { min-width: 0; }
.detail { font-size: .8125rem; word-break: break-all; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: var(--s4) 0; }
.pager .btn { flex: 1; }
.pager-now { color: var(--ink-3); white-space: nowrap; }
@media (min-width: 768px) {
  .act-form { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .tablewrap td.actions { min-width: 15rem; }
  .pager .btn { flex: none; min-width: 120px; }
  .pager { justify-content: center; }
}
.tablewrap th { white-space: nowrap; } .tablewrap td[data-label="ใช้งาน"] { white-space: nowrap; }
@media (max-width: 767.98px) { .form-sticky .form-actions:has(> :only-child) { grid-template-columns: 1fr; } }

/* ---------- T55/T56 ผู้ติดต่อ + ยืม-คืน ---------- */
.badge-t-err { background: var(--err-bg); color: var(--err); } .badge-t-warn { background: var(--warn-bg); color: var(--warn); }
.badge-t-info { background: var(--info-bg); color: var(--info); } .badge-t-ok { background: var(--ok-bg); color: var(--ok); }
.badge-t-rep { background: #f3e8fb; color: #6b21a8; } .badge-t-mute { background: var(--line); color: var(--ink-2); }
.text-warn { color: var(--warn); }
.tone-err { --tone: var(--c-del); } .tone-warn { --tone: #d97706; } .tone-info { --tone: var(--c-view); }
.tone-ok { --tone: var(--c-pay); } .tone-rep { --tone: var(--c-refund); } .tone-mute { --tone: var(--line-2); }

/* ชิปกรอง: มือถือเลื่อนแนวนอนเฉพาะแถบนี้ ; แท็บเล็ตขึ้นไปขึ้นบรรทัดใหม่ */
.chips { display: flex; gap: var(--s2); overflow-x: auto; margin: 0 calc(var(--s4) * -1) var(--s3); padding: 0 var(--s4) var(--s2);
  scroll-snap-type: x proximity; scroll-padding-inline: var(--s4); scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.chip { flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s4); border: 1px solid var(--line-2);
  border-radius: 22px; background: var(--surface); color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip-err:not(.on) { color: var(--err); border-color: #f2bcbc; }
.filter-contact { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); margin-bottom: var(--s4); }

/* กล่อง "ของที่ต้องซื้อมาคืน" */
.callout { display: flex; align-items: center; gap: var(--s3); min-height: 64px; padding: var(--s3) var(--s4); margin-bottom: var(--s4);
  border: 1px solid #d9b8f1; border-left: 6px solid var(--c-refund); border-radius: var(--r); background: #f9f1fe; color: var(--ink); text-decoration: none; }
.callout .ic { width: 28px; height: 28px; color: var(--c-refund); }
.callout b { display: block; font-weight: 600; } .callout small { display: block; color: var(--ink-2); font-size: .9375rem; }

/* การ์ดรายการยืม */
.borrow-list { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s3); }
.borrow-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--tone, var(--brand)); border-radius: var(--r); padding: var(--s4); box-shadow: var(--shadow); }
.borrow-card:hover { border-color: var(--tone, var(--brand)); }
.borrow-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.borrow-name { min-width: 0; }
.borrow-card h2 { font-size: 1.125rem; margin: 0 0 var(--s1); }
.borrow-card p { margin-bottom: var(--s2); }
.borrow-qty { flex: none; margin: 0; text-align: right; line-height: 1.3; }
.borrow-qty b { display: block; font-size: 1.75rem; font-weight: 600; color: var(--tone, var(--ink)); }
.borrow-qty span { display: block; font-size: .875rem; color: var(--ink-3); }
.borrow-qty small { display: block; font-size: .8125rem; color: var(--ink-3); }
.borrow-meta { margin-bottom: 0 !important; }
.pills { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); }
.pills li { padding: 2px var(--s3); border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font-size: .875rem; color: var(--ink-2); }
.pills .pill-warn { background: var(--warn-bg); border-color: #ecd68f; color: var(--warn); }
.borrow-table { display: none; }

/* รายละเอียดรายการ */
.qty-hero p { margin: 0 0 var(--s3); display: flex; align-items: baseline; gap: var(--s3); }
.qty-hero b { font-size: 2.5rem; line-height: 1.1; font-weight: 600; color: var(--brand); }
.qty-hero span { color: var(--ink-3); }
.qty-grid { margin: 0 0 var(--s4); display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.qty-grid > div { padding: var(--s2) var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.qty-grid > .hot { background: var(--warn-bg); border-color: #ecd68f; }
.qty-grid dt { font-size: .8125rem; color: var(--ink-3); line-height: 1.35; }
.qty-grid dd { margin: 0; font-size: 1.25rem; font-weight: 600; }
.tablewrap tr.is-cancelled td { color: var(--ink-3); text-decoration: line-through; }
.tablewrap tr.is-cancelled td .badge { text-decoration: none; }
.ledger-detail { text-align: right; }
.edit-box > summary, .cancel-box > summary, .add-box > summary { list-style: none; cursor: pointer; }
.edit-box > summary::-webkit-details-marker, .cancel-box > summary::-webkit-details-marker, .add-box > summary::-webkit-details-marker { display: none; }
.edit-box[open] > summary, .cancel-box[open] > summary, .add-box[open] > summary { margin-bottom: var(--s4); }
.deposit-box { padding: var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.deposit-box [hidden] { display: none; }

/* สมุดผู้ติดต่อ */
.contact-list { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s3); }
.contact.is-off { background: var(--surface-2); }
.contact-name { margin: 0 0 var(--s2); font-size: 1.125rem; }
.contact-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); align-items: flex-start; }
.contact-actions form { margin: 0; }
.add-box { padding: var(--s3); }
.add-box:not([open]) { background: transparent; border: 0; box-shadow: none; padding: 0; }

/* ช่องจำนวน: stepper +/− ใหญ่ (ปุ่มเกิดจาก JS ; ไม่มี JS = ช่องตัวเลขปกติ) */
.qty-row { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
.qty-row > label { font-weight: 500; color: var(--ink-2); }
.qty-row > label small { display: block; font-weight: 400; color: var(--ink-3); font-size: .875rem; }
.qty-group { padding: var(--s3) var(--s3) 0; margin-bottom: var(--s4); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); }
.qty-group legend { padding: 0 var(--s2); font-weight: 600; }
.stepper { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; gap: var(--s2); }
.stepper input { text-align: center; font-size: 1.5rem; font-weight: 600; min-height: 56px !important; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-btn { display: grid; place-items: center; min-height: 56px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--brand); font-size: 1.75rem; font-weight: 600; line-height: 1; cursor: pointer; touch-action: manipulation; }
.step-btn:active { background: var(--brand-soft); }
.step-btn:disabled { color: var(--line-2); cursor: not-allowed; }
.remain { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: var(--info-bg); color: var(--info); font-size: 1.0625rem; }
.remain b { font-size: 1.25rem; }
.remain.over { background: var(--err-bg); color: var(--err); font-weight: 600; }
.remain.done { background: var(--ok-bg); color: var(--ok); }


/* fix(ui): สรุปจำนวนบนมือถือแสดงเฉพาะช่อง > 0 + "ดูทั้งหมด" ; ครบทุกช่องที่ >=768 */
.qty-grid { grid-template-columns: repeat(2, 1fr); }
.qty-grid dt { font-size: .875rem; }
.qty-full { display: none; }
.qty-more { margin: 0 0 var(--s4); }
.qty-more > summary { list-style: none; cursor: pointer; }
.qty-more > summary::-webkit-details-marker { display: none; }
.qty-more[open] > summary { margin-bottom: var(--s2); }
.qty-more .qty-grid { margin-bottom: 0; }
/* ช่องแนบไฟล์: input จริงซ่อนแบบเข้าถึงได้ (ไม่ใช่ display:none) label เป็นปุ่ม */
.filepick { position: relative; }
.filepick-input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); opacity: 0; border: 0 !important; min-height: 0 !important; }
.filepick-btn { width: 100%; cursor: pointer; }
.filepick-input:focus-visible + .filepick-btn { outline: 3px solid #f59e0b; outline-offset: 2px; }
.filepick-status.has-files { color: var(--ok); font-weight: 500; }
.filepick-status.is-bad { color: var(--err); font-weight: 500; }
/* ปุ่มบันทึกติดล่าง: ช่องที่โฟกัส/เลื่อนถึงต้องไม่ไปอยู่หลังปุ่ม+แถบเมนู */
@media (max-width: 767.98px) {
  /* เว้นท้ายฟอร์มเท่าแถบเมนู+safe-area (ส่วนเกินทับพื้นที่ padding ของหน้า ไม่เห็นเป็นช่องว่าง) → ปุ่มติดล่างปลดล็อกก่อนฟอร์มสุด ไม่บังช่องท้ายฟอร์ม */
  .card > .form-sticky { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); margin-bottom: calc(-1 * (var(--tabbar-h) + var(--safe-b))); }
  html { scroll-padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 96px); }
  .form-sticky input, .form-sticky select, .form-sticky textarea, .form-sticky .filepick { scroll-margin-bottom: calc(var(--tabbar-h) + var(--safe-b) + 96px); }
}

@media (min-width: 768px) {
  .chips { flex-wrap: wrap; overflow: visible; margin: 0 0 var(--s3); padding: 0; }
  .filter-contact { max-width: 28rem; }
  .borrow-list, .contact-list { grid-template-columns: 1fr 1fr; }
  .qty-grid { grid-template-columns: repeat(5, 1fr); }
  .qty-nz, .qty-more { display: none; }
  .qty-full { display: grid; }
  .filepick-btn { width: auto; justify-self: start; }
  .qty-row { grid-template-columns: minmax(0, 1fr) 15rem; align-items: center; }
  .callout { max-width: 36rem; }
}
@media (min-width: 1024px) {
  .borrow-cards { display: none; }
  .borrow-table { display: block; margin-bottom: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
  .borrow-table table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
  .borrow-table th, .borrow-table td { padding: var(--s2) var(--s2); border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
  .borrow-table thead th { background: var(--surface-2); font-weight: 600; color: var(--ink-2); font-size: .875rem; }
  .borrow-table th.num, .borrow-table td.num { text-align: right; }
  .borrow-table tbody th { font-weight: 600; }
  .borrow-table tbody tr { box-shadow: inset 4px 0 0 var(--tone, transparent); }
  .borrow-table tbody tr:hover { background: var(--surface-2); }
  .borrow-table .badge { white-space: normal; }
}
@media (min-width: 768px) { .ledger-detail { text-align: left; } }
.tablewrap td[data-label="วันที่"] { white-space: nowrap; }
.photos { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.photos img { display: block; width: 88px; height: 88px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); }
.tablewrap td .photos { justify-content: flex-end; }
@media (min-width: 768px) { .tablewrap td .photos { justify-content: flex-start; } }

/* ---------- T27/T59: ปิดงาน ประวัติ หมวด เงิน ซองเร็ว ลบ ---------- */
.os-list .os-item { display: grid; gap: 2px; min-height: var(--tap); color: var(--ink); text-decoration: none; }
.os-list .os-item:hover b { text-decoration: underline; }
.cat-list { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s3); }
.cat.is-off { background: var(--surface-2); }
.cat-name { margin: 0 0 var(--s2); font-weight: 600; font-size: 1.0625rem; }
.cat-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); align-items: flex-start; }
.cat-actions form { margin: 0; }
.danger-box { border-color: #f2bcbc; border-left: 6px solid var(--c-del); }
.danger-box h2 { color: var(--err); }
.kpis-2 { grid-template-columns: repeat(2, 1fr); }
.money-list { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s3); }
.money { margin-bottom: 0; position: relative; }
.money.is-cancelled { background: var(--surface-2); }
.money.is-cancelled .money-amt { text-decoration: line-through; color: var(--ink-3); }
.money-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.money-name { min-width: 0; }
.money h2, .money h3 { margin: 0 0 var(--s1); font-size: 1.0625rem; }
.money-donor { margin: 0 0 var(--s1); font-weight: 500; }
.money-amt { flex: none; margin: 0; font-size: 1.25rem; font-weight: 600; color: var(--c-pay); text-align: right; }
.money-big { margin: 0 0 var(--s3); font-size: 2rem; font-weight: 600; color: var(--brand); }
.money-src { position: relative; z-index: 1; }
.money .badge-row { margin: var(--s2) 0 0; }
.rev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.rev { padding: var(--s3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.rev-head { margin: 0 0 var(--s1); }
.rev-changes { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); font-size: .9375rem; }
/* ซองเร็ว */
.quick-form .field > .label { font-size: 1.0625rem; }
.quick-form input:not([type=radio]):not([type=checkbox]), .quick-form select { min-height: 56px; font-size: 1.25rem; }
.quick-form input[name=amount] { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.seg-opt { position: relative; display: block; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 52px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); font-weight: 500; cursor: pointer; }
.seg-opt input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.seg-opt input:focus-visible + span { outline: 3px solid #f59e0b; outline-offset: 2px; }
.more-opts > summary { list-style: none; cursor: pointer; display: inline-flex; margin-bottom: var(--s3); }
.more-opts > summary::-webkit-details-marker { display: none; }
/* ข้อความยืนยันหลังบันทึกซอง: ใหญ่ ชัด */
.page > .alert-ok { font-size: 1.125rem; font-weight: 600; padding: var(--s4); }
@media (min-width: 768px) {
  .money-list, .cat-list { grid-template-columns: 1fr 1fr; }
  .kpis-2 { grid-template-columns: repeat(2, minmax(0, 14rem)); }
}

/* ---------- fix(ui): mobile sweep ---------- */
.backlink-row { margin: 0 0 var(--s1); }
.backlink, .tap-link { display: inline-flex; align-items: center; min-height: var(--tap); }
.backlink { padding-right: var(--s3); font-size: .9375rem; }
.otp-boxes { gap: 4px; grid-template-columns: repeat(3, minmax(0, 1fr)) 6px repeat(3, minmax(0, 1fr)); }
.kpi .num, .money-big { text-align: left; }
.form-sticky.bar-only .form-actions { margin-top: 0; }

/* ---- T56/T57 ส่วนเงินในหน้ารายละเอียดการยืม (borrow_money_forms) ---- */
.btn-refund, .btn-pay { color: #fff; }
.msec { padding: 0; }
.msec > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 56px; padding: var(--s3) var(--s4); cursor: pointer; font-weight: 600; }
.msec > summary::-webkit-details-marker, .act > summary::-webkit-details-marker, .cx > summary::-webkit-details-marker { display: none; }
.msec > summary::after { content: "\25BE"; color: var(--ink-3); margin-left: var(--s2); }
.msec[open] > summary::after { content: "\25B4"; }
.msec-b { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--s1); justify-content: flex-end; }
.msec-body { padding: 0 var(--s4) var(--s4); display: grid; gap: var(--s4); }
.msec-body h3 { margin: 0; font-size: 1rem; }
.mform { display: grid; gap: var(--s3); padding: var(--s3) 0; }
.act > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center; min-height: 48px; }
.act[open] > summary { margin-bottom: var(--s2); }
.act > .mform { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s3); }
.act + .act { margin-top: var(--s2); }
.btn-block { width: 100%; }
.kv-2 { grid-template-columns: 1fr 1fr; }
.kv .hot dd { color: var(--warn); }
.mrows { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.mrow { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s3); display: grid; gap: var(--s1); }
.mrow.is-cancelled { opacity: .65; }
.mrow.is-cancelled .mrow-amt { text-decoration: line-through; }
.mrow-top { display: flex; justify-content: space-between; gap: var(--s3); align-items: flex-start; }
.mrow-t, .mrow-amt { margin: 0; font-weight: 600; }
.text-warn { color: var(--warn); }
/* ยกเลิกธุรกรรม: <details> เปิดเป็น bottom sheet (ไม่ต้องใช้ JS) */
.cx > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; min-height: 44px; margin-top: var(--s2); }
.cx[open] > summary { display: none; }
.cx[open]::before { content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 90; }
.cx-body { position: fixed; left: 0; right: 0; bottom: 0; z-index: 91; background: var(--surface); padding: var(--s4) var(--s4) calc(var(--s4) + var(--safe-b)); border-radius: var(--r) var(--r) 0 0; max-height: 85vh; overflow: auto; display: grid; gap: var(--s3); }
.cx-body { text-align: left; font-weight: 400; }
.cx-body h3 { margin: 0; }
@media (min-width: 768px) {
  .cx-body { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 480px; border-radius: var(--r); }
}
.cx > summary { white-space: nowrap; }
.ledger-detail > div { text-align: inherit; }

/* ---- T58 ซื้อของ / ใบซื้อ ---- */
.shop-list { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s3); }
.shop-item { margin-bottom: 0; display: grid; gap: var(--s3); }
.shop-item.is-cancelled { opacity: .65; }
.shop-item.is-mine { border-left: 4px solid var(--brand); }
.shop-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.shop-name { margin: 0; font-size: 1.0625rem; }
.shop-qty { margin: 0; font-weight: 600; white-space: nowrap; }
.shop-money { gap: var(--s2); }
.shop-sum { padding: var(--s3) var(--s4); }
.shop-toggle { margin: 0 0 var(--s4); }
.shop-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.25rem; margin: 0 0 var(--s3); }
.plines { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; gap: var(--s3); }
.pline { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s3); }
.pline-h { margin: 0 0 var(--s2); font-weight: 600; color: var(--ink-2); }
.pline .field:last-child { margin-bottom: 0; }
@media (min-width: 768px) { .shop-list { grid-template-columns: 1fr 1fr; } }
/* ---- T61 แจ้งเตือน ---- */
.notif-list { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s2); }
.notif { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink); text-decoration: none; }
.notif.is-unread { background: var(--info-bg); border-color: #b3d9ef; }
.notif-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: transparent; }
.notif.is-unread .notif-dot { background: var(--info); }
.notif-body { display: grid; gap: 2px; flex: 1; min-width: 0; }
.notif-title { font-weight: 500; }
.notif.is-unread .notif-title { font-weight: 700; }
[hidden] { display: none !important; }
.shop-money dd { text-align: left; }

/* ---- T60 ภาพรวมงาน (KPI + ต้องทำต่อ) ---- */
.sum-kpis { margin-bottom: var(--s4); }
.sum-kpis .kpi { display: grid; gap: var(--s1); border-left: 4px solid var(--line-2); }
.sum-kpis .kpi span { order: -1; }
.sum-kpis .kpi b { font-size: 1.1875rem; }
.sum-kpis .kpi small { font-size: .875rem; font-weight: 400; color: var(--ink-3); }
.sum-kpis .k-in { border-left-color: var(--c-pay); }
.sum-kpis .k-out { border-left-color: var(--c-del); }
.sum-kpis .k-bal { border-left-color: var(--c-add); }
.sum-kpis .k-bal.is-neg b { color: var(--err); }
.sum-kpis .k-borrow { border-left-color: var(--c-edit); }
.todo { border-left: 4px solid var(--c-edit); }
.todo h2 { margin: 0 0 var(--s2); }
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s1); }
.todo-list a { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); min-height: 48px; padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--warn-bg); color: var(--warn); text-decoration: none; font-weight: 500; }
.todo-list a.is-err { background: var(--err-bg); color: var(--err); }
.print-links { display: grid; gap: var(--s2); margin: 0 0 var(--s4); }
@media (min-width: 768px) { .print-links { grid-template-columns: auto auto; justify-content: start; } }
.btn-print { background: #4b5563; color: #fff; }
/* ---- หน้าพิมพ์ A4 (T50/T60) : ตาราง ไม่ใช่การ์ด ---- */
.print-page { max-width: 210mm; margin: 0 auto; background: #fff; color: #000; }
.print-bar { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.print-head { border-bottom: 2px solid #000; margin-bottom: var(--s3); }
.print-head h1 { margin: 0 0 var(--s1); font-size: 1.375rem; }
.print-head p { margin: 0 0 var(--s1); }
.print-page h2 { font-size: 1.0625rem; margin: var(--s4) 0 var(--s1); }
.ptable { width: 100%; border-collapse: collapse; font-size: .9375rem; display: table; }
.ptable th, .ptable td { border: 1px solid #888; padding: 6px 8px; text-align: left; vertical-align: top; background: #fff; }
.ptable thead th { background: #eee; }
.ptable .num, .ptable th.num { text-align: right; }
.ptable .ptotal th, .ptable .ptotal td { font-weight: 700; background: #f3f3f3; }
.ptable tbody th { font-weight: 500; width: 62%; }
.psign { display: flex; justify-content: space-between; gap: var(--s6); margin-top: 28mm; font-size: .9375rem; }
@media screen and (max-width: 640px) { .print-page { overflow-x: auto; } .ptable { min-width: 480px; } }
@page { size: A4; margin: 14mm; }
@media print {
  .noprint, .testsite, .print-bar { display: none !important; }
  body, .print-page { background: #fff !important; }
  .page { padding: 0 !important; }
  .ptable { font-size: 11pt; }
  .print-page h2, .ptable tr { break-inside: avoid; }
  .print-page h2 { break-after: avoid; }
  .psign { break-inside: avoid; }
}
.ev-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin: var(--s3) 0 0; }
.ev-kpis > div { display: grid; gap: 2px; padding: var(--s2) var(--s3); background: var(--surface-2); border-radius: var(--r-sm); min-width: 0; }
.ev-kpis dt { font-size: .875rem; color: var(--ink-3); }
.ev-kpis dd { margin: 0; font-weight: 600; font-size: .9375rem; overflow-wrap: anywhere; }
.ev-kpis dd.neg { color: var(--err); }
.msec .kv dd, .shop-money dd { text-align: left; }
