/* ============================================================
   SARABUN — Design tokens + shared components
   ============================================================ */
:root {
  --navy-950: #071630;
  --navy-900: #0a1f44;
  --navy-800: #0f2d5e;
  --navy-700: #16407f;
  --blue-600: #1f5fbf;
  --blue-500: #2f7bea;
  --blue-100: #dbe8fb;
  --blue-50: #eef4fd;
  --gold: #c9a24a;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --border-strong: #cfd7e3;
  --text: #0f172a;
  --text-2: #475467;
  --text-3: #8592a6;

  --ok: #12805c;
  --ok-bg: #e4f6ee;
  --warn: #b45309;
  --warn-bg: #fdf1dc;
  --danger: #c0302b;
  --danger-bg: #fdeceb;
  --info: #1f5fbf;
  --info-bg: #e8f0fd;

  /* unit colours — taken from the RTAF infographic */
  --u1: #2563eb; --u1-bg: #e6eefe; --u1-ink: #1b46b5;
  --u2: #16a34a; --u2-bg: #e3f6ea; --u2-ink: #0f7a38;
  --u3: #7c3aed; --u3-bg: #efe8fd; --u3-ink: #5b21b6;
  --u4: #ea6a12; --u4-bg: #fdeede; --u4-ink: #b4500a;
  --u5: #0d9488; --u5-bg: #ddf4f1; --u5-ink: #0a6e65;
  --u6: #475569; --u6-bg: #e8ecf2; --u6-ink: #334155;
  --hol: #c0302b; --hol-bg: #fdeceb;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-2: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-3: 0 18px 48px rgba(10, 31, 68, .22), 0 4px 12px rgba(10, 31, 68, .1);
  --font: 'Sarabun', 'TH Sarabun New', 'TH SarabunPSK', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 272px;
  --topbar-h: 64px;
  --sat: env(safe-area-inset-top, 0px);   /* แถบสถานะ iPhone เมื่อหน้าเว็บขยายเต็มจอ (viewport-fit=cover / PWA) */
  /* tokens ที่เปลี่ยนตามโหมดสว่าง/มืด */
  color-scheme: light;
  --muted-bg: var(--muted-bg); --hover: var(--hover); --grid-minor: var(--grid-minor); --weekend: #fafbfd; --today-col: #f7faff;
  --stripe: rgba(255, 255, 255, .55); --bar-target: #d4dff3; --shn-bg: #e4e7ef; --shn-ink: #2a3350;
  --sidebar-bg: var(--navy-900); --accent: var(--navy-800); --accent-hover: var(--navy-700); --accent-ink: var(--navy-700);
  --danger-ink: #8f1f1b; --danger-border: #f4c8c6; --info-ink: #174a96; --info-border: #c7dafa; --warn-ink: #7c3a05; --warn-border: #f3d9a4;
}
/* โหมดมืด: ตามระบบ (ถ้าไม่ได้เลือกเอง) หรือเลือกเองจากปุ่มในแถบหัว (html[data-theme]) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #0b1220; --surface: #111a2b; --surface-2: #162136; --border: #223049; --border-strong: #31415f;
  --text: #e7ecf5; --text-2: #a9b5ca; --text-3: #7a879e;
  --blue-50: #132443; --blue-100: #1b335f; --blue-600: #5b9bff; --blue-500: #6aa6ff;
  --ok: #3ccf98; --ok-bg: rgba(18, 128, 92, .2); --warn: #f3b25a; --warn-bg: rgba(180, 83, 9, .22);
  --danger: #ff7b74; --danger-bg: rgba(192, 48, 43, .22); --info: #7fb0ff; --info-bg: rgba(47, 123, 234, .2);
  --u1-bg: rgba(37, 99, 235, .2); --u1-ink: #9dbbff; --u2-bg: rgba(22, 163, 74, .2); --u2-ink: #6fe09a;
  --u3-bg: rgba(124, 58, 237, .24); --u3-ink: #c9b0ff; --u4-bg: rgba(234, 106, 18, .22); --u4-ink: #ffb27a;
  --u5-bg: rgba(13, 148, 136, .22); --u5-ink: #6ee0d3; --u6-bg: rgba(100, 116, 139, .25); --u6-ink: #b6c2d4; --hol: #ff7b74; --hol-bg: rgba(192, 48, 43, .22);
  --muted-bg: #1c2740; --hover: #16213a; --grid-minor: #182237; --weekend: #0e1626; --today-col: #101c33;
  --stripe: rgba(255, 255, 255, .07); --bar-target: #2a3b5d; --shn-bg: #26324b; --shn-ink: #c9d3e6;
  --sidebar-bg: #070f20; --accent: #2f6fd6; --accent-hover: #3d7ee6; --accent-ink: #8ab4ff;
  --danger-ink: #ffb3ae; --danger-border: rgba(255, 123, 116, .35); --info-ink: #b9d2ff; --info-border: rgba(127, 176, 255, .35);
  --warn-ink: #ffd59a; --warn-border: rgba(243, 178, 90, .35);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 12px rgba(0, 0, 0, .45); --shadow-3: 0 18px 48px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220; --surface: #111a2b; --surface-2: #162136; --border: #223049; --border-strong: #31415f;
  --text: #e7ecf5; --text-2: #a9b5ca; --text-3: #7a879e;
  --blue-50: #132443; --blue-100: #1b335f; --blue-600: #5b9bff; --blue-500: #6aa6ff;
  --ok: #3ccf98; --ok-bg: rgba(18, 128, 92, .2); --warn: #f3b25a; --warn-bg: rgba(180, 83, 9, .22);
  --danger: #ff7b74; --danger-bg: rgba(192, 48, 43, .22); --info: #7fb0ff; --info-bg: rgba(47, 123, 234, .2);
  --u1-bg: rgba(37, 99, 235, .2); --u1-ink: #9dbbff; --u2-bg: rgba(22, 163, 74, .2); --u2-ink: #6fe09a;
  --u3-bg: rgba(124, 58, 237, .24); --u3-ink: #c9b0ff; --u4-bg: rgba(234, 106, 18, .22); --u4-ink: #ffb27a;
  --u5-bg: rgba(13, 148, 136, .22); --u5-ink: #6ee0d3; --u6-bg: rgba(100, 116, 139, .25); --u6-ink: #b6c2d4; --hol: #ff7b74; --hol-bg: rgba(192, 48, 43, .22);
  --muted-bg: #1c2740; --hover: #16213a; --grid-minor: #182237; --weekend: #0e1626; --today-col: #101c33;
  --stripe: rgba(255, 255, 255, .07); --bar-target: #2a3b5d; --shn-bg: #26324b; --shn-ink: #c9d3e6;
  --sidebar-bg: #070f20; --accent: #2f6fd6; --accent-hover: #3d7ee6; --accent-ink: #8ab4ff;
  --danger-ink: #ffb3ae; --danger-border: rgba(255, 123, 116, .35); --info-ink: #b9d2ff; --info-border: rgba(127, 176, 255, .35);
  --warn-ink: #ffd59a; --warn-border: rgba(243, 178, 90, .35);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 4px 12px rgba(0, 0, 0, .45); --shadow-3: 0 18px 48px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* แอปจริงไม่ซูม: ปิดถ่างนิ้ว/แตะสองครั้งซูม (เลื่อนแนวตั้ง-แนวนอนได้ปกติ) และไม่ให้ iOS ขยายตัวอักษรเองเมื่อหมุนจอ */
html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: var(--shadow-1); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(15, 23, 42, .06); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 15px; }
.btn.icon { width: 38px; padding: 0; }
.btn.icon.sm { width: 32px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .lbl { font-size: 15px; font-weight: 500; color: var(--text-2); }
.field .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; }
/* iOS: ช่องวันที่/เวลาแบบ native มีความกว้างขั้นต่ำของตัวเองจนล้นออกนอกฟอร์ม และจัดข้อความกลาง */
.field { min-width: 0; }
.input, .select, .textarea { min-width: 0; max-width: 100%; }
input[type="date"].input, input[type="time"].input { -webkit-appearance: none; appearance: none; display: block; text-align: left; line-height: 40px; }
input[type="date"].input::-webkit-date-and-time-value, input[type="time"].input::-webkit-date-and-time-value { text-align: left; margin: 0; }
.select.sm { height: 34px; padding: 0 8px; font-size: 14px; border-radius: 8px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(47, 123, 234, .18); }
.input.err, .textarea.err { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(192, 48, 43, .12); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.hint { font-size: 14px; color: var(--text-3); }
.hint.err { color: var(--danger); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .suffix {
  display: flex; align-items: center; padding: 0 12px; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-2); font-size: 15px; white-space: nowrap;
}
.search {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); color: var(--text-3);
}
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--text); }
.kbd { font-size: 12.5px; padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface-2); color: var(--text-3); }

/* segmented control */
.seg { display: inline-flex; padding: 3px; background: var(--muted-bg); border-radius: 10px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 14px; border-radius: 8px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.seg button[aria-pressed="true"], .seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 14px; font-weight: 500; white-space: nowrap;
  background: var(--muted-bg); color: var(--text-2);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.u1 { background: var(--u1-bg); color: var(--u1-ink); } .chip.u2 { background: var(--u2-bg); color: var(--u2-ink); }
.chip.u3 { background: var(--u3-bg); color: var(--u3-ink); } .chip.u4 { background: var(--u4-bg); color: var(--u4-ink); }
.chip.u5 { background: var(--u5-bg); color: var(--u5-ink); }
.u1 { --c: var(--u1); --cb: var(--u1-bg); --ci: var(--u1-ink); } .u2 { --c: var(--u2); --cb: var(--u2-bg); --ci: var(--u2-ink); }
.u3 { --c: var(--u3); --cb: var(--u3-bg); --ci: var(--u3-ink); } .u4 { --c: var(--u4); --cb: var(--u4-bg); --ci: var(--u4-ink); }
.u5 { --c: var(--u5); --cb: var(--u5-bg); --ci: var(--u5-ink); }
.u6 { --c: var(--u6); --cb: var(--u6-bg); --ci: var(--u6-ink); } .chip.u6 { background: var(--u6-bg); color: var(--u6-ink); }
.hol { --c: var(--hol); --cb: var(--hol-bg); --ci: var(--hol); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--navy-700); color: #fff; font-size: 14px; font-weight: 600; flex: none;
  border: 2px solid var(--surface);
}
.avatar.lg { width: 44px; height: 44px; font-size: 17px; }
.avatar.xs { width: 22px; height: 22px; font-size: 11.5px; border-width: 1.5px; }
.avatars { display: inline-flex; } .avatars .avatar { margin-left: -8px; } .avatars .avatar:first-child { margin-left: 0; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-h h3 { font-size: 17px; font-weight: 600; }
.card-b { padding: 16px 18px 18px; }
.progress { height: 8px; border-radius: 999px; background: var(--muted-bg); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--blue-600)); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15.5px; }
.tbl th { text-align: left; font-weight: 600; font-size: 14px; color: var(--text-2); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl tr.sel { background: var(--blue-50); }
.tbl td.r, .tbl th.r { text-align: right; }

/* ---------- overlays ---------- */
.scrim { position: fixed; inset: 0; background: rgba(7, 22, 48, .5); backdrop-filter: blur(2px); z-index: 80; display: none; }
.scrim.on { display: block; animation: fade .15s; }
.modal {
  position: fixed; z-index: 90; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  display: none; flex-direction: column; overflow: hidden;
}
.modal.on { display: flex; animation: pop .18s ease-out; }
.modal-h { padding: 20px 24px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.modal-h h2 { font-size: 20.5px; font-weight: 600; }
.modal-b { padding: 20px 24px; overflow: auto; }
.modal-f { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; align-items: center; background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 120;
  background: var(--navy-900); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-3);
  display: flex; align-items: center; gap: 10px; font-weight: 500; animation: pop .2s;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); background: var(--surface); }
