/* ระบบตัวชี้วัดแผนยุทธศาสตร์ — ใช้ token เดียวกับ hr-theme.css */
:root {
  --sp-teal: #0d7377;
  --sp-info: #0f4c5c;
  --sp-good-bg: #e6f4ea;
  --sp-good: #1e7b34;
  --sp-ok-bg: #e8f1f8;
  --sp-ok: #002d56;
  --sp-warn-bg: #fff4e5;
  --sp-warn: #9a5b00;
  --sp-bad-bg: #fdecea;
  --sp-bad: #b42318;
  --sp-none-bg: #f1f3f5;
  --sp-none: #8592a3;
}

.sp-body [hidden] { display: none !important; }

html.hr-theme body.sp-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sp-system-switch {
  margin-left: auto;
  display: inline-flex;
  padding: 0.18rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.sp-system-switch a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}

.sp-system-switch a:hover,
.sp-system-switch a:focus-visible { color: #fff; background: rgba(255, 255, 255, 0.14); }

.sp-system-switch a.is-active {
  background: #fff;
  color: var(--hr-navy);
  font-weight: 600;
}

@media (max-width: 560px) {
  .sp-system-switch a { padding: 0.28rem 0.5rem; }
  .sp-system-switch a span { display: none; }
}

.sp-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sp-teal);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex: 0 0 auto;
}

.sp-infobar {
  background: var(--sp-info);
}

.sp-user-name {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .sp-user-name { display: none; }
}

.sp-user-menu {
  position: relative;
  z-index: 30;
}

.sp-user-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.15rem 0.35rem 0.15rem 0.15rem;
  list-style: none;
  border-radius: 999px;
  cursor: pointer;
}

.sp-user-menu > summary::-webkit-details-marker,
.sp-user-menu > summary::marker {
  display: none;
  content: "";
}

.sp-user-menu > summary:hover,
.sp-user-menu > summary:focus-visible,
.sp-user-menu[open] > summary {
  background: #e8f1f8;
  color: var(--hr-navy);
}

.sp-user-menu > summary:focus-visible {
  outline: none;
  box-shadow: var(--hr-focus);
}

.sp-user-menu > summary .bx-chevron-down {
  font-size: 1.05rem;
  color: var(--hr-muted);
}

.sp-user-menu[open] > summary .hr-user-avatar {
  box-shadow: 0 0 0 2px var(--hr-navy);
}

.sp-user-menu-panel {
  position: absolute;
  z-index: 31;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 12.5rem;
  padding: 0.35rem;
  background: var(--hr-surface);
  border: 1px solid var(--hr-border);
  border-radius: var(--hr-radius-sm);
  box-shadow: var(--hr-shadow);
}

.sp-user-menu-panel a,
.sp-user-menu-panel button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 40px;
  padding: 0.35rem 0.7rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--hr-ink);
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-size: 0.86rem;
  white-space: nowrap;
  cursor: pointer;
}

.sp-user-menu-panel a i,
.sp-user-menu-panel button i { font-size: 1.05rem; color: var(--hr-muted); }

.sp-user-menu-panel a:hover,
.sp-user-menu-panel a:focus-visible,
.sp-user-menu-panel a.is-active,
.sp-user-menu-panel button:hover,
.sp-user-menu-panel button:focus-visible {
  background: #e8f1f8;
  color: var(--hr-navy);
}

.sp-user-menu-panel a.is-active { font-weight: 600; }

.sp-main {
  flex: 1 0 auto;
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
  padding: 1.5rem 0 3rem;
}

.sp-main--wide {
  width: min(1360px, calc(100% - 2rem));
}

.sp-nav-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  margin: 0 0 1.25rem;
}

.sp-nav {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.35rem;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.1rem;
}

.sp-nav::-webkit-scrollbar { display: none; }

.sp-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  color: var(--hr-muted);
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
}

.sp-nav a:hover,
.sp-nav a.is-active {
  background: #e8f1f8;
  color: var(--hr-navy);
  font-weight: 600;
}

.sp-nav a i { font-size: 1rem; opacity: 0.85; }

.sp-nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.15rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #c2410c;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.sp-user-menu-panel a .sp-nav-count,
.sp-nav-menu-panel a .sp-nav-count { margin-left: auto; }

/* ป้ายบอกว่าเมนูนี้สำหรับใคร (ผู้กรอก / admin) */
.sp-nav-tag {
  display: inline-flex;
  align-items: center;
  height: 1.15rem;
  margin-left: 0.1rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
}
.sp-nav-tag.is-filler { background: #e6f6f3; border-color: #9fd9cd; color: #0f766e; }
.sp-nav-tag.is-admin { background: var(--sp-bad); border-color: var(--sp-bad); color: #fff; }

.sp-nav-menu {
  position: relative;
  flex: 0 0 auto;
  z-index: 30;
}

.sp-nav-menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  color: var(--hr-muted);
  font-size: 0.875rem;
  white-space: nowrap;
  list-style: none;
  cursor: pointer;
}

.sp-nav-menu > summary::-webkit-details-marker,
.sp-nav-menu > summary::marker {
  display: none;
  content: "";
}

.sp-nav-menu > summary:hover,
.sp-nav-menu > summary:focus-visible,
.sp-nav-menu[open] > summary,
.sp-nav-menu > summary.is-active {
  background: #e8f1f8;
  color: var(--hr-navy);
  font-weight: 600;
}

.sp-nav-menu > summary:focus-visible {
  outline: none;
  box-shadow: var(--hr-focus);
}

.sp-nav-menu > summary .bx-chevron-down {
  font-size: 1.05rem;
}

.sp-nav-menu-panel {
  position: absolute;
  z-index: 31;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 13.5rem;
  padding: 0.35rem;
  background: var(--hr-surface);
  border: 1px solid var(--hr-border);
  border-radius: var(--hr-radius-sm);
  box-shadow: var(--hr-shadow);
}

.sp-nav-menu-panel a,
.sp-nav-menu-panel button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 0.35rem 0.7rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--hr-ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.sp-nav-menu-panel a i,
.sp-nav-menu-panel button i { font-size: 1.05rem; color: var(--hr-muted); }

.sp-nav-menu-panel a:hover,
.sp-nav-menu-panel a:focus-visible,
.sp-nav-menu-panel a.is-active,
.sp-nav-menu-panel button:hover,
.sp-nav-menu-panel button:focus-visible,
.sp-nav-menu-panel button.is-active {
  background: #e8f1f8;
  color: var(--hr-navy);
}

.sp-nav-menu-panel a.is-active,
.sp-nav-menu-panel button.is-active { font-weight: 600; }

.sp-nav-rule {
  height: 0;
  margin: 0.3rem 0.45rem;
  border-top: 1px solid var(--hr-border);
}

.hr-nav-sheet .sp-nav-rule {
  margin: 0.45rem 0.15rem;
}

.sp-body .hr-titlebar { position: relative; z-index: 40; }
.sp-admin-menu { margin-right: 0.15rem; }

.sp-dev-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0.15rem 0 0;
  padding: 0.42rem 0.8rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--hr-muted);
  font: inherit;
  font-size: 0.875rem;
  white-space: nowrap;
  cursor: pointer;
}

.sp-dev-link:hover,
.sp-dev-link:focus-visible,
.sp-dev-link.is-active {
  background: #e8f1f8;
  color: var(--hr-navy);
  font-weight: 600;
}

.sp-dev-link:focus-visible {
  outline: none;
  box-shadow: var(--hr-focus);
}

@media (max-width: 760px) {
  .sp-admin-menu,
  .sp-dev-link { display: none; }
}

.offcanvas.sp-admin-panel {
  --bs-offcanvas-width: min(1120px, 100vw);
  width: min(1120px, 100vw) !important;
}

.offcanvas.sp-admin-panel .offcanvas-body {
  padding: 0;
  overflow: hidden;
}

#spAdminFrame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #f4f7fb;
}

body.sp-embed { background: #f4f7fb; }
body.sp-embed .sp-main { padding-top: 1rem; padding-bottom: 2rem; }

button.hr-nav-sheet-link {
  width: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.sp-dev-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  min-height: 32px;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--hr-border);
  border-radius: 999px;
  background: var(--hr-surface);
  color: var(--hr-navy);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.sp-dev-btn:hover,
.sp-dev-btn:focus-visible,
.sp-dev-btn.is-active {
  background: #e8f1f8;
  color: var(--hr-navy);
  outline: none;
}

.sp-dev-btn:focus-visible { box-shadow: var(--hr-focus); }

.sp-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  margin-bottom: 0;
  padding-bottom: 1.25rem;
  background: var(--hr-bg);
}

.sp-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--hr-navy);
}

.sp-lead {
  margin: 0.25rem 0 0;
  color: var(--hr-muted);
  font-size: 0.9rem;
  line-height: 1.55;
  max-width: 72ch;
}

.sp-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.sp-year-picker { margin: 0; }
.sp-year-picker .form-select { min-width: 11rem; }

.sp-card {
  background: var(--hr-surface);
  border-radius: var(--hr-radius);
  box-shadow: var(--hr-shadow-sm);
  padding: 1.25rem 1.3rem;
}

.sp-card + .sp-card,
.sp-stack > * + * { margin-top: 1rem; }

.sp-section { margin-top: 1.75rem; }

.sp-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--hr-ink-strong);
}

.sp-section-title small {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--hr-muted);
}

