/* ==========================================================================
   ระบบบริหารงานบุคคล — ธีมตาม WEAL NEO SUPPLY (ทอง / เทาเข้ม / ขาว)
   ========================================================================== */

@font-face { font-family: "Sarabun"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Sarabun-Regular.ttf") format("truetype"); }
@font-face { font-family: "Sarabun"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/Sarabun-Medium.ttf") format("truetype"); }
@font-face { font-family: "Sarabun"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Sarabun-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Sarabun"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Sarabun-Bold.ttf") format("truetype"); }

:root {
  --gold: #D4AF37; --gold-2: #E2C25A; --gold-ink: #8C6A1E; --gold-soft: #F7E7B0; --gold-bg: #FBF5E1;
  --ink: #1A1F24; --ink-2: #2B3036; --ink-3: #4A4F55; --steel: #667085; --silver: #C7CDD4;
  --paper: #F5F6F8; --line: #E5E7EB; --line-2: #D1D5DB; --white: #fff;
  --ok: #1E8A5D; --ok-bg: #E6F4EC; --warn: #9A6B00; --warn-bg: #FFF6DB;
  --danger: #C13F35; --danger-bg: #FBECEA; --info: #2F5A8A; --info-bg: #E8F0F9;
  --grad-gold: linear-gradient(135deg, #F7E7B0 0%, #D4AF37 55%, #C49A2F 100%);
  --grad-dark: linear-gradient(160deg, #2B3036 0%, #1A1F24 100%);
  --font: "Sarabun", "Leelawadee UI", "Leelawadee", "Thonburi", "Tahoma", sans-serif;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(26,31,36,.06), 0 8px 24px -12px rgba(26,31,36,.18);
  --sidebar-w: 264px; --topbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
a { color: var(--gold-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
code { font-family: Consolas, monospace; font-size: .9em; background: var(--paper); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--steel); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
:focus-visible { outline: 3px solid rgba(212,175,55,.6); outline-offset: 2px; }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--grad-dark); color: var(--silver);
  display: flex; flex-direction: column; z-index: 40; transform: translateX(-100%); transition: transform .2s ease, width .2s ease;
}
.sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
.backdrop { position: fixed; inset: 0; background: rgba(26,31,36,.5); z-index: 35; display: none; }
.backdrop.show { display: block; }
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); min-height: var(--topbar-h); }
.brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 8px; padding: 2px; }
.brand b { display: block; color: #fff; font-size: .98rem; font-weight: 600; line-height: 1.25; }
.brand span { display: block; color: var(--gold); font-size: .75rem; letter-spacing: .04em; }
.nav { flex: 1; overflow-y: auto; padding: 8px 8px 16px; }
.nav details { margin-top: 6px; }
.nav summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gold); font-weight: 600; border-radius: var(--r-sm); }
.nav summary::-webkit-details-marker { display: none; }
.nav summary .i { width: 16px; height: 16px; transition: transform .2s; }
.nav details[open] summary .i { transform: rotate(180deg); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin: 1px 0; border-radius: var(--r-sm); color: #E6E8EB; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.on { background: rgba(212,175,55,.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav a.on .i { color: var(--gold); }
.nav a .lbl { flex: 1; min-width: 0; }
.nav .soon { font-size: .68rem; background: rgba(255,255,255,.1); color: var(--silver); padding: 0 6px; border-radius: 10px; }
.sidebar-foot { padding: 10px 16px; font-size: .75rem; color: var(--steel); border-top: 1px solid rgba(255,255,255,.08); }

.main-wrap { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.topbar .title { flex: 1; min-width: 0; font-weight: 600; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid transparent; background: transparent; border-radius: 50%; color: var(--ink-3); cursor: pointer; }
.icon-btn:hover { background: var(--paper); border-color: var(--line); }
.badge-dot { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; font-weight: 600; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; cursor: pointer; padding: 4px; border-radius: 24px; font: inherit; color: var(--ink); }
.user-btn:hover { background: var(--paper); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--grad-gold); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; flex: none; }
.user-btn .nm { display: none; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.content { flex: 1; padding: 16px; width: 100%; max-width: 1280px; margin: 0 auto; }

@media (min-width: 992px) {
  .sidebar { transform: none; }
  .main-wrap { margin-left: var(--sidebar-w); transition: margin-left .2s ease; }
  .menu-btn-mobile { display: none !important; }
  body.nav-collapsed .sidebar { width: 72px; }
  body.nav-collapsed .main-wrap { margin-left: 72px; }
  body.nav-collapsed .brand div, body.nav-collapsed .nav .lbl, body.nav-collapsed .nav .soon,
  body.nav-collapsed .nav summary span, body.nav-collapsed .sidebar-foot { display: none; }
  body.nav-collapsed .nav a { justify-content: center; }
  body.nav-collapsed .nav summary { justify-content: center; }
  .user-btn .nm { display: inline; }
  .content { padding: 24px; }
}
@media (max-width: 991.98px) { .menu-btn-desktop { display: none !important; } }

/* ---------- Dropdown ---------- */
.dd { position: relative; }
.dd-panel { position: absolute; right: 0; top: calc(100% + 6px); width: min(360px, calc(100vw - 24px)); background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); display: none; z-index: 50; overflow: hidden; }
.dd.open .dd-panel { display: block; }
.dd-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.dd-head button { border: 0; background: none; color: var(--gold-ink); font: inherit; font-size: .85rem; cursor: pointer; }
.dd-list { max-height: 60vh; overflow-y: auto; }
.dd-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--ink); }
.dd-item:hover { background: var(--paper); text-decoration: none; }
.dd-item.unread { background: var(--gold-bg); }
.dd-item b { display: block; font-weight: 600; font-size: .92rem; }
.dd-item span { display: block; font-size: .82rem; color: var(--steel); }
.dd-foot { display: block; text-align: center; padding: 10px; font-size: .9rem; }
.dd-menu a, .dd-menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 11px 14px; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.dd-menu a:hover, .dd-menu button:hover { background: var(--paper); text-decoration: none; }
.dd-empty { padding: 24px; text-align: center; color: var(--steel); }