.login-brand {
  position: relative; overflow: hidden; color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(80, 150, 255, .45), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(47, 123, 234, .35), transparent 60%),
    linear-gradient(160deg, #0a1f44 0%, #0f2d5e 55%, #16407f 100%);
}
.login-brand::before { /* radar rings */
  content: ""; position: absolute; right: -240px; top: 50%; width: 900px; height: 900px; transform: translateY(-50%); border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 58px, rgba(255, 255, 255, .06) 58px 59px);
  mask-image: radial-gradient(circle, #000 20%, transparent 70%);
}
.login-brand::after { /* sweep */
  content: ""; position: absolute; right: -240px; top: 50%; width: 900px; height: 900px; transform: translateY(-50%); border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(120, 180, 255, .22), transparent 22%);
  mask-image: radial-gradient(circle, #000 15%, transparent 68%);
  animation: sweep 9s linear infinite;
}
@keyframes sweep { to { transform: translateY(-50%) rotate(360deg); } }
.brand-row { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
/* ตรา SARABAN สีเงินอยู่บนแผ่นกรมท่าเสมอ — บนพื้นสว่างสีเงินจะจางหาย */
.logo-mark { width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; flex: none; border-radius: 26%; padding: 0 7px;
  background: radial-gradient(120% 70% at 50% 0, rgba(120, 170, 255, .35), transparent 60%), linear-gradient(180deg, #18428a, #081a3a);
  box-shadow: 0 2px 6px rgba(8, 26, 58, .35), inset 0 0 0 1px rgba(255, 255, 255, .08); }
.logo-mark img { display: block; width: 100%; height: auto; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .45)); }
/* หน้า login: โลโก้เต็ม (ตรา + SARABAN) บนพื้นกรมท่า */
.brand-logo { height: 124px; width: auto; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35)); }
.brand-sub { display: grid; gap: 2px; font-size: 15px; line-height: 1.45; border-left: 1px solid rgba(255, 255, 255, .25); padding-left: 16px; }
.brand-sub > span { opacity: .8; } .brand-sub > b { font-weight: 600; font-size: 17px; }
.nb { white-space: nowrap; }   /* ไม่ตัดคำกลางชื่อระบบ/ชื่อหน่วย */
.top-logo { display: none; width: 34px; height: 34px; }
.top-logo { border-radius: 10px; padding: 0 4px; }
.brand-row b { display: block; font-size: 19.5px; letter-spacing: .2px; }
.brand-row span { font-size: 14.5px; opacity: .75; }
.brand-hero { position: relative; z-index: 1; max-width: 520px; }
.brand-hero h1 { font-size: clamp(28px, 3vw, 40px); line-height: 1.25; font-weight: 700; letter-spacing: -.2px; }
.brand-hero p { margin-top: 14px; font-size: 18.5px; opacity: .85; max-width: 460px; }
.brand-points { margin: 30px 0 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.brand-points li { display: flex; gap: 12px; align-items: flex-start; }
.brand-points .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .18); flex: none; }
.brand-points b { font-weight: 600; display: block; } .brand-points span { font-size: 15px; opacity: .72; }
.brand-foot { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; font-size: 15px; opacity: .8; }
.brand-foot em { font-style: italic; letter-spacing: .4px; }

.login-main { display: flex; align-items: center; justify-content: center; padding: 32px; position: relative; }
.login-card { width: min(420px, 100%); }
.login-card h2 { font-size: 30px; font-weight: 700; letter-spacing: -.2px; }
.login-card .sub { margin-top: 6px; color: var(--text-2); }
.mode { margin: 24px 0 20px; display: grid; grid-template-columns: 1fr 1fr; }
.mode.seg button { height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.otp input {
  width: 100%; height: 56px; text-align: center; font-size: 27.5px; font-weight: 600; border-radius: 12px;
  border: 1.5px solid var(--border-strong); background: var(--surface); transition: .15s;
}
.otp input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(47, 123, 234, .18); }
.otp.err input { border-color: var(--danger); background: var(--surface); animation: shake .3s; }
.otp.busy input { opacity: .6; background: var(--surface-2); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.notice { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; font-size: 15.5px; align-items: flex-start; margin-bottom: 18px; }
.notice svg { margin-top: 2px; }
.notice.err { background: var(--danger-bg); color: var(--danger-ink); border: 1px solid var(--danger-border); }
.notice.info { background: var(--info-bg); color: var(--info-ink); border: 1px solid var(--info-border); }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-border); }
.notice b { display: block; font-weight: 600; }
.help-row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: 12px; margin-top: 22px; color: var(--text-2); font-size: 15px; }
.help-row .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--blue-50); color: var(--blue-600); display: grid; place-items: center; flex: none; }
.spin { width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; }
.spin.dark { border-color: var(--border-strong); border-top-color: var(--blue-600); }
@keyframes rot { to { transform: rotate(360deg); } }
.login-foot { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; font-size: 14px; color: var(--text-3); }