/* หน้ากลุ่มงาน/ประเภท: แถบเลือกประเภทตรึงด้านบน ไม่เลื่อนตามรายการ */
.sp-catalog-bar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  margin: 0 0 1rem;
  padding: 0.65rem 0 0.75rem;
  background: var(--hr-bg);
}
body.sp-embed .sp-catalog-bar {
  position: sticky;
  top: 0;
  margin: -1rem -1rem 1rem;
  padding: 0.7rem 1rem;
  background: var(--hr-surface);
  border-bottom: 1px solid var(--hr-border);
}
.sp-catalog-bar .btn-group { flex: 0 0 auto; }
.sp-catalog-bar .btn-group .btn { min-width: 6.25rem; }
.sp-catalog-search-field { position: relative; flex: 1 1 14rem; max-width: none; }
.sp-catalog-count {
  margin-left: auto;
  color: var(--hr-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}
.sp-catalog-search-field i {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  transform: translateY(-50%);
  color: var(--hr-muted);
  font-size: 1.1rem;
  pointer-events: none;
}
.sp-catalog-search-field .form-control { padding-left: 2.3rem; }

.sp-catalog-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.sp-catalog-card {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.9rem 1rem;
  background: var(--hr-surface);
  border-radius: var(--hr-radius);
  box-shadow: var(--hr-shadow-sm);
}

.sp-catalog-card-main { min-width: 0; flex: 1 1 auto; }

.sp-catalog-card-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--hr-ink-strong);
}

.sp-catalog-card-nick {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--hr-muted);
}

.sp-catalog-card-use {
  flex: 0 0 auto;
  color: var(--hr-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.sp-catalog-card .btn { flex: 0 0 auto; }

.sp-muted { color: var(--hr-muted); }
.sp-small { font-size: 0.82rem; }
.sp-xs { font-size: 0.75rem; }

.sp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  gap: 0.75rem;
}

.sp-stat {
  background: var(--hr-surface);
  border-radius: var(--hr-radius);
  box-shadow: var(--hr-shadow-sm);
  padding: 0.95rem 1rem;
}

.sp-stat-label {
  font-size: 0.78rem;
  color: var(--hr-muted);
  margin: 0 0 0.25rem;
}

.sp-stat-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--hr-navy);
  line-height: 1.2;
}

.sp-stat-sub {
  font-size: 0.75rem;
  color: var(--hr-muted);
  margin-top: 0.2rem;
}

.sp-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.sp-chip i { font-size: 0.85rem; }
.sp-chip.is-done { background: var(--sp-good-bg); color: var(--sp-good); }
.sp-chip.is-na { background: var(--sp-none-bg); color: #5c6b7a; }
.sp-chip.is-pending { background: var(--sp-warn-bg); color: var(--sp-warn); }
.sp-chip.is-missing { background: var(--sp-bad-bg); color: var(--sp-bad); }
.sp-chip.is-off { background: transparent; color: var(--sp-none); font-weight: 500; }
.sp-chip.is-lock { background: #eef1f6; color: #3d4b5c; }
.sp-chip.is-info { background: var(--sp-ok-bg); color: var(--sp-ok); }

.sp-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
}

.sp-score.is-good { background: var(--sp-good-bg); color: var(--sp-good); }
.sp-score.is-ok { background: var(--sp-ok-bg); color: var(--sp-ok); }
.sp-score.is-warn { background: var(--sp-warn-bg); color: var(--sp-warn); }
.sp-score.is-bad { background: var(--sp-bad-bg); color: var(--sp-bad); }
.sp-score.is-none { background: var(--sp-none-bg); color: var(--sp-none); }
.sp-score.is-override { box-shadow: inset 0 0 0 2px #e91e63; }

.sp-flag {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.3rem;
  color: var(--sp-warn);
  font-size: 0.78rem;
  line-height: 1.45;
}

.sp-flag i { font-size: 0.95rem; margin-top: 0.05rem; }

.sp-flag-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #f5a623;
  vertical-align: middle;
}

.sp-override-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #e91e63;
  vertical-align: middle;
}

/* รายการตัวชี้วัด */
.sp-plan-block + .sp-plan-block { margin-top: 1.5rem; }

.sp-plan-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.sp-plan-no {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--hr-navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sp-plan-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--hr-ink-strong);
  line-height: 1.45;
}

.sp-plan-meta { margin: 0.1rem 0 0; font-size: 0.78rem; color: var(--hr-muted); }

.sp-kpi-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.sp-kpi-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--hr-surface);
  border-radius: var(--hr-radius);
  box-shadow: var(--hr-shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.15s ease;
}

.sp-kpi-item:hover {
  box-shadow: 0 0 0 2px #b7d4ea, var(--hr-shadow-sm);
}

/* รายการที่เพิ่งเปิด offcanvas/modal — อยู่ 5 วินาที */
.sp-kpi-item.sp-row-hl,
.svp-child.sp-row-hl,
.sp-plan-head.sp-row-hl,
.svp-section-head.sp-row-hl {
  position: relative;
  outline: 2px solid #f59e0b;
  outline-offset: -2px;
  background-color: #fffbeb;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
  transition: none;
  animation: sp-row-hl 1.6s ease-out 1;
}
.sp-row-hl { scroll-margin: 6rem; }
tr.sp-row-hl > td,
tr.sp-row-hl > th {
  background-color: #fffbeb;
  box-shadow: inset 0 2px 0 #f59e0b, inset 0 -2px 0 #f59e0b;
  animation: sp-row-hl-cell 1.6s ease-out 1;
}
tr.sp-row-hl > :first-child {
  box-shadow: inset 0 2px 0 #f59e0b, inset 0 -2px 0 #f59e0b, inset 5px 0 0 #f59e0b;
}
tr.sp-row-hl > :last-child {
  box-shadow: inset 0 2px 0 #f59e0b, inset 0 -2px 0 #f59e0b, inset -2px 0 0 #f59e0b;
}
@keyframes sp-row-hl {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.65); }
  35% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0.25); }
  100% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18); }
}
@keyframes sp-row-hl-cell {
  0%, 45% { background-color: #fde68a; }
  100% { background-color: #fffbeb; }
}
@media (prefers-reduced-motion: reduce) {
  .sp-kpi-item.sp-row-hl,
  .svp-child.sp-row-hl,
  .sp-plan-head.sp-row-hl,
  .svp-section-head.sp-row-hl,
  tr.sp-row-hl > td,
  tr.sp-row-hl > th { animation: none; }
}

.sp-kpi-main {
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.sp-kpi-main:hover .sp-kpi-name,
.sp-kpi-main:focus-visible .sp-kpi-name { color: var(--hr-navy); }

.sp-owner-list {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem 0.55rem;
}

.sp-owner-name {
  font-weight: 600;
  color: var(--hr-navy);
}

.sp-owner-group {
  font-weight: 500;
  color: var(--hr-muted);
}

.sp-owner-btn {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--hr-navy);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
}

.sp-owner-btn:hover,
.sp-owner-btn[aria-expanded="true"] { text-decoration-style: solid; }

.sp-owner-btn:focus-visible {
  outline: 2px solid var(--hr-navy);
  outline-offset: 2px;
  border-radius: 4px;
}

/* boxicons ชุดที่ใช้อยู่ไม่มี bxl-line */
.bx.bxl-line::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.48 2 2 6.02 2 10.5c0 4.13 3.66 7.6 8.63 8.22.34.07.8.22.92.51.1.26.07.67.03 1.04l-.15 1.02c-.05.28-.22 1.1.96.6 1.18-.5 6.37-3.75 8.7-6.42C22.76 13.74 24 12.2 24 10.5 24 6.02 17.52 2 12 2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.48 2 2 6.02 2 10.5c0 4.13 3.66 7.6 8.63 8.22.34.07.8.22.92.51.1.26.07.67.03 1.04l-.15 1.02c-.05.28-.22 1.1.96.6 1.18-.5 6.37-3.75 8.7-6.42C22.76 13.74 24 12.2 24 10.5 24 6.02 17.52 2 12 2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.dropdown-item .bxl-line { color: #06c755; }
.dropdown-item:disabled .bxl-line { color: inherit; }

.sp-line-icon { color: #06c755; font-size: 1.05em; }

.sp-owner .dropdown-menu {
  min-width: 11rem;
  padding: 0.35rem;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
}

.sp-owner .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  border-radius: 8px;
  font-weight: 600;
}

a.sp-qcell {
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
}

button.sp-fill-btn {
  display: inline-block;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

button.sp-fill-btn:hover,
button.sp-fill-btn:focus-visible {
  box-shadow: 0 0 0 2px currentColor;
  outline: none;
}

.sp-kpi-item.is-inactive { opacity: 0.6; }

.sp-kpi-code {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--hr-navy);
  background: #e8f1f8;
  border-radius: 6px;
  padding: 0.05rem 0.4rem;
  margin-right: 0.35rem;
}

.sp-kpi-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--hr-ink-strong);
  line-height: 1.45;
}

.sp-kpi-meta {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--hr-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.85rem;
}

.sp-kpi-quarters {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 0.35rem;
  justify-content: end;
}

.sp-qcell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 4.6rem;
}

.sp-qcell-label { font-size: 0.68rem; color: var(--hr-muted); }

.sp-kpi-item.has-menu {
  position: relative;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem 0.75rem;
}

.sp-kpi-menu .dropdown-menu,
.sp-stat-menu .dropdown-menu { min-width: 12rem; }

