:root {
  --hs-primary: #008CFF;
  --hs-primary-dark: #0070D1;
  --hs-primary-soft: #E6F3FF;
  --hs-bg: #F4F7FB;
  --hs-border: #E6EBF2;
  --hs-text: #1F2A37;
  --hs-muted: #6B7A90;
  --sidebar-w: 256px;
  --bs-primary: #008CFF;
  --bs-primary-rgb: 0, 140, 255;
  --bs-link-color: #0070D1;
  --bs-link-color-rgb: 0, 112, 209;
  --bs-body-font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-color: #1F2A37;
  --bs-border-radius: .6rem;
}
body { background: var(--hs-bg); font-size: .95rem; }
.btn-primary { --bs-btn-bg: var(--hs-primary); --bs-btn-border-color: var(--hs-primary); --bs-btn-hover-bg: var(--hs-primary-dark);
  --bs-btn-hover-border-color: var(--hs-primary-dark); --bs-btn-active-bg: var(--hs-primary-dark); --bs-btn-disabled-bg: var(--hs-primary); }
.btn-outline-primary { --bs-btn-color: var(--hs-primary); --bs-btn-border-color: var(--hs-primary); --bs-btn-hover-bg: var(--hs-primary);
  --bs-btn-hover-border-color: var(--hs-primary); --bs-btn-active-bg: var(--hs-primary-dark); }
.text-primary { color: var(--hs-primary) !important; }
.bg-primary-soft { background: var(--hs-primary-soft) !important; }
.form-control:focus, .form-select:focus { border-color: #66B9FF; box-shadow: 0 0 0 .2rem rgba(0, 140, 255, .15); }
.form-check-input:checked { background-color: var(--hs-primary); border-color: var(--hs-primary); }
.nav-tabs .nav-link.active { color: var(--hs-primary); border-bottom: 2px solid var(--hs-primary); }

/* ---------- layout ---------- */
.sidebar { background: #fff; border-right: 1px solid var(--hs-border); }
@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); overflow-y: auto; z-index: 1030; }
  .has-sidebar .main-wrap { margin-left: var(--sidebar-w); }
}
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg { --bs-offcanvas-width: 280px; }
  .has-sidebar .content { padding-bottom: 84px !important; }
}
.sidebar-brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem; border-bottom: 1px solid var(--hs-border); }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #00A3FF, #0066E0); color: #fff;
  display: grid; place-items: center; font-size: 1.25rem; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0, 140, 255, .3); }
.brand-name { font-weight: 700; max-width: 170px; }
.brand-sub { font-size: .72rem; color: var(--hs-muted); letter-spacing: .5px; }
.sidebar-nav { padding: .6rem .75rem 1.5rem; }
.nav-section { font-size: .7rem; font-weight: 600; text-transform: uppercase; color: #9AA8BC; letter-spacing: .6px; padding: 1rem .7rem .35rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: .6rem; color: #3D4B5F;
  text-decoration: none; font-size: .92rem; margin-bottom: 2px; transition: background .15s, color .15s; }