/* dev panel (mock only) */
.dev {
  position: fixed; right: 16px; top: 16px; z-index: 70; width: 232px; background: #111a2e; color: #cfd8ea;
  border-radius: 14px; box-shadow: var(--shadow-3); font-size: 14px; overflow: hidden;
}
.dev summary { list-style: none; padding: 10px 14px; cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.dev summary::-webkit-details-marker { display: none; }
.dev .body { padding: 4px 8px 10px; display: grid; gap: 2px; max-height: 60vh; overflow: auto; }
.dev button { text-align: left; border: 0; background: transparent; color: #cfd8ea; padding: 6px 8px; border-radius: 7px; font-size: 14px; }
.dev button:hover { background: rgba(255, 255, 255, .08); }
.dev button.on { background: rgba(47, 123, 234, .3); color: #fff; }
.dev small { padding: 4px 8px; color: #7e8aa5; }

.upload { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); }
.upload .ph { width: 56px; height: 56px; border-radius: 50%; background: var(--muted-bg); display: grid; place-items: center; color: var(--text-3); flex: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--text-2); }
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--navy-800); }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: calc(26px + var(--sat)) 22px 30px; min-height: 0; }
  .brand-hero { margin: 28px 0 0; } .brand-points, .brand-foot { display: none; }
  .brand-hero h1 { font-size: 27.5px; } .brand-hero p { font-size: 16px; }
  .login-brand::before, .login-brand::after { width: 520px; height: 520px; right: -200px; top: 40%; }
  .login-main { padding: 0 18px 90px; margin-top: -18px; }
  .login-card { background: var(--surface); border-radius: 22px 22px 0 0; padding: 26px 0 0; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; }
  .modal.on { animation: up .22s ease-out; }
  .dev { width: 200px; top: auto; bottom: 10px; right: 10px; }
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; background: var(--sidebar-bg); color: #c9d6ee;
  display: flex; flex-direction: column; padding: 16px 12px; scrollbar-width: thin; scrollbar-color: #2a4170 transparent;
}
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; color: #fff; }
.sb-brand .logo-mark { width: 44px; height: 44px; }
.sb-brand b { display: block; font-size: 17px; line-height: 1.2; } .sb-brand span { font-size: 13px; opacity: .65; }
.sb-sec { margin: 14px 10px 6px; font-size: 12.5px; letter-spacing: .6px; text-transform: uppercase; color: #7f92b8; font-weight: 600; }
.nav-i {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 10px; border: 0; background: transparent;
  color: inherit; text-align: left; font-weight: 500; position: relative;
}
.nav-i:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-i.on { background: rgba(47, 123, 234, .22); color: #fff; }
.nav-i.on::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #6fa8ff; }
.nav-i .tag { margin-left: auto; font-size: 12.5px; background: rgba(255, 255, 255, .14); padding: 1px 7px; border-radius: 99px; }
.nav-i .tag.hot { background: #e5484d; color: #fff; }
.nav-i .chev { margin-left: auto; transition: transform .15s; opacity: .6; }
.nav-g.open > .nav-i .chev { transform: rotate(180deg); }
.nav-i.has-on { color: #fff; }   /* ส่วนงานที่มีเมนูย่อยกำลังเปิดอยู่ */
.nav-g > .nav-i .chev { padding: 0; }
.nav-u { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: #fff; background: var(--c); flex: none; }
.nav-sub { display: none; margin: 2px 0 6px 21px; padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .12); }
.nav-g.open > .nav-sub { display: block; }
.nav-sub .nav-i { padding: 7px 10px; font-size: 15.5px; font-weight: 400; color: #aebcdc; }
.nav-sub .nav-i.on { color: #fff; font-weight: 500; }
.sb-foot { margin-top: auto; padding-top: 14px; }
.sb-user { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); }
.sb-user b { color: #fff; display: block; font-size: 15px; line-height: 1.3; } .sb-user span { font-size: 13px; opacity: .65; }
.sb-user .avatar { border-color: transparent; background: #2f7bea; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 15px; min-width: 0; }
.crumbs b { color: var(--text); font-weight: 600; font-size: 17px; }
.topbar .search { width: min(360px, 34vw); margin-left: auto; }
.top-actions { display: flex; align-items: center; gap: 6px; }
/* ตัวเลขคำขอรออนุมัติบนปุ่มโปรไฟล์ของแอดมิน */
#me { position: relative; }
#me.has-count::after { content: attr(data-count); position: absolute; top: -1px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: #e5484d; color: #fff; font-size: 11.5px; font-weight: 700; line-height: 18px; text-align: center; border: 2px solid var(--bg); }
/* สลับโหมดผู้ดูแลระบบ (เมนูโปรไฟล์) */
.mode-switch { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 14px; text-align: left; border: 1px solid var(--warn-border); background: var(--warn-bg); color: var(--text); }
.mode-switch .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--warn); color: #fff; flex: none; }
.mode-switch b { display: block; font-weight: 600; } .mode-switch small { display: block; color: var(--text-2); font-size: 13.5px; line-height: 1.35; }
.mode-switch .count { margin-left: auto; background: #e5484d; color: #fff; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.mode-switch > svg { margin-left: auto; color: var(--text-3); }
.mode-switch.on { border-color: var(--border-strong); background: var(--surface-2); } .mode-switch.on .ic { background: var(--accent); }
/* ป้ายบนแถบหัวขณะอยู่ในโหมดผู้ดูแล */
.admin-chip { margin-left: 4px; flex: none; }
body.admin-mode .topbar { box-shadow: inset 0 -3px 0 var(--warn); }
/* โปรไฟล์ของฉัน */
.pf-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.pf-side { padding: 24px 18px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.pf-photo { position: relative; width: 120px; height: 120px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--navy-700); color: #fff; font-size: 44px; font-weight: 700; margin-bottom: 10px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--border); }
.pf-photo img { width: 100%; height: 100%; object-fit: cover; }
.pf-name { font-size: 19px; font-weight: 700; line-height: 1.35; }
.sb-user[data-go] { cursor: pointer; } .sb-user[data-go]:hover { background: rgba(255, 255, 255, .1); }
@media (max-width: 900px) { .pf-grid { grid-template-columns: 1fr; } }
.badge-dot { position: relative; } .badge-dot::after { content: ""; position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: #e5484d; border: 2px solid var(--bg); }
.content { padding: 24px; flex: 1; min-width: 0; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-h h1 { font-size: 27.5px; font-weight: 700; letter-spacing: -.2px; }
.page-h p { color: var(--text-2); margin-top: 2px; }
.page-h .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-btn { display: none; }
.bottom-nav { display: none; }
.drawer-sb { display: none; }

@media (max-width: 1100px) and (min-width: 769px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 14px 10px; align-items: stretch; }
  .sb-brand div, .sb-sec, .nav-i > span:not(.nav-u), .nav-i .tag, .nav-i .chev, .nav-sub, .sb-user div { display: none; }
  .nav-i { justify-content: center; padding: 11px 0; } .sb-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .sb-user { justify-content: center; padding: 8px 0; background: none; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  /* ขยายแถบหัวขึ้นไปคลุมใต้แถบสถานะ iPhone แล้วดันเนื้อหาลงมา — ไม่งั้นพอเลื่อนหน้าแถบหัวจะมุดใต้นาฬิกาและโดนเบลอทับ */
  /* ทึบและไม่เบลอบนมือถือ — iOS ใช้สีของแถบหัวที่ทึบไปเติมใต้แถบสถานะ ถ้าโปร่ง/เบลอจะได้ขอบเบลอทับแทน */
  .topbar { padding: var(--sat) 12px 0; gap: 8px; height: calc(56px + var(--sat)); background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .topbar .search, .topbar .kbd { display: none; }
  .menu-btn { display: inline-flex; } .top-logo { display: grid; } .crumbs { margin-right: auto; } .crumbs .crumb-pre { display: none; }
  .content { padding: 16px 14px 96px; }
  .page-h h1 { font-size: 23px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12.5px; color: var(--text-3); padding: 6px 0; border-radius: 10px; font-weight: 500; }
  .bottom-nav button.on { color: var(--accent-ink); }
  .bottom-nav button.on .pill { background: var(--blue-100); }
  .bottom-nav .pill { width: 52px; height: 28px; border-radius: 99px; display: grid; place-items: center; }
  .drawer-sb { display: block; position: fixed; top: 0; bottom: 0; left: 0; width: min(310px, 86vw); z-index: 90; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-3); }
  .drawer-sb.on { transform: none; }
  .drawer-sb .sidebar { display: flex; width: 100%; padding-top: calc(16px + var(--sat)); }
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.hello { display: flex; gap: 20px; align-items: stretch; margin-bottom: 20px; flex-wrap: wrap; }
.hello-card {
  flex: 1 1 520px; border-radius: var(--r-xl); padding: 24px 28px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(600px 260px at 100% 0, rgba(111, 168, 255, .4), transparent 60%), linear-gradient(135deg, #0f2d5e, #16407f);
  display: flex; flex-direction: column; justify-content: space-between; gap: 18px; min-height: 164px;
}
.hello-card h1 { font-size: 27.5px; font-weight: 700; } .hello-card p { opacity: .8; margin-top: 4px; }
.hello-card .row { display: flex; gap: 10px; flex-wrap: wrap; }
.hello-card .btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .22); color: #fff; }
.hello-card .btn:hover { background: rgba(255, 255, 255, .24); }
.hello-card .btn.solid { background: #fff; color: var(--navy-800); border-color: #fff; }
.kpis { flex: 2 1 420px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .t { font-size: 14.5px; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; }
.kpi .v { font-size: 32px; font-weight: 700; letter-spacing: -.5px; line-height: 1.1; }
.kpi .d { font-size: 14px; }
.kpi .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--cb, var(--blue-50)); color: var(--ci, var(--blue-600)); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stack { display: grid; gap: 18px; align-content: start; }
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(188px, 1fr)); gap: 14px; }
.unit-card { padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); text-align: left; position: relative; overflow: hidden; transition: .15s; }
.unit-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--c); }
.unit-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.unit-card .n { width: 34px; height: 34px; border-radius: 10px; background: var(--cb); color: var(--ci); display: grid; place-items: center; font-weight: 700; }
.unit-card h4 { margin-top: 12px; font-size: 16.5px; font-weight: 600; line-height: 1.3; }
.unit-card p { color: var(--text-2); font-size: 14.5px; margin-top: 2px; }
.unit-card .foot { display: flex; justify-content: space-between; margin-top: 14px; font-size: 14px; color: var(--text-2); }
.agenda-row { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: flex-start; cursor: pointer; }
.agenda-row:last-child { border-bottom: 0; }
.agenda-row .tm { width: 62px; flex: none; font-variant-numeric: tabular-nums; }
.agenda-row .tm b { display: block; font-size: 16px; } .agenda-row .tm span { font-size: 14px; color: var(--text-3); }
.agenda-row .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c); flex: none; }
.agenda-row h4 { font-size: 16px; font-weight: 600; } .agenda-row p { font-size: 14.5px; color: var(--text-2); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.agenda-row.now { background: linear-gradient(90deg, var(--cb), transparent 70%); margin: 0 -18px; padding: 12px 18px; }
.feed { display: grid; gap: 14px; }
.feed-i { display: flex; gap: 12px; font-size: 15px; } .feed-i .t { color: var(--text-3); font-size: 14px; }
.mini-bars { display: flex; align-items: flex-end; gap: 10px; height: 120px; }
.mini-bars div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: 13px; color: var(--text-3); }
.mini-bars i { width: 100%; border-radius: 6px 6px 3px 3px; background: var(--blue-100); display: block; }
.mini-bars .today i { background: var(--accent); } .mini-bars .today { color: var(--text); font-weight: 600; }

@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .unit-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .unit-card { padding: 14px; } .unit-card .foot { flex-direction: column; gap: 2px; } .kpis { grid-template-columns: 1fr 1fr; } .kpi .v { font-size: 27.5px; } .hello-card { padding: 20px; } .hello-card h1 { font-size: 23px; } }

/* ============================================================
   CALENDAR
   ============================================================ */
.cal { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 18px; align-items: start; }
.cal-side { display: grid; gap: 14px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.cal-side .card-b { padding: 14px; }
.mini { width: 100%; }
.mini-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 600; }
.mini table { width: 100%; border-collapse: collapse; text-align: center; font-size: 14px; }
.mini th { color: var(--text-3); font-weight: 500; padding: 4px 0; }
.mini td { padding: 1px 0; }
.mini td button { width: 30px; height: 30px; border: 0; background: none; border-radius: 50%; position: relative; font-variant-numeric: tabular-nums; }
.mini td button:hover { background: var(--muted-bg); }
.mini td.out button { color: var(--text-3); opacity: .6; }
.mini td.in-week { background: var(--blue-50); }
.mini td.in-week:first-child { border-radius: 99px 0 0 99px; } .mini td.in-week:last-child { border-radius: 0 99px 99px 0; }
.mini td.today button { background: var(--accent); color: #fff; font-weight: 600; }
.mini td.has button::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--blue-500); }
.mini td.today.has button::after { background: #fff; }
.layer { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-radius: 8px; cursor: pointer; user-select: none; }
.layer:hover { background: var(--surface-2); }
.layer input { display: none; }
.layer .box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--c); display: grid; place-items: center; color: #fff; flex: none; }
.layer input:checked + .box { background: var(--c); }
.layer .box svg { width: 12px; height: 12px; stroke-width: 3; opacity: 0; } .layer input:checked + .box svg { opacity: 1; }
.layer small { margin-left: auto; color: var(--text-3); }
.layer span.nm { font-size: 15px; line-height: 1.3; }

.cal-main { overflow: hidden; }
.cal-bar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cal-bar h2 { font-size: 22px; font-weight: 700; margin: 0 6px; letter-spacing: -.2px; min-width: 150px; }
.cal-bar .sp { flex: 1; }
.cal-bar .nav { display: flex; gap: 4px; }

/* time grid */
.tg { --hh: 56px; position: relative; overflow: auto; max-height: calc(100dvh - var(--topbar-h) - 170px); min-height: 480px; }
.tg-head { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(96px, 1fr)); position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--border); min-width: calc(56px + var(--cols) * 96px); }
.tg-head .dh { padding: 10px 8px 8px; text-align: center; border-left: 1px solid var(--border); }
.tg-head .dh small { display: block; font-size: 14px; color: var(--text-2); font-weight: 500; }
.tg-head .dh b { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 20.5px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tg-head .dh.today small { color: var(--accent-ink); } .tg-head .dh.today b { background: var(--accent); color: #fff; }
.tg-head .dh.wk small, .tg-head .dh.wk b { color: var(--text-3); }
.tg-allday { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(96px, 1fr)); border-bottom: 1px solid var(--border); position: sticky; top: 66px; z-index: 5; background: var(--surface); min-width: calc(56px + var(--cols) * 96px); }
.tg-allday .lab { font-size: 12px; color: var(--text-3); padding: 6px 6px 0 0; text-align: right; }
.tg-allday .cell { border-left: 1px solid var(--border); padding: 3px; min-height: 30px; display: grid; gap: 2px; align-content: start; }
.tg-body { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(96px, 1fr)); position: relative; min-width: calc(56px + var(--cols) * 96px); }
.tg-hours div { height: var(--hh); position: relative; font-size: 12.5px; color: var(--text-3); text-align: right; padding-right: 8px; }
.tg-hours div span { position: relative; top: -8px; background: var(--surface); padding: 0 2px; }
.tg-hours div:first-child span { visibility: hidden; }
.tg-col { position: relative; border-left: 1px solid var(--border);
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(var(--grid-minor) 1px, transparent 1px);
  background-size: 100% var(--hh), 100% calc(var(--hh) / 2); }
.tg-col.wk { background-color: var(--weekend); } .tg-col.today { background-color: var(--today-col); }
.ev {
  position: absolute; left: 3px; right: 5px; border-radius: 8px; padding: 4px 8px; overflow: hidden; cursor: pointer; font-size: 14px; line-height: 1.3;
  background: var(--cb); color: var(--ci); border-left: 4px solid var(--c); box-shadow: 0 1px 2px rgba(15, 23, 42, .08); transition: box-shadow .12s, transform .12s;
}
.ev:hover { box-shadow: var(--shadow-2); z-index: 4; }
.ev b { display: block; font-weight: 600; color: var(--text); font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ev span { display: block; font-variant-numeric: tabular-nums; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.live { background: var(--c); color: #fff; } .ev.live b { color: #fff; }
.ev.sm b { -webkit-line-clamp: 1; } .ev.sm { padding-top: 2px; }
.ev.allday { position: static; padding: 2px 8px; border-left-width: 3px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.allday.hol { background: var(--hol-bg); color: var(--hol); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #e5484d; z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #e5484d; }
.now-lab { position: absolute; left: 4px; transform: translateY(-50%); font-size: 12px; background: #e5484d; color: #fff; padding: 0 5px; border-radius: 5px; z-index: 4; font-variant-numeric: tabular-nums; }

/* month */
.mg-h { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.mg-h div { padding: 9px 10px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.mg { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(118px, 1fr); }
.mg-c { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 5px 5px 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.mg-c:nth-child(7n) { border-right: 0; }
.mg-c:hover { background: var(--hover); }
.mg-c.out { background: var(--weekend); } .mg-c.out .dn { color: var(--text-3); }
.mg-c.wk .dn { color: var(--text-2); }
.mg-c .dn { font-size: 14.5px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 1px; font-variant-numeric: tabular-nums; }
.mg-c.today .dn { background: var(--accent); color: #fff; }
.mg-e { display: flex; align-items: center; gap: 6px; padding: 1px 6px; border-radius: 5px; font-size: 13px; line-height: 1.5; background: var(--cb); color: var(--ci); overflow: hidden; white-space: nowrap; cursor: pointer; border-left: 3px solid var(--c); }
.mg-e i { font-style: normal; font-variant-numeric: tabular-nums; opacity: .8; flex: none; } .mg-e span { overflow: hidden; text-overflow: ellipsis; }
.mg-e.hol { background: var(--hol-bg); color: var(--hol); font-weight: 500; }
.mg-more { font-size: 13px; color: var(--text-2); padding: 0 6px; font-weight: 500; }
.mg-more:hover { color: var(--blue-600); }

/* agenda list */
.ag { padding: 6px 18px 18px; }
.ag-day { display: grid; grid-template-columns: 78px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.ag-day:last-child { border-bottom: 0; }
.ag-d { text-align: center; } .ag-d small { display: block; font-size: 14px; color: var(--text-2); font-weight: 500; } .ag-d b { font-size: 30px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ag-d.today b { display: inline-grid; place-items: center; width: 44px; height: 44px; background: var(--accent); color: #fff; border-radius: 50%; font-size: 25.5px; }
.ag-list { display: grid; gap: 8px; }
.ag-e { display: flex; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; background: var(--cb); border-left: 4px solid var(--c); }
.ag-e:hover { box-shadow: var(--shadow-2); }
.ag-e .tm { width: 96px; flex: none; font-variant-numeric: tabular-nums; font-size: 15px; color: var(--ci); font-weight: 500; }
.ag-e h4 { font-size: 16px; font-weight: 600; color: var(--text); } .ag-e p { font-size: 14.5px; color: var(--text-2); display: flex; gap: 6px; align-items: center; margin-top: 2px; flex-wrap: wrap; }

/* event drawer */
.drawer { position: fixed; z-index: 90; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); background: var(--surface); box-shadow: var(--shadow-3); display: none; flex-direction: column; }
.drawer.on { display: flex; animation: slide-in .2s ease-out; }
.drawer-h { padding: 18px 20px; border-top: 6px solid var(--c, var(--blue-600)); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.drawer-h h2 { font-size: 22px; font-weight: 700; line-height: 1.35; }
.drawer-b { padding: 0 20px 20px; overflow: auto; flex: 1; display: grid; gap: 16px; align-content: start; grid-auto-rows: max-content; }   /* ไม่ให้กล่อง overflow:hidden ถูกบีบเมื่อเนื้อหายาวกว่าลิ้นชัก */
.drawer-f { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.kv { display: flex; gap: 12px; align-items: flex-start; } .kv .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); flex: none; }
.kv b { display: block; font-weight: 500; } .kv span { color: var(--text-2); font-size: 15px; }
@media (max-width: 768px) {
  .drawer { top: auto; width: 100%; max-height: 88dvh; border-radius: 22px 22px 0 0; }
  .drawer.on { animation: up .22s ease-out; }
}

/* mobile calendar */
.mcal { display: none; }
.mcal .mc-top { padding: 12px 14px 4px; display: flex; align-items: center; justify-content: space-between; }
.mcal .mc-top h2 { font-size: 23px; font-weight: 700; }
.mcal .mc-grid { padding: 0 8px 10px; }
.mcal table { width: 100%; border-collapse: collapse; text-align: center; }
.mcal th { font-size: 14px; color: var(--text-3); font-weight: 500; padding: 8px 0; }
.mcal td { padding: 2px 0; }
.mcal td button { width: 40px; height: 46px; border: 0; background: none; border-radius: 14px; display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 6px; gap: 3px; font-size: 17px; font-variant-numeric: tabular-nums; }
.mcal td.out button { color: var(--text-3); opacity: .55; }
.mcal td.today button { color: var(--accent-ink); font-weight: 700; }
.mcal td.sel button { background: var(--accent); color: #fff; }
.mcal .dots { display: flex; gap: 2px; height: 5px; } .mcal .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
.mcal td.sel .dots i { background: #fff; }
.mcal .mc-day { padding: 14px; border-top: 1px solid var(--border); background: var(--surface-2); min-height: 260px; }
.mcal .mc-day h3 { font-size: 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.fab { display: none; position: fixed; right: 16px; bottom: 84px; z-index: 45; width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: #fff; box-shadow: var(--shadow-3); place-items: center; }
@media (max-width: 1100px) { .cal { grid-template-columns: 1fr; } .cal-side { display: none; } }
@media (max-width: 768px) {
  .cal-desktop { display: none; } .mcal { display: block; } .fab { display: grid; }
  .page-h.cal-h { display: none; }
  .mcal .layers { scrollbar-width: none; } .mcal .layers::-webkit-scrollbar { display: none; }
  .mcal td button { height: 42px; }
}

/* ============================================================
   RESOURCE TIMELINE (rooms / vehicles)
   ============================================================ */
.tl { --cw: 72px; --lw: 200px; overflow: auto; position: relative; }
.tl-grid { min-width: calc(var(--lw) + var(--cw) * 12); }
.tl-row { display: grid; grid-template-columns: var(--lw) 1fr; border-bottom: 1px solid var(--border); }
.tl-row.head { position: sticky; top: 0; z-index: 5; background: var(--surface); }
.tl-lab { padding: 12px 14px; display: flex; gap: 10px; align-items: center; position: sticky; left: 0; background: var(--surface); z-index: 4; border-right: 1px solid var(--border); }
.tl-lab .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--u4-bg); color: var(--u4-ink); display: grid; place-items: center; flex: none; }
.tl-lab b { display: block; font-size: 15.5px; line-height: 1.25; } .tl-lab span { font-size: 13px; color: var(--text-3); }
.tl-hours { display: grid; grid-template-columns: repeat(12, 1fr); }
.tl-hours div { padding: 10px 0 8px 8px; font-size: 14px; color: var(--text-2); border-left: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.tl-track { position: relative; height: 64px;
  background-image: linear-gradient(90deg, var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: calc(100% / 12) 100%, calc(100% / 24) 100%; }
.tl-track .free { position: absolute; inset: 0; opacity: 0; display: grid; place-items: center; color: var(--text-3); font-size: 14px; }
.bk { position: absolute; top: 8px; bottom: 8px; border-radius: 9px; padding: 4px 10px; background: var(--cb); border-left: 4px solid var(--c); color: var(--ci); font-size: 14px; overflow: hidden; cursor: pointer; line-height: 1.3; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.bk b { display: block; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; font-variant-numeric: tabular-nums; }
.bk.pend { background-image: repeating-linear-gradient(135deg, var(--stripe) 0 6px, transparent 6px 12px); border-left-style: dashed; }
.bk.clash { background: var(--danger-bg); border-left-color: var(--danger); color: var(--danger); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: #e5484d; z-index: 3; pointer-events: none; }
.tl-now::before { content: ""; position: absolute; top: -1px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: #e5484d; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); padding: 12px 16px; border-top: 1px solid var(--border); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; background: var(--cb, var(--blue-100)); border-left: 3px solid var(--c, var(--blue-600)); }
.tl-toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tl-toolbar h2 { font-size: 19.5px; font-weight: 700; margin: 0 6px; }
.tl-toolbar .sp { flex: 1; }
@media (max-width: 768px) { .tl { --cw: 64px; --lw: 124px; } .tl-lab { padding: 10px; } .tl-lab .ic { display: none; } .tl-lab span { display: none; } }

/* ============================================================
   ROSTER
   ============================================================ */
.ro { overflow: auto; }
.ro table { border-collapse: separate; border-spacing: 0; min-width: 880px; width: 100%; }
.ro th, .ro td { border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); padding: 8px; text-align: center; vertical-align: middle; }
.ro th:first-child, .ro td:first-child { border-left: 0; text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 210px; }
.ro thead th { background: var(--surface-2); position: sticky; top: 0; z-index: 3; font-weight: 600; }
.ro thead th:first-child { z-index: 4; }
.ro thead th small { display: block; color: var(--text-3); font-weight: 400; font-size: 13px; }
.ro thead th.today { background: var(--blue-50); color: var(--blue-600); } .ro thead th.closed { background: var(--muted-bg); color: var(--text-3); }
.ro td.closed { background: repeating-linear-gradient(135deg, var(--weekend) 0 8px, var(--surface) 8px 16px); }
.ro .person { display: flex; gap: 10px; align-items: center; } .ro .person b { display: block; font-size: 15.5px; font-weight: 600; line-height: 1.25; } .ro .person span { font-size: 14px; color: var(--text-3); }
.sh { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; min-height: 44px; border-radius: 9px; padding: 3px 4px; font-size: 14px; font-weight: 600; cursor: pointer; line-height: 1.25; border: 1px solid transparent; }
.sh small { font-weight: 400; font-size: 12.5px; opacity: .85; font-variant-numeric: tabular-nums; }
.sh.m { background: var(--u1-bg); color: var(--u1-ink); } .sh.a { background: var(--u4-bg); color: var(--u4-ink); }
.sh.n { background: var(--shn-bg); color: var(--shn-ink); } .sh.off { background: transparent; color: var(--text-3); font-weight: 400; border: 1px dashed var(--border-strong); }
.sh.lv { background: var(--u3-bg); color: var(--u3-ink); } .sh.od { background: var(--u5-bg); color: var(--u5-ink); }
.sh:hover { border-color: currentColor; }
.ro tfoot td { background: var(--surface-2); font-size: 14.5px; font-weight: 600; }
.cov { display: inline-flex; gap: 5px; align-items: center; } .cov.low { color: var(--danger); } .cov.ok { color: var(--ok); }
.ro-leg { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-2); align-items: center; }
.ro-leg .sh { width: auto; min-height: 0; padding: 2px 9px; cursor: default; flex-direction: row; gap: 6px; }

/* ============================================================
   DOCS (inbox)
   ============================================================ */
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 18px; align-items: start; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 13px 12px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tabs button.on { color: var(--accent-ink); border-bottom-color: var(--accent-ink); }
.tabs .cnt { background: var(--muted-bg); font-size: 12.5px; padding: 0 7px; border-radius: 99px; color: var(--text-2); }
.tabs button.on .cnt { background: var(--blue-100); color: var(--navy-700); }
.toolbar { display: flex; gap: 8px; padding: 12px 14px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--border); }
.toolbar .search { flex: 1 1 200px; }
.pri { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.pri i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pri.p3 { color: var(--danger); } .pri.p2 { color: var(--warn); } .pri.p1 { color: var(--text-3); font-weight: 500; }
.doc-no { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 14.5px; }
.doc-title { font-weight: 600; max-width: 380px; }
.steps { display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 22px 1fr; gap: 12px; position: relative; padding-bottom: 16px; }
.step::before { content: ""; position: absolute; left: 10px; top: 22px; bottom: 0; width: 2px; background: var(--border); }
.step:last-child::before { display: none; } .step:last-child { padding-bottom: 0; }
.step .pt { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; z-index: 1; }
.step.done .pt { background: var(--ok); border-color: var(--ok); color: #fff; } .step.done::before { background: var(--ok); }
.step.cur .pt { border-color: var(--blue-600); box-shadow: 0 0 0 4px rgba(47, 123, 234, .2); }
.step .pt svg { width: 12px; height: 12px; stroke-width: 3; }
.step b { display: block; font-weight: 600; font-size: 15.5px; } .step span { font-size: 14.5px; color: var(--text-2); }
.doc-detail { position: sticky; top: calc(var(--topbar-h) + 16px); }
.attach { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.attach .ic { width: 36px; height: 36px; border-radius: 9px; background: var(--danger-bg); color: var(--danger); display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: none; }
.attach b { display: block; font-weight: 500; font-size: 15px; } .attach span { font-size: 14px; color: var(--text-3); }
.back-m { display: none; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } .doc-detail { position: static; } }
@media (max-width: 768px) {
  .split.has-sel .doc-list { display: none; }
  .split:not(.has-sel) .doc-detail { display: none; }
  .back-m { display: inline-flex; } .tbl.stack-m thead { display: none; }
  .tbl.stack-m tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .tbl.stack-m td { border: 0; padding: 0; } .tbl.stack-m td.hide-m { display: none; }
  .tbl.stack-m td.t { grid-column: 1 / -1; order: 2; } .doc-title { max-width: none; }
}

/* ============================================================
   BUDGET
   ============================================================ */
.big { font-size: 30px; font-weight: 700; letter-spacing: -.4px; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding-top: 8px; position: relative; }
.bars .g { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; font-size: 13px; color: var(--text-3); position: relative; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; flex: 1; }
.bars .pair i { width: 38%; max-width: 20px; border-radius: 5px 5px 2px 2px; display: block; }
.bars .pair i.t { background: var(--bar-target); } .bars .pair i.a { background: var(--blue-600); }
.bars .g.cur { color: var(--text); font-weight: 600; }
.bars .g.fut .pair i.a { display: none; }
.donut-w { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; flex: none; }
.lg-i { display: flex; gap: 10px; align-items: center; font-size: 15px; padding: 4px 0; } .lg-i i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); } .lg-i b { margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; }

/* ============================================================
   GANTT
   ============================================================ */
.gt { overflow: auto; --mw: 72px; --lw: 290px; }
.gt-in { min-width: calc(var(--lw) + var(--mw) * 12); position: relative; }
.gt-row { display: grid; grid-template-columns: var(--lw) 1fr; border-bottom: 1px solid var(--border); min-height: 52px; }
.gt-row.head { position: sticky; top: 0; z-index: 6; background: var(--surface); }
.gt-row.grp { background: var(--surface-2); min-height: 38px; }
.gt-lab { position: sticky; left: 0; z-index: 4; background: inherit; background-color: var(--surface); border-right: 1px solid var(--border); padding: 9px 14px; display: flex; flex-direction: column; justify-content: center; }
.gt-row.grp .gt-lab { background: var(--surface-2); flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; font-weight: 600; }
.gt-lab b { font-weight: 600; font-size: 15.5px; line-height: 1.3; } .gt-lab span { font-size: 14px; color: var(--text-3); }
.gt-months { display: grid; grid-template-columns: repeat(12, 1fr); }
.gt-months div { padding: 9px 0 9px 10px; font-size: 14px; font-weight: 500; color: var(--text-2); border-left: 1px solid var(--border); }
.gt-months div small { display: block; font-weight: 400; color: var(--text-3); font-size: 12.5px; }
.gt-track { position: relative; background-image: linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: calc(100% / 12) 100%; }
.gt-bar { position: absolute; top: 14px; height: 24px; border-radius: 7px; background: var(--cb); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); overflow: hidden; cursor: pointer; }
.gt-bar i { position: absolute; inset: 0 auto 0 0; background: var(--c); opacity: .9; }
.gt-bar span { position: relative; padding: 0 8px; font-size: 13px; font-weight: 600; line-height: 22px; color: var(--ci); white-space: nowrap; mix-blend-mode: normal; }
.gt-ms { position: absolute; top: 17px; width: 16px; height: 16px; transform: rotate(45deg); background: var(--surface); border: 3px solid var(--c); border-radius: 3px; margin-left: -8px; }
.gt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: #e5484d; z-index: 3; }
.gt-today span { position: absolute; top: 4px; left: 4px; font-size: 12px; background: #e5484d; color: #fff; padding: 0 6px; border-radius: 5px; }

/* ============================================================
   UNIT page
   ============================================================ */
.unit-hero {
  border-radius: var(--r-xl); padding: 26px 28px; color: #fff; margin-bottom: 20px; position: relative; overflow: hidden;
  background: radial-gradient(500px 220px at 100% 0, rgba(255, 255, 255, .22), transparent 60%), linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 60%, #0a1f44));
  display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.unit-hero .num-badge { width: 56px; height: 56px; border-radius: 16px; background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .3); display: grid; place-items: center; font-size: 30px; font-weight: 700; flex: none; }
.unit-hero h1 { font-size: 27.5px; font-weight: 700; } .unit-hero p { opacity: .85; margin-top: 2px; }
.unit-hero .stats { display: flex; gap: 26px; } .unit-hero .stats b { display: block; font-size: 27.5px; line-height: 1.1; } .unit-hero .stats span { font-size: 14px; opacity: .8; }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.sub-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.sub-card .h { display: flex; gap: 12px; align-items: center; }
.sub-card .code { width: 40px; height: 40px; border-radius: 11px; background: var(--cb); color: var(--ci); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; }
.sub-card h3 { font-size: 17px; font-weight: 600; line-height: 1.3; } .sub-card .h span { font-size: 14px; color: var(--text-3); }
.sub-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; color: var(--text-2); font-size: 15px; }
.sub-card li { display: flex; gap: 8px; } .sub-card li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--c); margin-top: 8px; flex: none; opacity: .6; }
.sub-card .f { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }

/* ============================================================
   ADMIN
   ============================================================ */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .stat-row { grid-template-columns: 1fr 1fr; } }
.who { display: flex; gap: 10px; align-items: center; } .who b { display: block; font-weight: 600; line-height: 1.25; } .who span { font-size: 14px; color: var(--text-3); }
.row-acts { display: flex; gap: 6px; justify-content: flex-end; }

/* emblem watermarks */
.login-brand .wm { position: absolute; right: -90px; bottom: -70px; width: 440px; opacity: .1; filter: grayscale(.2); pointer-events: none; }
.hello-card::after { content: ""; position: absolute; right: -30px; bottom: -40px; width: 200px; height: 200px; background: url(icons/emblem-rtaf.png) center/contain no-repeat; opacity: .13; pointer-events: none; }
@media (max-width: 900px) { .login-brand .wm { width: 240px; right: -50px; bottom: -40px; } .logo-mark { width: 46px; height: 46px; } .brand-logo { height: 84px; } .brand-sub { font-size: 13.5px; } .brand-sub > b { font-size: 15px; }
  .login-brand .brand-row { flex-direction: column; align-items: flex-start; gap: 10px; } .login-brand .brand-sub { border-left: 0; padding-left: 0; } }

/* ปุ่มสลับโหมดสว่าง/มืด */
.theme-btn svg { width: 19px; height: 19px; }

/* มือถือ: คอลัมน์ชื่อ (ค้างซ้าย) ของไทม์ไลน์โครงการและตารางเวรแคบลง ให้ช่องข้อมูลเลื่อนดูได้กว้างขึ้น */
@media (max-width: 768px) {
  .gt { --lw: 140px; --mw: 64px; }
  .gt-lab { padding: 8px 10px; }
  .gt-lab b { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .gt-lab span { font-size: 12.5px; }
  .gt-row.grp .gt-lab { font-size: 14px; gap: 6px; }
  .gt-months div { padding-left: 6px; }

  .crumbs b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .admin-chip > span { display: none; }   /* มือถือ: เหลือแค่ไอคอนโล่ */   /* ชื่อหน้ายาวไม่ตัดเป็น 2 บรรทัด */
  .ro table { min-width: calc(124px + 7 * 82px); }
  .ro th, .ro td { padding: 6px; min-width: 82px; }
  .ro th:first-child, .ro td:first-child { min-width: 124px; max-width: 124px; padding: 6px 8px; }
  .ro .person .avatar { display: none; }
  .ro .person b { font-size: 14px; }
  .ro .person span { font-size: 12px; }
  .ro thead th small { font-size: 11.5px; }
  .sh small { font-size: 11px; }
}

/* จัดการผู้ใช้บนมือถือ: แต่ละคนเป็นการ์ด ไม่ต้องเลื่อนตารางแนวนอน */
.u-org-m { display: none; }
@media (max-width: 768px) {
  .tbl.users thead { display: none; }
  .tbl.users tr { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; padding: 14px; border-bottom: 1px solid var(--border); align-items: start; }
  .tbl.users td { border: 0; padding: 0; }
  .tbl.users .u-who { grid-column: 1 / -1; }
  .tbl.users .u-org { display: none; }
  .tbl.users .u-org-m { display: block; }
  .tbl.users .u-role { grid-column: 1 / -1; }
  .tbl.users .u-role > div { grid-template-columns: 1fr 1fr; min-width: 0 !important; }
  .tbl.users .u-last { text-align: right; font-size: 14px; }
  .tbl.users .u-act { grid-column: 1 / -1; }
  .tbl.users .u-act:empty, .tbl.users .u-act .row-acts:empty { display: none; }
  .tbl.users .row-acts { justify-content: stretch; }
  .tbl.users .row-acts .btn { flex: 1; height: 40px; }
  .tbl.users .row-acts .btn.ghost { border-color: var(--border-strong); }
}

/* ============================================================
   WORKSPACE — พื้นที่งานของกลุ่มงาน (#/ws/...)
   ============================================================ */
.ws-head { position: relative; padding: 4px 0 18px 16px; margin-bottom: 18px; border-left: 4px solid var(--c); }
.ws-crumb { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; font-weight: 500; }
.ws-crumb .nav-u { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.ws-head h1 { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.2px; }
.ws-head p { color: var(--text-2); }
.ws { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.ws-nav { position: sticky; top: calc(var(--topbar-h) + 16px); padding: 8px; display: grid; gap: 2px; }
.ws-nav-g { font-size: 12.5px; font-weight: 600; color: var(--text-3); letter-spacing: .4px; padding: 10px 10px 4px; }
.ws-nav-i { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; color: var(--text-2); font-weight: 500; line-height: 1.35; }
.ws-nav-i:hover { background: var(--hover); color: var(--text); }
.ws-nav-i.on { background: var(--cb); color: var(--ci); font-weight: 600; }
.ws-nav-i svg { flex: none; }
.ws-main { min-width: 0; }
.ws-leaf-h { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.ws-leaf-ic { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--cb); color: var(--ci); flex: none; }
.ws-leaf-h h2 { font-size: 21px; font-weight: 700; line-height: 1.3; }
.ws-leaf-h p { color: var(--text-2); font-size: 14.5px; margin-top: 2px; }
.ws-leaf-acts { margin-left: auto; display: flex; gap: 8px; flex: none; }
.ws-empty { padding: 48px 20px; display: grid; justify-items: center; gap: 6px; text-align: center; color: var(--text-2); }
.ws-none { padding: 36px; text-align: center; color: var(--text-3); }
.ws-who { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ws-who .avatar { background: var(--navy-700); border: 0; }
.ws-dl { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; margin: 0; }
.ws-dl dt { color: var(--text-3); font-size: 14px; } .ws-dl dd { margin: 0; font-weight: 500; }

/* ทะเบียน: สถิติตามสถานะ (กดเพื่อกรอง) */
.ws-stats { display: flex; gap: 10px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.ws-stat { flex: 1 0 120px; text-align: left; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); display: grid; gap: 2px; }
.ws-stat b { font-size: 24px; line-height: 1.1; } .ws-stat span { color: var(--text-2); font-size: 13.5px; }
.ws-stat.on { border-color: var(--c); box-shadow: 0 0 0 2px var(--cb); }
.tone-ok { color: var(--ok); } .tone-warn { color: var(--warn); } .tone-danger { color: var(--danger); } .tone-info { color: var(--info); } .tone-u3 { color: var(--u3-ink); }
.tbl.reg tbody tr { cursor: pointer; }
.tbl.reg .reg-title b { font-weight: 600; }

/* บอร์ดงาน */
.kb { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.kb-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 220px; scroll-snap-align: start; transition: background .15s; }
.kb-col.over { background: var(--cb); border-color: var(--c); }
.kb-h { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 4px; }
.kb-h .cnt { background: var(--muted-bg); border-radius: 99px; padding: 0 8px; font-size: 13px; color: var(--text-2); }
.kb-col.last .kb-h b { color: var(--ok); }
.kb-list { display: grid; gap: 8px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c); border-radius: 12px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow-1); display: grid; }
.kb-card:hover { box-shadow: var(--shadow-2); } .kb-card.drag { opacity: .5; }
.kb-card b { font-weight: 600; line-height: 1.4; }
.kb-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.kb-meta .num { display: inline-flex; align-items: center; gap: 4px; } .kb-meta .late { color: var(--danger); font-weight: 600; }
.kb-empty { color: var(--text-3); font-size: 13.5px; text-align: center; padding: 18px 0; }
.kb-steps { display: grid; gap: 6px; }

/* กำหนดการ */
.ag-day.past { opacity: .6; }

/* เช็กลิสต์ */
.ck-head { padding: 14px 18px; display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.ck-head > div:first-child { display: grid; } .ck-head b { font-size: 16px; }
.ck-prog { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; max-width: 360px; }
.ck-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.ck-g { padding: 8px 8px 10px; }
.ck-gh { display: flex; justify-content: space-between; padding: 8px 10px; }
.ck-i { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.ck-i:hover { background: var(--hover); }
.ck-i input { position: absolute; opacity: 0; pointer-events: none; }
.ck-box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; color: #fff; margin-top: 1px; }
.ck-box svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; }
.ck-i.done .ck-box { background: var(--ok); border-color: var(--ok); } .ck-i.done .ck-box svg { opacity: 1; }
.ck-i.done > span:last-child { color: var(--text-3); text-decoration: line-through; }
.ck-i input:focus-visible + .ck-box { outline: 2px solid var(--blue-500); outline-offset: 2px; }

/* คลังเอกสาร / สื่อ */
.lib-search { margin-bottom: 10px; } .lib-search .search { width: 100%; height: 44px; }
.lib-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; } .lib-cats .chip { border: 0; cursor: pointer; height: 30px; padding: 0 12px; font-size: 13.5px; }
.lib-list { overflow: hidden; }
.lib-row { display: flex; gap: 14px; align-items: center; width: 100%; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--border); background: transparent; text-align: left; }
.lib-row:last-child { border-bottom: 0; } .lib-row:hover { background: var(--hover); }
.lib-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--cb); color: var(--ci); flex: none; }
.lib-main { flex: 1; min-width: 0; display: grid; } .lib-main b { font-weight: 600; }
.lib-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.lib-tile { border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-lg); padding: 0 0 12px; overflow: hidden; text-align: left; display: grid; gap: 4px; box-shadow: var(--shadow-1); }
.lib-tile:hover { box-shadow: var(--shadow-2); }
.lib-tile b, .lib-tile .muted { padding: 0 12px; } .lib-tile .muted { font-size: 13px; }
.lib-thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; color: rgba(255, 255, 255, .85); margin-bottom: 6px; }
.lib-thumb.t0 { background: linear-gradient(135deg, #1f5fbf, #0f2d5e); } .lib-thumb.t1 { background: linear-gradient(135deg, #7c3aed, #3b1a7a); }
.lib-thumb.t2 { background: linear-gradient(135deg, #0d9488, #0a4a45); } .lib-thumb.t3 { background: linear-gradient(135deg, #ea6a12, #8a3b08); }
.lib-thumb.t4 { background: linear-gradient(135deg, #475569, #1e293b); }

/* ศูนย์รวมงาน */
.ev-hero { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; padding: 20px 24px; border-radius: var(--r-xl); color: #fff; margin-bottom: 16px;
  background: radial-gradient(500px 200px at 100% 0, rgba(255, 255, 255, .2), transparent 60%), linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #0a1f44)); }
.ev-hero > div { display: grid; text-align: center; min-width: 120px; } .ev-count { font-size: 52px; font-weight: 700; line-height: 1; }
.ev-hero dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; flex: 1 1 300px; } .ev-hero dt { opacity: .75; } .ev-hero dd { margin: 0; font-weight: 600; }
.ev-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ev-tasks, .ev-teams { display: grid; gap: 10px; }
.ev-task { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; } .ev-task b { font-weight: 500; } .ev-task .muted { grid-column: 2; font-size: 13px; }
.ev-team { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; } .ev-team .muted { font-size: 13px; } .ev-team .chip { grid-row: 1 / 3; grid-column: 2; align-self: center; }

/* หน้าที่มีอยู่แล้วฝังในพื้นที่งาน: ซ่อนหัวเรื่องซ้ำ เหลือปุ่มคำสั่ง */
.ws-embed .page-h > div:first-child { display: none; }
.ws-embed .page-h { margin-bottom: 12px; justify-content: flex-end; }

/* ภาพรวมส่วนงาน: รายการงานย่อย */
.leaf-list { display: grid; gap: 4px; }
.leaf-i { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 10px; background: var(--surface-2); text-align: left; color: var(--text); }
.leaf-i:hover { background: var(--cb); color: var(--ci); }
.leaf-i svg { color: var(--ci); flex: none; } .leaf-i span { flex: 1; line-height: 1.35; } .leaf-i small { color: var(--text-3); font-size: 12px; white-space: nowrap; }

@media (max-width: 1100px) { .ev-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .ws { grid-template-columns: 1fr; }
  /* มือถือ: รายการงานย่อยเป็นแถบเลื่อนแนวนอนติดใต้แถบหัว */
  .ws-nav { position: sticky; top: calc(56px + var(--sat)); z-index: 20; display: flex; gap: 6px; overflow-x: auto; padding: 8px; border-radius: 14px; scrollbar-width: none; }
  .ws-nav::-webkit-scrollbar { display: none; }
  .ws-nav-g { display: none; }
  .ws-nav-i { width: auto; flex: none; white-space: nowrap; padding: 8px 12px; border: 1px solid var(--border); }
  .ws-nav-i.on { border-color: var(--c); }
  .ws-head h1 { font-size: 23px; }
  .ws-leaf-h { flex-wrap: wrap; } .ws-leaf-acts { margin-left: 0; width: 100%; } .ws-leaf-acts .btn { flex: 1; height: 40px; }
  .ws-dl { grid-template-columns: 110px 1fr; }
  /* ทะเบียนบนมือถือ: การ์ดต่อรายการ */
  .tbl.reg thead { display: none; }
  .tbl.reg tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .tbl.reg td { border: 0; padding: 0; text-align: left !important; font-size: 14px; }
  .tbl.reg td.reg-title { grid-column: 1 / -1; font-size: 15.5px; }
  .tbl.reg td:not(.reg-title):not(.reg-status)::before { content: attr(data-l); display: block; color: var(--text-3); font-size: 12px; }
  .kb { grid-auto-columns: 82%; }
  .lib-tags { display: none; }
  .lib-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* ============================================================
   รูปภาพ: ภาพแทน แกลเลอรี ดูเต็มจอ อัปโหลด
   ============================================================ */
.ph-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ph-ph { width: 100%; height: 100%; display: grid; place-items: center; align-content: center; gap: 6px; color: rgba(255, 255, 255, .9); text-align: center; }
.ph-ph svg.i { width: clamp(18px, 28%, 60px); height: auto; stroke-width: 1.4; }
.ph-ph small { font-size: 11.5px; opacity: .75; }
.ph-ph.t0 { background: radial-gradient(120% 90% at 20% 10%, #3b7be0, #0f2d5e); } .ph-ph.t1 { background: radial-gradient(120% 90% at 20% 10%, #9a67f5, #3b1a7a); }
.ph-ph.t2 { background: radial-gradient(120% 90% at 20% 10%, #22b5a6, #0a4a45); } .ph-ph.t3 { background: radial-gradient(120% 90% at 20% 10%, #f28a3c, #8a3b08); }
.ph-ph.t4 { background: radial-gradient(120% 90% at 20% 10%, #7a8aa3, #1e293b); }
.gal-t .ph-ph small, .reg-thumb .ph-ph small, .drop-prev .ph-ph small, .kb-ph .ph-ph small { display: none; }

.gal { display: grid; gap: 10px; }
.gal-main { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; border: 0; border-radius: 14px; overflow: hidden; cursor: zoom-in; background: var(--muted-bg); }
.gal-zoom { position: absolute; right: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 99px; background: rgba(7, 15, 32, .6); color: #fff; font-size: 13px; backdrop-filter: blur(4px); }
.gal-empty { aspect-ratio: 16 / 9; border: 1.5px dashed var(--border-strong); border-radius: 14px; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--text-3); }
.gal-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.gal-t { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; outline: 2px solid transparent; outline-offset: 1px; }
.gal-t.on { outline-color: var(--c); }
.gal-t > button:first-child { display: block; width: 100%; height: 100%; padding: 0; border: 0; }
.gal-cover { position: absolute; left: 4px; bottom: 4px; padding: 0 6px; border-radius: 6px; background: var(--c); color: #fff; font-size: 11px; line-height: 18px; }
.gal-star, .gal-del { position: absolute; top: 4px; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 99px; background: rgba(7, 15, 32, .65); color: #fff; opacity: 0; transition: opacity .15s; }
.gal-star { left: 4px; } .gal-del { right: 4px; } .gal-del:hover { background: var(--danger); } .gal-star:hover { background: var(--gold); }
.gal-star svg, .gal-del svg { width: 13px; height: 13px; }
.gal-t:hover .gal-star, .gal-t:hover .gal-del, .gal-t:focus-within .gal-star, .gal-t:focus-within .gal-del { opacity: 1; }
@media (hover: none) { .gal-star, .gal-del { opacity: 1; } }
.gal-add { aspect-ratio: 1; display: grid; place-items: center; align-content: center; gap: 2px; border: 1.5px dashed var(--border-strong); border-radius: 10px; color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.gal-add:hover { border-color: var(--c); color: var(--ci); background: var(--cb); }

.lb { position: fixed; inset: 0; z-index: 150; display: grid; grid-template-rows: auto 1fr; background: rgba(3, 8, 20, .94); color: #fff; animation: fade .15s; }
.lb-bar { display: flex; align-items: center; gap: 14px; padding: calc(10px + var(--sat)) 16px 10px; }
.lb-bar > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .75; }
.lb-bar .btn { color: #fff; }
.lb-stage { display: grid; place-items: center; padding: 8px 16px 24px; min-height: 0; }
.lb-media { max-width: min(1100px, 92vw); max-height: calc(100dvh - 120px); width: auto; height: auto; border-radius: 8px; }
.lb-media.ph-ph { width: min(900px, 92vw); height: auto; aspect-ratio: 4 / 3; max-height: calc(100dvh - 120px); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 99px; border: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .14); color: #fff; }
.lb-nav:hover { background: rgba(255, 255, 255, .26); } .lb-nav.prev { left: 16px; } .lb-nav.next { right: 16px; }
@keyframes fade { from { opacity: 0; } }

/* ทะเบียนแบบการ์ดภาพ (วัตถุพิพิธภัณฑ์ / ครุภัณฑ์คอมพิวเตอร์) */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.mcard { display: grid; padding: 0; text-align: left; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-1); transition: transform .18s, box-shadow .18s; }
.mcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.mcard-ph { position: relative; aspect-ratio: 4 / 3; overflow: hidden; }
.mcard-ph > :first-child { transition: transform .4s; } .mcard:hover .mcard-ph > :first-child { transform: scale(1.04); }
.mcard-n { position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; background: rgba(7, 15, 32, .6); color: #fff; font-size: 12.5px; }
.mcard-n svg { width: 13px; height: 13px; }
.mcard-st { position: absolute; left: 8px; bottom: 8px; } .mcard-st .chip { background: var(--surface); box-shadow: var(--shadow-1); }
.mcard-b { padding: 10px 12px 12px; display: grid; gap: 4px; }
.mcard-b b { font-weight: 600; line-height: 1.35; }
.mcard-b > span { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.mcard-b small { color: var(--text-3); font-size: 12.5px; }
.reg-thumb { width: 64px; } .reg-thumb > * { width: 52px; height: 40px; border-radius: 7px; overflow: hidden; }
.reg-thumb .ph-ph svg.i { width: 20px; }

/* บอร์ดงาน: ภาพบนการ์ด */
.kb-ph { position: relative; margin: -10px -12px 8px -12px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 9px 11px 0 0; }
.kb-ph > span { position: absolute; right: 6px; bottom: 6px; padding: 0 7px; border-radius: 99px; background: rgba(7, 15, 32, .6); color: #fff; font-size: 12px; }

/* ช่องอัปโหลดรูปในฟอร์ม */
.drop { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1.5px dashed var(--border-strong); border-radius: 12px; cursor: pointer; color: var(--text-2); }
.drop > span { display: grid; } .drop b { color: var(--text); font-weight: 600; }
.drop:hover { border-color: var(--accent); background: var(--blue-50); }
.drop-prev { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; } .drop-prev:empty { display: none; }
.drop-prev > * { width: 64px; height: 64px; border-radius: 8px; overflow: hidden; }

/* ============================================================
   ห้องสมุดแบบชั้นหนังสือ (ประวัติ นขต.ทอ. / จดหมายเหตุ)
   ============================================================ */
.shelf-bar { padding: 12px 14px; display: grid; gap: 10px; margin-bottom: 6px; }
.shelf-bar .search { width: 100%; height: 44px; }
.shelf-f { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.shelf-f label { display: grid; gap: 2px; } .shelf-f label > span { color: var(--text-3); font-size: 12.5px; }
.shelf-f .seg { margin-left: auto; } .shelf-f .seg button { padding: 0 12px; display: grid; place-items: center; }
.shelf-count { font-size: 13px; }

.shelf { margin-top: 18px; }
.shelf-h { display: flex; gap: 10px; align-items: baseline; padding: 0 4px 8px; } .shelf-h b { font-size: 17px; } .shelf-h .muted { font-size: 13.5px; }
.shelf-row {
  --sb1: #f4ede1; --sb2: #e2d4bd; --plank: #8b5e3c; --plank-hi: #a8764f;
  --bw: 132px; --bh: calc(var(--bw) * 1.5);   /* ขนาดเล่ม — ชั้นไม้วางใต้หนังสือทุกแถวที่ตัดบรรทัด */
  display: flex; flex-wrap: wrap; gap: 40px 22px; align-items: flex-end; padding: 24px 24px 16px; border-radius: 14px;
  background:
    linear-gradient(transparent 0 var(--bh), var(--plank-hi) var(--bh) calc(var(--bh) + 3px), var(--plank) calc(var(--bh) + 3px) calc(var(--bh) + 16px),
      rgba(0, 0, 0, .2) calc(var(--bh) + 16px), transparent calc(var(--bh) + 26px)) 0 24px / 100% calc(var(--bh) + 40px) repeat-y,
    linear-gradient(var(--sb1), var(--sb2));
  box-shadow: inset 0 14px 22px -14px rgba(0, 0, 0, .25), var(--shadow-1);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .shelf-row { --sb1: #1c2539; --sb2: #131a2a; --plank: #4d3424; --plank-hi: #6b4a33; } }
:root[data-theme="dark"] .shelf-row { --sb1: #1c2539; --sb2: #131a2a; --plank: #4d3424; --plank-hi: #6b4a33; }

.book-btn { flex: none; padding: 0; border: 0; background: transparent; perspective: 900px; margin-bottom: -1px; }
.book {
  position: relative; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; justify-items: center; text-align: center;
  width: var(--bw, 132px); aspect-ratio: 2 / 3; padding: 12px 10px 10px 18px; border-radius: 3px 8px 8px 3px; overflow: hidden;
  color: #f5ecd6; background: linear-gradient(135deg, #1d4280, #0b1f45);
  box-shadow: inset 7px 0 8px -4px rgba(0, 0, 0, .5), inset -1px 0 0 rgba(255, 255, 255, .14), 4px 8px 14px rgba(0, 0, 0, .32);
  transform-origin: left center; transition: transform .28s ease, box-shadow .28s ease;
}
.book::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, .14); }
.book::after { content: ''; position: absolute; inset: 7px 7px 7px 15px; border: 1px solid rgba(214, 177, 92, .6); border-radius: 2px; pointer-events: none; }
.book-btn:hover .book, .book-btn:focus-visible .book { transform: rotateY(-20deg) translateY(-8px); box-shadow: inset 7px 0 8px -4px rgba(0, 0, 0, .5), 14px 18px 22px rgba(0, 0, 0, .35); }
/* ให้ชั้นดูมีชีวิต: สีและความสูงของแต่ละเล่มต่างกันเล็กน้อย */
.shelf-row .book-btn:nth-child(3n+2) .book { filter: saturate(.8) brightness(1.12); }
.shelf-row .book-btn:nth-child(3n) .book { filter: brightness(.88); }
.shelf-row .book-btn:nth-child(4n+2) .book { aspect-ratio: 2 / 2.82; }
.shelf-row .book-btn:nth-child(5n+4) .book { aspect-ratio: 2 / 2.9; }
.bk-top { font-size: 10px; letter-spacing: .1em; opacity: .8; }
.bk-emb { width: 40px; height: 40px; object-fit: contain; margin: 8px 0 4px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
.bk-title { align-self: center; font-size: 14px; font-weight: 700; line-height: 1.28; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 1px rgba(0, 0, 0, .3); }
.bk-foot { font-size: 10px; opacity: .78; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.bk-maroon { background: linear-gradient(135deg, #8c2533, #4a0f18); }
.bk-forest { background: linear-gradient(135deg, #22654c, #0e3326); }
.bk-leather { background: radial-gradient(140% 100% at 30% 20%, #7d5230, #3a2312); }
.bk-parchment { color: #3b2a12; background: linear-gradient(135deg, #efe3c3, #cbb487); box-shadow: inset 7px 0 8px -4px rgba(80, 50, 10, .35), 4px 8px 14px rgba(0, 0, 0, .25); }
.bk-parchment::after { border-color: rgba(110, 72, 22, .5); } .bk-parchment::before { background: rgba(80, 50, 10, .15); }
.bk-parchment .bk-title { text-shadow: none; }
.bk-disc { border-radius: 6px; padding-left: 10px; background:
  radial-gradient(circle at 50% 62%, rgba(255, 255, 255, .08) 0 9px, transparent 10px 30px, rgba(255, 255, 255, .12) 31px 33px, transparent 34px),
  linear-gradient(160deg, #26334b, #0d1424); }
.bk-disc::before { display: none; } .bk-disc::after { inset: 7px; }
.book.xs { width: 34px; padding: 0; border-radius: 2px 4px 4px 2px; box-shadow: inset 4px 0 4px -2px rgba(0, 0, 0, .45), 1px 2px 4px rgba(0, 0, 0, .25); }
.book.xs > * { display: none; } .book.xs::after { inset: 3px 3px 3px 7px; } .book.xs::before { left: 4px; width: 1px; }
.mini-book { flex: none; display: grid; }
.book.lg { width: 200px; padding: 18px 14px 14px 26px; }
.book.lg .bk-top { font-size: 12px; } .book.lg .bk-emb { width: 60px; height: 60px; margin: 12px 0 6px; } .book.lg .bk-title { font-size: 18px; } .book.lg .bk-foot { font-size: 12px; }
.book.lg::before { left: 13px; } .book.lg::after { inset: 10px 10px 10px 21px; }

.book-detail { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }
.bd-cover { perspective: 900px; } .bd-cover .book { transform: rotateY(-8deg); }
.bd-info h2 { font-size: 22px; line-height: 1.3; margin-bottom: 12px; }
.bd-info .ws-dl { grid-template-columns: 96px 1fr; }

/* โหมดอ่าน e-book */
.reader { position: fixed; inset: 0; z-index: 150; display: grid; grid-template-rows: auto 1fr auto; color: #f1e9da; animation: fade .18s;
  background: radial-gradient(900px 500px at 50% 40%, #3a2c1e, #15100b); }
.rd-bar { display: flex; align-items: center; gap: 14px; padding: calc(10px + var(--sat)) 16px 10px; }
.rd-bar b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rd-bar .num { opacity: .75; font-size: 14px; white-space: nowrap; } .rd-bar .btn { color: #f1e9da; }
.rd-stage { display: flex; justify-content: center; align-items: center; padding: 8px 16px; min-height: 0; }
.rd-page { position: relative; width: min(44vw, 520px, calc((100dvh - 150px) / 1.414)); aspect-ratio: 1 / 1.414; overflow: hidden; padding: 7% 8% 9%;
  background: #fbf7ee; color: #2a2418; box-shadow: 0 18px 40px rgba(0, 0, 0, .5); border-radius: 4px; font-size: clamp(13px, 1.1vw, 16px); }
.rd-page:first-child:not(:only-child) { border-radius: 6px 0 0 6px; box-shadow: inset -26px 0 30px -24px rgba(60, 40, 10, .45), 0 18px 40px rgba(0, 0, 0, .5); }
.rd-page:last-child:not(:only-child) { border-radius: 0 6px 6px 0; box-shadow: inset 26px 0 30px -24px rgba(60, 40, 10, .45), 0 18px 40px rgba(0, 0, 0, .5); }
.rd-page h3 { font-size: 1.45em; margin-bottom: .7em; color: #1b2a4a; }
.rd-page p { line-height: 1.75; text-indent: 2em; margin: 0 0 .8em; }
.rd-fig { aspect-ratio: 16 / 9; margin-top: 1em; display: grid; place-items: center; align-content: center; gap: 4px; background: #ece3cf; color: #a08f6f; border-radius: 4px; }
.rd-no { position: absolute; bottom: 3%; left: 0; right: 0; text-align: center; font-size: 12px; color: #9a8b70; }
.rd-cover { display: grid; place-items: center; background: #e7decb; }
.rd-cover .book.lg { width: 72%; }
.rd-nav { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
.rd-nav input[type=range] { flex: 1; max-width: 420px; accent-color: var(--gold); }

@media (max-width: 900px) {
  .mgrid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .mcard-b > span:nth-child(3), .mcard .ph-ph small { display: none; }
  .tbl.reg td.reg-thumb { grid-column: 1 / -1; width: auto; } .tbl.reg td.reg-thumb > * { width: 100%; height: 140px; }
  .tbl.reg td.reg-thumb::before { display: none; }
  .shelf-f label { flex: 1 1 calc(50% - 10px); } .shelf-f .select { width: 100%; }
  .shelf-f .seg { margin-left: 0; }
  .shelf-row { --bw: 92px; gap: 40px 10px; padding: 24px 10px 16px; justify-content: space-evenly; }
  .book { padding: 9px 6px 7px 13px; } .bk-top, .bk-foot { font-size: 8.5px; letter-spacing: 0; }
  .shelf-row .bk-code { display: none; } .shelf-row .bk-emb { width: 26px; height: 26px; margin: 5px 0 3px; } .shelf-row .bk-title { font-size: 11.5px; -webkit-line-clamp: 4; } .bk-emb { width: 32px; height: 32px; } .bk-title { font-size: 12.5px; }
  .book.lg { width: 168px; }
  .book-detail { grid-template-columns: 1fr; justify-items: center; gap: 16px; } .bd-info { width: 100%; }
  .rd-page { width: min(92vw, calc((100dvh - 150px) / 1.414)); font-size: 14px; }
  .lb-nav { top: auto; bottom: 18px; transform: none; }
}

/* ============================================================
   ทำเนียบติดต่อ — การ์ดวงกลมต่อคน + ปุ่มโทร / อีเมล / LINE
   ============================================================ */
.ct-bar { padding: 12px 14px; display: grid; gap: 10px; margin-bottom: 16px; }
.ct-bar .search { width: 100%; height: 44px; }
.ct-units { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; } .ct-units::-webkit-scrollbar { display: none; }
.ct-units .chip { border: 0; cursor: pointer; height: 32px; padding: 0 12px; white-space: nowrap; gap: 6px; flex: none; }
.ct-units .chip b { font-weight: 600; opacity: .7; } .ct-units .chip .dot { width: 7px; height: 7px; }
.ct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.ct-card { position: relative; display: grid; grid-template-rows: 1fr auto; padding-bottom: 16px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-1); transition: transform .18s, box-shadow .18s; }
.ct-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 66px;
  background: radial-gradient(160px 80px at 85% 0, rgba(255, 255, 255, .22), transparent 70%), linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 45%, #0a1f44)); }
.ct-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.ct-card.me { border-color: var(--c); box-shadow: 0 0 0 2px var(--cb), var(--shadow-1); }
.ct-open { position: relative; display: grid; justify-items: center; text-align: center; gap: 3px; width: 100%; padding: 22px 14px 12px; border: 0; background: none; color: inherit; }
.ct-ava { position: relative; display: grid; place-items: center; width: 88px; height: 88px; margin-bottom: 8px; border-radius: 50%; overflow: hidden; flex: none;
  color: #fff; font-size: 32px; font-weight: 600; background: linear-gradient(145deg, color-mix(in srgb, var(--c) 80%, #fff), color-mix(in srgb, var(--c) 55%, #071630));
  border: 4px solid var(--surface); box-shadow: 0 0 0 2px var(--c), 0 8px 18px rgba(7, 22, 48, .22); }
.ct-ava img { width: 100%; height: 100%; object-fit: cover; }
.ct-ava.xl { width: 116px; height: 116px; font-size: 44px; }
.ct-me { position: absolute; top: 10px; right: 10px; padding: 0 9px; border-radius: 99px; background: var(--surface); color: var(--ci); font-size: 12px; font-weight: 600; line-height: 20px; }
.ct-name { font-size: 16.5px; font-weight: 600; line-height: 1.3; }
.ct-nick { display: inline-block; padding: 0 10px; border-radius: 99px; background: var(--cb); color: var(--ci); font-size: 13px; line-height: 21px; }
.ct-pos { font-size: 13.5px; line-height: 1.35; color: var(--text-2); min-height: 2.7em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ct-unit { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-3); }
.ct-unit .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.ct-acts { position: relative; display: flex; justify-content: center; gap: 10px; }
.ct-act { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; text-decoration: none; box-shadow: 0 3px 8px rgba(7, 22, 48, .18); transition: transform .15s, filter .15s; }
.ct-act:hover { transform: translateY(-2px) scale(1.06); filter: brightness(1.08); } .ct-act:active { transform: scale(.94); }
.ct-act.call { background: #0f8a6c; } .ct-act.mail { background: #2f6fd6; } .ct-act.line { background: #06c755; }
.ct-act.off { background: var(--muted-bg); color: var(--text-3); box-shadow: none; opacity: .55; pointer-events: none; }
.ct-acts.big { gap: 10px; }
.ct-acts.big .ct-act { flex: 1; width: auto; height: 66px; border-radius: 16px; gap: 3px; align-content: center; font-size: 13.5px; font-weight: 500; }
.ct-detail { gap: 18px; }
.ct-hero { display: grid; justify-items: center; text-align: center; gap: 4px; }
.ct-hero h2 { font-size: 21px; font-weight: 600; line-height: 1.3; } .ct-hero p { color: var(--text-2); margin: 0 0 4px; }
.ct-rows { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.ct-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--border); }
.ct-row:last-child { border-bottom: 0; }
.ct-row-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--cb); color: var(--ci); flex: none; }
.ct-row > div { flex: 1; min-width: 0; display: grid; } .ct-row small { color: var(--text-3); font-size: 12.5px; }
.ct-row b { font-weight: 500; overflow-wrap: anywhere; } .ct-row a { color: var(--accent-ink); text-decoration: none; }
@media (max-width: 900px) {
  .ct-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ct-card { border-radius: 18px; padding-bottom: 12px; } .ct-card::before { height: 52px; }
  .ct-open { padding: 16px 8px 10px; } .ct-ava { width: 70px; height: 70px; font-size: 26px; border-width: 3px; margin-bottom: 6px; }
  .ct-name { font-size: 14.5px; } .ct-pos { font-size: 12.5px; } .ct-nick { font-size: 12px; }
  .ct-acts { gap: 8px; } .ct-act { width: 36px; height: 36px; }
}