.sp-plan-head .sp-kpi-menu { flex: 0 0 auto; margin-top: -0.25rem; }

.sp-stat.has-menu { position: relative; }
.sp-stat.has-menu .sp-stat-label { padding-right: 1.75rem; }
.sp-stat-menu { position: absolute; top: 0.4rem; right: 0.35rem; }

details.sp-section > summary { cursor: pointer; }

@media (max-width: 760px) {
  .sp-kpi-item { grid-template-columns: 1fr; }
  .sp-kpi-item.has-menu { grid-template-columns: 1fr; }
  .sp-kpi-item.has-menu .sp-kpi-main { padding-right: 2rem; }
  .sp-kpi-item > .sp-kpi-menu { position: absolute; top: 0.45rem; right: 0.35rem; }
  .sp-kpi-quarters { justify-content: start; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .sp-qcell { min-width: 0; }
}

/* หน้ากรอกข้อมูล */
.sp-kpi-head {
  display: grid;
  gap: 1rem;
}

@media (min-width: 900px) {
  .sp-kpi-head { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
}

.sp-def {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 0.4rem 0.85rem;
  margin: 0;
  font-size: 0.88rem;
}

.sp-def dt { color: var(--hr-muted); font-weight: 500; }
.sp-def dd { margin: 0; color: var(--hr-ink); }

@media (max-width: 520px) {
  .sp-def { grid-template-columns: 1fr; gap: 0.1rem; }
  .sp-def dd { margin-bottom: 0.45rem; }
}

.sp-bands {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.sp-bands td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--hr-border);
}

.sp-bands tr:last-child td { border-bottom: 0; }
.sp-bands td:first-child { width: 3rem; }

.sp-qgrid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 900px) {
  .sp-qgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.sp-qcard {
  background: var(--hr-surface);
  border-radius: var(--hr-radius);
  box-shadow: var(--hr-shadow-sm);
  padding: 1.1rem 1.15rem 1.2rem;
  border-top: 3px solid transparent;
}

.sp-qcard.is-current { border-top-color: var(--hr-navy); }
.sp-qcard.is-locked { background: #fafbfc; }

.sp-qcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.sp-qcard-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--hr-ink-strong);
}

.sp-qcard .form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #3d4b5c;
  margin-bottom: 0.25rem;
}

.sp-qcard .form-text { font-size: 0.75rem; }

.sp-score-preview {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--hr-radius-sm);
  background: #f7f9fb;
  font-size: 0.85rem;
}

.sp-override-box {
  margin-top: 0.85rem;
  padding: 0.75rem;
  border: 1px dashed #f3b6c9;
  border-radius: var(--hr-radius-sm);
  background: #fff8fb;
}

.sp-status-toggle .btn { font-size: 0.82rem; }

.sp-meta-line {
  margin-top: 0.65rem;
  font-size: 0.74rem;
  color: var(--hr-muted);
}

/* รายงาน */
.sp-table-wrap {
  position: relative;
  overflow-x: auto;
  background: var(--hr-surface);
  border-radius: var(--hr-radius);
  box-shadow: var(--hr-shadow-sm);
}

.sp-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
  min-width: 1080px;
}

.sp-table th,
.sp-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--hr-border);
  vertical-align: top;
}

.sp-table thead th {
  background: #f7f9fb;
  color: #3d4b5c;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.sp-table thead tr:first-child th { border-bottom-color: #e9edf2; }

.sp-table .sp-col-kpi {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  min-width: 18rem;
  max-width: 26rem;
  box-shadow: 1px 0 0 var(--hr-border);
}

.sp-table thead .sp-col-kpi { background: #f7f9fb; z-index: 2; }
.sp-table .sp-q-start { border-left: 1px solid var(--hr-border); }
.sp-table .sp-col-unit { min-width: 9rem; }
.sp-table td.num { text-align: center; white-space: nowrap; }
.sp-table td.res { min-width: 6.5rem; max-width: 10rem; }
.sp-table tr.sp-row-total td { background: #f7f9fb; font-weight: 600; }
.sp-table tr.sp-row-total .sp-col-kpi { background: #f7f9fb; }
.sp-table tr.sp-row-avg td { background: #eef5fb; font-weight: 700; color: var(--hr-navy); }
.sp-table tr.sp-row-avg .sp-col-kpi { background: #eef5fb; }
.sp-table tr:last-child td { border-bottom: 0; }

.sp-res-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.sp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  font-size: 0.78rem;
  color: var(--hr-muted);
  margin: 0.75rem 0 0;
}

.sp-summary-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

/* ผู้ใช้ */
.sp-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(15, 34, 58, 0.08);
}

.sp-avatar--text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8f1f8;
  color: var(--hr-navy);
  font-weight: 700;
  font-size: 0.85rem;
}

.sp-avatar.is-lg { width: 48px; height: 48px; font-size: 1.05rem; }

.sp-profile-head { align-items: flex-start; margin-bottom: 1rem; }
.sp-profile-head .sp-person-name { font-size: 1rem; }
.sp-profile-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 220px;
  margin: -1.1rem -1.25rem 1rem;
  background: #f7f9fb;
}
.sp-profile-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  margin: 0;
  overflow: hidden;
  background: #e8eef5;
}
.sp-profile-cover img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 280px;
  object-fit: contain;
  object-position: center;
}
.sp-profile-hero-name {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
  padding: 1rem 1.15rem;
}
.sp-profile-hero-name .sp-person-name {
  font-size: 1.2rem;
  line-height: 1.35;
}

.sp-profile-title {
  margin: 0.25rem 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--hr-navy);
}

.sp-profile + .sp-profile-title { margin-top: 1.15rem; }

.sp-duty {
  margin-top: 1.35rem;
  padding-top: 1.05rem;
  border-top: 1px solid var(--hr-border);
}

.sp-duty-title {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--hr-navy);
}

.sp-duty-group + .sp-duty-group { margin-top: 0.95rem; }

.sp-duty-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem;
  padding: 0.2rem 0 0.2rem 0.6rem;
  border-left: 3px solid var(--hr-navy);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--hr-ink-strong);
}

.sp-duty-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.15rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #e8f1f8;
  color: var(--hr-navy);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  vertical-align: 0.05em;
}

.sp-duty-name { min-width: 0; }

.sp-duty-gap {
  flex: 0 0 auto;
  padding: 0.05rem 0.45rem;
  font-size: 0.68rem;
}
button.sp-duty-gap {
  border: 0;
  cursor: pointer;
  line-height: inherit;
}

.sp-duty-miss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.15rem;
  margin-left: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--sp-bad-bg, #fdecec);
  color: var(--sp-bad, #c23b3b);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  vertical-align: 0.05em;
}

.sp-duty-empty { margin: 0 0 0.15rem; }

.sp-duty-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sp-duty-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--hr-border);
  font-size: 0.82rem;
  line-height: 1.45;
}

.sp-duty-list li:last-child { border-bottom: 0; padding-bottom: 0; }

.sp-duty-link {
  color: inherit;
  text-decoration: none;
}

.sp-duty-link:hover { color: var(--hr-navy); }

.sp-duty-code { font-weight: 700; margin-right: 0.3rem; }

.sp-duty-year { color: var(--hr-muted); margin-left: 0.3rem; }

.sp-profile {
  display: grid;
  gap: 0.7rem;
  margin: 0 0 0.25rem;
}

.sp-profile-row {
  display: grid;
  grid-template-columns: 7.25rem minmax(0, 1fr);
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--hr-border);
}

.sp-profile-row:last-child { border-bottom: 0; padding-bottom: 0; }

.sp-profile-row dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--hr-muted);
}

.sp-profile-row dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--hr-ink-strong);
  overflow-wrap: anywhere;
}

.sp-profile-row a { color: var(--hr-navy); }

@media (max-width: 420px) {
  .sp-profile-row { grid-template-columns: 1fr; gap: 0.1rem; }
}

.sp-prov {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.12rem 0.45rem 0.12rem 0.28rem;
  line-height: 1.2;
  margin: 0.1rem 0.25rem 0.1rem 0;
  vertical-align: middle;
}
.sp-prov .bx { font-size: 1.05rem; line-height: 1; }