.nav-item i { font-size: 1.1rem; width: 1.2rem; text-align: center; color: #8695AB; }
.nav-item:hover { background: #F1F6FC; color: var(--hs-primary-dark); }
.nav-item.active { background: var(--hs-primary-soft); color: var(--hs-primary-dark); font-weight: 600; }
.nav-item.active i { color: var(--hs-primary); }

.topbar { position: sticky; top: 0; z-index: 1020; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hs-border); display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; min-height: 60px; }
.topbar-title { font-weight: 600; font-size: 1.05rem; }
.btn-icon { border: 0; background: transparent; padding: .35rem .5rem; color: #3D4B5F; }
.btn-icon:hover { background: #F1F6FC; }
.user-chip { display: flex; align-items: center; gap: .55rem; border: 1px solid var(--hs-border); border-radius: 2rem; padding: .2rem .7rem .2rem .25rem; background: #fff; }
.content { padding: 1.4rem 1.5rem 2rem; }
@media (max-width: 575.98px) { .content { padding: 1rem .9rem 1.5rem; } }

.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1025; background: #fff; border-top: 1px solid var(--hs-border);
  display: flex; justify-content: space-around; padding: .35rem 0 calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 14px rgba(16, 24, 40, .06); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: .7rem; color: #7A889C; text-decoration: none; gap: 1px; }
.bottom-nav a i { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--hs-primary); font-weight: 600; }

/* ---------- components ---------- */
.card { border: 1px solid var(--hs-border); border-radius: 14px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-header { background: transparent; border-bottom: 1px solid var(--hs-border); font-weight: 600; padding: .85rem 1.1rem; }
.card-header:first-child { border-radius: 14px 14px 0 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h4 { margin: 0; font-weight: 700; }
.page-head .sub { color: var(--hs-muted); font-size: .88rem; }
.card.stat-card { display: flex; flex-direction: row; align-items: center; gap: .9rem; }
@media (max-width: 575.98px) { .card.stat-card { flex-direction: column; align-items: flex-start; gap: .5rem; } .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; } }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--hs-muted); font-size: .82rem; }
.soft-blue { background: #E6F3FF; color: #008CFF; } .soft-green { background: #E3F8EF; color: #12A150; }
.soft-orange { background: #FFF2E0; color: #E8860C; } .soft-red { background: #FDECEC; color: #E5484D; }
.soft-purple { background: #F0EBFF; color: #7C5CFA; } .soft-teal { background: #E0F7F5; color: #0BA5A0; }
.table > :not(caption) > * > * { vertical-align: middle; padding: .6rem .75rem; }
.table thead th { font-size: .8rem; color: #5B6B82; font-weight: 600; background: #F8FAFD; white-space: nowrap; border-bottom-color: var(--hs-border); }
.table-hover tbody tr:hover > * { background: #F7FBFF; }
.avatar { width: 38px; height: 38px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.avatar.sm { width: 32px; height: 32px; font-size: .85rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.8rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--hs-muted); }
.empty-state i { font-size: 2.6rem; color: #B7C4D6; display: block; margin-bottom: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: #F1F5FA; border-radius: 1rem; padding: .15rem .6rem; font-size: .8rem; color: #45556C; }
.hero { background: linear-gradient(120deg, #008CFF 0%, #2E6BFF 100%); color: #fff; border: 0; border-radius: 16px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .1); }
.hero .btn-light { color: var(--hs-primary-dark); font-weight: 600; }
.clock-big { font-size: 3.2rem; font-weight: 700; letter-spacing: 1px; }
.btn-clock { min-width: 150px; padding: .9rem 1.2rem; font-size: 1.15rem; border-radius: 1rem; }
.progress { height: .55rem; border-radius: 1rem; }
.sub-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.sub-tabs a { padding: .4rem .9rem; border-radius: 2rem; background: #fff; border: 1px solid var(--hs-border); color: #45556C; text-decoration: none; font-size: .88rem; }
.sub-tabs a.active { background: var(--hs-primary); border-color: var(--hs-primary); color: #fff; }
.kanban { display: flex; gap: .9rem; overflow-x: auto; padding-bottom: .5rem; }
.kanban-col { min-width: 250px; flex: 1; background: #EEF3F9; border-radius: 12px; padding: .7rem; }
.kanban-card { background: #fff; border-radius: 10px; padding: .65rem .75rem; margin-bottom: .55rem; border: 1px solid var(--hs-border); display: block; color: inherit; text-decoration: none; }
.kanban-card:hover { border-color: #9DD0FF; }
.score-btns .btn { min-width: 42px; }

/* ---------- org chart ---------- */
.orgchart-wrap { overflow: auto; padding: 1rem 0 2rem; }
.orgchart, .orgchart ul { padding-top: 22px; position: relative; display: flex; justify-content: center; margin: 0; padding-left: 0; }
.orgchart li { list-style: none; text-align: center; position: relative; padding: 22px 6px 0; }
.orgchart li::before, .orgchart li::after { content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 22px; border-top: 2px solid #C5D3E5; }
.orgchart li::after { right: auto; left: 50%; border-left: 2px solid #C5D3E5; }
.orgchart li:only-child::before, .orgchart li:only-child::after { display: none; }
.orgchart li:only-child { padding-top: 0; }
.orgchart li:first-child::before, .orgchart li:last-child::after { border: 0 none; }
.orgchart li:last-child::before { border-right: 2px solid #C5D3E5; border-radius: 0 8px 0 0; }
.orgchart li:first-child::after { border-radius: 8px 0 0 0; }
.orgchart ul ul::before, .orgchart > li > ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 22px; border-left: 2px solid #C5D3E5; }
.orgchart > li { padding-top: 0; }
.orgchart > li::before, .orgchart > li::after { display: none; }
.org-card { display: inline-block; min-width: 170px; max-width: 220px; background: #fff; border: 1px solid var(--hs-border); border-top: 4px solid var(--hs-primary);
  border-radius: 12px; padding: .6rem .75rem; box-shadow: 0 2px 6px rgba(16, 24, 40, .06); font-size: .85rem; }
.org-card .unit-type { font-size: .7rem; color: var(--hs-muted); text-transform: uppercase; letter-spacing: .4px; }
.org-card .unit-name { font-weight: 700; color: var(--hs-text); line-height: 1.25; }
.org-card .head { display: flex; align-items: center; gap: .4rem; justify-content: center; margin-top: .4rem; font-size: .8rem; }
.org-card .people { margin-top: .4rem; text-align: left; border-top: 1px dashed var(--hs-border); padding-top: .35rem; font-size: .76rem; color: #45556C; }
.org-card.lv2 { border-top-color: #00B8A9; } .org-card.lv3 { border-top-color: #F59E0B; } .org-card.lv4 { border-top-color: #8B5CF6; }
.org-card.lv5 { border-top-color: #EC4899; } .org-card.lv6, .org-card.lv7, .org-card.lv8, .org-card.lv9, .org-card.lv10 { border-top-color: #64748B; }
.tree-list ul { list-style: none; padding-left: 1.3rem; border-left: 2px dashed #D5DFEC; margin-left: .55rem; }
.tree-list li { margin: .3rem 0; }

/* ---------- auth pages ---------- */
.guest { background: linear-gradient(135deg, #E9F4FF 0%, #F7FAFF 55%, #EAF0FF 100%); min-height: 100vh; }
.guest .content { max-width: 1100px; margin: auto; }
.auth-card { border: 0; border-radius: 18px; box-shadow: 0 20px 50px rgba(0, 80, 160, .12); }

/* ---------- payslip / print ---------- */
.payslip { max-width: 820px; margin: auto; background: #fff; padding: 2rem; border-radius: 14px; }
.payslip td { padding: .25rem .5rem; }
@media print {
  .no-print, .sidebar, .topbar, .bottom-nav { display: none !important; }
  .has-sidebar .main-wrap { margin-left: 0 !important; }
  body { background: #fff; }
  .payslip { box-shadow: none !important; padding: 0; }
  .content { padding: 0 !important; }
}
