html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* ===== Global loading overlay (dim + progress ring) ===== */
#app-saving-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000; /* สูงกว่า modal ของ bootstrap (1055) */
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.48);
  cursor: wait;
  backdrop-filter: blur(1px);
  pointer-events: all;
}

#app-saving-overlay.show {
  display: flex;
}

body.app-overlay-open {
  overflow: hidden;
}

body.app-overlay-open main,
body.app-overlay-open header,
body.app-overlay-open footer {
  pointer-events: none;
  user-select: none;
}

#app-saving-overlay .app-saving-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.1rem 1.6rem;
  background: #fff;
  border-radius: 0.9rem;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.28);
  color: #1e293b;
  font-size: 1rem;
  font-weight: 500;
}

#app-saving-overlay .spinner-border {
  width: 2rem;
  height: 2rem;
  color: #2563eb;
  border-right-color: transparent;
}

/* ===== Invoice type badges ===== */
.badge.badge-type-service {
  background-color: #3055fc;
  color: #fff;
}

.badge.badge-type-goods {
  background-color: #fc8230;
  color: #fff;
}

/* ===== Action buttons (list rows) ===== */
.action-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.btn-action {
  --btn-action-bg: #6c757d;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0.5rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.2px;
  color: #fff;
  background-color: var(--btn-action-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}

.btn-action:hover {
  color: #fff;
  filter: brightness(1.07);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

.btn-action:active {
  transform: translateY(0);
  filter: brightness(0.97);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.btn-action:focus-visible {
  outline: none;
  box-shadow: 0 0 0 0.2rem rgba(37, 140, 251, 0.4);
}

/* Color variants */
.btn-action.action-view {
  --btn-action-bg: #0ea5b7;
}

.btn-action.action-pdf {
  --btn-action-bg: #2f855a;
}

.btn-action.action-copy {
  --btn-action-bg: #4f6df5;
}

.btn-action.action-delete {
  --btn-action-bg: #e05260;
}

.btn-action.action-download {
  --btn-action-bg: #2f855a;
}

.btn-action.action-generate {
  --btn-action-bg: #2f855a;
}

.btn-action.action-regenerate {
  --btn-action-bg: #6c757d;
}

.btn-action.action-upload {
  --btn-action-bg: #4f6df5;
}

/* แถว 50ทวิ ที่สร้างเอง (manual) — ชมพูอ่อนมาก เพื่อแยกจากแถวปกติ */
.table > tbody > tr.wht-manual {
  --bs-table-bg: #fdeff3;
  --bs-table-accent-bg: #fdeff3;
  --bs-table-striped-bg: #fdeff3;
  --bs-table-hover-bg: #f9e4eb;
}

/* Disabled / non-clickable state - clearly greyed out */
.btn-action:disabled,
.btn-action.disabled {
  background-color: #e9ecef;
  color: #9aa0a6;
  box-shadow: inset 0 0 0 1px #ced4da;
  cursor: not-allowed;
  filter: none;
  transform: none;
  opacity: 1;
}

.btn-action:disabled:hover,
.btn-action.disabled:hover {
  background-color: #e9ecef;
  color: #9aa0a6;
  filter: none;
  transform: none;
  box-shadow: inset 0 0 0 1px #ced4da;
}

/* ===== แถวใบกำกับซื้อจากคู่ค้าต่างประเทศ ===== */
.table > tbody > tr > td.cell-overseas-partner {
  background-color: #e3f2fd;
  box-shadow: none;
}

/* ===== Date picker แบบพุทธศักราช ===== */
.be-datepicker {
  position: relative;
}

.be-dp-display {
  background-color: #fff;
  cursor: pointer;
}

.be-dp-display:disabled {
  cursor: default;
}

.be-dp-panel {
  position: absolute;
  z-index: 1055;
  top: calc(100% + 4px);
  left: 0;
  min-width: 19rem;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.be-dp-head {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.be-dp-head .be-dp-month {
  flex: 1 1 auto;
}

.be-dp-head .be-dp-year {
  flex: 0 0 6rem;
}

.be-dp-nav {
  flex: 0 0 auto;
  padding: 0.15rem 0.5rem;
  line-height: 1;
}

.be-dp-grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.be-dp-grid th {
  padding: 0.2rem 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: #6c757d;
  text-align: center;
}

.be-dp-grid td {
  padding: 1px;
  text-align: center;
}

.be-dp-day {
  width: 100%;
  padding: 0.3rem 0;
  font-size: 0.9rem;
  color: #212529;
  background: none;
  border: 0;
  border-radius: 0.35rem;
}

.be-dp-day:hover {
  background-color: #e9ecef;
}

.be-dp-day.be-dp-muted {
  color: #adb5bd;
}

.be-dp-day.be-dp-today {
  box-shadow: inset 0 0 0 1px #0d6efd;
}

.be-dp-day.be-dp-selected {
  color: #fff;
  background-color: #0d6efd;
}

.be-dp-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* ===== Branding: 24Pulse ===== */
:root {
  --pulse-blue: #2563eb;
  --pulse-teal: #14b8a6;
  --pulse-slate: #334155;
  --pulse-bg: #f5f7fb;
  --pulse-card: #ffffff;
  --pulse-border: #e2e8f0;
}

.navbar-brand-24pulse {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 0;
  text-decoration: none;
}

.navbar-brand-24pulse:hover {
  opacity: 0.92;
}

.brand-logo-main {
  height: 40px;
  width: auto;
  max-width: 180px;
  display: block;
  object-fit: contain;
  border-radius: 0.4rem;
}

.brand-logo-login {
  height: 56px;
  width: auto;
  max-width: 240px;
  display: block;
  margin: 0 auto 1rem;
  object-fit: contain;
  border-radius: 0.5rem;
}

.brand-wordmark {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
  color: var(--pulse-blue);
  line-height: 1;
}

.brand-wordmark span {
  color: var(--pulse-slate);
  font-weight: 600;
}

@media (max-width: 576px) {
  .brand-logo-main {
    height: 32px;
    max-width: 140px;
  }

  .brand-logo-login {
    height: 48px;
    max-width: 200px;
  }

  .brand-wordmark {
    font-size: 1rem;
  }
}

/* ===== Dashboard ===== */
.dashboard-page {
  padding-top: 0.25rem;
}

.dashboard-kicker {
  color: var(--pulse-teal);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-title {
  color: #0f172a;
  font-weight: 700;
}

.dashboard-dot {
  margin: 0 0.35rem;
  color: #94a3b8;
}

.dashboard-kpi {
  display: block;
  height: 100%;
  padding: 1.1rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
  color: inherit;
  cursor: default;
  user-select: none;
}

.dashboard-kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.dashboard-kpi-title {
  color: #475569;
  font-size: 0.9rem;
  font-weight: 600;
}

.dashboard-kpi-value {
  font-size: 1.9rem;
  font-weight: 750;
  line-height: 1.1;
  color: #0f172a;
  margin-bottom: 0.35rem;
}

.dashboard-kpi-sub {
  color: #64748b;
  font-size: 0.86rem;
  line-height: 1.35;
}

.dashboard-kpi-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: #c2410c;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.dashboard-kpi-primary {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.dashboard-kpi-teal {
  background: #f0fdfa;
  border-color: #99f6e4;
}

.dashboard-kpi-warning {
  background: #fffbeb;
  border-color: #fde68a;
}

.dashboard-kpi-danger {
  background: #fef2f2;
  border-color: #fecaca;
}

.dashboard-kpi-danger .dashboard-kpi-badge {
  background: rgba(255, 255, 255, 0.8);
  color: #b91c1c;
}

.dashboard-section-title {
  color: #0f172a;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.dashboard-menu-card {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  min-height: 104px;
  padding: 1rem 1.05rem;
  background: var(--pulse-card);
  border: 1px solid var(--pulse-border);
  border-radius: 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.035);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.dashboard-menu-card:hover,
.dashboard-menu-card:focus-visible {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  color: inherit;
  outline: none;
}

.dashboard-menu-icon {
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: linear-gradient(160deg, #eff6ff 0%, #ecfeff 70%, #f0fdfa 100%);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.dashboard-menu-icon img {
  width: 42px;
  height: 42px;
  filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.12));
}

.dashboard-menu-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.dashboard-menu-desc {
  color: #64748b;
  font-size: 0.86rem;
  line-height: 1.4;
}

.dashboard-coming-soon {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 700;
}

.dashboard-menu-card.is-coming-soon {
  background: #f8fafc;
  cursor: default;
  pointer-events: none;
  opacity: 0.88;
  box-shadow: none;
}

.dashboard-menu-card.is-coming-soon:hover,
.dashboard-menu-card.is-coming-soon:focus-visible {
  transform: none;
  border-color: var(--pulse-border);
  box-shadow: none;
}

.dashboard-menu-card.is-coming-soon .dashboard-menu-icon {
  filter: grayscale(0.35);
  opacity: 0.85;
}

/* ===== HR pages (Employees / SSO / Student Loan) ===== */
.hr-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.hr-page-header h1,
.hr-page-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.hr-page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ปุ่ม HR ชุดเดียวทุกหน้า ทุกส่วน: พนักงาน / ประกันสังคม / กยศ */
.hr-ui {
  --hr-btn-radius: 0.5rem;
  --hr-btn-height: 2.35rem;
  --hr-btn-pad-x: 0.95rem;
  --hr-btn-font: 0.875rem;
  --hr-btn-hover-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
}

.hr-ui .btn:not(.btn-close),
.hr-ui .btn-sm,
.hr-ui .btn-action {
  box-sizing: border-box;
  border-radius: var(--hr-btn-radius);
  min-height: var(--hr-btn-height);
  height: var(--hr-btn-height);
  padding: 0 var(--hr-btn-pad-x);
  font-size: var(--hr-btn-font);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-shadow: none;
  transform: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.hr-ui .btn:not(.btn-close):hover,
.hr-ui .btn-sm:hover,
.hr-ui .btn-action:hover {
  transform: none;
  box-shadow: var(--hr-btn-hover-shadow);
}

.hr-ui .btn-action:hover {
  filter: brightness(1.05);
}

.hr-ui .btn:not(.btn-close):active,
.hr-ui .btn-sm:active,
.hr-ui .btn-action:active {
  transform: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.hr-ui .btn-action:active {
  filter: brightness(0.97);
}

.hr-filter {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.hr-table {
  --bs-table-cell-padding-y: 0.85rem;
}

.hr-status {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35em 0.75em;
  border-radius: 999px;
  line-height: 1.2;
}

.hr-status-paid,
.hr-status-active {
  background: #d1fae5;
  color: #065f46;
}

.hr-status-pending {
  background: #fef3c7;
  color: #92400e;
}

.hr-status-inactive {
  background: #e2e8f0;
  color: #475569;
}

.hr-flag-yes {
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3em 0.7em;
  border-radius: 999px;
}

.hr-flag-no {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3em 0.7em;
  border-radius: 999px;
}

.hr-card-calc {
  border-left: 4px solid #0ea5e9;
}

.hr-card-slip {
  border-left: 4px solid #8b5cf6;
}

.hr-variance {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  color: #9a3412;
  font-weight: 500;
}

.hr-kv {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.65rem 1rem;
  align-items: start;
}

.hr-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.5rem;
}

@media (max-width: 767.98px) {
  .hr-info-grid,
  .hr-kv {
    grid-template-columns: 1fr;
  }
}

.hr-info-item .label {
  color: #64748b;
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

.hr-info-item .value {
  font-weight: 500;
}

/* ===== Employee details ===== */
.emp-details .emp-profile {
  border: 1px solid #e2e8f0;
  border-radius: 0.9rem;
}

.emp-profile-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.15rem 1.35rem;
}

.emp-profile-identity {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  min-width: 0;
}

.emp-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 0.85rem;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.emp-profile-head h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
}

.emp-en-name {
  color: #64748b;
  font-size: 0.92rem;
  margin-top: 0.1rem;
}

.emp-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.emp-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #475569;
  font-size: 0.9rem;
}

.emp-profile-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.emp-tabs {
  margin-top: 1.15rem;
  margin-bottom: 0;
  border-bottom: 1px solid #e2e8f0;
}

.emp-tabs .nav-link {
  color: #64748b;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.7rem 1rem;
}

.emp-tabs .nav-link:hover {
  color: #1e293b;
}

.emp-tabs .nav-link.active {
  color: #1d4ed8;
  background: transparent;
  border-bottom-color: #2563eb;
  font-weight: 600;
}

.emp-panel {
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 0.9rem 0.9rem;
}

.emp-panel .table-responsive {
  overflow: visible;
}

.emp-info-section + .emp-info-section {
  border-top: 1px solid #eef2f7;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
}

.emp-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.emp-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1.75rem;
}

.emp-details .hr-info-item .value {
  font-weight: 600;
  color: #0f172a;
}

.emp-danger-card {
  border: 1px solid #fecaca;
  background: #fff7f7;
}

.emp-table thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 0.82rem;
  border-bottom-width: 1px;
}

.emp-table td {
  overflow: visible;
  vertical-align: middle;
}

.emp-col-amount {
  min-width: 8rem;
}

.emp-col-date {
  min-width: 11rem;
}

.emp-row-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.payroll-row-error {
  background-color: #fff7ed;
}


.emp-add-form {
  border-top: 1px solid #eef2f7;
  padding: 1rem 1.15rem 1.15rem;
}

.emp-add-form .form-label {
  line-height: 1.35;
}

.slf-details .hr-card-slip .emp-section-title {
  margin-top: 0;
}

@media (max-width: 991.98px) {
  .slf-details .hr-card-slip .col-lg-6 + .col-lg-6 .emp-section-title {
    margin-top: 1.25rem;
  }
}

.slf-details .emp-profile-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.slf-barcode {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 16rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.85rem;
}

.slf-barcode img {
  max-width: 100%;
  max-height: 280px;
}

.slf-details .hr-info-item .value {
  font-weight: 500;
}

.slf-details .hr-info-item .form-control {
  font-weight: 400;
  max-width: 16rem;
}

@media (max-width: 767.98px) {
  .emp-profile-head {
    flex-direction: column;
  }

  .emp-info-grid {
    grid-template-columns: 1fr;
  }
}