.sp-prov.is-line { background: #06c755; color: #fff; }
.sp-prov.is-line .bx { color: #fff; }
.sp-prov.is-google { background: #fff; color: #3c4043; box-shadow: inset 0 0 0 1px #dadce0; }
.sp-prov.is-google .bx { color: #4285f4; }
.sp-prov.is-staff { background: #002d56; color: #fff; }
.sp-prov.is-staff .bx { color: #fff; }

.sp-member-login {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.sp-member-login .sp-prov { margin: 0; }

.sp-member-search { width: min(100%, 24rem); }
.sp-member-group + .sp-member-group { margin-top: 1.35rem; }
.sp-member-group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.7rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--hr-border);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--hr-navy);
}
.sp-member-rows { display: flex; flex-direction: column; gap: 0.85rem; }
.sp-member-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.sp-member-row .sp-person { align-items: flex-start; flex: 1 1 auto; }
.sp-member-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex: 0 0 auto;
}
.sp-member-actions { min-width: min(100%, 16rem); }
.sp-line-name,
.sp-google-name {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.15rem;
  font-weight: 600;
}
.sp-line-name { color: #06c755; }
.sp-google-name { color: #3c4043; }
.sp-google-name .bx { color: #4285f4; }
.sp-member-row[hidden],
.sp-member-group[hidden],
.sp-member-table tr[data-member-row][hidden],
.sp-member-table tbody[data-member-group][hidden] { display: none !important; }

.sp-member-table { min-width: 68rem; }
.sp-member-table .sp-gap-col,
.sp-member-table .sp-gap-cell {
  width: 8rem;
  text-align: center;
}
.sp-member-table .sp-gap-col { white-space: normal; line-height: 1.25; }
.sp-member-table thead th:first-child { text-align: left; }
.sp-member-table .sp-member-group-row th {
  background: #f7f9fb;
  text-align: left;
  color: var(--hr-navy);
  font-size: 0.95rem;
}
.sp-gap-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}
.sp-gap-cell.is-open .sp-gap-num { background: var(--sp-bad-bg); color: var(--sp-bad); }
.sp-gap-cell.is-done .sp-gap-num { background: var(--sp-good-bg); color: var(--sp-good); }
.sp-gap-cell.is-none .sp-gap-num { color: var(--hr-muted); font-weight: 500; background: transparent; }
button.sp-gap-num {
  border: 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}
button.sp-gap-num:hover { filter: brightness(0.96); }
button.sp-gap-num:focus-visible { outline: 2px solid #002d56; outline-offset: 2px; }
.offcanvas.member-fill { width: min(1500px, 100vw) !important; }
.offcanvas.member-fill .offcanvas-header { align-items: flex-start; }
.offcanvas.member-fill .offcanvas-title { line-height: 1.45; }
.member-fill-switch { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.member-fill-switch button {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid #e6ebf1;
  border-radius: 10px;
  background: #fff;
  color: #1f2a37;
  font-weight: 600;
  text-align: left;
}
.member-fill-switch button.is-on { border-color: #002d56; background: #e8f1f8; color: #002d56; }
.member-fill-no {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #fdecea;
  color: #c2413b;
  font-size: 0.75rem;
}
.member-fill-switch button.is-on .member-fill-no { background: #002d56; color: #fff; }
.member-ql-form { display: flex; flex-direction: column; gap: 0.75rem; }
.member-ql-year { display: grid; gap: 0.35rem; padding: 0.75rem; border: 1px solid #e6ebf1; border-radius: 12px; }
.member-ql-year.is-focus { border-color: #b9cfe3; background: #f4f8fb; }
.member-ql-year h3 { margin: 0; font-size: 0.95rem; }
#memberFill .svp-grid-wrap { overflow-x: auto; }
html.hr-theme .tooltip.hr-tooltip .tooltip-inner {
  white-space: pre-line;
  text-align: left;
}
.sp-member-table .sp-member-tools { align-items: flex-end; }
.sp-member-table .sp-member-actions { min-width: min(100%, 14rem); }

@media (max-width: 760px) {
  section.sp-card:has(.sp-member-table) {
    padding: 0;
    background: transparent;
    box-shadow: none;
  }

  .sp-table-wrap:has(.sp-member-table) {
    overflow: visible;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
  }

  .sp-member-table {
    min-width: 0;
  }

  .sp-member-table,
  .sp-member-table tbody {
    display: block;
  }

  .sp-member-table thead,
  .sp-member-table caption {
    display: none;
  }

  .sp-member-table tr.sp-member-group-row {
    display: block;
    margin: 0.85rem 0 0;
  }

  .sp-member-table tr.sp-member-group-row th {
    display: block;
    padding: 0.2rem 0 0.15rem;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .sp-member-table tr[data-member-row] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.12rem 0.85rem;
    margin: 0;
    padding: 0.7rem 0 0.6rem;
    border: 0;
    border-bottom: 1px solid var(--hr-border);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .sp-member-table tr[data-member-row] > td {
    display: block;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .sp-member-table tr[data-member-row] > td:first-child,
  .sp-member-table tr[data-member-row] > td:last-child {
    grid-column: 1 / -1;
  }

  .sp-member-table tr[data-member-row] > td.sp-gap-cell {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.35rem;
    width: auto;
    padding: 0.05rem 0;
    border-radius: 0;
    background: transparent;
    text-align: left;
  }

  .sp-member-table td.sp-gap-cell[data-label]::before {
    content: attr(data-label);
    display: block;
    margin: 0;
    color: var(--hr-muted);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.3;
  }

  .sp-member-table tr[data-member-row] { position: relative; }
  .sp-member-table .sp-person { align-items: flex-start; }
  .sp-member-table .sp-person-sub {
    overflow: visible;
    white-space: normal;
    text-overflow: unset;
  }

  .sp-member-table tr[data-member-row]:not(:has(.sp-member-actions)) > td:first-child {
    padding-right: 2.1rem;
  }

  .sp-member-table tr[data-member-row]:not(:has(.sp-member-actions)) > td:last-child {
    position: absolute;
    top: 0.45rem;
    right: 0.35rem;
    width: auto;
    margin: 0;
    grid-column: auto;
    grid-row: 1;
  }

  .sp-member-table tr[data-member-row]:not(:has(.sp-member-actions)) .sp-member-tools {
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    align-items: flex-end;
  }

  .sp-member-table tr[data-member-row]:has(.sp-member-actions) .sp-member-tools {
    align-items: stretch;
    width: 100%;
    margin-top: 0.15rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--hr-border);
  }

  .sp-member-table .sp-member-actions {
    width: 100%;
    min-width: 0;
  }

  .sp-member-table .sp-member-actions > .d-flex {
    flex-wrap: wrap;
  }

  .sp-member-table .sp-member-actions .btn {
    flex: 1 1 7rem;
  }
}

.sp-member-photo {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  line-height: 0;
  cursor: zoom-in;
}
.sp-member-photo:focus-visible {
  outline: 2px solid var(--hr-navy);
  outline-offset: 2px;
}

.sp-member-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--hr-border);
}
.sp-member-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--hr-muted);
  font-weight: 700;
  line-height: 1.3;
}
.sp-member-tab small { font-weight: 600; opacity: 0.75; }
.sp-member-tab.is-on {
  color: var(--hr-navy);
  background: #fff;
  border-bottom-color: var(--hr-navy);
}
.sp-member-tab:focus-visible { outline: 2px solid #002d56; outline-offset: 2px; }
[data-member-pane][hidden] { display: none !important; }

.sp-wg { content-visibility: auto; contain-intrinsic-size: auto 32rem; }
.sp-wg[hidden] { display: none !important; }
.sp-wg-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.sp-wg-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--hr-navy);
}
.sp-wg-foot {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--hr-border);
}
.sp-wg-foot-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.55rem;
}
.sp-wg-kicker {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--hr-ink-strong);
}
.sp-wg-foot-head .sp-wg-kicker { margin: 0; }
.sp-wg-add {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin: 0;
  padding: 0.15rem 0.4rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--hr-muted);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
}
.sp-wg-add .bx { font-size: 1rem; }
.sp-wg-add:hover { color: var(--hr-navy); background: #f4f7fb; }
.sp-wg-add:focus-visible { outline: 2px solid #002d56; outline-offset: 2px; }
.sp-wg-people {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.sp-wg-person {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 100%;
  padding: 0.28rem 0.7rem 0.28rem 0.28rem;
  border: 1px solid var(--hr-border);
  border-radius: 999px;
  background: #fff;
}
.sp-wg-person .sp-person-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}
.sp-wg-cats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.sp-wg-cat {
  min-width: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--hr-border);
  border-radius: 12px;
  background: #f8fafc;
}
.sp-wg-cat h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.55rem;
  font-size: 0.92rem;
}
.sp-wg-cat h4 small { font-weight: 600; color: var(--hr-muted); }
.sp-wg-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.sp-wg-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  background: #fff;
}
.sp-wg-item.is-open { background: var(--sp-bad-bg); }
.sp-wg-name { min-width: 0; font-size: 0.84rem; line-height: 1.4; }
.sp-wg-item .btn,
.sp-wg-item .sp-chip { flex: 0 0 auto; }
@media (max-width: 800px) {
  #memberGroupsPane {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
  }
  #memberGroupsPane > .sp-wg.sp-card {
    margin-top: 0;
    padding: 0;
    border: 1px solid var(--hr-border);
    border-radius: 16px;
    box-shadow: none;
    overflow: hidden;
  }
  .sp-wg-head { padding: 0.85rem 0.95rem 0.65rem; }
  .sp-wg-title { font-size: 1.02rem; }
  .sp-wg-cats {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 0;
  }
  .sp-wg-cat {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .sp-wg-cat + .sp-wg-cat { border-top: 1px solid var(--hr-border); }
  .sp-wg-cat h4 {
    margin: 0;
    padding: 0.55rem 0.95rem 0.2rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--hr-muted);
  }
  .sp-wg-cat > p { margin: 0; padding: 0.15rem 0.95rem 0.7rem; }
  .sp-wg-items { gap: 0; }
  .sp-wg-item {
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    padding: 0.7rem 0.95rem;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .sp-wg-item + .sp-wg-item { border-top: 1px solid #eef1f4; }
  .sp-wg-item.is-open { background: #fff7f6; }
  .sp-wg-item .btn {
    padding: 0.18rem 0.6rem;
    font-size: 0.78rem;
    border-radius: 999px;
  }
  .sp-wg-foot {
    margin: 0;
    padding: 0.7rem 0.95rem 0.85rem;
    border-top: 1px solid var(--hr-border);
    background: #fbfcfd;
  }
  .sp-wg-people {
    flex-wrap: nowrap;
    gap: 0.55rem;
    overflow-x: auto;
    padding-bottom: 0.1rem;
  }
  .sp-wg-person {
    flex: 0 0 auto;
    max-width: 16rem;
    border: 0;
    background: transparent;
    padding: 0.1rem 0.2rem 0.1rem 0;
  }
}

@media (min-width: 801px) {
  #memberGroupsPane > .sp-wg.sp-card {
    padding: 0;
    border: 1px solid var(--hr-border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 34, 58, 0.04), 0 10px 28px rgba(15, 34, 58, 0.05);
    overflow: hidden;
  }
  .sp-wg-head {
    align-items: center;
    padding: 1.05rem 1.25rem 0.95rem;
  }
  .sp-wg-title { font-size: 1.16rem; letter-spacing: -0.015em; }
  .sp-wg-head > p {
    margin: 0;
    padding: 0.22rem 0.65rem;
    border-radius: 999px;
    background: #f3f6f9;
    font-weight: 600;
  }
  .sp-wg-cats {
    gap: 0;
    margin-top: 0;
    border-top: 1px solid var(--hr-border);
  }
  .sp-wg-cat {
    padding: 0.95rem 1.2rem 1.05rem;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
  .sp-wg-cat:nth-child(odd) { border-right: 1px solid var(--hr-border); }
  .sp-wg-cat:nth-child(n + 3) { border-top: 1px solid var(--hr-border); }
  .sp-wg-cat h4 {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--hr-muted);
  }
  .sp-wg-items { gap: 0.1rem; }
  .sp-wg-item {
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.4rem;
    border-radius: 8px;
    background: transparent;
  }
  .sp-wg-item.is-open { background: #fff6f5; }
  .sp-wg-name { font-size: 0.9rem; line-height: 1.45; }
  .sp-wg-item .btn {
    padding: 0.22rem 0.75rem;
    border-radius: 999px;
    font-size: 0.78rem;
  }
  .sp-wg-foot {
    margin: 0;
    padding: 0.9rem 1.25rem 1.05rem;
    border-top: 1px solid var(--hr-border);
    background: #fbfcfd;
  }
  .sp-wg-kicker {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--hr-muted);
  }
  .sp-wg-person {
    border-color: transparent;
    background: transparent;
  }
}

.sp-person {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.sp-person-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--hr-ink-strong);
  line-height: 1.35;
}

.sp-person-sub {
  font-size: 0.74rem;
  color: var(--hr-muted);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-owner-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sp-owner-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.3rem 0.2rem 0.25rem;
  border-radius: 999px;
  background: #f3f6f9;
  font-size: 0.8rem;
  max-width: 100%;
}

.sp-owner-chip .sp-avatar { width: 24px; height: 24px; font-size: 0.7rem; }

.sp-owner-chip button {
  border: 0;
  background: transparent;
  color: #8592a3;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.sp-owner-chip button:hover { background: #e4e8ee; color: var(--sp-bad); }

.sp-picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.sp-picker-label {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--hr-muted, #6c7a89);
}

.sp-picker-list.is-compact {
  max-height: 16rem;
  overflow: auto;
  margin-top: 0.55rem;
}

.sp-picker-item {
  width: 100%;
  text-align: start;
  border: 1px solid #e8edf5;
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.6rem 0.7rem;
}
.sp-picker-row {
  display: flex;
  align-items: stretch;
  border: 1px solid #e8edf5;
  border-radius: 0.75rem;
  background: #fff;
}
.sp-picker-row.is-selected { border-color: #b7e4c7; background: #f3fbf6; }
.sp-picker-row:hover { border-color: #b7d4ea; }
.sp-picker-row > .sp-picker-item {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
}
.sp-picker-row > .sp-picker-item:hover,
.sp-picker-row > .sp-picker-item:focus-visible { background: transparent; }
.sp-picker-kebab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  margin: 0 0.35rem 0 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #5c6b7a;
  cursor: pointer;
}
.sp-picker-kebab:hover,
.sp-picker-kebab[aria-expanded="true"] { background: #e8eef5; color: #1e3a5f; }
.sp-picker-float {
  position: fixed;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  min-width: 10.5rem;
  margin: 0;
  padding: 0.3rem;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(16, 36, 64, 0.16);
}
.sp-picker-float[hidden] { display: none; }
.sp-picker-float .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.65rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.88rem;
  text-align: start;
  cursor: pointer;
}
.sp-picker-float .dropdown-item:hover,
.sp-picker-float .dropdown-item:focus-visible { background: #eef5fb; outline: none; }

.sp-picker-item:hover,
.sp-picker-item:focus-visible { border-color: #b7d4ea; background: #f7fbfe; }
.sp-picker-item.is-selected { border-color: #b7e4c7; background: #f3fbf6; opacity: 1; cursor: default; }
.sp-picker-item:disabled { opacity: 0.6; }

.sp-unit { position: relative; }
.sp-unit-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 0.375rem 0.75rem;
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  background: #fff;
  color: var(--hr-ink, #1f2d3d);
  font: inherit;
  font-size: 1rem;
  line-height: 1.5;
  text-align: start;
  cursor: pointer;
}
.sp-unit-btn.is-placeholder { color: #6c757d; }
.sp-unit-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-unit-btn > i { flex: none; color: #6c757d; font-size: 1.15rem; transition: transform 0.15s ease; }
.sp-unit-btn[aria-expanded="true"] { border-color: #86b7fe; box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15); }
.sp-unit-btn[aria-expanded="true"] > i { transform: rotate(180deg); }
.sp-unit-btn:focus-visible { outline: none; border-color: #86b7fe; box-shadow: var(--hr-focus); }
.sp-unit-pop {
  width: 20rem;
  background: #fff;
  border: 0;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 36, 64, 0.16);
  overflow: hidden;
}
.sp-unit-search {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.75rem;
  background: #f7fafc;
  border-bottom: 1px solid #e7eef5;
}
.sp-unit-search > i { color: #6c7a89; font-size: 1.05rem; }
.sp-unit-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 0.9rem;
  color: inherit;
}
.sp-unit-search input:focus { outline: none; }
.sp-unit-list { max-height: 16rem; overflow: auto; padding: 0.35rem; }
.sp-unit-opt {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
  text-align: start;
  white-space: normal;
  cursor: pointer;
}
.sp-unit-opt:hover,
.sp-unit-opt.is-active { background: #eef5fb; }
.sp-unit-opt.is-selected { background: #e7f1fb; font-weight: 600; color: #1e3a5f; }
.sp-unit-empty { margin: 0; padding: 0.7rem 0.6rem; color: #6c7a89; font-size: 0.82rem; }

#catalogRows [data-delete]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#userEdit .select2-container { width: 100% !important; }
#userEdit .select2-container--default .select2-selection--single {
  min-height: 38px;
  border: 1px solid var(--hr-border, #d9e2ec);
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
}
#userEdit .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  padding-left: 0.75rem;
  color: inherit;
}
#userEdit .select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; }
#userEdit .select2-dropdown { border-color: var(--hr-border, #d9e2ec); }
#userEdit .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--hr-border, #d9e2ec);
  border-radius: 0.375rem;
  min-height: 36px;
  padding: 0.25rem 0.6rem;
}
#userEdit .select2-results__option { white-space: normal; }
#userEdit .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: #002d56;
}

#memberEdit .select2-container { width: 100% !important; }
#memberEdit .select2-container--default .select2-selection--single {
  min-height: 42px;
  border: 1px solid #d5e0ea;
  border-radius: 10px;
  background: #f8fafc;
  display: flex;
  align-items: center;
}
#memberEdit .select2-container--default.select2-container--open .select2-selection--single,
#memberEdit .select2-container--default.select2-container--focus .select2-selection--single {
  border-color: #7aa2c4;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 45, 86, 0.12);
}
#memberEdit .select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 1.35;
  padding-left: 0.85rem;
  color: #1e3a5f;
  font-weight: 600;
}
#memberEdit .select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #7b8b9a;
  font-weight: 500;
}
#memberEdit .select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 40px;
}
#memberEdit .select2-dropdown {
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 4px;
  box-shadow: 0 12px 32px rgba(17, 24, 39, 0.14);
}
#memberEdit .select2-search--dropdown { padding: 0.55rem 0.55rem 0.2rem; }
#memberEdit .select2-search--dropdown .select2-search__field {
  border: 1px solid #d5e0ea;
  border-radius: 8px;
  min-height: 38px;
  padding: 0.35rem 0.75rem;
  background: #f8fafc;
}
#memberEdit .select2-search--dropdown .select2-search__field:focus {
  border-color: #7aa2c4;
  background: #fff;
  outline: none;
}
#memberEdit .select2-results__options { max-height: 16rem; padding-bottom: 0.35rem; }
#memberEdit .select2-results__option {
  white-space: normal;
  margin: 0.1rem 0.4rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  line-height: 1.4;
}
#memberEdit .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: #e8f1f8;
  color: #002d56;
}
#memberEdit .select2-container--default .select2-results__option--selected {
  background: #eef6fb;
  color: #002d56;
  font-weight: 700;
}
#memberEdit .select2-results__message {
  padding: 0.7rem 0.85rem;
  color: #6c7a89;
}

