/* Layout: แอปมือถือ แถบหัว + เมนูติดด้านบน (มุมล่างขวาว่างไว้ ป้าย Netlify แพ็กฟรีจะไม่บังปุ่ม) · ตารางกว้างเลื่อนแนวนอนในกล่องของตัวเอง */
:root{
  --bg:#f3f6f5; --surface:#ffffff; --sunk:#e7eeec; --line:#d3dedb; --fg:#13211f; --mute:#5b6f6b;
  --accent:#0f6b61; --accent-ink:#ffffff; --accent-soft:#d6ece8;
  --train:#1d4ed8; --ok:#15803d; --ok-soft:#dcfce7; --warn:#b45309; --warn-soft:#fef3c7; --bad:#b91c1c;
  --we:#e3e9e7;
  --c-m:#dbeefe; --c-a:#fdf0c4; --c-n:#e9e2fd; --c-ma:#fbe08a; --c-mn:#d9cffb; --c-bd:#cbf3f9; --c-x:#ffffff; --c-vac:#d7f5e1; --c-lv:#fbe3ef; --c-tr:#e8eef6;
  --f-display:"Mitr","IBM Plex Sans Thai",system-ui,sans-serif; --f-body:"IBM Plex Sans Thai",system-ui,sans-serif;
  --r:14px;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#0d1716; --surface:#152321; --sunk:#1c2d2a; --line:#2a3f3b; --fg:#e4efec; --mute:#93aaa5;
  --accent:#4fc2b2; --accent-ink:#06201c; --accent-soft:#173f39;
  --train:#7aa7ff; --ok:#4ade80; --ok-soft:#14331f; --warn:#fbbf24; --warn-soft:#3a2c0b; --bad:#f87171;
  --we:#1a2927;
  --c-m:#1b3550; --c-a:#4a3c10; --c-n:#30264f; --c-ma:#5a4710; --c-mn:#3b2f63; --c-bd:#11424a; --c-x:#152321; --c-vac:#16402a; --c-lv:#4a1f33; --c-tr:#22303f;
  color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#0d1716; --surface:#152321; --sunk:#1c2d2a; --line:#2a3f3b; --fg:#e4efec; --mute:#93aaa5;
  --accent:#4fc2b2; --accent-ink:#06201c; --accent-soft:#173f39;
  --train:#7aa7ff; --ok:#4ade80; --ok-soft:#14331f; --warn:#fbbf24; --warn-soft:#3a2c0b; --bad:#f87171;
  --we:#1a2927;
  --c-m:#1b3550; --c-a:#4a3c10; --c-n:#30264f; --c-ma:#5a4710; --c-mn:#3b2f63; --c-bd:#11424a; --c-x:#152321; --c-vac:#16402a; --c-lv:#4a1f33; --c-tr:#22303f;
  color-scheme:dark}
