/* HR101 — แอปรวม · Clean Teal */
:root {
  --pri: #0e7490; --pri-d: #155e75; --pri-s: #e0f2f1; --bg: #f6f8fa; --card: #fff;
  --ink: #0f172a; --mut: #334155; --mut2: #475569; --line: #e2e8f0;
  --ok: #15803d; --ok-s: #dcfce7; --warn: #92400e; --warn-s: #fef3c7; --bad: #b91c1c; --bad-s: #fee2e2;
  --info: #1e40af; --info-s: #dbeafe; --vio: #6d28d9; --vio-s: #ede9fe;
  --r: 16px; --safe-b: env(safe-area-inset-bottom, 0px);
  --fs: 1; /* ขนาดตัวอักษร: 1 / 1.25 / 1.5 (ตั้งจาก html[data-fs]) */
}
* { box-sizing: border-box; }
html, body { touch-action: pan-x pan-y; margin: 0; background: var(--bg); color: var(--ink); font: calc(16px * var(--fs))/1.5 'IBM Plex Sans Thai', system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--pri); }
a:hover { color: var(--pri-d); }
.hidden { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid rgba(14, 116, 144, .45); outline-offset: 2px; }

/* ---------- buttons / inputs ---------- */
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--pri); background: #fff; color: var(--pri); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { background: var(--pri-s); }
.btn-pri { background: var(--pri); color: #fff; border-color: var(--pri); }
.btn-pri:hover { background: var(--pri-d); color: #fff; }
.btn-danger { color: var(--bad); border-color: #fca5a5; }
.btn-danger:hover { background: var(--bad-s); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-ghost { border-color: transparent; background: transparent; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .btn { flex: 1; }
.inp, select.inp, textarea.inp { font-size: calc(16px * var(--fs)); width: 100%; min-height: 44px; border: 1px solid #cbd5e1; border-radius: 12px; padding: 0 12px; background: #fff; }
textarea.inp { padding: 10px 12px; min-height: 84px; resize: vertical; }
.inp:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 3px rgba(14, 116, 144, .15); }
.fl { display: block; font-size: calc(13px * var(--fs)); color: var(--mut); margin: 12px 0 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(140px * var(--fs))), 1fr)); gap: 8px; }
.grid2 > * { min-width: 0; }
.inp, input[type=date], input[type=time] { min-width: 0; max-width: 100%; }
.grid2 .fl { margin-top: 8px; }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 20px; }
.login-box { width: 100%; max-width: 380px; }
.login-logo { display: block; width: 104px; height: 104px; object-fit: contain; margin: 0 auto 10px; }
.login-title { text-align: center; font-size: calc(24px * var(--fs)); font-weight: 600; margin: 0; }
.login-sub { text-align: center; color: var(--mut); margin: 2px 0 18px; }
.field-wrap { position: relative; }
.fi { position: absolute; left: 12px; top: 12px; color: var(--mut2); }
.inp.with-icon { padding-left: 42px; }
.inp.with-eye { padding-right: 48px; }
.eye { position: absolute; right: 2px; top: 0; width: 44px; height: 44px; border: 0; background: none; color: var(--mut2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.guide { margin-top: 6px; font-size: calc(13px * var(--fs)); color: var(--pri); background: var(--pri-s); border-radius: 10px; padding: 6px 10px; }
.sug { list-style: none; margin: 6px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; max-height: 180px; overflow: auto; }
.sug li button { width: 100%; text-align: left; min-height: 40px; border: 0; background: none; border-radius: 8px; padding: 0 10px; cursor: pointer; font-weight: 600; }
.sug li button:hover { background: var(--pri-s); }
.err { margin-top: 12px; color: var(--bad); background: var(--bad-s); border-radius: 10px; padding: 8px 12px; font-size: calc(14px * var(--fs)); text-align: center; }
#loginBtn { margin-top: 18px; }
.login-ver { text-align: center; color: var(--mut2); font-size: calc(12px * var(--fs)); margin-top: 28px; }

/* ---------- app shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.main { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 8px; min-height: 64px; }
.top h1 { font-size: calc(18px * var(--fs)); font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .sub { display: block; font-size: calc(13px * var(--fs)); color: var(--mut); font-weight: 400; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); position: relative; text-decoration: none; flex: none; }
.icon-btn.plain { border-color: transparent; }
.dot { position: absolute; top: 8px; right: 9px; min-width: 9px; height: 9px; border-radius: 999px; background: #dc2626; border: 2px solid #fff; }
.avatar { width: 44px; height: 44px; border-radius: 14px; background: var(--pri-s); color: var(--pri); display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.view { flex: 1; padding: 14px 16px calc(150px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 760px; margin: 0 auto; }
.view:focus { outline: none; }
.view.flush { padding: 0 0 calc(84px + var(--safe-b)); max-width: none; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 6px calc(6px + var(--safe-b)); }
.tab { text-decoration: none; color: var(--mut2); font-size: calc(12px * var(--fs)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border-radius: 12px; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--pri); font-weight: 600; }
.tab-plus { width: 50px; height: 50px; border-radius: 16px; background: var(--pri); color: #fff; display: flex; align-items: center; justify-content: center; margin-top: -20px; box-shadow: 0 6px 16px rgba(14, 116, 144, .3); }
.tab-plus svg { width: 24px; height: 24px; stroke-width: 2.4; }

.side { display: none; }
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 240px 1fr; }
  .side { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow: auto; background: #fff; border-right: 1px solid var(--line); padding: 16px 12px; }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; }
  .side-brand img { width: 38px; height: 38px; object-fit: contain; }
  .side-brand b { display: block; font-size: calc(14px * var(--fs)); }
  .side-brand small { color: var(--mut2); font-size: calc(12px * var(--fs)); }
  .side a { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border-radius: 10px; text-decoration: none; color: #334155; font-size: calc(14px * var(--fs)); }
  .side a:hover { background: #f1f5f9; }
  .side a.on { background: var(--pri-s); color: var(--pri); font-weight: 600; }
  .side .sgrp { font-size: calc(12px * var(--fs)); color: var(--mut2); margin: 12px 10px 4px; }
  .tabbar { display: none; }
  .view { padding-bottom: 88px; }
  .view.flush { padding-bottom: 0; }
  .wide2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
}

/* ---------- content ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card.flat { padding: 2px 14px; }
a.card { display: block; }
a.card.li { display: flex; }
.card h2, .h2 { font-size: calc(14px * var(--fs)); font-weight: 600; color: var(--mut); margin: 0 0 6px; }
.sec { font-size: calc(13px * var(--fs)); font-weight: 600; color: var(--mut); margin: 4px 0 -2px; }
.muted { color: var(--mut); font-size: calc(13px * var(--fs)); }
.small { font-size: calc(12px * var(--fs)); color: var(--mut2); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: calc(12px * var(--fs)); font-weight: 500; padding: 3px 10px; border-radius: 999px; background: #f1f5f9; color: #334155; white-space: nowrap; }
.p-ok { background: var(--ok-s); color: var(--ok); } .p-warn { background: var(--warn-s); color: var(--warn); }
.p-bad { background: var(--bad-s); color: var(--bad); } .p-info { background: var(--info-s); color: var(--info); }
.p-pri { background: var(--pri-s); color: var(--pri); } .p-vio { background: var(--vio-s); color: var(--vio); }
.li { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-size: calc(14px * var(--fs)); font-weight: 500; }
.li .s { font-size: calc(12px * var(--fs)); color: var(--mut); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--mut); cursor: pointer; font-size: calc(13px * var(--fs)); }
.chip.on { background: var(--pri); border-color: var(--pri); color: #fff; font-weight: 600; }
.seg { display: flex; flex-wrap: wrap; background: #eef2f6; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1 1 auto; white-space: nowrap; min-height: 40px; border: 0; background: none; border-radius: 9px; color: var(--mut); cursor: pointer; font-size: calc(14px * var(--fs)); }
.seg button.on { background: #fff; color: var(--pri); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.seg.solid { background: #fff; border: 1px solid var(--line); }
.seg.solid button.on { background: var(--pri); color: #fff; box-shadow: none; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(72px * var(--fs)), 1fr)); gap: 8px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 9px; min-width: 0; }
.kpi b { display: block; font-size: calc(22px * var(--fs)); font-weight: 700; line-height: 1.2; }
.kpi span { font-size: calc(12px * var(--fs)); color: var(--mut); display: block; line-height: 1.35; }
.notice { background: #f0f9ff; border: 1px solid #bae6fd; color: #075985; border-radius: 14px; padding: 10px 12px; font-size: calc(13px * var(--fs)); }
.notice.ok { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.empty { text-align: center; color: var(--mut2); padding: 24px 8px; font-size: calc(14px * var(--fs)); }
.skel { height: 64px; border-radius: 14px; background: linear-gradient(90deg, #eef2f6, #f8fafc, #eef2f6); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* clock */
.clock-big { font-size: calc(56px * var(--fs)); font-weight: 700; letter-spacing: -1px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.clock-big small { font-size: calc(20px * var(--fs)); color: var(--mut2); font-weight: 600; }
.center { text-align: center; }

/* quota */
.quotas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.quota { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.quota b { font-size: calc(22px * var(--fs)); font-weight: 700; }
.quota span { display: block; font-size: calc(12px * var(--fs)); color: var(--mut); }

/* type chips (leave) */
.types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.type { min-height: 56px; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; padding: 6px; }
.type b { display: block; font-size: calc(14px * var(--fs)); font-weight: 600; }
.type span { font-size: calc(12px * var(--fs)); color: var(--mut); }
.type.on { border: 2px solid var(--pri); background: var(--pri-s); color: var(--pri); }
.type.on span { color: var(--pri); }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; text-align: center; }
.cal .h { font-size: calc(12px * var(--fs)); color: var(--mut); padding: 4px 0; }
.cal button { min-height: 44px; border: 0; border-radius: 10px; background: none; cursor: pointer; font-size: calc(14px * var(--fs)); padding: 4px 0 0; display: flex; flex-direction: column; align-items: center; color: var(--ink); }
.cal button.wk { color: var(--bad); }
.cal button.out { opacity: .35; }
.cal button.today { background: #fbe4e6; }
/* สีเต็มช่องตามประเภท (ลำดับ: วันหยุด > ลา > นอกสถานที่/เวร) */
.cal button.f-holiday { background: #111827; color: #fff; }
.cal button.f-leave { background: #15803d; color: #fff; }
.cal button.f-offsite { background: #6d28d9; color: #fff; }
.cal button.f-night { background: #bae6fd; color: #0f172a; }
.cal button.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--pri); font-weight: 700; }
.dots { display: flex; gap: 2px; height: 6px; margin-top: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; box-shadow: 0 0 0 1px #fff; }
.c-leave { background: #15803d; } .c-offsite { background: #6d28d9; } .c-night { background: #bae6fd; } .c-holiday { background: #111827; } .c-today { background: #fbe4e6; }
.ev { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--pri); border-radius: 14px; padding: 10px 14px; }
.ev.leave { border-left-color: #15803d; } .ev.offsite { border-left-color: #6d28d9; } .ev.night { border-left-color: #38bdf8; } .ev.holiday { border-left-color: #111827; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: calc(12px * var(--fs)); color: #334155; margin-top: 10px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(15,23,42,.15); }

/* menu tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.tile { --c: var(--pri); position: relative; overflow: hidden; text-decoration: none; color: #0b1220; font-weight: 600; background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15, 23, 42, .06); border-radius: 14px; padding: 12px 6px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: calc(12px * var(--fs)); min-height: 88px; }
.tile:hover { border-color: var(--c); color: #0b1220; }
.tile::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--c); }
.tile .ic { width: 40px; height: 40px; color: var(--c); display: flex; align-items: center; justify-content: center; }
.tile .ic svg { width: calc(30px * min(var(--fs), 1.25)); height: calc(30px * min(var(--fs), 1.25)); stroke-width: 2.6; }
/* สีประจำหมวด (ชุดเดียวกับปฏิทิน) — ตัวอักษรเป็นสีดำเสมอ */
.tile.tc-time { --c: #15803d; } .tile.tc-off { --c: #7e22ce; } .tile.tc-leave { --c: #c2410c; } .tile.tc-cal { --c: #1d4ed8; }
.tile.tc-night { --c: #0369a1; } .tile.tc-tt { --c: #b45309; } .tile.tc-rep { --c: #be185d; } .tile.tc-appr { --c: #0e7490; } .tile.tc-sys { --c: #334155; }
.tile.vio { --c: var(--vio); }
.tile .new { position: absolute; top: 6px; right: 6px; font-size: calc(12px * var(--fs)); font-weight: 600; color: var(--pri); background: var(--pri-s); padding: 0 6px; border-radius: 999px; }
.tile .old { position: absolute; top: 6px; right: 6px; font-size: calc(12px * var(--fs)); color: var(--mut2); background: #f1f5f9; padding: 0 6px; border-radius: 999px; }

/* bars */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; margin-top: 10px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.bars i { width: 100%; max-width: 28px; background: var(--pri); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars span { font-size: calc(12px * var(--fs)); color: var(--mut2); }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: calc(13px * var(--fs)); }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--mut); font-weight: 500; }

/* switch */
.sw { position: relative; width: 48px; height: 28px; flex: none; }
.sw input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.sw span { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: background .15s; pointer-events: none; }
.sw span::after { content: ''; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sw input:checked + span { background: var(--pri); }
.sw input:checked + span::after { transform: translateX(20px); }
.sw input:focus-visible + span { outline: 3px solid rgba(14, 116, 144, .45); outline-offset: 2px; }

/* legacy frame */
.frame { width: 100%; border: 0; display: block; background: var(--bg); height: calc(100vh - 64px - 84px - var(--safe-b)); height: calc(100dvh - 64px - 84px - var(--safe-b)); }
@media (min-width: 900px) { .frame { height: calc(100vh - 64px); height: calc(100dvh - 64px); } }

/* sheet / toast */
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: #fff; width: 100%; max-width: 520px; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); max-height: 90vh; overflow: auto; }
@media (min-width: 600px) { .sheet { align-items: center; } .sheet-card { border-radius: 20px; } }
.sheet-card h3 { margin: 0 0 6px; font-size: calc(18px * var(--fs)); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + var(--safe-b)); z-index: 70; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: calc(14px * var(--fs)); max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(15, 23, 42, .25); }
.toast.bad { background: var(--bad); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* print (ใบลา) */
.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; font: 16px/1.8 'IBM Plex Sans Thai', serif; color: #000; padding: 24px; }
}

/* กำลังเข้าสู่ระบบ */
.loading { position: fixed; inset: 0; z-index: 80; background: rgba(246, 248, 250, .94); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.ld-ring { position: relative; width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; }
.ld-ring::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 5px solid var(--pri-s); border-top-color: var(--pri); border-right-color: var(--pri); animation: spin 1s linear infinite; }
.ld-ring img { width: 78px; height: 78px; object-fit: contain; }
.ld-text { font-weight: 600; color: var(--pri); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ld-ring::before { animation-duration: 3s; } }
/* ข้อความต้อนรับ */
.welcome { text-align: center; }
.welcome h3 { font-size: calc(20px * var(--fs)); margin: 4px 0 6px; }
.welcome .wx { margin-top: 12px; background: var(--pri-s); color: var(--pri-d); border-radius: 12px; padding: 10px 12px; font-size: calc(14px * var(--fs)); }
.ver { text-align: center; color: var(--mut2); font-size: calc(12px * var(--fs)); margin: 8px 0 0; }

/* ปุ่มลอยแจ้ง Request / Issue */
.fab { position: fixed; right: 14px; bottom: calc(76px + var(--safe-b)); z-index: 35; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--pri); color: #fff; box-shadow: 0 6px 18px rgba(15, 23, 42, .25); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.fab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 900px) { .fab { bottom: 24px; right: 24px; } }
.fb-type { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 6px; }
.fb-type button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; font: inherit; font-size: calc(14px * var(--fs)); color: var(--ink); cursor: pointer; }
.fb-type button.on { border-color: var(--pri); background: var(--pri-s, #e0f2f1); color: var(--pri); font-weight: 600; }
.badge-t { display: inline-block; font-size: calc(12px * var(--fs)); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge-t.issue { background: #fee2e2; color: #991b1b; } .badge-t.request { background: #dbeafe; color: #1e3a8a; }
.badge-s { display: inline-block; font-size: calc(12px * var(--fs)); padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: #334155; }
.badge-s.s0 { background: #fef3c7; color: #78350f; } .badge-s.s1 { background: #dbeafe; color: #1e3a8a; } .badge-s.s2 { background: #dcfce7; color: #14532d; }

/* ปฏิทินแบบ A */
.calA-h { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; font-size: calc(12px * var(--fs)); font-weight: 600; color: var(--mut); padding: 2px 0 6px; }
.calA-h .we { color: #b91c1c; }
.calA { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid #e2e8f0; border-left: 1px solid #e2e8f0; }
.calA button { position: relative; min-width: 0; min-height: 72px; background: #fff; border: 0; border-right: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; padding: 4px; text-align: left; display: flex; flex-direction: column; align-items: stretch; gap: 2px; color: #0f172a; font: inherit; cursor: pointer; }
.calA .n { font-size: calc(13px * var(--fs)); font-weight: 700; line-height: 1.2; }
.calA button.wk { background: #eef0f3; }
.calA button.today { background: #fbe4e6; }
.calA button.hol { background: #374151; color: #fff; }
.calA button.out { opacity: .35; }
.calA button.sel { box-shadow: inset 0 0 0 2px var(--pri); }
.calA .hn { font-size: calc(12px * var(--fs)); line-height: 1.25; color: #fff; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.calA .ch { display: block; font-size: calc(12px * var(--fs)); font-weight: 600; line-height: 1.35; border-radius: 4px; padding: 1px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch.l { background: #ea580c; color: #111827; } .ch.o { background: #6d28d9; color: #fff; } .ch.n { background: #bae6fd; color: #0f172a; }
.ch.s { background: #f0f9ff; color: #0c4a6e; border: 1.5px dashed #0284c7; padding: 0 2px; }
.calA .more { font-size: calc(12px * var(--fs)); font-weight: 700; color: #9a3412; line-height: 1.3; }
.calA button.hol .more { color: #fed7aa; }
.calA .cdot { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: #dc2626; }
.c-leave { background: #ea580c !important; } .c-holiday { background: #374151 !important; } .c-wk { background: #eef0f3; } .c-sug { background: #f0f9ff; border: 1.5px dashed #0284c7 !important; } .c-dot { background: #dc2626; border-radius: 50% !important; width: 8px !important; height: 8px !important; }
.ev.leave { border-left-color: #ea580c; } .ev.holiday { border-left-color: #374151; }
.pop-hol { background: #374151; color: #fff; border-radius: 12px; padding: 10px 12px; font-size: calc(14px * var(--fs)); }
.pop-row { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.pop-row .t { font-weight: 600; } .pop-row .s { font-size: calc(13px * var(--fs)); color: var(--mut); }
.pop-av { width: 36px; height: 36px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; background: #e2e8f0; color: #0f172a; }
.pop-av.leave { background: #ea580c; color: #111827; } .pop-av.offsite { background: #6d28d9; color: #fff; } .pop-av.night { background: #bae6fd; color: #0f172a; }
.fair { display: grid; grid-template-columns: 1fr 48px 72px 70px; gap: 4px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: calc(14px * var(--fs)); }
.fair > :not(:first-child) { text-align: center; } .fair.h { font-size: calc(12px * var(--fs)); color: var(--mut); border-bottom-color: var(--line); }
/* ตารางสอน */
.tt-row { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.tt-row.now { background: #e0f2f1; border-color: var(--pri); }
.tt-row .t { font-weight: 600; } .tt-row .s { font-size: calc(13px * var(--fs)); color: var(--mut); }
.tt-p { width: 40px; text-align: center; } .tt-p span { display: block; font-size: calc(12px * var(--fs)); color: var(--mut); } .tt-p b { font-size: calc(18px * var(--fs)); }

/* สถานะกำลังโหลด */
.netbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 90; overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none; }
.netbar.on { opacity: 1; }
.netbar::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--pri); animation: netbar 1.1s ease-in-out infinite; }
@keyframes netbar { 0% { left: -40%; } 100% { left: 100%; } }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid #cbd5e1; border-top-color: var(--pri); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--mut); font-size: calc(14px * var(--fs)); padding: 6px 0; }
.frame-wrap { position: relative; }
.frame-load { position: absolute; inset: 0 0 auto 0; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 0; color: var(--mut); font-size: calc(14px * var(--fs)); background: var(--bg); }
@media (prefers-reduced-motion: reduce) { .netbar::after, .spin { animation-duration: 3s; } }
.seg button.tt-hol { color: #9a3412; }
.linkbtn { border: 0; background: none; color: var(--pri); text-decoration: underline; font: inherit; padding: 0; cursor: pointer; }

/* ---------- ขนาดตัวอักษร 3 ระดับ ---------- */
html[data-fs="2"] { --fs: 1.25; }
html[data-fs="3"] { --fs: 1.5; }
html[data-fs="2"] svg, html[data-fs="3"] svg { width: calc(20px * min(var(--fs), 1.25)); height: calc(20px * min(var(--fs), 1.25)); }
.fs-switch { display: inline-flex; gap: 6px; align-items: center; }
.fs-switch button { min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 700; cursor: pointer; padding: 0 10px; }
.fs-switch button[aria-pressed="true"] { background: var(--pri); border-color: var(--pri); color: #fff; }
.fs-switch button:nth-child(1) { font-size: 15px; } .fs-switch button:nth-child(2) { font-size: 19px; } .fs-switch button:nth-child(3) { font-size: 23px; }

/* ---------- เวรกลางคืนสัปดาห์นี้ (หน้าหลัก) ---------- */
.nw { display: flex; flex-direction: column; gap: 4px; }
.nw-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; }
.nw-row.today { background: #fdf2f8; }
.nw-row.mine { background: #e0f2fe; outline: 1.5px solid #0369a1; }
.nw-d { width: 44px; flex: none; display: flex; gap: 4px; align-items: baseline; }
.nw-d span { color: var(--mut); font-size: calc(13px * var(--fs)); }
/* ---------- ตารางสอน/ตารางงาน ---------- */
.ch.t { background: #fde68a; color: #0f172a; }
.pill.sch-hol { background: #374151; color: #fff; } .pill.sch-leave { background: #ffedd5; color: #9a3412; }
.pill.sch-off { background: #f3e8ff; color: #6b21a8; } .pill.sch-night { background: #e0f2fe; color: #075985; }
.sch-day.today { outline: 2px solid var(--pri); }