/* ฟอร์มผู้ดูแล */
.sp-admin-kpi {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid var(--hr-border);
}

.sp-admin-kpi:first-child { border-top: 0; }

.sp-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
}

.sp-icon-btn {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

@media (max-width: 640px) {
  .sp-admin-kpi { grid-template-columns: 1fr; }
  .sp-admin-actions { justify-content: flex-start; }
}

.sp-crit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (max-width: 520px) {
  .sp-crit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.sp-lock-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.sp-lock-item {
  border: 1px solid var(--hr-border);
  border-radius: var(--hr-radius-sm);
  padding: 0.75rem 0.85rem;
  background: #fff;
}

.sp-lock-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.88rem;
}

.sp-progress {
  height: 0.4rem;
  background: #eef1f6;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0 0.35rem;
}

.sp-progress > span {
  display: block;
  height: 100%;
  background: var(--sp-teal);
}

.sp-warn-box {
  padding: 0.75rem 0.9rem;
  border-radius: var(--hr-radius-sm);
  background: var(--hr-warn-bg);
  border: 1px solid var(--hr-warn-border);
  color: var(--hr-warn-ink);
  font-size: 0.86rem;
  line-height: 1.55;
}

.sp-info-box {
  padding: 0.75rem 0.9rem;
  border-radius: var(--hr-radius-sm);
  background: #eef5fb;
  color: #1f3b57;
  font-size: 0.86rem;
  line-height: 1.55;
}

.sp-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--hr-muted);
}