/* ---------- Page header / cards ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--steel); margin: 2px 0 0; font-size: .92rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 1px 2px rgba(26,31,36,.04); padding: 16px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card.accent { border-top: 3px solid var(--gold); }
@media (min-width: 768px) { .card { padding: 20px 24px; } }
.grid { display: grid; gap: 16px; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 640px) and (max-width: 1099.98px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.welcome { background: var(--grad-dark); color: #fff; border: 0; position: relative; overflow: hidden; }
.welcome::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle, rgba(212,175,55,.35), transparent 70%); }
.welcome h1 { color: #fff; }
.welcome .muted { color: var(--silver); }
.tile { display: flex; align-items: center; gap: 12px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); color: var(--ink); min-height: 64px; }
.tile:hover { border-color: var(--gold); text-decoration: none; box-shadow: var(--shadow); }
.tile .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--gold-bg); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; flex: none; }
.tile b { font-weight: 600; display: block; line-height: 1.3; }
.tile small { color: var(--steel); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: inherit; font-size: .95rem; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--gold); text-decoration: none; }
.btn:disabled, .btn.is-loading { opacity: .65; cursor: progress; }
.btn-primary { background: var(--grad-gold); border-color: transparent; color: var(--ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.04); box-shadow: 0 8px 18px -10px rgba(179,138,46,.9); }
.btn-dark { background: var(--grad-dark); color: #fff; border-color: var(--ink); }
.btn-dark:hover { border-color: var(--gold); }
.btn-danger { background: #fff; color: var(--danger); border-color: #EBC3BF; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn .i { width: 18px; height: 18px; }
.link-btn { border: 0; background: none; color: var(--gold-ink); font: inherit; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 14px 20px; }
@media (min-width: 768px) { .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid .span-2 { grid-column: 1 / -1; } }
.field { min-width: 0; }
.field > label, .label { display: block; font-weight: 500; margin-bottom: 4px; font-size: .95rem; }
.req { color: var(--danger); }
.hint { font-size: .85rem; color: var(--steel); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 9px 12px; font: inherit; font-size: 16px; /* >=16px กันมือถือซูม */
  color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-sm); transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 110px; resize: vertical; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,.25); }