*{box-sizing:border-box}
html,body{height:100%}
body{background:var(--bg);color:var(--fg);font-family:var(--f-body);font-size:15px;line-height:1.5;-webkit-tap-highlight-color:transparent}
body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);z-index:30;background:var(--accent)}
button,select,input{font:inherit;color:inherit}
.top{position:sticky;top:env(safe-area-inset-top,0px);z-index:20;background:var(--accent);color:var(--accent-ink);padding-block:10px 12px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
.top .row1{display:flex;align-items:center;gap:10px;justify-content:space-between}
.top h1{font-family:var(--f-display);font-weight:500;font-size:19px;margin:0;line-height:1.2;text-wrap:balance}
.top .sub{font-size:12.5px;opacity:.85}
.who{display:flex;align-items:center;gap:6px;background:rgba(255,255,255,.16);border-radius:999px;padding:4px 6px 4px 10px;font-size:13px;max-width:52%}
.who select{background:transparent;border:0;color:inherit;font-weight:600;max-width:100%;min-width:0}
.who select option{color:#13211f}
main{padding-block:14px 96px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));max-width:980px;margin:0 auto;display:flex;flex-direction:column;gap:14px}
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:14px}
.card h2{font-family:var(--f-display);font-weight:500;font-size:17px;margin:0 0 8px}
.mute{color:var(--mute)} .small{font-size:13px}
.demo{font-size:12.5px;background:var(--warn-soft);color:var(--warn);border-radius:10px;padding:8px 12px}
.tabs{display:grid;margin:8px -6px 0;background:rgba(255,255,255,.12);border-radius:12px;padding:2px}
.tabs button{border:0;background:none;padding:5px 1px 6px;display:flex;flex-direction:column;align-items:center;gap:1px;font-size:11.5px;color:inherit;opacity:.82;cursor:pointer;min-height:48px;border-radius:10px;min-width:0}
.tabs button span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tabs button svg{width:20px;height:20px}
.tabs button[aria-current="page"]{background:var(--surface);color:var(--accent);opacity:1;font-weight:600}
.tabs button:focus-visible,button:focus-visible,select:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.btn{border:0;border-radius:12px;padding:11px 16px;background:var(--accent);color:var(--accent-ink);font-weight:600;cursor:pointer;min-height:44px}
.btn.ghost{background:var(--sunk);color:var(--fg)}
.btn.block{width:100%}
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:6px 12px;font-size:13.5px;cursor:pointer;min-height:36px}
.chip[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:var(--accent-ink);font-weight:600}
/* ปฏิทินเวรของฉัน */
.cal{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px}
.cal .dow{text-align:center;font-size:12px;color:var(--mute);padding-bottom:2px}
.day{border:1px solid var(--line);border-radius:10px;min-height:58px;padding:4px 3px 3px;display:flex;flex-direction:column;align-items:center;justify-content:space-between;background:var(--surface);cursor:pointer;position:relative}
.day.we{background:var(--we)}
.day .d{font-size:11.5px;color:var(--mute);align-self:flex-start;padding-left:3px;font-variant-numeric:tabular-nums}
.day .c{font-weight:700;font-size:15px;border-radius:7px;padding:1px 5px;max-width:100%;overflow:hidden;white-space:nowrap}
.day .was{font-size:10px;color:var(--mute);text-decoration:line-through}
.day.chg .c{text-decoration:underline;text-underline-offset:3px}
.day.tr .c{color:var(--train)}
.day.empty{visibility:hidden}
.stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
.stat{background:var(--sunk);border-radius:12px;padding:8px 10px}
.stat b{display:block;font-family:var(--f-display);font-weight:500;font-size:22px;font-variant-numeric:tabular-nums;line-height:1.1}
.stat span{font-size:12px;color:var(--mute)}
.legend{display:flex;flex-wrap:wrap;gap:6px 12px;font-size:12.5px;color:var(--mute)}
.legend i{display:inline-block;width:12px;height:12px;border-radius:4px;vertical-align:-1px;margin-right:4px;border:1px solid var(--line)}
/* ตาราง */
.scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
table.grid{border-collapse:separate;border-spacing:0;font-size:12.5px;font-variant-numeric:tabular-nums}
.grid th,.grid td{border-bottom:1px solid var(--line);border-right:1px solid var(--line);text-align:center;padding:0;height:30px;min-width:34px;white-space:nowrap}
.grid th{background:var(--sunk);font-weight:600;font-size:11.5px;line-height:1.15;padding:3px 0;position:sticky;top:0;z-index:2}
.grid .nm{position:sticky;left:0;z-index:3;background:var(--surface);text-align:left;padding:0 8px;min-width:96px;max-width:96px;overflow:hidden;text-overflow:ellipsis;font-weight:500;box-shadow:1px 0 0 var(--line)}
.grid th.nm{z-index:4;background:var(--sunk)}
.grid th.we{background:var(--we)}
.grid td.chg{font-weight:700;text-decoration:underline}
.grid td.tr{color:var(--train);font-weight:700}
.grid tr.sum td{background:var(--sunk);font-weight:600}
.grid tr.sum td.short{color:var(--bad)}
.grid tr.me td.nm{color:var(--accent)}
.grid td.tot{background:var(--sunk);font-weight:600}
/* แผ่นล่าง (เลือกเวร) */
.sheet-bg{position:fixed;inset:0;background:rgba(5,15,13,.45);z-index:40}
.sheet{position:fixed;left:0;right:0;bottom:0;z-index:41;background:var(--surface);border-radius:18px 18px 0 0;padding-block:12px calc(76px + env(safe-area-inset-bottom,0px));padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));max-height:86vh;overflow:auto;display:flex;flex-direction:column;gap:12px;max-width:640px;margin:0 auto}
.sheet .grab{width:40px;height:5px;border-radius:9px;background:var(--line);align-self:center}
.sheet h3{font-family:var(--f-display);font-weight:500;font-size:18px;margin:0}
.codes{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}
.codes button{border:1px solid var(--line);border-radius:10px;min-height:44px;font-weight:700;cursor:pointer;color:var(--fg)}
.codes button[aria-pressed="true"]{outline:3px solid var(--accent);outline-offset:-1px}
label.f{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var(--mute)}
label.f input,label.f select{border:1px solid var(--line);background:var(--surface);border-radius:10px;padding:10px 12px;min-height:44px;width:100%}
.frow{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.list{display:flex;flex-direction:column;gap:8px}
.item{display:flex;gap:10px;align-items:flex-start;padding:10px 12px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
.item .when{font-variant-numeric:tabular-nums;font-weight:600;min-width:64px;color:var(--accent)}
.item .body{min-width:0;flex:1}
.item .title{font-weight:600;color:var(--train)}
.pill{display:inline-flex;align-items:center;gap:4px;border-radius:999px;padding:3px 10px;font-size:12.5px;font-weight:500}
.pill.ok{background:var(--ok-soft);color:var(--ok)} .pill.wait{background:var(--warn-soft);color:var(--warn)}
.status{border:2px solid var(--warn);border-radius:var(--r);padding:14px;background:var(--surface);display:flex;flex-direction:column;gap:10px}
.status.done{border-color:var(--ok)}
.status h2{margin:0;font-family:var(--f-display);font-weight:500;font-size:17px}
.toast{position:fixed;left:50%;transform:translateX(-50%);top:calc(12px + env(safe-area-inset-top,0px));background:var(--fg);color:var(--bg);padding:10px 16px;border-radius:12px;font-size:14px;z-index:50;max-width:calc(100% - 32px);text-align:center}
.pick{display:grid;grid-template-columns:repeat(auto-fill,minmax(118px,1fr));gap:4px 10px;max-height:220px;overflow:auto;border:1px solid var(--line);border-radius:10px;padding:8px}
.pick label{font-size:14px;display:flex;gap:6px;align-items:center;min-height:32px}
.seg{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.credit{text-align:center;font-size:12px;color:var(--mute);padding-top:6px}
@media (min-width:760px){.stats{grid-template-columns:repeat(8,minmax(0,1fr))} .day{min-height:70px}}
@media (prefers-reduced-motion:no-preference){.sheet{animation:up .18s ease-out}@keyframes up{from{transform:translateY(24px);opacity:.6}}}
/* ---- เพิ่มสำหรับระบบจริง ---- */
.top .mnav{display:flex;align-items:center;gap:4px;margin-top:6px}
.top .mnav button{background:rgba(255,255,255,.16);border:0;color:inherit;border-radius:10px;min-width:40px;min-height:36px;font-size:18px;cursor:pointer}
.top .mnav b{font-family:var(--f-display);font-weight:500;font-size:15px;min-width:120px;text-align:center}
.menu-btn{background:rgba(255,255,255,.16);border:0;color:inherit;border-radius:999px;padding:6px 12px;font-size:13.5px;cursor:pointer;max-width:55vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-height:36px}
.login{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:16px}
.login .card{width:100%;max-width:380px;display:flex;flex-direction:column;gap:12px}
.login h1{font-family:var(--f-display);font-weight:500;font-size:22px;margin:0;color:var(--accent)}
.err{background:color-mix(in srgb,var(--bad) 16%,var(--surface));color:var(--bad);border-radius:10px;padding:8px 12px;font-size:14px}
.okmsg{background:var(--ok-soft);color:var(--ok);border-radius:10px;padding:8px 12px;font-size:14px}
.code-c{color:var(--fg)}
.grid td.code-c{color:var(--fg)}
.grid td.tr{color:var(--train)}
.grid td.edit{cursor:pointer}
.grid td.req{color:var(--bad);font-weight:700}
.pin{font-family:var(--f-display);font-size:30px;letter-spacing:4px;text-align:center;background:var(--sunk);border-radius:12px;padding:10px}
.tools{display:flex;flex-wrap:wrap;gap:8px}
.loading{padding:40px 0;text-align:center;color:var(--mute)}
input[type=file]{max-width:100%}
.hist .item .when{min-width:74px}
.rnd{font-size:11.5px;background:var(--warn-soft);color:var(--warn);border-radius:999px;padding:1px 8px;margin-left:4px}
@media print{
  @page{size:A4 landscape;margin:8mm}
  .top,.tabs,.noprint,.credit,.toast,#sheet{display:none!important}
  html,body{height:auto!important;margin:0!important}
  body.printing #app{display:none!important}
  #printarea{display:block!important}
  body{background:#fff!important;background-image:none!important;color:#000;font-size:9px}
  main{padding:0;max-width:none}
  .scroll{overflow:visible;border:0}
  .grid th,.grid td{min-width:0;height:auto;padding:1px;font-size:8px}
  .grid .nm{position:static;min-width:0;max-width:none}
  .grid th{position:static}
  .print-title{display:block!important;font-size:12px;font-weight:700;margin-bottom:4px}
}
.print-title{display:none}

/* ---- รอบ 2: ธีม, หลังบ้าน, จัดเวร, เตือน, ฟอร์มพิมพ์ ---- */
:root{--cmix:100%}
:root[data-dark="1"]{--cmix:34%;color-scheme:dark}
body{background-color:var(--bg);background-image:var(--pattern,none);background-attachment:fixed}
.top{box-shadow:0 2px 10px rgba(0,0,0,.12)}
main{padding-bottom:calc(96px + env(safe-area-inset-bottom,0px))}
.warn{background:var(--warn-soft);color:var(--warn);border-radius:10px;padding:8px 12px;font-size:13.5px}
.warn:empty{display:none}
.subtabs{display:flex;gap:6px;overflow-x:auto;padding-bottom:2px;scrollbar-width:none}
.subtabs .chip{white-space:nowrap}
.grid tr.sum td.short.click{cursor:pointer;text-decoration:underline dotted}
.issues .item{cursor:pointer}
.issues .item.static{cursor:default}
.kv{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
.tbl{width:100%;border-collapse:collapse;font-size:13.5px}
.tbl th,.tbl td{border-bottom:1px solid var(--line);padding:6px 4px;text-align:left;vertical-align:top}
.tbl th{color:var(--mute);font-weight:600;font-size:12.5px}
.tbl input{width:64px;border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:6px;min-height:36px}
.srow{display:flex;align-items:center;gap:10px;padding:9px 10px;border:1px solid var(--line);border-radius:12px;background:var(--surface);cursor:pointer;width:100%;text-align:left}
.srow .nm{flex:1;min-width:0}
.srow .tag{font-size:12px;color:var(--mute)}
.srow.off{opacity:.55}
.sug{display:flex;flex-direction:column;gap:8px}
.sug button{display:flex;justify-content:space-between;align-items:center;gap:8px;border:1px solid var(--line);border-radius:12px;background:var(--surface);padding:10px 12px;cursor:pointer;min-height:48px;text-align:left}
.sug button b{font-size:16px}
.chk{display:flex;gap:8px;align-items:center;font-size:14px;color:var(--fg);min-height:36px}
.chk input{width:20px;height:20px}
.themes{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:8px}
.themes button{border:2px solid var(--line);border-radius:12px;padding:0;overflow:hidden;cursor:pointer;background:none;min-height:64px;display:flex;flex-direction:column}
.themes button[aria-pressed="true"]{border-color:var(--accent);outline:2px solid var(--accent)}
.themes .sw{height:34px;display:flex}
.themes .sw i{flex:1}
.themes span{font-size:12px;padding:3px 4px;color:var(--fg);background:var(--surface)}
.preview-bar{position:sticky;top:0;z-index:5;border:2px solid var(--accent);background:var(--accent-soft)}
.linkbtn{background:none;border:0;color:var(--accent);text-decoration:underline;cursor:pointer;padding:6px 0;font-size:14px;min-height:36px}
#printarea{display:none}
@media print{
  #printarea .pf{page-break-after:always;break-after:page}
  #printarea .pf:last-child{page-break-after:auto}
}
.pf{font-family:"Sarabun","IBM Plex Sans Thai",sans-serif;color:#000;background:#fff}
.pf h1{font-size:15px;text-align:center;margin:0}
.pf h2{font-size:12.5px;text-align:center;margin:0 0 3px;font-weight:600}
.pf table{border-collapse:collapse;width:100%;table-layout:fixed}
.pf th,.pf td{border:1px solid #000;font-size:var(--pfs,8px);text-align:center;padding:0;height:var(--prh,13px);overflow:hidden;white-space:nowrap}
.pf th{font-weight:700}
.pf td.l{text-align:left;padding-left:2px}
.pf .we{background:#d9d9d9!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
.pf .tr{color:#1d4ed8}
.pf .foot{display:flex;justify-content:space-between;gap:12px;margin-top:5px;font-size:10px}
.pf .sign{text-align:center;min-width:200px;line-height:1.7}
@media (max-width:520px){.top .sub{display:none}.top{padding-block:8px 8px}.top .mnav{margin-top:4px}}

/* หัวตาราง (วันที่ + วัน) ติดด้านบนเมื่อเลื่อนลง: กล่องตารางเลื่อนได้ในตัวเอง ทั้งแนวตั้งและแนวนอน */
.scroll{max-height:calc(100dvh - 150px);overflow:auto;overscroll-behavior:contain}
@supports not (height:100dvh){.scroll{max-height:calc(100vh - 150px)}}
.grid thead th{position:sticky;top:0;z-index:2;box-shadow:0 1px 0 var(--line)}
.grid thead th.nm{z-index:5;left:0}
@media print{.scroll{max-height:none!important;overflow:visible!important}}
.ccols{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:6px}
.crow{display:flex;align-items:center;gap:8px;border:1px solid var(--line);border-radius:10px;padding:4px 8px}
.crow .code-c{min-width:44px;text-align:center;border-radius:7px;padding:4px 6px;font-weight:700;border:1px solid var(--line)}
.crow input[type=color]{width:40px;height:32px;border:0;background:none;padding:0}
.crow .linkbtn{font-size:12px;min-height:28px;padding:0}
/* หัวเว็บไม่ติดจอ (เลื่อนขึ้นไปเมื่อเลื่อนลง) ตารางจะได้ใช้ทั้งจอ และหัววันที่ของตารางไม่ถูกบัง */
.top{position:relative;top:auto}
.scroll{max-height:calc(100dvh - 12px)}
@supports not (height:100dvh){.scroll{max-height:calc(100vh - 12px)}}
/* Assign ประจำวัน */
.asdays{display:flex;gap:4px;overflow-x:auto;padding:8px 0 2px;-webkit-overflow-scrolling:touch}
.asdays .chip{display:flex;flex-direction:column;align-items:center;min-width:42px;padding:4px 6px;line-height:1.1;border-radius:10px}
.asdays .chip small{font-size:11px;opacity:.75}
.asdays .chip.we:not([aria-pressed="true"]){background:var(--we)}
.asbox{margin-top:10px}
.asg{border-collapse:collapse;font-size:13px;min-width:1060px;width:100%}
.asg th,.asg td{border:1px solid var(--line);padding:3px 4px;text-align:center;white-space:nowrap;height:28px;min-width:58px}
.asg thead th{position:sticky;top:0;z-index:2;background:var(--surface)}
.asg thead tr:nth-child(2) th{top:29px}
.asg th.sh{min-width:40px;writing-mode:vertical-rl;transform:rotate(180deg);font-size:15px}
.asg th.ty{min-width:46px}
.asg tr.first td,.asg tr.first th{border-top:2.5px solid var(--fg)}
.asg td.l{text-align:left;white-space:normal;min-width:0}
.asg td.lab{font-weight:600;color:var(--mute)}
.asg td.ed{cursor:pointer}
.asg td.ed:hover{outline:2px solid var(--accent);outline-offset:-2px}
.asg td.chg{background:color-mix(in srgb,#fde047 35%,var(--surface))}
.asg td.bad{color:#b91c1c;font-weight:700}
.asg td s{color:var(--mute)}
.aspick{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:6px;max-height:300px;overflow:auto}
.aspick button{border:1px solid var(--line);border-radius:10px;background:var(--surface);min-height:44px;cursor:pointer;color:var(--fg);padding:4px 6px}
.aspick button[aria-pressed="true"]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent);font-weight:700}
.aspick button.sp{border-style:dashed;color:var(--mute)}
.pf.asp{border:1.6px solid #000;padding:6px 8px 4px;break-inside:avoid;page-break-inside:avoid}
.pf.asp .ashd{text-align:center;font-size:15px;line-height:1.9;margin-bottom:4px;position:relative}
.pf.asp .ashd .g{display:inline-block;min-width:56px;padding:0 8px;margin:0 2px;font-weight:700}
.pf.asp .ashd .dt{position:absolute;right:6px;top:0;font-size:13px}
/* พิมพ์แบบฟอร์มกระดาษเดิม: หัวตารางสีเทา · ช่องที่มีชื่อมีกรอบ · ช่องว่างเทาอ่อนไม่มีเส้น · แถวสูงพอเขียนแก้ */
.pf.asp .asg{min-width:0;width:100%;table-layout:fixed;border-collapse:collapse;color:#000;font-size:13px;border:1.5px solid #000}
.pf.asp .asg th,.pf.asp .asg td{border:none;height:var(--asrh,30px);min-width:0;font-size:13px;padding:1px 3px;white-space:normal;line-height:1.15;overflow:hidden;-webkit-print-color-adjust:exact;print-color-adjust:exact}
.pf.asp .asg th{background:#d9d9d9!important;border:1px solid #000;font-weight:700}
.pf.asp .asg td.v{border:1px solid #000;background:#fff!important;font-weight:600}
.pf.asp .asg td.lab{background:#d9d9d9!important;color:#000}
.pf.asp .asg td.e{background:#fff;color:#777}
.pf.asp .asg td.l{text-align:left;font-weight:400;font-size:11.5px}
.pf.asp .asg th.sh{width:46px;font-size:15px;writing-mode:horizontal-tb;transform:none}
.pf.asp .asg th.ty{width:62px;font-size:13px}
.pf.asp .asg thead th{position:static;height:24px;font-size:12.5px}
.pf.asp .asg tr.first td,.pf.asp .asg tr.first th{border-top:2px solid #000}
.pf.asp .asg tbody tr:last-child td,.pf.asp .asg tbody tr:last-child th{border-bottom:1.5px solid #000}
.pf.asp .asg td.bad{color:#b91c1c}
.pf.asp .asfoot{display:grid;grid-template-columns:1fr auto;gap:10px;margin-top:6px;align-items:stretch}
.pf.asp .asfoot .nt{font-size:10.5px;line-height:1.35;background:#fff;padding:4px 6px;-webkit-print-color-adjust:exact;print-color-adjust:exact}
.pf.asp .asfoot .sign{display:grid;grid-template-columns:auto 130px;align-items:center;font-size:14px;min-width:0;line-height:1.2}
.pf.asp .asfoot .sign span{background:#d9d9d9;padding:8px 10px;height:100%;display:flex;align-items:center;box-shadow:inset 0 0 0 .6px #000;-webkit-print-color-adjust:exact;print-color-adjust:exact}
.pf.asp .asfoot .sign b{padding:8px 10px;height:100%;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 0 0 .6px #000}
.asg .bdc{display:inline-block;border:1.3px solid currentColor;border-radius:999px;padding:0 4px;font-size:.78em;line-height:1.25;font-weight:700;margin-left:2px}
.asnote{border-left:4px solid #f59e0b}
.asnote.ok{border-left-color:#22c55e}
.aspick button.no{border-style:dashed;color:#b45309;background:color-mix(in srgb,#fde68a 25%,var(--surface))}
.asfoot{display:flex;justify-content:space-between;gap:20px;margin-top:8px;font-size:12px;align-items:flex-end}
.asfoot .sign{white-space:nowrap;font-size:14px}
/* รหัสยาว (มี / หรือตัวห้อย): ย่อให้พอดีช่อง ขึ้นบรรทัดหลัง / ได้ */
.grid td.k4,.grid td.k6{white-space:normal;line-height:1.05;letter-spacing:-.2px;word-break:keep-all}
.grid td.k4{font-size:11px}
.grid td.k6{font-size:9.5px}
.day .c.k4,.day .c.k6{white-space:normal;line-height:1.1;padding:1px 2px;letter-spacing:-.3px;overflow:visible;text-align:center}
.day .c.k4{font-size:12px}
.day .c.k6{font-size:10px}
.codes button.k4{font-size:14px}
.codes button.k6{font-size:12.5px;line-height:1.1}
/* หน้าเปลี่ยนเวร: เวรตอนนี้ → เลือกเป็น (ตัวใหญ่ อ่านง่าย) */
.cnow{display:flex;align-items:center;justify-content:center;gap:14px;padding:10px;border:1px solid var(--line);border-radius:14px;background:var(--sunk);text-align:center}
.cnow .arrow{font-size:26px;color:var(--mute)}
.cbig{display:inline-block;min-width:84px;padding:8px 12px;border-radius:12px;font-size:34px;font-weight:800;line-height:1.15;border:1px solid var(--line);margin-top:2px}
.cgrp{border:1px solid var(--line);border-radius:12px;padding:6px 10px;background:var(--surface)}
.cgrp summary{cursor:pointer;min-height:36px;display:flex;align-items:center;gap:6px;font-size:14px;font-weight:600}
@media print{.grid td.k4,.grid td.k6{font-size:7px}}
.pf td.k4{font-size:calc(var(--pfs,8px) * .85)}
.pf td.k6{font-size:calc(var(--pfs,8px) * .72);letter-spacing:-.3px}
/* เงิน OT */
.paytbl th, .paytbl td { min-width: 72px; padding: 4px 8px; white-space: nowrap; }
.paytbl td:nth-child(3) { min-width: 240px; font-size: 13px; }
/* หน้าเวรของฉัน: สรุป เงิน เวรยาว */
.stat.hl{background:var(--accent-soft);outline:2px solid var(--accent)}
.card.money .big{font-family:var(--f-display);font-size:30px;font-weight:600;margin:2px 0 4px;color:var(--accent)}
/* เวรยาว: ระดับ 1 เหลืองไข่อ่อนมาก · ระดับ 2 ส้มอ่อน ชัดขึ้นหน่อย */
.day.longrun.lr1,.lr-key.lr1{background:color-mix(in srgb,#fef3c7 40%,var(--surface));border-color:color-mix(in srgb,#eab308 18%,var(--line))}
.day.longrun.lr2,.lr-key.lr2{background:color-mix(in srgb,#fb923c 26%,var(--surface));border-color:color-mix(in srgb,#f97316 60%,var(--line))}
.lr-key{display:inline-block;width:14px;height:14px;border-radius:4px;vertical-align:-2px;border:1px solid}
/* แจ้งเตือนเล็กใต้เมนู */
.notice{margin-top:8px;display:flex;align-items:center;gap:8px;justify-content:space-between;background:var(--surface);color:var(--fg);border-radius:12px;padding:6px 6px 6px 12px;font-size:14px;opacity:0;transform:translateY(-4px);transition:opacity .35s,transform .35s;box-shadow:0 2px 8px rgba(0,0,0,.12)}
.notice.show{opacity:1;transform:none}
.notice button{border:0;background:transparent;color:var(--mute);font-size:16px;min-width:32px;min-height:32px;cursor:pointer}
@media (prefers-reduced-motion:reduce){.notice{transition:none}}
/* ช่องแลกกับใคร */
.swapbox{display:flex;gap:6px}.swapbox input{flex:1;min-width:0}.swapbox .btn{min-height:40px;padding:6px 12px}
/* ตัวเลือกพื้นหลัง/สติ๊กเกอร์ในรูปเวร */
.chip.swatch{display:inline-flex;align-items:center;gap:6px}
.chip.swatch input{margin:0}
.chip.swatch i{display:inline-block;width:14px;height:14px;border-radius:50%}
.chip.swatch:has(input:checked){border-color:var(--accent);background:var(--accent-soft);font-weight:600}
.notice{align-items:flex-start}.notice .nlist{display:grid;gap:4px;padding:2px 0}
.notice.mini{background:transparent;box-shadow:none;padding:0;justify-content:flex-start}
.notice .npill{background:var(--surface);color:var(--fg);border-radius:999px;padding:4px 12px;font-size:13px;min-height:30px;box-shadow:0 1px 4px rgba(0,0,0,.12)}
/* คิวหยุดเทศกาล */
.hqbox{background:color-mix(in srgb,var(--accent,#0f6b61) 10%,transparent);border-radius:12px;padding:10px 12px;margin:8px 0;line-height:1.7}
.hqtbl td,.hqtbl th{padding:4px 8px}
.hqme{font-weight:700;text-decoration:underline}
td.hqq{font-weight:700}
.hqtbl{width:100%}.hqtbl td.nm,.hqtbl th.nm{min-width:240px;max-width:none;position:static}
.hqrule{border-top:1px solid var(--line);padding:10px 0}

/* หัวหน้าจัดเวร: ทำงานติดกันเกินกำหนด → แถบส้มล่างช่อง */
.grid td.runx:not(.nm){box-shadow:inset 0 -4px 0 #f97316}
.grid td.nm.runx{color:#c2410c;font-weight:700}
@media print{.grid td.runx{box-shadow:none}}

/* แถบเมฆ + รูปของฉัน (ธีมพีชก้อนเมฆ) */
.deco{position:relative;overflow:hidden;display:flex;align-items:center;gap:14px;margin:0 0 10px;padding:14px 16px;border-radius:18px;background:linear-gradient(135deg,#ffd9c4,#ffeee4 55%,#fff6f0);border:1px solid #f8cdb6;min-height:104px}
.deco .ph{position:relative;z-index:1;width:84px;height:84px;flex:none;border-radius:50%;border:4px solid #fff;box-shadow:0 3px 10px rgba(207,106,67,.25);overflow:hidden;background:#fff;display:grid;place-items:center;font-size:36px}
.deco .ph img{width:100%;height:100%;object-fit:cover}
.deco .tx{position:relative;z-index:1;display:flex;flex-direction:column;color:#8a3d22}
.deco .tx b{font-size:18px}.deco .tx small{color:#b0603f}
.deco .dc{position:absolute;background:#fff;border-radius:999px;opacity:.9}
.deco .dc::before,.deco .dc::after{content:"";position:absolute;background:#fff;border-radius:50%}
.deco .c1{width:90px;height:28px;right:18px;top:16px}.deco .c1::before{width:40px;height:40px;left:14px;top:-20px}.deco .c1::after{width:30px;height:30px;left:46px;top:-13px}
.deco .c2{width:64px;height:20px;right:120px;bottom:12px;opacity:.75}.deco .c2::before{width:28px;height:28px;left:10px;top:-14px}.deco .c2::after{width:22px;height:22px;left:32px;top:-9px}
.deco .c3{width:46px;height:15px;left:58px;bottom:8px;opacity:.85}.deco .c3::before{width:20px;height:20px;left:8px;top:-10px}.deco .c3::after{width:15px;height:15px;left:24px;top:-6px}

.deco.gen{background:linear-gradient(135deg,color-mix(in srgb,var(--accent) 24%,var(--surface)),var(--surface));border-color:var(--line)}
.deco.gen .ph{box-shadow:0 3px 10px color-mix(in srgb,var(--accent) 30%,transparent);border-color:var(--surface);background:var(--surface)}
.deco.gen .tx{color:var(--fg)}.deco.gen .tx small{color:var(--mute)}
.deco.gen .dc,.deco.gen .dc::before,.deco.gen .dc::after{background:var(--surface)}
.deco.gen .dc{opacity:.55}
.cpick input[type=color]{width:100%;height:42px;border:1px solid var(--line);border-radius:10px;background:var(--surface);padding:2px}
.patpick{display:grid;grid-template-columns:repeat(auto-fill,minmax(64px,1fr));gap:6px;margin:6px 0 10px}
.patpick button{height:52px;border:2px solid var(--line);border-radius:10px;cursor:pointer;font-size:11px;color:var(--fg)}
.patpick button[aria-pressed="true"]{border-color:var(--accent);outline:2px solid var(--accent)}
.cprev{display:flex;gap:8px;margin:0 0 10px}.cprev span{flex:1;padding:10px;border-radius:10px;text-align:center;font-weight:700}
.cprev .a{background:var(--accent);color:var(--accent-ink)}.cprev .s{background:var(--surface);color:var(--fg);border:1px solid var(--line)}

.asguide{border-left:4px solid var(--accent);padding:10px 14px}
.asguide b{font-size:15px}

/* ---------- หน้าจัดเวรแบบ Google Sheet (grid.js) ---------- */
.grid.ge td.edit{cursor:cell;position:relative;user-select:none;-webkit-user-select:none}
.grid.ge td.sel::after{content:'';position:absolute;inset:0;background:color-mix(in srgb,var(--accent) 18%,transparent);pointer-events:none}
.grid.ge td.cur{outline:2.5px solid var(--accent);outline-offset:-2px;z-index:1}
.grid td.dif{position:relative}.grid td.dif::before{content:'';position:absolute;top:0;left:0;border-top:7px solid #eab308;border-right:7px solid transparent;pointer-events:none}
.grid thead th.hsel{background:color-mix(in srgb,var(--accent) 28%,var(--sunk))}
.grid td .rqb,.rqb{position:absolute;top:0;right:1px;font-size:8.5px;font-style:normal;color:var(--bad);line-height:1.05;font-weight:700;pointer-events:none}
.rqb[style*="static"]{font-size:11px;border:1px dashed var(--bad);border-radius:4px;padding:0 3px}
.grid td .rqg{color:var(--bad);opacity:.5;font-style:italic;font-weight:600}
#gwrap{position:relative}
#gwrap:focus{outline:2px solid color-mix(in srgb,var(--accent) 45%,transparent);outline-offset:1px}
.gedi{position:fixed;z-index:60;font:inherit;font-size:15px;font-weight:700;text-align:center;border:2px solid var(--accent);border-radius:4px;background:var(--surface);color:var(--fg);padding:0 4px;box-shadow:0 3px 12px rgb(0 0 0/.22);box-sizing:border-box}
.gedi.bad{border-color:var(--bad);background:color-mix(in srgb,var(--bad) 10%,var(--surface))}
.gdd{position:fixed;z-index:61;min-width:270px;max-width:min(360px,94vw);max-height:280px;overflow:auto;background:var(--surface);border:1px solid var(--line);border-radius:10px;box-shadow:0 10px 28px rgb(0 0 0/.2);padding:4px}
.gdh{font-size:11.5px;padding:4px 8px 6px;color:var(--mute);display:flex;justify-content:space-between;gap:6px}
.gdi{display:flex;gap:8px;align-items:center;padding:5px 8px;border-radius:8px;cursor:pointer;font-size:13px;line-height:1.25}
.gdi.hi,.gdi:hover{background:color-mix(in srgb,var(--accent) 14%,var(--surface))}
.gdi .gc{min-width:46px;text-align:center;border-radius:6px;padding:2px 4px;font-weight:700;border:1px solid var(--line)}
.gdi .gl{flex:1}.gdi .gw{color:var(--warn);font-size:11px;max-width:150px}.gdi .rqw{color:var(--bad)}
.gmodes{display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));gap:8px;margin-top:10px}
.gm{border:1px solid var(--line);border-radius:12px;padding:8px 10px;background:var(--sunk)}
.gmt{font-weight:700;font-size:14px;margin-bottom:2px}
.gm .chip:not([aria-pressed="true"]){background:var(--surface)}
.chip:disabled{opacity:.45;cursor:default}
.gebar{position:relative;z-index:2;display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:8px 10px;margin:8px 0 4px;box-shadow:0 2px 8px rgb(0 0 0/.06)}
.gebar .btn{min-height:38px;padding:8px 12px}
.geinfo{margin:2px 4px 6px;min-height:18px}
.grid.lvl .nm{min-width:150px;max-width:170px}
.grid.lvl td{min-width:26px;font-size:12px}
.tbl.lvq td,.tbl.lvq th{padding:4px 6px;white-space:nowrap}.tbl.lvq td.l{text-align:left}
.tbl.lvq select{max-width:190px}
@media print{.gebar,.geinfo,.gmodes{display:none!important}}
.gekey{position:absolute;left:0;top:0;width:1px;height:1px;opacity:0;padding:0;border:0;resize:none;pointer-events:none;overflow:hidden}
.tbl.lvq input[type=date]{width:auto}
.gmd{margin-top:8px}.gmd>summary{cursor:pointer;padding:4px 0}
/* ---------- รอบ 2 พ.ย. (บ่าย): ใบพิมพ์ใหม่ + แถวระดับใต้ตาราง ---------- */
.prv{position:fixed;inset:0;z-index:60;background:#dfe3e6;display:flex;flex-direction:column;color:#111}
.prvbar{background:var(--surface);color:var(--fg);padding:10px 14px;display:flex;flex-direction:column;gap:6px;box-shadow:0 2px 8px rgba(0,0,0,.18)}
.prvrow{display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:space-between}
.prvpages{flex:1;overflow:auto;padding:14px 12px 60px;display:flex;flex-direction:column;align-items:center;gap:18px}
.prvp{background:#fff;box-shadow:0 2px 12px rgba(0,0,0,.25);padding:10px}
body.prv-on{overflow:hidden}
.pf.pt table{border-collapse:collapse;width:100%;table-layout:fixed}
.pf.pt td{border:1px solid #000;font-size:var(--pfs);height:var(--prh);text-align:center;vertical-align:middle;padding:0 1px;overflow:hidden;white-space:nowrap;font-weight:700;color:#000;line-height:1.1;-webkit-print-color-adjust:exact;print-color-adjust:exact}
.pf.pt tr.ft td,.pf.pt tr.tl td,.pf.pt tr.sub td{height:auto;padding-top:3px;padding-bottom:3px}
.pf.pt[contenteditable]:focus{outline:none}
.pf.pt[contenteditable] td:focus-within,.pf.pt[contenteditable] td:hover{box-shadow:inset 0 0 0 1px #0f6b61}
@media print{#prv{display:none!important}}
.grid tr.lvh td{background:var(--sunk);font-size:12px;text-align:left;padding:3px 6px}
.grid tr.lvr td{font-size:11.5px;height:22px;padding:0 2px}
.grid tr.lvr td.nm{font-size:11.5px;border-left:5px solid var(--lc,#999);white-space:nowrap}
.grid tr.lvr td.z{color:var(--mute);opacity:.55}
.grid tr.lvr td.v{color:var(--lc);font-weight:700}
.grid tr.lvr.ru td.nm{border-left-color:var(--bad);font-style:italic}
.grid tr.lvr.sh0 td{border-top:2px solid var(--line)}
.grid td.nm.lvk{box-shadow:inset 5px 0 0 var(--lc)}
.lvdot{display:inline-block;width:11px;height:11px;border-radius:3px;background:var(--lc);margin:0 4px -1px 8px}
details.gdc>summary{cursor:pointer;list-style:none;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
details.gdc>summary::-webkit-details-marker{display:none}
details.gdc>summary::before{content:'▸';font-size:13px;color:var(--mute)}
details.gdc[open]>summary::before{content:'▾'}
details.gdc>summary h2{margin:0}
.sndl .item .when{min-width:96px}