.sp-empty i { font-size: 2rem; color: #c4cdd8; display: block; margin-bottom: 0.5rem; }

/* หน้าเข้าสู่ระบบ */
.sp-login-grid {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 860px) {
  .sp-login-grid {
    grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.1fr);
    align-items: stretch;
  }
  .sp-login-grid > section:last-child {
    display: flex;
    flex-direction: column;
  }
  .sp-login-grid .sp-steps {
    flex: 1;
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
}

.sp-login-grid .hr-login-card {
  padding: 1.6rem 1.5rem 1.5rem;
}

.sp-login-grid .hr-login-title {
  margin: 0 0 1.15rem;
}

.sp-steps {
  display: grid;
  gap: 0.75rem;
}

.sp-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  align-items: start;
  background: var(--hr-surface);
  border-radius: var(--hr-radius);
  box-shadow: var(--hr-shadow-sm);
  padding: 1rem;
}

.sp-step-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--hr-navy);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sp-step h3 { margin: 0 0 0.15rem; font-size: 0.95rem; font-weight: 700; color: var(--hr-ink-strong); }
.sp-step p { margin: 0; font-size: 0.82rem; color: var(--hr-muted); line-height: 1.5; }

.sp-btn-staff {
  background: #fff;
  color: var(--hr-navy);
  border-color: #d7e0ea;
}