.input.is-invalid { border-color: var(--danger); background: #FFFBFA; }
.input[readonly] { background: var(--paper); }
.field-error { color: var(--danger); font-size: .875rem; margin-top: 4px; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--gold-ink); flex: none; }
.input-group { position: relative; display: flex; }
.input-group .input { padding-right: 48px; }
.input-group .addon { position: absolute; right: 2px; top: 2px; bottom: 2px; width: 44px; border: 0; background: transparent; color: var(--steel); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm); }
.input-group .addon:hover { color: var(--ink); }
.caps-warn { display: none; color: var(--warn); font-size: .85rem; margin-top: 4px; }
.caps-warn.show { display: flex; align-items: center; gap: 4px; }
fieldset.section { border: 0; padding: 0; margin: 0 0 8px; }
fieldset.section > legend { font-weight: 600; font-size: 1.05rem; padding: 0; margin-bottom: 12px; color: var(--ink); }
.sticky-actions { position: sticky; bottom: 0; z-index: 20; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); margin: 0 -16px -16px; padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-radius: 0 0 var(--r-lg) var(--r-lg); }
@media (min-width: 768px) { .sticky-actions { margin: 0 -24px -20px; padding: 12px 24px; } }
.filters { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .filters { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; } }

/* ---------- Alerts / toast ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid; margin-bottom: 14px; font-size: .95rem; }
.alert .i { margin-top: 2px; }
.alert-success { background: var(--ok-bg); border-color: #BFE3CF; color: #165E40; }
.alert-error { background: var(--danger-bg); border-color: #EBC3BF; color: #8E2A22; }
.alert-warning { background: var(--warn-bg); border-color: #F1DE9C; color: #6E4D00; }
.alert-info { background: var(--info-bg); border-color: #C7D8EC; color: #234467; }
.alert .x { margin-left: auto; border: 0; background: none; color: inherit; cursor: pointer; padding: 0 4px; font-size: 1.2rem; line-height: 1; }
.toasts { position: fixed; top: 70px; right: 12px; left: 12px; z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toasts .alert { pointer-events: auto; box-shadow: var(--shadow); margin: 0; animation: toast-in .25s ease; }
@media (min-width: 640px) { .toasts { left: auto; width: 420px; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Badges / status ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 500; border: 1px solid var(--line-2); background: #fff; color: var(--ink-3); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); border-color: #BFE3CF; color: var(--ok); }
.badge-warn { background: var(--warn-bg); border-color: #F1DE9C; color: var(--warn); }
.badge-danger { background: var(--danger-bg); border-color: #EBC3BF; color: var(--danger); }
.badge-info { background: var(--info-bg); border-color: #C7D8EC; color: var(--info); }
.badge-gold { background: var(--gold-bg); border-color: var(--gold-soft); color: var(--gold-ink); }

/* ---------- Tables (เป็นการ์ดบนมือถือ) ---------- */
.table-wrap { width: 100%; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-weight: 600; color: var(--ink-3); background: var(--paper); font-size: .85rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:hover { background: #FCFCFD; }
.table .actions-cell { white-space: nowrap; text-align: right; }
@media (max-width: 767.98px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 10px; padding: 6px 4px; background: #fff; }
  .table.responsive td { border: 0; padding: 5px 10px; display: flex; gap: 12px; justify-content: space-between; text-align: right; overflow-wrap: anywhere; }
  .table.responsive td::before { content: attr(data-label); font-weight: 600; color: var(--steel); text-align: left; flex: none; max-width: 45%; }
  .table.responsive td.actions-cell { justify-content: flex-end; }
  .table.responsive td.actions-cell::before { content: none; }
  .table.responsive td:empty { display: none; }
}
@media (min-width: 768px) { .table-wrap { overflow-x: auto; } }
.empty { text-align: center; padding: 36px 16px; color: var(--steel); }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.pagination a, .pagination span { min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; color: var(--ink); }
.pagination .cur { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination a:hover { border-color: var(--gold); text-decoration: none; }

/* ---------- Permission matrix ---------- */
.perm-group { margin-bottom: 18px; }
.perm-group h3 { font-size: .95rem; color: var(--gold-ink); text-transform: uppercase; letter-spacing: .04em; }
.perm-row { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.perm-row .nm { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.perm-row .acts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; align-items: center; }
.perm-row .acts .check { padding: 2px 0; }
.perm-row .scope { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.perm-row .scope select { width: auto; min-width: 180px; }
@media (min-width: 900px) {
  .perm-row { display: grid; grid-template-columns: minmax(200px, 1.2fr) 3fr minmax(190px, 1fr); align-items: center; gap: 12px; }
  .perm-row .acts, .perm-row .scope { margin-top: 0; }
}

/* ---------- Auth pages ---------- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--grad-dark); position: relative; overflow-x: hidden; }
.auth-body::before { content: ""; position: absolute; width: 520px; height: 520px; right: -180px; top: -200px; border-radius: 50%; background: radial-gradient(circle, rgba(212,175,55,.28), transparent 65%); pointer-events: none; }
.auth-card { position: relative; width: 100%; max-width: 440px; background: #fff; border-radius: var(--r-lg); box-shadow: 0 30px 60px -30px rgba(0,0,0,.6); padding: 28px 22px; border-top: 4px solid var(--gold); }
.auth-card.wide { max-width: 720px; }
@media (min-width: 480px) { .auth-card { padding: 32px 32px; } }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand img { width: 84px; height: 84px; object-fit: contain; }
.auth-brand h1 { font-size: 1.3rem; margin: 6px 0 0; }
.auth-brand p { color: var(--steel); margin: 2px 0 0; font-size: .9rem; }
.auth-foot { text-align: center; margin-top: 16px; font-size: .9rem; }
.auth-copy { position: relative; text-align: center; color: var(--steel); font-size: .8rem; margin-top: 16px; }
.notice-box { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; background: var(--paper); margin-bottom: 14px; font-size: .95rem; }

/* ---------- Thai date picker ---------- */
.dp { position: relative; }
.dp .input { padding-right: 48px; }
.dp-pop { position: absolute; z-index: 70; top: calc(100% + 4px); left: 0; width: 300px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 10px; display: none; }
.dp.open .dp-pop { display: block; }
.dp-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.dp-head select { flex: 1; min-height: 36px; font: inherit; font-size: 16px; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 2px 4px; background: #fff; }
.dp-head button { width: 36px; height: 36px; border: 1px solid var(--line-2); background: #fff; border-radius: var(--r-sm); cursor: pointer; font-size: 1.1rem; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-grid .dow { font-size: .78rem; color: var(--steel); padding: 4px 0; }
.dp-grid button { height: 36px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; font: inherit; font-size: .92rem; color: var(--ink); }
.dp-grid button:hover { background: var(--gold-bg); }
.dp-grid button.today { box-shadow: inset 0 0 0 1px var(--gold); }
.dp-grid button.sel { background: var(--ink); color: #fff; }
.dp-grid button.sun { color: var(--danger); }
.dp-grid button.sel.sun { color: #fff; }
.dp-foot { display: flex; justify-content: space-between; margin-top: 6px; }

/* ---------- Modal / timeout bar ---------- */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(26,31,36,.55); display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.show { display: flex; }
.modal-box { background: #fff; border-radius: var(--r-lg); max-width: 420px; width: 100%; padding: 22px; box-shadow: var(--shadow); border-top: 4px solid var(--gold); }
.modal-box h3 { margin-bottom: 8px; }
.modal-box .actions { justify-content: flex-end; margin-top: 18px; }
.timeout-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 75; background: var(--ink); color: #fff; border-radius: var(--r-md); padding: 12px 14px; display: none; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow); border-left: 4px solid var(--gold); }
.timeout-bar.show { display: flex; }
.timeout-bar span { flex: 1; min-width: 200px; }
@media (min-width: 640px) { .timeout-bar { left: auto; width: 460px; } }

/* ---------- Misc ---------- */
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--steel); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.diff { width: 100%; border-collapse: collapse; font-size: .9rem; }
.diff th, .diff td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.diff .old { background: #FFF6F5; } .diff .new { background: #F2FAF5; }
.copy-row { display: flex; gap: 6px; }
.copy-row .input { font-family: Consolas, monospace; font-size: 14px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 38px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--gold-bg); color: var(--gold-ink); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .85rem; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 1.6rem; line-height: 1.1; }
.code-box { font-family: Consolas, monospace; font-size: 2rem; letter-spacing: .3em; font-weight: 700; color: var(--ink); background: var(--gold-bg); border: 1px dashed var(--gold); border-radius: var(--r-md); padding: 10px 16px; display: inline-block; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; border-bottom: 3px solid transparent; color: var(--ink-3); }
.tabs a.on { border-color: var(--gold); color: var(--ink); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

@media print {
  .sidebar, .topbar, .toasts, .actions, .sticky-actions, .pagination, .no-print { display: none !important; }
  .main-wrap { margin: 0 !important; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}

/* ---------- ปฏิทินรายเดือน (Phase 1) ---------- */
.months { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.mcal { border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px; background: #fff; }
.mcal-head { font-weight: 600; text-align: center; margin-bottom: 4px; }
.mcal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .85rem; }
.mcal-grid span { padding: 3px 0; border-radius: 4px; }
.mcal-grid .dow { color: var(--steel); font-size: .75rem; }
.mcal-grid .today { box-shadow: inset 0 0 0 2px var(--ink); font-weight: 700; }
.d-weekly { background: #E5E7EB; color: var(--ink-3); }
.d-trad { background: #FBECEA; color: var(--danger); font-weight: 600; }
.d-company { background: var(--gold-soft); color: var(--gold-ink); font-weight: 600; }
.d-sub { background: var(--info-bg); color: var(--info); font-weight: 600; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
[hidden] { display: none !important; }
.leave-preview { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.leave-preview > div { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 8px; display: flex; flex-direction: column; text-align: center; }
/* ---------- พนักงาน (Phase 2) ---------- */
.emp-cell { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.emp-cell:hover { text-decoration: none; }
.emp-cell:hover b { color: var(--gold-ink); }
.emp-photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: var(--paper); }
.emp-photo.lg { width: 64px; height: 64px; }
@media (max-width: 767.98px) { .table.responsive td .emp-cell { justify-content: flex-end; text-align: right; } }
/* ---------- Phase 3: ลงเวลา / คำขอ / อนุมัติ ---------- */
.i.flip { transform: scaleX(-1); }
.form-grid.cols-3 { grid-template-columns: 1fr; }
@media (min-width: 768px) { .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input { width: auto; min-width: 160px; }
.month-nav { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.month-nav b { min-width: 120px; text-align: center; }
.emp-pick { display: grid; gap: 4px 12px; grid-template-columns: 1fr; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; }
@media (min-width: 640px) { .emp-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.clock-card { text-align: center; }
.big-clock { font-size: clamp(2.6rem, 14vw, 4rem); font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 6px 0 8px; }
.punch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.punch-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 120px; border: 0; border-radius: var(--r-lg); font: inherit; font-size: 1.15rem; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); color: var(--white); }
.punch-btn .i { width: 30px; height: 30px; }
.punch-btn small { font-size: .82rem; font-weight: 400; opacity: .9; }
.punch-btn.in { background: var(--ok); }
.punch-btn.out { background: var(--grad-dark); }
.punch-btn:disabled { opacity: .6; cursor: progress; }
.punch-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.photo-pick { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: var(--r-md); background: var(--white); cursor: pointer; }
.photo-pick input { max-width: 100%; }
.punch-status { grid-column: 1 / -1; margin: 0; min-height: 1.5em; text-align: center; font-weight: 600; }
.punch-status.ok { color: var(--ok); }
.punch-status.err { color: var(--danger); }
.balance-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.balance { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--white); }
.balance .big { font-size: 1.5rem; font-weight: 700; color: var(--gold-ink); line-height: 1.2; }
.preview-box { padding: 10px 14px; border-radius: var(--r-md); background: var(--gold-bg); border: 1px solid var(--gold-soft); }
.preview-box p { margin: 2px 0; }
.preview-box .pv-err { color: var(--danger); }
.preview-box .pv-err::before { content: "✕ "; }
.preview-box .pv-warn { color: var(--warn); }
.preview-box .pv-warn::before { content: "! "; font-weight: 700; }
.approval-card { display: flex; flex-direction: column; gap: 6px; }
.approval-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.approval-actions .copy-row { flex: 1; min-width: 220px; }
.timesheet tr.is-holiday td { background: var(--paper); }
.timesheet tr.is-absent td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.timesheet tr.is-today td { background: var(--gold-bg); }
.grid-4.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-4.stats .card { padding: 12px 14px; }
.grid-4.stats .stat b { font-size: 1.3rem; }
@media (min-width: 1100px) { .grid-4.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.liff-wait { text-align: center; padding: 18px 0; font-weight: 600; color: var(--ink-3); }
.liff-wait.err { color: var(--danger); }

/* ---------- Phase 4: สลิปเงินเดือน ---------- */
.payslip-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; border-bottom: 2px solid var(--gold); padding-bottom: 10px; margin-bottom: 10px; }
.payslip-logo { height: 44px; }
.payslip-kv { margin-bottom: 12px; }
.payslip-cols .table { margin: 0; }
.payslip-net { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 8px; padding: 12px 16px; border-radius: var(--r-md); background: var(--gold-bg); border: 1px solid var(--gold-soft); }
.payslip-net b { font-size: 1.5rem; }
@media (max-width: 520px) { .payslip-head { grid-template-columns: 1fr; } .payslip-head .right { text-align: left; } }
@media print {
  .sidebar, .topbar, .backdrop, .timeout-bar, .toasts, .no-print-head .actions, .alert { display: none !important; }
  .main-wrap { margin: 0 !important; padding: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; border: 0 !important; }
  .payslip-cols { grid-template-columns: 1fr 1fr !important; }
}

/* ---------- Phase 5: แดชบอร์ด ---------- */
.dash-today { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 8px; }
@media (min-width: 768px) { .dash-today { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.dash-tile { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--white); color: inherit; min-width: 0; }
.dash-tile b { font-size: 1.6rem; line-height: 1.1; }
.dash-tile .small { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
a.dash-tile:hover { text-decoration: none; border-color: var(--gold); }
.dash-pending { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dash-events li { display: flex; gap: 10px; align-items: flex-start; }
.dash-events .ic { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-bg); color: var(--gold-ink); }
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; align-items: end; height: 190px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.bar-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; outline: none; }
.bar { display: block; width: 70%; max-width: 34px; background: var(--gold); border-radius: 4px 4px 0 0; min-height: 0; }
.bar-col:hover .bar, .bar-col:focus .bar { background: var(--gold-ink); }
.bar-val { font-size: .7rem; color: var(--ink-3); margin-bottom: 2px; white-space: nowrap; }
.bar-label { position: absolute; bottom: -20px; font-size: .72rem; color: var(--steel); }
.bars { margin-bottom: 26px; }
.bar-col[data-tip]:hover::after, .bar-col[data-tip]:focus::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); z-index: 5; background: var(--ink); color: #fff; font-size: .78rem; padding: 6px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; }
.bar-col:first-child[data-tip]:hover::after, .bar-col:first-child[data-tip]:focus::after { left: 0; transform: none; }
.bar-col:last-child[data-tip]:hover::after, .bar-col:last-child[data-tip]:focus::after { left: auto; right: 0; transform: none; }
@media (max-width: 520px) { .bar-val { display: none; } }
.dash-table summary { cursor: pointer; color: var(--ink-3); font-size: .9rem; }

/* ---------- Phase 6: คู่มือตั้งค่าครั้งแรก ---------- */
.progress { height: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: var(--gold); }
.setup-list { list-style: none; margin: 0; padding: 0; }
.setup-list li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.setup-list li:first-child { border-top: 0; }
.setup-list li.ok .i { color: var(--ok); }
.setup-list li.todo .i { color: var(--warn); }
.mt-xs { margin-top: 6px; }

/* ---------- Phase 7: แถบกรอกแทนพนักงาน ---------- */
.acting-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border-radius: 10px; background: var(--gold-bg); border: 2px solid var(--gold); }
.acting-bar > div { flex: 1; min-width: 180px; }
.acting-bar form { margin: 0; }
.payslip-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 28px 0 12px; text-align: center; line-height: 1.9; font-size: .92rem; }