.sp-btn-staff:hover,
.sp-btn-staff:focus-visible { background: #f8fafc; color: var(--hr-navy); }

.sp-staff-form {
  padding: 0.9rem 0.95rem 1rem;
  border: 1px solid #d7e0ea;
  border-radius: var(--hr-radius-sm);
  background: #f8fafc;
}

.sp-staff-form .form-label { font-size: 0.82rem; margin-bottom: 0.25rem; }

.sp-history-item {
  padding: 0.75rem 0;
  border-top: 1px solid var(--hr-border);
}

.sp-history-item:first-child { border-top: 0; padding-top: 0; }

.sp-history-item.has-menu {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}

.sp-history-item.has-menu .sp-history-main {
  flex: 1 1 auto;
  min-width: 0;
}

.sp-history-item .hr-dev-menu {
  flex: 0 0 auto;
  margin-top: -0.15rem;
}

.sp-history-item .hr-dev-menu .dropdown-menu {
  min-width: 12.5rem;
}

.sp-diff {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
}

.sp-diff li { line-height: 1.5; }
.sp-diff .old { color: #8592a3; text-decoration: line-through; }
.sp-diff .new { color: var(--hr-ink-strong); font-weight: 600; }

.sp-footer {
  flex: 0 0 auto;
  text-align: center;
  padding: 1.25rem 1rem 1.5rem;
  color: var(--hr-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--hr-border);
  background: var(--hr-surface);
}

.sp-footer p { margin: 0; }

.offcanvas.sp-offcanvas { width: min(560px, 100vw) !important; }
.offcanvas.sp-offcanvas.sp-offcanvas-lg { width: min(1080px, 100vw) !important; }
.offcanvas.sp-offcanvas.sp-offcanvas-lg.is-all { width: min(1320px, 100vw) !important; }
.offcanvas.sp-offcanvas-lg.is-all .offcanvas-body {
  container-type: inline-size;
  container-name: spfill;
}
.offcanvas.sp-offcanvas .offcanvas-body { padding: 1.1rem 1.25rem 1.5rem; }
.offcanvas.sp-offcanvas .form-label { font-size: 0.82rem; font-weight: 600; color: #3d4b5c; }
.offcanvas.sp-offcanvas-lg .offcanvas-header { align-items: flex-start; }
.offcanvas.sp-offcanvas-lg .offcanvas-title { line-height: 1.45; }

.sp-fill-layout {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 840px) {
  .sp-fill-layout:not(.is-all) {
    grid-template-columns: minmax(16rem, 0.9fr) minmax(0, 1.15fr);
    align-items: start;
  }
}

@container spfill (min-width: 720px) {
  .sp-fill-layout.is-all {
    grid-template-columns: minmax(14rem, 17rem) minmax(0, 1fr);
    align-items: start;
  }

  .sp-fill-layout.is-all .sp-fill-side {
    position: sticky;
    top: 0;
  }
}

@container spfill (min-width: 980px) {
  .sp-fill-layout.is-all .sp-qgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.sp-fill-layout.is-all .sp-qcard {
  box-shadow: var(--hr-shadow-sm);
  padding: 1rem 1rem 1.05rem;
  background: var(--hr-surface);
}

.sp-fill-side {
  background: #f7f9fb;
  border-radius: var(--hr-radius);
  padding: 1rem 1.05rem 1.1rem;
}

.sp-fill-layout .sp-qcard {
  box-shadow: none;
  padding: 0;
  background: transparent;
}

.sp-title-short { display: none; }

.sp-tabbar { display: none; }

#sp-summary,
#sp-report { scroll-margin-top: 0.75rem; }

@media (max-width: 760px) {
  .sp-body .hr-infobar,
  .sp-body .hr-org-sub { display: none; }

  .sp-body .hr-crest { width: 36px; height: 36px; }

  .sp-body .hr-topbar { padding: 0.45rem 0.75rem; }

  .sp-body .hr-topbar-inner,
  .sp-body .hr-titlebar-inner { width: min(1120px, calc(100% - 1.25rem)); }

  .sp-body .hr-topbar-inner > div { min-width: 0; }

  .sp-body .hr-org-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sp-body .hr-titlebar-inner { min-height: 48px; gap: 0.5rem; }

  .sp-body .sp-badge { width: 30px; height: 30px; font-size: 1rem; }

  .sp-body .hr-product-title {
    min-width: 0;
    overflow: hidden;
    font-size: 0.95rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sp-body .sp-title-long { display: none; }
  .sp-body .sp-title-short { display: inline; }

  .sp-body .sp-system-switch a { padding: 0.28rem 0.45rem; }
  .sp-body .sp-system-switch a span { display: none; }

  .sp-main {
    width: min(1120px, calc(100% - 1.25rem));
    padding-top: 0.9rem;
  }

  .sp-page-head { padding-bottom: 0.85rem; }

  .sp-title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 1.05rem;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .sp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }

  .sp-kpi-name,
  .sp-plan-name,
  .svp-issue-title,
  .svp-group-title,
  .offcanvas.sp-offcanvas .offcanvas-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .sp-owner-btn,
  .sp-owner-name {
    max-width: 8.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sp-kpi-meta > span {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sp-qcell .sp-chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sp-table .sp-col-kpi { min-width: 9.5rem; max-width: 12rem; }

  .sp-table .sp-col-kpi a,
  .sp-table .sp-col-kpi > div:first-child {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  body.sp-body.has-tabbar {
    padding-bottom: calc(4.35rem + env(safe-area-inset-bottom, 0px));
  }

  body.sp-body.has-tabbar .sp-nav-bar,
  body.sp-body.has-tabbar .sp-footer { display: none; }

  body.sp-body.has-tabbar .sp-main { padding-bottom: 1rem; }

  body.sp-body.has-tabbar .devkit-fab {
    bottom: calc(5.35rem + env(safe-area-inset-bottom, 0px));
  }

  body.sp-body.has-tabbar .sp-help-fab {
    bottom: calc(5.35rem + env(safe-area-inset-bottom, 0px));
  }

  html:not(.devkit-off) body.sp-body.has-tabbar:has(.devkit-fab) .sp-help-fab,
  body.sp-body.has-tabbar:has(.sp-chat-fab) .sp-help-fab {
    bottom: calc(9.6rem + env(safe-area-inset-bottom, 0px));
  }

  html:not(.devkit-off) body.sp-body.has-tabbar:has(.devkit-fab):has(.sp-chat-fab) .sp-help-fab,
  body.sp-body.has-tabbar:has(.devkit-fab):has(.sp-chat-fab) .sp-help-fab {
    bottom: calc(13.85rem + env(safe-area-inset-bottom, 0px));
  }

  body.sp-body.has-tabbar .svp-savebar {
    bottom: calc(4.35rem + env(safe-area-inset-bottom, 0px));
  }

  .sp-tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1032;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    margin: 0;
    padding: 0.3rem 0.15rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
    scrollbar-width: none;
    background: #fff;
    border-top: 1px solid var(--hr-border);
    box-shadow: 0 -4px 16px rgba(15, 34, 58, 0.08);
  }

  .sp-tabbar::-webkit-scrollbar { display: none; }

  .sp-tabbar .hr-bottom-nav-item {
    flex: 1 0 auto;
    min-width: 4.4rem;
    max-width: 6.5rem;
  }

  .sp-tabbar .hr-bottom-nav-item[aria-expanded="true"] {
    color: var(--hr-navy);
    background: rgba(0, 45, 86, 0.06);
  }
}

@media print {
  .hr-chrome, .sp-nav-bar, .sp-nav, .sp-tabbar, .sp-head-actions, .sp-footer, .hr-feedback-fab, .sp-help-fab, #spGuide, #spAdminSheet { display: none !important; }
  .sp-main { width: 100%; padding: 0; }
  .sp-table-wrap { box-shadow: none; overflow: visible; }
}

.lf-facts { margin: 0 0 1rem; }
.lf-facts div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.5rem; padding: 0.55rem 0; border-bottom: 1px solid var(--hr-border); }
.lf-facts dt { margin: 0; color: var(--hr-muted); font-size: 0.82rem; }
.lf-facts dd { margin: 0; font-weight: 600; }

/* ---------------------------------------------------------------- ความคิดเห็นตัวชี้วัด (แชต) */

.sp-chat-name {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sp-chat-name:hover { color: var(--hr-navy); text-decoration: underline; }
.sp-chat-name:focus-visible,
.sp-chat-row:focus-visible { outline: none; box-shadow: var(--hr-focus); border-radius: 4px; }

.sp-chat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #e02424;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: 0.1em;
}
.sp-chat-badge[hidden] { display: none; }

.sp-chat-fab {
  position: fixed;
  z-index: 1030;
  right: 1.25rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  width: auto;
  min-width: 3.5rem;
  height: 3.5rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--hr-line);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(6, 120, 60, 0.3);
  cursor: pointer;
}
.sp-chat-fab:hover { background: var(--hr-line-hover); }
.sp-chat-fab:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 3px var(--hr-line); }
body:has(.devkit-fab) .sp-chat-fab { bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
.sp-chat-fab-badge {
  position: absolute;
  top: -0.2rem;
  right: -0.2rem;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #e02424;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
}
.sp-chat-fab-badge[hidden] { display: none; }

.offcanvas.sp-chat {
  --bs-offcanvas-width: 440px;
  display: flex;
  flex-direction: column;
  font-family: var(--hr-font);
}
.sp-chat-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: #0f1e45;
  color: #fff;
}
.sp-chat-head-text { flex: 1 1 auto; min-width: 0; }
.sp-chat-kicker { margin: 0 0 0.1rem; font-size: 0.75rem; color: rgba(255, 255, 255, 0.7); }
.sp-chat-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.sp-chat-back {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  margin-left: -0.35rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
}
.sp-chat-back:hover { background: rgba(255, 255, 255, 0.12); }
.sp-chat-back[hidden] { display: none; }

.sp-chat-body { flex: 1 1 auto; overflow-y: auto; background: #fff; }
.sp-chat-loading { margin: 0; padding: 1rem; color: var(--hr-muted); }
.sp-chat-empty { padding: 3rem 1.5rem; text-align: center; color: var(--hr-ink); }
.sp-chat-empty i { display: block; margin-bottom: 0.5rem; font-size: 2.5rem; color: #c4cdd8; }
.sp-chat-empty p { margin: 0 0 0.25rem; }

.sp-chat-section { margin: 0; padding: 0.9rem 1rem 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--hr-muted); }
.sp-chat-section.is-unread { color: #b0123f; }

.sp-chat-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 1rem 0;
}
.sp-chat-row:hover { background: #f6f8fa; }
.sp-chat-row > .sp-chat-avatar-btn { align-self: flex-start; margin-top: 0.1rem; }
.sp-chat-row-main {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.25rem 0 0.75rem;
  border: 0;
  border-bottom: 1px solid var(--hr-border);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.sp-chat-row.is-unread .sp-chat-row-main { padding-right: 2.25rem; }
.sp-chat-row-main:focus-visible,
.sp-chat-avatar-btn:focus-visible,
.sp-chat-who-btn:focus-visible,
.sp-chat-tab:focus-visible,
.sp-chat-kpi-item:focus-visible,
.sp-chat-hist-item:focus-visible { outline: none; box-shadow: var(--hr-focus); border-radius: 6px; }
.sp-chat-row-top { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; }
.sp-chat-row-top .sp-chat-who { flex: 1 1 auto; font-size: 1rem; }
.sp-chat-row-time { flex: 0 0 auto; font-size: 0.72rem; color: var(--hr-muted); }
.sp-chat-row-msg {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.9rem;
  color: #8a96a3;
}
.sp-chat-row.is-unread .sp-chat-row-msg { color: var(--hr-ink-strong); font-weight: 500; }
.sp-chat-row-kpi {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.72rem;
  color: var(--hr-muted);
}
.sp-chat-row-count {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: #e02424;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4rem;
  text-align: center;
}

.sp-chat-avatar {
  flex: 0 0 auto;
  border-radius: 999px;
  object-fit: cover;
  background: #e8edf3;
}
.sp-chat-avatar.is-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dfe7f1;
  color: var(--hr-navy);
  font-weight: 600;
}

.sp-chat-who {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.4rem;
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.35;
}
.sp-chat-who-name { font-weight: 600; color: var(--hr-ink-strong); }
.sp-chat-who.is-admin .sp-chat-who-name { color: #c08b0c; }
.sp-chat-crown {
  align-self: center;
  padding: 0.12rem 0.25rem;
  border-radius: 6px;
  background: #fdf1cf;
  color: #d39a06;
  font-size: 0.85em;
}
.sp-chat-unit { font-size: 0.75rem; font-weight: 400; color: var(--hr-muted); }

.sp-chat-thread { padding: 0.75rem 0.9rem 1rem; background: #eef2f6; min-height: 100%; }
.sp-chat-thread-empty { margin: 2rem 0; text-align: center; color: var(--hr-muted); font-size: 0.9rem; }
.sp-chat-day { margin: 0.75rem 0; text-align: center; }
.sp-chat-day span {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  background: rgba(15, 30, 69, 0.12);
  color: var(--hr-ink);
  font-size: 0.72rem;
}
.sp-chat-msg { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.65rem; }
.sp-chat-msg.is-mine { justify-content: flex-end; }
.sp-chat-msg-col { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; max-width: 78%; }
.sp-chat-msg.is-mine .sp-chat-msg-col { align-items: flex-end; }
.sp-chat-line { display: flex; align-items: flex-end; gap: 0.35rem; }
.sp-chat-bubble {
  padding: 0.5rem 0.8rem;
  border-radius: 1.1rem;
  border-top-left-radius: 0.35rem;
  background: #fff;
  color: var(--hr-ink-strong);
  font-size: 0.92rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(15, 34, 58, 0.06);
}
.sp-chat-msg.is-mine .sp-chat-bubble {
  border-top-left-radius: 1.1rem;
  border-top-right-radius: 0.35rem;
  background: #8de055;
}
.sp-chat-time { flex: 0 0 auto; font-size: 0.68rem; color: var(--hr-muted); }

.sp-chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hr-border);
  background: #fff;
}
.sp-chat-compose[hidden] { display: none; }
.sp-chat-compose textarea {
  min-height: 2.5rem;
  max-height: 140px;
  resize: none;
  border-radius: 1.25rem;
  padding: 0.5rem 0.9rem;
}
.sp-chat-send {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--hr-line);
  color: #fff;
  font-size: 1.15rem;
}
.sp-chat-send:hover { background: var(--hr-line-hover); }
.sp-chat-compose.is-sending .sp-chat-send { opacity: 0.6; pointer-events: none; }

@media (max-width: 760px) {
  body.sp-body.has-tabbar .sp-chat-fab { bottom: calc(5.35rem + env(safe-area-inset-bottom, 0px)); }
  body.sp-body.has-tabbar:has(.devkit-fab) .sp-chat-fab { bottom: calc(9.6rem + env(safe-area-inset-bottom, 0px)); }
  .offcanvas.sp-chat { --bs-offcanvas-width: 100%; }
}

.sp-chat-avatar-btn,
.sp-chat-who-btn {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.sp-chat-avatar-btn { border-radius: 999px; }
.sp-chat-avatar-btn:hover .sp-chat-avatar { box-shadow: 0 0 0 2px var(--hr-line); }
.sp-chat-who-btn { line-height: inherit; text-align: left; }
.sp-chat-who-btn:hover .sp-chat-who-name { text-decoration: underline; }

.sp-chat-head-avatar { flex: 0 0 auto; display: inline-flex; }
.sp-chat-head-avatar[hidden] { display: none; }
.sp-chat-sub { margin: 0.1rem 0 0; font-size: 0.78rem; color: rgba(255, 255, 255, 0.7); }
.sp-chat-head.is-person { background: #fff; color: var(--hr-ink-strong); border-bottom: 1px solid var(--hr-border); }
.sp-chat-head.is-person .sp-chat-title { color: var(--hr-ink-strong); -webkit-line-clamp: 1; }
.sp-chat-head.is-person .sp-chat-title.is-admin { color: #c08b0c; }
.sp-chat-head.is-person .sp-chat-title .sp-chat-crown { margin-left: 0.35rem; font-size: 0.8em; vertical-align: 0.1em; }
.sp-chat-head.is-person .sp-chat-sub { color: var(--hr-muted); }
.sp-chat-head.is-person .sp-chat-back { color: var(--hr-ink-strong); }
.sp-chat-head.is-person .sp-chat-back:hover { background: #f1f4f7; }

.sp-chat-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  padding: 0.5rem;
  background: #fff;
  border-bottom: 1px solid var(--hr-border);
}
.sp-chat-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.45rem 0.25rem;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--hr-ink);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
}
.sp-chat-tab i { font-size: 1.15rem; }
.sp-chat-tab:hover { background: #f4f6f8; }
.sp-chat-tab.is-active { background: #e9ecf1; color: var(--hr-ink-strong); }
.sp-chat-pane-empty { margin: 0; padding: 2.5rem 1rem; text-align: center; color: var(--hr-muted); }
.sp-chat-pane-group {
  margin: 0;
  padding: 0.85rem 1rem 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--hr-ink-strong);
}
.sp-chat-kpi-item,
.sp-chat-hist-item {
  display: flex;
  width: 100%;
  padding: 0.65rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--hr-border);
  background: none;
  color: var(--hr-ink);
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: left;
}
.sp-chat-kpi-item:hover,
.sp-chat-hist-item:hover { background: #f6f8fa; }
.sp-chat-kpi-item { align-items: flex-start; gap: 0.6rem; }
.sp-chat-kpi-item i { margin-top: 0.15rem; color: var(--hr-line); font-size: 1.05rem; }
.sp-chat-kpi-item.is-inactive { color: var(--hr-muted); }
.sp-chat-hist-item { flex-direction: column; gap: 0.15rem; }
.sp-chat-hist-top { display: flex; align-items: baseline; gap: 0.5rem; }
.sp-chat-hist-kpi {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--hr-ink-strong);
}
.sp-chat-hist-top time { flex: 0 0 auto; font-size: 0.72rem; color: var(--hr-muted); }
.sp-chat-hist-body { white-space: pre-line; overflow-wrap: anywhere; }
.sp-chat-hist-sys { font-size: 0.72rem; color: var(--hr-muted); }

.sp-chat-info-photo { display: flex; justify-content: center; padding: 1.25rem 1rem 0.5rem; }
.sp-chat-info { margin: 0; }
.sp-chat-info-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--hr-border);
  font-size: 0.9rem;
}
.sp-chat-info-row dt { flex: 0 0 auto; font-weight: 400; color: var(--hr-muted); }
.sp-chat-info-row dd { margin: 0; min-width: 0; font-weight: 600; color: var(--hr-ink-strong); text-align: right; overflow-wrap: anywhere; }
.sp-chat-info-row dd .sp-chat-who { justify-content: flex-end; font-size: inherit; }
.sp-chat-title-link { color: inherit; text-decoration: none; }
.sp-chat-title-link:hover,
.sp-chat-title-link:focus-visible { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.sp-chat-title-link i { margin-left: 0.25rem; font-size: 1.05em; vertical-align: -0.1em; opacity: 0.75; }

[id^="kpi-"],
[id^="ql-"] { scroll-margin: 6rem 0; }
@keyframes sp-chat-hl {
  0%, 60% { background-color: #fff3c4; box-shadow: 0 0 0 3px #f5c542; }
  100% { background-color: transparent; box-shadow: 0 0 0 3px transparent; }
}
.sp-chat-hl { animation: sp-chat-hl 4s ease-out; border-radius: var(--hr-radius-sm); }
@keyframes sp-chat-hl-cell {
  0%, 60% { background-color: #fff3c4; }
  100% { background-color: transparent; }
}
tr.sp-chat-hl > td { animation: sp-chat-hl-cell 4s ease-out; }
tr.sp-chat-hl { animation: none; }

/* ---------------------------------------------------------------- คำแนะนำรายหน้า */

.sp-help-fab {
  position: fixed;
  z-index: 1031;
  right: 1.25rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 3.5rem;
  height: 3.5rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background: #0d7377;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(13, 115, 119, 0.28);
  cursor: pointer;
}

html:not(.devkit-off) body:has(.devkit-fab) .sp-help-fab,
body:has(.sp-chat-fab) .sp-help-fab {
  bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
}

html:not(.devkit-off) body:has(.devkit-fab):has(.sp-chat-fab) .sp-help-fab,
body:has(.devkit-fab):has(.sp-chat-fab) .sp-help-fab {
  bottom: calc(9.75rem + env(safe-area-inset-bottom, 0px));
}

.sp-help-fab-icon {
  display: block;
  width: 1.7rem;
  height: 1.7rem;
}

.sp-help-fab:hover,
.sp-help-fab:focus-visible {
  background: #095c5f;
  color: #fff;
}

.sp-help-fab:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px #0d7377;
}

.offcanvas.sp-guide {
  --bs-offcanvas-width: min(440px, 100vw);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

.sp-guide-role {
  margin: 0 0 0.15rem;
  color: #0d7377;
  font-size: 0.78rem;
  font-weight: 700;
}

.sp-guide-lead,
.sp-guide-steps p {
  margin: 0;
  color: var(--hr-muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.sp-guide-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.sp-guide-steps li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
}

.sp-guide-num {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0d7377;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}

.sp-guide-steps h3,
.sp-guide-more {
  margin: 0 0 0.2rem;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--hr-ink-strong);
}

.sp-guide-more {
  margin: 1.25rem 0 0.75rem;
  font-size: 1.02rem;
}

.sp-guide-text {
  white-space: pre-wrap;
  color: var(--hr-ink, #1c2430);
  font-size: 0.95rem;
  line-height: 1.65;
}

.sp-guide-pick {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 0.9rem;
  color: var(--hr-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.sp-guide-pick select,
.sp-guide-input {
  width: 100%;
  border: 1px solid var(--hr-border, #d5dde6);
  border-radius: 0.7rem;
  background: #fff;
  color: inherit;
  font: inherit;
}

.sp-guide-pick select {
  min-height: 2.4rem;
  padding: 0.35rem 0.6rem;
  font-weight: 600;
}

.sp-guide-input {
  min-height: 16rem;
  padding: 0.75rem 0.8rem;
  line-height: 1.6;
  resize: vertical;
}

.sp-guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.sp-guide-edit {
  margin-top: 0.9rem;
}

.sp-guide-status {
  min-height: 1.2rem;
  margin: 0.55rem 0 0;
  color: #0d7377;
  font-size: 0.82rem;
}

.offcanvas.sp-guide .offcanvas-body {
  flex: 1 1 auto;
  min-height: 0;
}

.sp-guide-ask {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: min(46vh, 22rem);
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hr-border, #d5dde6);
  background: #f4faf9;
}

.offcanvas.sp-guide.is-folded .offcanvas-header .sp-guide-lead,
.offcanvas.sp-guide.is-folded .offcanvas-body {
  display: none;
}

.offcanvas.sp-guide.is-folded .sp-guide-ask {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
}

.offcanvas.sp-guide.is-folded .sp-guide-ask-log:not(:empty) {
  flex: 1 1 auto;
  max-height: none;
}

.sp-guide-ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sp-guide-fold {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: none;
  color: #0d7377;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sp-guide-fold:focus-visible {
  outline: 2px solid #0d7377;
  outline-offset: 2px;
}

.sp-guide-ask-kicker {
  margin: 0;
  color: #0d7377;
  font-size: 0.78rem;
  font-weight: 700;
}

.sp-guide-ask-kicker i { margin-right: 0.2rem; vertical-align: -0.1em; }

.sp-guide-ask-log {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
  overflow: auto;
}

.sp-guide-ask-log:empty { display: none; }

.sp-guide-ask-log:not(:empty) { max-height: 12rem; }

.sp-guide-ask-msg {
  max-width: 92%;
  padding: 0.45rem 0.7rem;
  border-radius: 0.85rem;
  white-space: pre-wrap;
  font-size: 0.88rem;
  line-height: 1.5;
}

.sp-guide-ask-msg.is-user {
  align-self: flex-end;
  background: #0d7377;
  color: #fff;
}

.sp-guide-ask-msg.is-ai {
  align-self: flex-start;
  background: #fff;
  color: var(--hr-ink, #1c2430);
  border: 1px solid var(--hr-border, #d5dde6);
}

.sp-guide-ask-form {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
}

.sp-guide-ask-form textarea {
  flex: 1 1 auto;
  min-height: 2.5rem;
  max-height: 6rem;
  resize: none;
  border: 1px solid var(--hr-border, #d5dde6);
  border-radius: 1.25rem;
  padding: 0.5rem 0.85rem;
  background: #fff;
  font: inherit;
  line-height: 1.45;
}

.sp-guide-ask-form button {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 999px;
  background: #0d7377;
  color: #fff;
  font-size: 1.1rem;
}

.sp-guide-ask-form button:hover,
.sp-guide-ask-form button:focus-visible { background: #095c5f; }

.sp-guide-ask-form.is-sending button { opacity: 0.6; }

.sp-guide-ask-error {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
}

.sp-guide-ask-error:empty { display: none; }

.sp-guide-ask-error { color: #b42318; }

/* ---------------------------------------------------------------- ติดตั้งแอป (PWA) */

@media (max-width: 760px) {
  body.sp-body .hr-pwa-prompt { padding-right: 5.25rem; }
  body.sp-body.has-tabbar .hr-pwa-prompt { bottom: calc(5.35rem + env(safe-area-inset-bottom, 0px)); }
}
