/* =============================================================
   Design System — DOAE HRCS
   Unified tokens & components (Style Soft)
   ============================================================= */

/* -------------------------------------------------------------
   1. CSS Custom Properties (Tokens)
      NOTE: --ds-* tokens are defined in design-tokens.css
   ------------------------------------------------------------- */

/* -------------------------------------------------------------
   2. Base Reset for ds scope
   ------------------------------------------------------------- */
.ds-scope {
  font-family: var(--ds-font-family-sans-th);
  font-size: var(--ds-font-size-base);
  color: var(--ds-color-gray-900);
  line-height: 1.5;
  box-sizing: border-box;
}
.ds-scope *, .ds-scope *::before, .ds-scope *::after {
  box-sizing: inherit;
}

/* -------------------------------------------------------------
   3. Summary Card
   ------------------------------------------------------------- */
.ds-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--ds-space-md);
  padding: var(--ds-space-lg);
  background: var(--ds-color-bg);
  border-radius: var(--ds-radius-soft);
  box-shadow: var(--ds-shadow-soft);
  margin-bottom: var(--ds-space-lg);
}
.ds-summary-item {
  text-align: center;
  padding: var(--ds-space-md);
  border-radius: var(--ds-radius-soft);
}
/* Summary Card — emp_type background colors */
.ds-summary-svnt {
  background: var(--ds-color-emp-svnt);
  color: var(--ds-color-bg);
}
.ds-summary-svnt .ds-summary-value,
.ds-summary-svnt .ds-summary-label { color: var(--ds-color-bg); }
.ds-summary-svnt .ds-dot { background: rgba(255,255,255,0.6); }

.ds-summary-per {
  background: var(--ds-color-emp-per);
  color: var(--ds-color-bg);
}
.ds-summary-per .ds-summary-value,
.ds-summary-per .ds-summary-label { color: var(--ds-color-bg); }
.ds-summary-per .ds-dot { background: rgba(255,255,255,0.6); }

.ds-summary-gov {
  background: var(--ds-color-emp-gov);
  color: var(--ds-color-bg);
}
.ds-summary-gov .ds-summary-value,
.ds-summary-gov .ds-summary-label { color: var(--ds-color-bg); }
.ds-summary-gov .ds-dot { background: rgba(255,255,255,0.6); }
.ds-summary-value {
  font-size: var(--ds-font-size-2xl);
  font-weight: 700;
  display: block;
}
.ds-summary-label {
  font-size: var(--ds-font-size-sm);
  color: var(--ds-color-gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-xs);
  margin-top: var(--ds-space-xs);
}
.ds-summary-legend {
  padding: 0.75rem var(--ds-space-lg);
  background: var(--ds-color-gray-50);
  border-top: 1px solid var(--ds-color-gray-200);
  border-radius: 0 0 var(--ds-radius-soft) var(--ds-radius-soft);
  font-size: var(--ds-font-size-sm);
  color: var(--ds-color-gray-500);
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-md);
}

/* -------------------------------------------------------------
   4. Personnel Color Dots
   ------------------------------------------------------------- */
.ds-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ds-dot-svnt { background: var(--ds-color-emp-svnt); }
.ds-dot-gov  { background: var(--ds-color-emp-gov); }
.ds-dot-per  { background: var(--ds-color-emp-per); }

/* -------------------------------------------------------------
   5. Org Card (Node)
   ------------------------------------------------------------- */
.ds-org-node {
  background: var(--ds-color-bg);
  border-radius: var(--ds-radius-soft);
  box-shadow: var(--ds-shadow-soft);
  overflow: hidden;
  width: 320px;
  max-width: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ds-org-node:hover {
  transform: translateY(-2px);
  box-shadow: var(--ds-shadow-soft-lg);
}

/* Header — color varies by level via data-level */
.ds-org-header {
  padding: 0.75rem var(--ds-space-md);
  color: var(--ds-color-bg);
  font-weight: 600;
  font-size: var(--ds-font-size-base); /* 16px — bumped from 14px for readability */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-sm);
}
.ds-org-node[data-level="1"] .ds-org-header {
  background: var(--ds-color-level-1);
}
.ds-org-node[data-level="2"] .ds-org-header {
  background: var(--ds-color-level-2);
}
.ds-org-node[data-level="3"] .ds-org-header {
  background: var(--ds-color-level-3);
}
.ds-org-node[data-level="4"] .ds-org-header {
  background: var(--ds-color-level-3);
  color: var(--ds-color-bg);
}

.ds-org-name {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.4;
  flex: 1;
}
.ds-org-sub-count {
  font-size: var(--ds-font-size-sm); /* 14px — bumped from 12px */
  opacity: 0.85;
  white-space: nowrap;
}

/* Personnel metrics area */
.ds-org-metrics {
  padding: 0.75rem var(--ds-space-md);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-sm);
}
.ds-metric {
  display: flex;
  align-items: center;
  gap: var(--ds-space-sm);
  font-size: var(--ds-font-size-sm);
}
.ds-metric-label {
  color: var(--ds-color-gray-500);
  min-width: 2.5em;
}
.ds-metric-value {
  font-weight: 600;
  color: var(--ds-color-gray-900);
  font-size: var(--ds-font-size-base); /* 16px — bumped from 14px, key data */
}
.ds-metric-direct {
  font-size: var(--ds-font-size-sm); /* 14px — bumped from 12px */
  color: var(--ds-color-gray-400);
  margin-left: auto;
}
.ds-metric-direct::before {
  content: '|';
  margin-right: 4px;
}
.ds-legend-direct-sep::before {
  content: '|';
}

/* Local (internal-only) node highlight */
.ds-org-local {
  border: 2px solid var(--ds-color-emp-local);
}
.ds-org-local .ds-org-header {
  background: var(--ds-color-emp-local) !important;
  color: var(--ds-color-bg);
}

/* Actions — always visible */
.ds-org-actions {
  display: flex;
  gap: var(--ds-space-sm);
  padding: 0.75rem var(--ds-space-md);
  border-top: 1px solid var(--ds-color-gray-200);
}

/* -------------------------------------------------------------
   6. Buttons
   ------------------------------------------------------------- */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-sm);
  padding: var(--ds-space-sm) var(--ds-space-md);
  border-radius: 999px; /* Pill shape */
  font-family: var(--ds-font-family-sans-th);
  font-size: var(--ds-font-size-sm);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.5;
  height: auto;
}
/* .ds-btn-primary consolidated into the ADR-017 AAA block near end of file. */
.ds-btn-outline {
  background: var(--ds-color-bg);
  color: var(--ds-color-brand);
  border: 1px solid var(--ds-color-brand);
}
.ds-btn-outline:hover {
  background: var(--ds-color-brand-light);
}
.ds-btn-sm {
  padding: var(--ds-space-xs) 0.75rem;
  font-size: var(--ds-font-size-sm); /* 14px — bumped from 12px */
}
.ds-btn-block {
  width: 100%;
}

/* -------------------------------------------------------------
   7. Tabs
   ------------------------------------------------------------- */
.ds-tabs {
  display: flex;
  gap: var(--ds-space-sm);
  margin-bottom: var(--ds-space-lg);
  border-bottom: 2px solid var(--ds-color-gray-200);
  padding-bottom: 0;
}
.ds-tab {
  padding: 0.75rem 1.25rem;
  font-size: var(--ds-font-size-sm);
  font-weight: 500;
  color: var(--ds-color-gray-500);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--ds-font-family-sans-th);
  position: relative;
  transition: color 0.2s ease;
}
.ds-tab:hover {
  color: var(--ds-color-brand);
}
.ds-tab.active {
  color: var(--ds-color-brand);
  font-weight: 600;
}

/* -------------------------------------------------------------
   8. Breadcrumb
   ------------------------------------------------------------- */
.ds-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--ds-space-sm);
  padding: 0.75rem 0;
  font-size: var(--ds-font-size-sm);
  flex-wrap: wrap;
}
/* ADR-017: legacy page-header breadcrumb (renamed from Bootstrap .breadcrumb to clear
   the CI lint) — restore the flex row + no bullets that Bootstrap's .breadcrumb provided. */
.breadcrumb-legacy { display: flex; flex-wrap: wrap; list-style: none; }
.ds-breadcrumb a {
  color: var(--ds-color-brand);
  text-decoration: none;
  transition: color 0.2s ease;
}
.ds-breadcrumb a:hover {
  text-decoration: underline;
}
.ds-breadcrumb-sep {
  color: var(--ds-color-gray-400);
}
.ds-breadcrumb-current {
  color: var(--ds-color-gray-700);
  font-weight: 600;
}

/* -------------------------------------------------------------
   9. Tree Layout (Hybrid Style: Horizontal Top, Vertical Bottom)
   ------------------------------------------------------------- */
.ds-tree-wrapper {
  overflow-x: auto;
  padding: var(--ds-space-xl) 0;
  width: 100%;
}

.ds-tree-hybrid {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 0 auto;
}

.ds-tree-root {
  position: relative;
  z-index: 2;
  padding-bottom: var(--ds-space-lg);
}

/* Trunk from root down to the branches */
.ds-tree-root > .ds-tree-node::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  width: 2px;
  height: var(--ds-space-lg);
  background-color: var(--ds-color-gray-300);
  transform: translateX(-50%);
}

.ds-tree-branches {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 100%;
}

/* --- Horizontal Rows (Level 2) --- */
.ds-tree-row {
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 0;
  list-style: none;
  align-items: start;
  position: relative;
  padding-bottom: var(--ds-space-lg);
}

/* Trunk passing through the row to the next row */
.ds-tree-row::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background-color: var(--ds-color-gray-300);
  transform: translateX(-50%);
  z-index: 0;
}
.ds-tree-row:last-child {
  padding-bottom: 0;
}
.ds-tree-row:last-child::after {
  display: none;
}

.ds-tree-row > li {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  /* Horizontal padding creates the gap between sibling cards, allowing horizontal lines to touch! */
  padding: var(--ds-space-lg) var(--ds-space-xxl) 0;
}

/* Horizontal connectors for row items */
.ds-tree-row > li::before, .ds-tree-row > li::after {
  content: '';
  position: absolute;
  top: 0;
  width: 50%;
  height: 2px;
  background-color: var(--ds-color-gray-300);
}
.ds-tree-row > li::before { left: 0; }
.ds-tree-row > li::after { right: 0; }
.ds-tree-row > li:first-child::before { display: none; }
.ds-tree-row > li:last-child::after { display: none; }
.ds-tree-row > li:only-child::before, .ds-tree-row > li:only-child::after { display: none; }

/* --- Responsive Grid (For Sub-Charts with many children) --- */
.ds-tree-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 5rem;
  padding: var(--ds-space-lg) 0 var(--ds-space-xl) 0;
  margin: 0 auto; /* Center the container itself */
  list-style: none;
  align-items: flex-start;
  position: relative;
  width: fit-content; /* Allow it to grow beyond screen width */
}

/* Top horizontal trunk */
.ds-tree-grid::before {
  content: '';
  position: absolute;
  top: 0;
  left: 160px; /* Half of min column width */
  right: 160px;
  height: 2px;
  background-color: var(--ds-color-gray-300);
  z-index: 0;
}

/* Trunk passing through the grid to the next grid (if multiple grids exist) */
.ds-tree-grid::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background-color: var(--ds-color-gray-300);
  transform: translateX(-50%);
  z-index: 0;
}

/* Don't pass through if it's the last grid */
.ds-tree-grid:last-child::after {
  display: none;
}

/* Hide horizontal trunk if there's only 1 child */
.ds-tree-grid:has(> li:only-child)::before {
  display: none;
}



.ds-tree-grid > li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 320px; /* Force strict width to prevent shrinking */
}

/* Vertical drop line. Connects the top horizontal branch to the card header. */
.ds-tree-grid > li::before {
  content: '';
  position: absolute;
  top: calc(-1 * var(--ds-space-lg));
  height: var(--ds-space-lg); /* ONLY drops to the top of the card! */
  left: 50%;
  width: 2px;
  background-color: var(--ds-color-gray-300);
  transform: translateX(-50%);
  z-index: 0;
}

/* Vertical drop to row node */
.ds-tree-node {
  position: relative;
  z-index: 2;
}
.ds-tree-row > li > .ds-tree-node::before {
  content: '';
  position: absolute;
  top: calc(-1 * var(--ds-space-lg));
  left: 50%;
  width: 2px;
  height: var(--ds-space-lg);
  background-color: var(--ds-color-gray-300);
  transform: translateX(-50%);
  z-index: 1;
}

/* -------------------------------------------------------------
   X. Floating Legend
   ------------------------------------------------------------- */
.ds-floating-legend-container {
  position: fixed;
  bottom: 80px;
  right: 25px;
  z-index: 999;
  transition: all 0.3s ease;
}

.ds-legend-toggle {
  background: white;
  border: 1px solid var(--ds-color-gray-300);
  color: var(--ds-color-gray-700);
  border-radius: 999px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--ds-shadow-soft);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.ds-legend-toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--ds-shadow-soft-lg);
}

.ds-floating-legend-panel {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: var(--ds-radius-soft);
  box-shadow: var(--ds-shadow-soft-lg);
  padding: 0.75rem var(--ds-space-md);
  width: 280px;
  font-size: var(--ds-font-size-sm);
  border: 1px solid var(--ds-color-gray-200);
}

@media (max-width: 768px) {
  .ds-floating-legend-container {
    right: 0 !important;
  }
  .ds-legend-text {
    display: none;
  }
  .ds-legend-toggle {
    padding: 0 !important;
    width: 48px;
    height: 48px;
    justify-content: center;
    border-radius: 50%;
  }
  .ds-legend-icon {
    font-size: 20px;
    margin: 0;
  }
}

/* --- Vertical Columns (Level 3+) --- */
.ds-tree-col {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: var(--ds-space-md) auto 0;
  list-style: none;
  position: relative;
  width: 100%;
  max-width: 320px; /* Match parent card max-width to align left edges */
}

.ds-tree-col > li {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-top: var(--ds-space-md);
  width: 100%;
  padding-left: var(--ds-space-lg); /* Indent children */
  box-sizing: border-box;
}
.ds-tree-col > li:first-child {
  padding-top: 0;
}

/* Horizontal branch from trunk to the card */
.ds-tree-col > li::before {
  content: '';
  position: absolute;
  top: calc(var(--ds-space-md) + 24px); /* Approx vertical center of header */
  left: 0;
  width: var(--ds-space-lg);
  height: 2px;
  background-color: var(--ds-color-gray-300);
}
.ds-tree-col > li:first-child::before {
  top: 24px;
}

/* Vertical trunk dropping from parent's left edge */
.ds-tree-col > li::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background-color: var(--ds-color-gray-300);
  z-index: 0;
}
.ds-tree-col > li:first-child::after {
  /* Reach up to connect to the bottom of the parent card */
  top: calc(-1 * var(--ds-space-md));
}

/* Stop trunk at the last child's horizontal branch */
.ds-tree-col > li:last-child::after {
  bottom: auto;
  height: calc(var(--ds-space-md) + 24px);
}
.ds-tree-col > li:first-child:last-child::after {
  height: calc(var(--ds-space-md) + 24px + var(--ds-space-md));
}

/* -------------------------------------------------------------
   9b. Sub-Chart Nest Folder Tree (Multi-column layout)
   ------------------------------------------------------------- */
.ds-subchart-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--ds-space-lg);
  padding-top: var(--ds-space-lg);
  position: relative;
  width: 100%;
}

/* Vertical connector from parent node center */
.ds-subchart-grid::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: var(--ds-space-lg);
  background-color: var(--ds-color-gray-300);
  transform: translateX(-50%);
}

.ds-subchart-item {
  flex: 1;
  min-width: 280px;
  max-width: 320px;
  position: relative;
}

/* Horizontal line spanning to the next item */
.ds-subchart-item::before {
  content: '';
  position: absolute;
  top: calc(-1 * var(--ds-space-lg));
  left: 0;
  width: calc(100% + var(--ds-space-lg));
  height: 2px;
  background-color: var(--ds-color-gray-300);
}

/* Don't span from the last item */
.ds-subchart-item:last-child::before {
  display: none;
}

/* Vertical trunk dropping down to the tree col */
.ds-subchart-item::after {
  content: '';
  position: absolute;
  top: calc(-1 * var(--ds-space-lg));
  left: 0;
  width: 2px;
  height: var(--ds-space-lg);
  background-color: var(--ds-color-gray-300);
}

/* Override .ds-tree-col inside .ds-subchart-item */
.ds-subchart-item .ds-tree-col {
  margin-top: 0;
}

/* Responsive: 1 column on mobile */
@media (max-width: 768px) {
  .ds-subchart-item::before {
    display: none; /* No horizontal lines on mobile */
  }
}

/* -------------------------------------------------------------
   10. Tables & Pagination
   ------------------------------------------------------------- */
.ds-table-soft {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ds-font-size-sm);
  text-align: left;
}
.ds-table-soft thead th {
  background-color: var(--ds-color-brand-secondary);
  color: var(--ds-color-bg);
  padding: 0.75rem var(--ds-space-md);
  font-weight: 600;
  border-bottom: none;
}
.ds-table-soft tbody td {
  padding: 0.75rem var(--ds-space-md);
  border-bottom: 1px solid var(--ds-color-gray-200);
  vertical-align: middle;
}
.ds-table-soft tbody tr:nth-child(even) {
  background-color: var(--ds-color-gray-50);
}
.ds-table-soft tbody tr:hover {
  background-color: color-mix(in srgb, var(--ds-color-brand) 5%, transparent);
}

.ds-pagination-soft {
  display: inline-flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: var(--ds-space-xs);
}
.ds-pagination-soft li {
  display: inline-block;
}
.ds-pagination-soft li a,
.ds-pagination-soft li span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 var(--ds-space-sm);
  border: 1px solid var(--ds-color-gray-300);
  background-color: var(--ds-color-bg);
  color: var(--ds-color-gray-700);
  font-size: var(--ds-font-size-sm);
  text-decoration: none;
  transition: all 0.2s;
}
.ds-pagination-soft li a:hover {
  background-color: var(--ds-color-gray-50);
  border-color: var(--ds-color-gray-400);
}
.ds-pagination-soft li.active span {
  background-color: var(--ds-color-brand);
  border-color: var(--ds-color-brand);
  color: var(--ds-color-bg);
}
.ds-pagination-soft li.disabled span {
  color: var(--ds-color-gray-400);
  background-color: var(--ds-color-gray-100);
  cursor: not-allowed;
}


/* -------------------------------------------------------------
   11. Card (generic)
   ------------------------------------------------------------- */
.ds-card-soft {
  background: var(--ds-color-bg);
  border-radius: var(--ds-radius-soft);
  box-shadow: var(--ds-shadow-soft);
  padding: var(--ds-space-lg);
  margin-bottom: var(--ds-space-lg);
}

/* -------------------------------------------------------------
   12. Print
   ------------------------------------------------------------- */
.ds-btn-print {
  background: var(--ds-color-gray-100);
  color: var(--ds-color-gray-700);
  border: 1px solid var(--ds-color-gray-200);
}
.ds-btn-print:hover {
  background: var(--ds-color-gray-200);
}

@media print {
  .ds-btn-print,
  .ds-org-actions { display: none !important; }
  .ds-org-node { box-shadow: none; border: 1px solid var(--ds-color-gray-300); }
  .ds-summary { box-shadow: none; border: 1px solid var(--ds-color-gray-300); }
}

/* -------------------------------------------------------------
   13. Responsive
   ------------------------------------------------------------- */
@media (max-width: 768px) {
  .ds-summary {
    grid-template-columns: repeat(2, 1fr);
  }
  .ds-org-node {
    min-width: 180px;
    max-width: 100%;
  }

  /* --- Convert Horizontal Grid to Nested Folder Tree --- */
  .ds-tree-branches {
    padding-top: var(--ds-space-md);
  }

  .ds-tree-grid {
    display: flex;
    flex-direction: column;
    gap: 0; /* Fix broken lines between li items */
    padding: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 320px;
  }
  /* Hide old vertical grid line */
  .ds-tree-grid::after {
    display: none;
  }
  /* Connect root to first grid */
  .ds-tree-grid:first-child::before {
    content: '';
    position: absolute;
    top: calc(-1 * var(--ds-space-md));
    left: 0;
    width: 50%;
    right: auto; /* Override desktop right constraint */
    height: 2px;
    background-color: var(--ds-color-gray-300);
    display: block;
    z-index: 0;
  }
  .ds-tree-grid:not(:first-child)::before {
    display: none;
  }

  .ds-tree-grid > li {
    flex: 0 0 auto;
    width: 100%;
    padding-top: var(--ds-space-lg);
    padding-left: var(--ds-space-lg);
    align-items: flex-start;
  }
  .ds-tree-grid > li:first-child {
    padding-top: 0;
  }

  /* Horizontal branch to card */
  .ds-tree-grid > li::before {
    content: '';
    position: absolute;
    top: calc(var(--ds-space-lg) + 24px);
    left: 0;
    width: var(--ds-space-lg);
    height: 2px;
    background-color: var(--ds-color-gray-300);
    transform: none;
  }
  .ds-tree-grid > li:first-child::before {
    top: 24px;
  }

  /* Vertical trunk segment on EACH li */
  .ds-tree-grid > li::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background-color: var(--ds-color-gray-300);
    transform: none;
    z-index: 0;
  }
  /* Reach up to connect to previous grid or top horizontal line */
  .ds-tree-grid > li:first-child::after {
    top: calc(-1 * var(--ds-space-md));
  }
  /* Stop trunk at the last item of the last grid */
  .ds-tree-grid:last-child > li:last-child::after {
    bottom: auto;
    height: calc(var(--ds-space-lg) + 24px);
  }
  .ds-tree-grid:last-child > li:first-child:last-child::after {
    height: calc(var(--ds-space-md) + 24px);
  }
}



/* -------------------------------------------------------------
   15. Form Inputs (Redesign)
   ------------------------------------------------------------- */
.ds-label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--ds-space-sm);
  color: var(--ds-color-gray-700);
  font-size: var(--ds-font-size-base);
}

/* ---- Checkbox & Radio ---- */
.ds-checkbox-soft, .ds-radio-soft {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.5rem;
}
.ds-checkbox-soft input[type="checkbox"],
.ds-radio-soft input[type="radio"] {
  margin-top: 0;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--ds-color-brand);
  cursor: pointer;
}
.ds-checkbox-soft label,
.ds-radio-soft label {
  margin: 0;
  cursor: pointer;
  color: var(--ds-color-gray-700);
  font-size: var(--ds-font-size-base);
  line-height: 1.5;
}

.ds-input-soft {
  display: block;
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid var(--ds-color-gray-300);
  padding: 0.5rem 0.75rem;
  font-size: var(--ds-font-size-base);
  font-family: inherit;
  color: var(--ds-color-gray-900);
  background-color: var(--ds-color-bg);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, background-color 0.15s ease-in-out;
  min-height: 48px; /* Touch target minimum */
}

.ds-input-soft:focus {
  border-color: var(--ds-color-brand);
  box-shadow: 0 0 0 0.25rem var(--ds-color-brand-light);
  outline: 0;
}

textarea.ds-input-soft {
  height: auto !important;
  min-height: 48px;
}

.ds-input-soft:read-only, .ds-input-soft:disabled {
  background-color: var(--ds-color-gray-100);
  color: var(--ds-color-gray-500);
  cursor: not-allowed;
}

select.ds-input-soft {
  appearance: auto;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* Section 17. Scoped Global UI Override (Sidebar + Navbar) removed per PM request */

/* -------------------------------------------------------------
   16. Radio & Checkbox (replaces legacy .checkbox-fade)
   ------------------------------------------------------------- */
.ds-radio-soft,
.ds-checkbox-soft {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-sm);
  cursor: pointer;
  font-size: var(--ds-font-size-base);
  color: var(--ds-color-gray-700);
  padding: var(--ds-space-sm) 0;
  user-select: none;
}
.ds-radio-soft input[type="radio"],
.ds-checkbox-soft input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ds-color-gray-300);
  background: var(--ds-color-bg);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.ds-radio-soft input[type="radio"] {
  border-radius: 50%;
}
.ds-checkbox-soft input[type="checkbox"] {
  border-radius: 0.375rem;
}
.ds-radio-soft input[type="radio"]:checked {
  border-color: var(--ds-color-brand);
  background: var(--ds-color-bg);
  box-shadow: inset 0 0 0 4px var(--ds-color-brand);
}
.ds-checkbox-soft input[type="checkbox"]:checked {
  border-color: var(--ds-color-brand);
  background: var(--ds-color-brand);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
}
.ds-radio-soft input:focus,
.ds-checkbox-soft input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--ds-color-brand-light);
}
.ds-radio-soft input:disabled,
.ds-checkbox-soft input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =============================================================
   Style Soft — Overrides (merged from design-system-soft.css)
   ============================================================= */


/* -------------------------------------------------------------
   Buttons — Gradient style
   ------------------------------------------------------------- */
/* .ds-btn-primary (gradient) removed — consolidated into the ADR-017 AAA block below. */
.ds-btn-outline {
  border-radius: 999px;
}
.ds-btn-outline:hover {
  background: var(--ds-color-brand-light);
}

/* -------------------------------------------------------------
   Tabs — Pill filled active
   ------------------------------------------------------------- */
.ds-tabs {
  border-bottom: none;
  gap: var(--ds-space-sm);
  background: var(--ds-color-gray-100);
  border-radius: 999px;
  padding: var(--ds-space-xs);
  display: inline-flex;
}
.ds-tab {
  border-radius: 999px;
  padding: var(--ds-space-sm) 1.25rem;
}
.ds-tab.active {
  background: var(--ds-color-brand);
  color: var(--ds-color-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.ds-tab:hover:not(.active) {
  background: var(--ds-color-gray-200);
}

/* -------------------------------------------------------------
   Cards — Visible border + stronger shadow (client feedback: stand out from white BG)
   ------------------------------------------------------------- */
.ds-org-node {
  border: 1px solid var(--ds-color-gray-200);
  border-radius: var(--ds-radius-soft);
  box-shadow: var(--ds-shadow-card);
}
.ds-card-soft {
  border: 1px solid var(--ds-color-gray-200);
  border-radius: var(--ds-radius-soft);
}
/* Personnel Card nodes — match shadow with main Org Chart nodes */
.ds-tree-node .ds-card-soft,
.ds-tree-root .ds-card-soft,
.ds-tree-col .ds-card-soft {
  box-shadow: var(--ds-shadow-card);
}
.ds-summary {
  border: 1px solid var(--ds-color-gray-200);
  border-radius: var(--ds-radius-soft);
}
/* Gradient headers per level removed per user request */
.ds-org-header {
  border-radius: var(--ds-radius-soft) var(--ds-radius-soft) 0 0;
}
.ds-org-name {
  white-space: normal;
  overflow: visible;
  line-height: 1.4;
}

/* -------------------------------------------------------------
   Org Card — Horizontal layout (Inline)
   ------------------------------------------------------------- */
.ds-tree-grid > li {
  flex: 0 0 auto; /* Allow node to expand width */
  min-width: 320px;
}

.ds-org-metrics {
  flex-direction: row;
  justify-content: center;
  gap: var(--ds-space-sm);
}

/* Metric items with colored outline */
.ds-metric {
  padding: var(--ds-space-xs) var(--ds-space-sm);
  border-radius: var(--ds-radius-lg);
  flex: 1;
  justify-content: center;
  background-color: transparent;
}
.ds-metric-svnt { border: 2px solid var(--ds-color-emp-svnt); }
.ds-metric-gov { border: 2px solid var(--ds-color-emp-gov); }
.ds-metric-per { border: 2px solid var(--ds-color-emp-per); }

.ds-org-node .ds-dot,
.ds-org-node .ds-metric-label {
  display: none;
}

.ds-metric-direct {
  color: var(--ds-color-gray-500);
  margin-left: var(--ds-space-xs);
}
.ds-metric-direct::before {
  content: '|';
  margin-right: 4px;
}
.ds-legend-direct-sep::before {
  content: '|';
}

/* -------------------------------------------------------------
   Summary Card — Softer appearance
   ------------------------------------------------------------- */
.ds-summary-item {
  background: var(--ds-color-gray-50);
  border-radius: var(--ds-radius-soft);
  padding: 1.25rem;
}
.ds-summary-value {
  background: linear-gradient(135deg, var(--ds-color-brand), var(--ds-color-brand-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* Summary Card — emp_type colored backgrounds override */
.ds-summary-item.ds-summary-svnt {
  background: var(--ds-color-emp-svnt);
}
.ds-summary-item.ds-summary-per {
  background: var(--ds-color-emp-per);
}
.ds-summary-item.ds-summary-gov {
  background: var(--ds-color-emp-gov);
}
.ds-summary-item.ds-summary-svnt .ds-summary-value,
.ds-summary-item.ds-summary-per .ds-summary-value,
.ds-summary-item.ds-summary-gov .ds-summary-value {
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: var(--ds-color-bg);
  background-clip: unset;
  color: var(--ds-color-bg);
}
.ds-summary-item.ds-summary-svnt .ds-summary-label,
.ds-summary-item.ds-summary-per .ds-summary-label,
.ds-summary-item.ds-summary-gov .ds-summary-label {
  color: rgba(255,255,255,0.9);
}

/* -------------------------------------------------------------
   Tables & Pagination (Soft Style)
   ------------------------------------------------------------- */
.ds-table-soft thead th {
  background: var(--ds-color-brand-secondary);
  border-bottom: none;
}
.ds-table-soft tbody tr:hover {
  background-color: rgba(0, 148, 255, 0.05);
}

.ds-pagination-soft li a,
.ds-pagination-soft li span {
  border-radius: 50%;
  border: none;
  background-color: transparent;
  color: var(--ds-color-gray-500);
}
.ds-pagination-soft li a:hover {
  background-color: var(--ds-color-gray-100);
  color: var(--ds-color-brand);
}
.ds-pagination-soft li.active span {
  background: var(--ds-color-brand);
  color: var(--ds-color-bg);
  box-shadow: 0 4px 10px rgba(0, 148, 255, 0.2);
}

/* -------------------------------------------------------------
   Breadcrumb — Rounded pill links
   ------------------------------------------------------------- */
.ds-breadcrumb a {
  padding: var(--ds-space-xs) 0.75rem;
  background: var(--ds-color-brand-light);
  border-radius: 999px;
  color: var(--ds-color-brand);
}
.ds-breadcrumb a:hover {
  background: var(--ds-color-brand-medium);
  text-decoration: none;
}

/* -------------------------------------------------------------
   Local node — Softer pink highlight
   ------------------------------------------------------------- */
.ds-org-local {
  border: none;
  background: linear-gradient(135deg, #FDF2F8, #FCE7F3);
}
.ds-org-local .ds-org-header {
  background: linear-gradient(135deg, var(--ds-color-emp-local), #F472B6) !important;
}

/* -------------------------------------------------------------
   Hover micro-animation
   ------------------------------------------------------------- */
.ds-org-node:hover {
  transform: translateY(-4px);
}

/* -------------------------------------------------------------
   Form Inputs (Soft Style)
   ------------------------------------------------------------- */
.ds-input-soft {
  display: block; width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: var(--ds-font-size-base); font-family: inherit;
  color: var(--ds-color-gray-900); background-color: var(--ds-color-bg);
  border: 1px solid var(--ds-color-gray-300);
  border-radius: var(--ds-radius-soft);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) inset;
  min-height: 48px;
  height: 48px !important;
  transition: border-color .15s ease, box-shadow .15s ease;
  line-height: 1.5;
}

.ds-input-soft:focus {
  outline: none;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--ds-color-brand) 20%, transparent), 0 0 0 1px var(--ds-color-brand);
  border-color: var(--ds-color-brand);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .ds-input-soft:focus {
    box-shadow: 0 4px 14px rgba(0, 148, 255, 0.15), 0 0 0 1px var(--ds-color-brand);
  }
}
.ds-input-soft:disabled { background-color: var(--ds-color-gray-100); color: var(--ds-color-gray-500); cursor: not-allowed; }
.ds-input-soft.is-invalid { border-color: var(--ds-color-danger); }

/* Scoped Global UI removed per PM request */

/* ============================================================
   ADR-017 — Style Soft for Blade atoms/molecules (Batch 0)
   Adds: full .ds-btn variant set (AAA-verified), .ds-select-soft,
   .ds-field (soft form-group), .ds-modal-soft. Reference:
   public/design-system-v2-preview/. Filled buttons use bold labels
   so white text qualifies as "large text" (≥4.5:1 = AAA-large).
   ============================================================ */

/* ---- Buttons: AAA fix + full variant set ---- */
.ds-btn-primary { background: var(--ds-color-primary); color: var(--ds-color-bg); font-weight: 700; border-radius: 999px; }
.ds-btn-primary:hover { background: var(--ds-color-primary-hover); color: var(--ds-color-bg); box-shadow: 0 4px 14px color-mix(in srgb, var(--ds-color-primary) 40%, transparent); }
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .ds-btn-primary:hover { box-shadow: 0 4px 14px rgba(7, 115, 223, 0.35); background: var(--ds-color-primary-hover); }
}
.ds-btn-secondary { background: var(--ds-color-gray-100); color: var(--ds-color-gray-700); border: 1px solid var(--ds-color-gray-300); }
.ds-btn-secondary:hover { background: var(--ds-color-gray-200); }

/* Option B: Outline with soft pastel bg (WCAG AAA/AA compliant colors) */
.ds-btn-success { background: var(--ds-color-success-bg); color: var(--ds-color-success-text); border: 1px solid var(--ds-color-success-border); font-weight: 700; }
.ds-btn-success:hover { background: color-mix(in srgb, var(--ds-color-success-bg) 90%, black); }

.ds-btn-save { background: var(--ds-color-primary); color: var(--ds-color-bg); font-weight: 700; } /* Keeps primary fill style for Save button */
.ds-btn-save:hover { background: var(--ds-color-primary-hover); }

.ds-btn-danger, .ds-btn-delete { background: var(--ds-color-danger-bg); color: var(--ds-color-danger-text); border: 1px solid var(--ds-color-danger-border); font-weight: 700; }
.ds-btn-danger:hover, .ds-btn-delete:hover { background: var(--ds-color-danger-border); color: var(--ds-color-danger-text-hover); border-color: var(--ds-color-danger-border-hover); }

.ds-btn-warning { background: var(--ds-color-warning-bg); color: var(--ds-color-warning-text); border: 1px solid var(--ds-color-warning-border); font-weight: 700; }
.ds-btn-warning:hover { background: color-mix(in srgb, var(--ds-color-warning-bg) 90%, black); }

.ds-btn-info { background: var(--ds-color-info-bg); color: var(--ds-color-info-text); border: 1px solid var(--ds-color-info-border); font-weight: 700; }
.ds-btn-info:hover { background: var(--ds-color-info-border); color: var(--ds-color-info-text-hover); border-color: var(--ds-color-info-border-hover); }

.ds-btn-dark { background: var(--ds-color-gray-900); color: var(--ds-color-bg); font-weight: 700; }
.ds-btn-dark:hover { background: var(--ds-color-black); }
.ds-btn-light { background: var(--ds-color-gray-100); color: var(--ds-color-gray-900); border: 1px solid var(--ds-color-gray-200); }
.ds-btn-light:hover { background: var(--ds-color-gray-200); }
.ds-btn-cancel { background: var(--ds-color-bg); color: var(--ds-color-gray-700); border: 1px solid var(--ds-color-gray-300); }
.ds-btn-cancel:hover { background: var(--ds-color-gray-100); }

.ds-btn:focus, .ds-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-color-primary) 35%, transparent); }
.ds-btn:disabled, .ds-btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- Select (matches .ds-input-soft) ---- */
.ds-select-soft {
  display: block; width: 100%;
  border-radius: var(--ds-radius-soft);
  border: 1px solid var(--ds-color-gray-300);
  padding: 0 2.5rem 0 0.75rem;
  font-size: var(--ds-font-size-base); font-family: inherit;
  color: var(--ds-color-gray-900); background-color: var(--ds-color-bg);
  min-height: 48px;
  height: 48px !important;
  line-height: 46px; /* align vertically inside 48px box */
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center;
}
.ds-select-soft:focus { outline: none; border-color: var(--ds-color-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-color-brand) 35%, transparent); }
.ds-select-soft:disabled { background-color: var(--ds-color-gray-100); color: var(--ds-color-gray-500); cursor: not-allowed; }
.ds-select-soft.is-invalid { border-color: var(--ds-color-danger); }

/* ---- Form field (soft form-group; replaces Bootstrap col grid) ---- */
.ds-field { margin-bottom: var(--ds-space-lg); }
.ds-field > .ds-label { margin-bottom: var(--ds-space-sm); }
.ds-field .req { color: var(--ds-color-danger); margin-left: 2px; }
.ds-field-help { font-size: var(--ds-font-size-sm); color: var(--ds-color-gray-700); margin-top: 6px; } /* AAA: gray-700 ≈10:1 */
.ds-field-error { font-size: var(--ds-font-size-sm); color: var(--ds-color-danger); margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.ds-field.is-invalid .ds-label { color: var(--ds-color-danger); }
.ds-field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 var(--ds-space-lg); }

/* ---- Modal (soft dialog shell) ---- */
.ds-modal-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: var(--ds-z-modal, 1050); }
.ds-modal-backdrop.open, .ds-modal-backdrop.show { display: flex; }
.ds-modal-soft { background: var(--ds-color-bg); border-radius: var(--ds-radius-soft); box-shadow: var(--ds-shadow-soft-lg); width: 100%; max-width: 520px; overflow: hidden; animation: dsModalIn .22s cubic-bezier(.22,1,.36,1); }
@keyframes dsModalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .ds-modal-soft { animation: none; } }
.ds-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: var(--ds-space-lg) var(--ds-space-lg) var(--ds-space-md); }
.ds-modal-head h3 { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--ds-color-gray-900); }
.ds-modal-close { border: none; background: var(--ds-color-gray-100); color: var(--ds-color-gray-700); width: 34px; height: 34px; border-radius: 999px; font-size: 1.1rem; cursor: pointer; line-height: 1; transition: background .15s ease; }
.ds-modal-close:hover { background: var(--ds-color-gray-200); }
.ds-modal-close:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-color-brand) 35%, transparent); }
.ds-modal-body { padding: 0 var(--ds-space-lg) var(--ds-space-md); color: var(--ds-color-gray-700); }
.ds-modal-foot { display: flex; justify-content: flex-end; gap: var(--ds-space-sm); padding: var(--ds-space-md) var(--ds-space-lg) var(--ds-space-lg); }

/* ============================================================
   ADR-017 Batch 2.5 — Style Soft component set 2
   feedback (alert/toast), pills (badge/chip/tag), indicators
   (progress/spinner/avatar), divider, empty-state, page-header,
   tooltip, dropdown. AAA tints (100/800 ≈7:1). No side-stripe.
   ============================================================ */

/* ---- Alert (soft tint + full border, AAA 100/800 pairs) ---- */
.ds-alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: .75rem; border: 1px solid; font-size: var(--ds-font-size-sm); line-height: 1.5; }
.ds-alert > i { font-size: 1.05rem; margin-top: 1px; }
.ds-alert b { font-weight: 700; }
.ds-alert .close { margin-left: auto; margin-top: -4px; margin-right: -4px; padding: 0; line-height: 1; opacity: 0.6; }
.ds-alert .close:hover { opacity: 1; }
.ds-alert-info { background: var(--ds-color-info-bg); border-color: var(--ds-color-info-border); color: var(--ds-color-info-text); }
.ds-alert-success { background: var(--ds-color-success-bg); border-color: var(--ds-color-success-border); color: var(--ds-color-success-text); }
.ds-alert-warning { background: var(--ds-color-warning-bg); border-color: var(--ds-color-warning-border); color: var(--ds-color-warning-text); }
.ds-alert-danger { background: var(--ds-color-danger-bg); border-color: var(--ds-color-danger-border); color: var(--ds-color-danger-text); }

/* ---- Pills: badge / status / chip / tag ---- */
.ds-badge-soft { display: inline-flex; align-items: center; gap: 5px; font-size: 0.875rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; line-height: 1.4; } /* Set min size to 14px */
.ds-badge-soft.is-draft, .ds-badge-soft.is-canceled { background: var(--ds-color-gray-200); color: var(--ds-color-gray-700); }
.ds-badge-soft.is-pending { background: var(--ds-color-warning-bg); color: var(--ds-color-warning-text); }
.ds-badge-soft.is-approved { background: var(--ds-color-success-bg); color: var(--ds-color-success-text); }
.ds-badge-soft.is-rejected { background: var(--ds-color-danger-bg); color: var(--ds-color-danger-text); }
.ds-chip-soft { display: inline-flex; align-items: center; gap: 6px; font-size: 1rem; font-weight: 500; padding: 6px 14px; border-radius: 999px; background: var(--ds-color-gray-100); color: var(--ds-color-gray-700); border: 1px solid var(--ds-color-gray-200); } /* Set min size to 16px */
.ds-chip-soft .x { cursor: pointer; color: var(--ds-color-gray-500); font-weight: 700; line-height: 1; display: inline-flex; align-items: center; justify-content: center; min-width: 20px; min-height: 20px; margin: -4px -6px -4px 0; padding: 4px 6px; border-radius: 999px; } /* P2 fix: larger touch target */
.ds-chip-soft .x:hover { color: var(--ds-color-gray-900); background: var(--ds-color-gray-200); }
.ds-tag-soft { display: inline-block; font-size: 0.875rem; font-weight: 600; padding: 3px 10px; border-radius: 6px; background: var(--ds-color-brand-light); color: #005490; } /* Set min size to 14px */
.ds-tag-soft.ds-tag--xs { font-size: 0.875rem; padding: 2px 8px; }
.ds-tag-soft.ds-tag--md { font-size: 1rem; padding: 4px 12px; }

/* ---- Toast (soft card + soft-lg shadow) ---- */
.ds-toast { display: flex; gap: 12px; align-items: flex-start; max-width: 380px; padding: 14px 16px; border-radius: .75rem; background: var(--ds-color-bg); box-shadow: var(--ds-shadow-soft-lg); border: 1px solid var(--ds-color-gray-200); }
.ds-toast .ic { width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; flex: none; color: var(--ds-color-bg); }
.ds-toast.is-success .ic { background: var(--ds-color-success); }
.ds-toast.is-danger .ic { background: var(--ds-color-danger); }
.ds-toast.is-info .ic { background: var(--ds-color-brand-dark); }
.ds-toast .body { font-size: var(--ds-font-size-sm); color: var(--ds-color-gray-700); }
.ds-toast .body b { display: block; color: var(--ds-color-gray-900); margin-bottom: 2px; }

/* ---- Indicators: progress / spinner / avatar ---- */
.ds-progress-container { display: flex; align-items: center; gap: var(--ds-space-sm); width: 100%; }
.ds-progress { height: 10px; border-radius: 999px; background: var(--ds-color-gray-200); overflow: hidden; flex: 1; }
.ds-progress-bar { height: 100%; border-radius: 999px; background: var(--ds-color-brand); transition: width .3s ease; }
.ds-progress-label { font-size: var(--ds-font-size-sm); font-weight: 700; color: var(--ds-color-gray-700); flex-shrink: 0; line-height: 1; }
.ds-spinner-soft { width: 28px; height: 28px; border-radius: 999px; border: 3px solid var(--ds-color-gray-200); border-top-color: var(--ds-color-brand); animation: dsspin .7s linear infinite; }
@keyframes dsspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ds-spinner-soft { animation-duration: 2s; } }
.ds-avatar { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: var(--ds-color-bg); background: var(--ds-color-brand-dark); }
.ds-avatar-group { display: flex; }
.ds-avatar-group .ds-avatar { border: 2px solid var(--ds-color-bg); margin-left: -10px; }
.ds-avatar-group .ds-avatar:first-child { margin-left: 0; }

/* ---- Divider ---- */
.ds-divider-soft { height: 1px; background: var(--ds-color-gray-200); border: 0; margin: 8px 0; }

/* ---- Empty state ---- */
.ds-empty { text-align: center; padding: 48px 24px; color: var(--ds-color-gray-700); }
.ds-empty .ic { width: 64px; height: 64px; border-radius: 999px; background: var(--ds-color-gray-100); display: grid; place-items: center; margin: 0 auto 16px; color: var(--ds-color-gray-400); font-size: 1.6rem; }
.ds-empty h4 { margin: 0 0 4px; color: var(--ds-color-gray-900); font-weight: 700; font-size: 1.05rem; }
.ds-empty p { margin: 0 0 16px; font-size: var(--ds-font-size-sm); }

/* ---- Page header ---- */
.ds-page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 16px; border-bottom: 1px solid var(--ds-color-gray-200); }
.ds-page-header .crumb { font-size: .78rem; color: var(--ds-color-gray-700); margin-bottom: 4px; }
.ds-page-header h1 { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--ds-color-gray-900); }
.ds-page-header-actions { display: flex; gap: var(--ds-space-sm); align-items: center; flex-wrap: wrap; }

/* ---- Tooltip (CSS; hover + focus for a11y) ---- */
.ds-tip { position: relative; display: inline-flex; }
.ds-tip .tip { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: var(--ds-color-gray-900); color: var(--ds-color-bg); font-size: .72rem; padding: 5px 9px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s ease; z-index: var(--ds-z-tooltip, 1070); }
.ds-tip:hover .tip, .ds-tip:focus-within .tip { opacity: 1; } /* P2 fix: focus-within for keyboard a11y */

/* ---- Dropdown menu (soft-lg shadow; escape overflow at call-site via position:fixed/portal) ---- */
.ds-dropdown { background: var(--ds-color-bg); border-radius: .75rem; box-shadow: var(--ds-shadow-soft-lg); border: 1px solid var(--ds-color-gray-200); padding: 6px; min-width: 200px; }
.ds-dropdown a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: .5rem; color: var(--ds-color-gray-700); text-decoration: none; font-size: var(--ds-font-size-sm); }
.ds-dropdown a:hover { background: var(--ds-color-gray-100); color: var(--ds-color-gray-900); }
.ds-dropdown a.is-danger { color: var(--ds-color-danger-text); }
.ds-dropdown a.is-danger:hover { background: var(--ds-color-danger-bg); }
.ds-dd-sep { height: 1px; background: var(--ds-color-gray-200); margin: 6px 4px; }

/* ---- Structural components (modal/form-group): CSS-only soft, no markup/JS change ---- */
/* Soft-ify ALL Bootstrap modals app-wide (cosmetic; .modal/.modal-content classes,
   data-dismiss, AJAX content-class hooks all untouched). Loaded after bootstrap.css. */
.modal-content { border-radius: var(--ds-radius-soft); box-shadow: var(--ds-shadow-soft-lg); border: 0; }
.modal-header, .modal-footer { border-color: var(--ds-color-gray-200); }
/* form-group: soften label to AAA gray-700 while keeping the Bootstrap col grid. */
.ds-form-group .col-form-label, .ds-form-group > label { color: var(--ds-color-gray-700); font-weight: 600; }

/* ============================================================
   Soft Style v2 Additions (Links, Switch, File Input, Date Input)
   ============================================================ */
/* ---- Link ---- */
.ds-link {
  color: var(--ds-color-primary);
  text-decoration: none;
  transition: color 0.15s ease, text-decoration 0.15s ease;
  font-weight: 600;
}
.ds-link:hover {
  color: var(--ds-color-primary-hover);
  text-decoration: underline;
}
.ds-link-primary { color: var(--ds-color-primary); }
.ds-link-primary:hover { color: var(--ds-color-primary-hover); }
.ds-link-muted { color: var(--ds-color-gray-500); }
.ds-link-muted:hover { color: var(--ds-color-gray-700); }
.ds-link-danger { color: var(--ds-color-danger); }
.ds-link-danger:hover { color: var(--ds-color-danger-text); }

/* Override legacy #01a9ac hardcodes globally within .ds-scope or where used */
.text-primary, a.text-primary:focus, a.text-primary:hover { color: var(--ds-color-primary) !important; }
.bg-primary { background-color: var(--ds-color-primary) !important; }
.tooltip-inner { background-color: var(--ds-color-primary); }
.bs-tooltip-top .arrow::before { border-top-color: var(--ds-color-primary); }
.bs-tooltip-bottom .arrow::before { border-bottom-color: var(--ds-color-primary); }

/* ---- iOS Switch ---- */
.ds-switch-soft {
  display: inline-flex;
  align-items: center;
}
.ds-switch-soft.custom-control {
  padding-left: 0;
  display: inline-flex;
  min-height: auto;
}
.ds-switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.ds-switch-label {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-sm);
  cursor: pointer;
  user-select: none;
  font-size: var(--ds-font-size-base);
  color: var(--ds-color-gray-700);
  margin-bottom: 0;
}
.ds-switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background-color: var(--ds-color-gray-300);
  border-radius: 999px;
  transition: background-color 0.2s ease;
}
.ds-switch-toggle::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.ds-switch-input:checked + .ds-switch-label .ds-switch-toggle {
  background-color: var(--ds-color-brand);
}
.ds-switch-input:checked + .ds-switch-label .ds-switch-toggle::before {
  transform: translateX(20px);
}
.ds-switch-input:focus + .ds-switch-label .ds-switch-toggle {
  box-shadow: 0 0 0 3px var(--ds-color-brand-light);
}
.ds-switch-input:disabled + .ds-switch-label {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- Date Input ---- */
.ds-date-input {
  position: relative;
}
.ds-date-icon {
  min-height: 48px;
  height: 48px !important;
  border-radius: 0 var(--ds-radius-soft) var(--ds-radius-soft) 0 !important;
  border: 1px solid var(--ds-color-gray-300);
  border-left: 0;
  background-color: var(--ds-color-gray-100);
  color: var(--ds-color-gray-500);
  display: flex;
  align-items: center;
  padding: 0 1rem;
}
.ds-date-input .ds-input-soft:focus + .input-group-append .ds-date-icon {
  border-color: var(--ds-color-brand);
}

/* Fix Datepicker Dropdown (dropdown แตก) */
.datepicker > div {
  display: none;
}
.datepicker.dropdown-menu {
  border-radius: var(--ds-radius-soft);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--ds-color-gray-200);
  padding: 8px;
  background-color: var(--ds-color-bg);
}
.datepicker table tr td.day, .datepicker table tr th.dow {
  text-align: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: none;
}
.datepicker table tr td.active, .datepicker table tr td.active:hover, .datepicker table tr td.active.disabled, .datepicker table tr td.active.disabled:hover {
  background-color: var(--ds-color-brand) !important;
  color: var(--ds-color-bg) !important;
  text-shadow: none;
  border-color: var(--ds-color-brand);
}
.datepicker table tr td.today, .datepicker table tr td.today:hover, .datepicker table tr td.today.disabled, .datepicker table tr td.today.disabled:hover {
  background-color: var(--ds-color-brand-light) !important;
  background-image: none !important;
  color: var(--ds-color-brand) !important;
}

/* ---- File Input ---- */
.ds-file-input-soft {
  display: block;
  width: 100%;
}
.ds-file-input-soft .custom-file {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 48px;
  margin-bottom: 0;
}
.ds-file-input-soft .custom-file-input {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 48px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.ds-file-input-soft .custom-file-label {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  z-index: 1;
  height: 48px;
  padding: 0 1rem;
  line-height: 46px; /* center vertically */
  color: var(--ds-color-gray-700);
  background-color: var(--ds-color-bg);
  border: 1px solid var(--ds-color-gray-300);
  border-radius: var(--ds-radius-soft);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) inset;
  display: flex;
  align-items: center;
}
.ds-file-input-soft .custom-file-label::after {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  line-height: 46px;
  color: var(--ds-color-gray-700);
  content: "เลือกไฟล์";
  background-color: var(--ds-color-gray-100);
  border-left: 1px solid var(--ds-color-gray-300);
  border-radius: 0 var(--ds-radius-soft) var(--ds-radius-soft) 0;
  height: 100%;
}
.ds-file-input-soft .custom-file-input:focus ~ .custom-file-label {
  border-color: var(--ds-color-brand);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--ds-color-brand) 20%, transparent), 0 0 0 1px var(--ds-color-brand);
}

/* ---- Date Input ---- */
.ds-date-input.input-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  width: 100%;
  border-radius: var(--ds-radius-soft);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ds-date-input .ds-date-display {
  display: block;
  flex: 1 1 auto;
  width: 1%;
  min-height: 48px;
  height: 48px !important;
  border-radius: var(--ds-radius-soft) 0 0 var(--ds-radius-soft) !important;
  border: 1px solid var(--ds-color-gray-300);
  border-right: none;
  padding: 0.5rem 0.75rem;
  font-size: var(--ds-font-size-base);
  font-family: inherit;
  color: var(--ds-color-gray-900);
  background-color: var(--ds-color-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) inset;
}
.ds-date-input .ds-date-display:focus {
  outline: 0;
}
.ds-date-input .input-group-append .input-group-text {
  background-color: var(--ds-color-gray-100);
  border: 1px solid var(--ds-color-gray-300);
  border-radius: 0 var(--ds-radius-soft) var(--ds-radius-soft) 0 !important;
  color: var(--ds-color-gray-500);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  height: 48px;
}
.ds-date-input:focus-within {
  box-shadow: 0 4px 14px color-mix(in srgb, var(--ds-color-brand) 20%, transparent), 0 0 0 1px var(--ds-color-brand);
}
.ds-date-input:focus-within .ds-date-display {
  border-color: var(--ds-color-brand);
}
.ds-date-input:focus-within .input-group-append .input-group-text {
  border-color: var(--ds-color-brand);
}

/* -------------------------------------------------------------
   Gap: Tabs/Headings → Table spacing
   ------------------------------------------------------------- */
.ds-btn-group + .table-responsive,
.ds-tabs + .table-responsive {
  margin-top: var(--ds-space-lg);
}
.ds-section-heading + .table-responsive {
  margin-top: var(--ds-space-md);
}

/* -------------------------------------------------------------
   Section Heading — icon circle + title + optional mock badge
   ------------------------------------------------------------- */
.ds-section-heading {
  display: flex;
  align-items: center;
  gap: var(--ds-space-sm);
  margin-bottom: var(--ds-space-lg);
  padding-bottom: var(--ds-space-sm);
  border-bottom: 1px solid var(--ds-color-gray-200);
}
.ds-section-heading-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-color-brand-light);
  color: var(--ds-color-brand);
  font-size: var(--ds-font-size-sm);
  flex-shrink: 0;
}
.ds-section-heading-title {
  font-weight: var(--ds-font-weight-bold);
  font-size: var(--ds-font-size-base);
  color: var(--ds-color-gray-900);
  flex: 1;
}
.ds-section-heading-mock {
  display: inline-flex;
  align-items: center;
  padding: var(--ds-space-xxs) var(--ds-space-sm);
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-medium);
  color: var(--ds-color-warning-text);
  background: var(--ds-color-warning-bg);
  border: 1px solid var(--ds-color-warning-border);
  border-radius: var(--ds-radius-pill);
  white-space: nowrap;
}
.ds-section-heading-actions {
  display: flex;
  align-items: center;
  gap: var(--ds-space-sm);
  margin-left: auto;
}

/* -------------------------------------------------------------
   Stat Card — KPI number with icon + color accent
   ------------------------------------------------------------- */
.ds-stat-card {
  display: flex;
  align-items: center;
  gap: var(--ds-space-md);
  padding: var(--ds-space-lg);
  background: var(--ds-color-bg);
  border: 1px solid var(--ds-color-gray-200);
  border-radius: var(--ds-radius-soft);
  box-shadow: var(--ds-shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.ds-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ds-shadow-card);
}
.ds-stat-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--ds-radius-lg);
  font-size: var(--ds-font-size-xl);
  flex-shrink: 0;
}
.ds-stat-card-icon--primary {
  background: var(--ds-color-brand-light);
  color: var(--ds-color-brand);
}
.ds-stat-card-icon--success {
  background: var(--ds-color-success-bg);
  color: var(--ds-color-success);
}
.ds-stat-card-icon--info {
  background: var(--ds-color-info-bg);
  color: var(--ds-color-info);
}
.ds-stat-card-body {
  flex: 1;
  min-width: 0;
}
.ds-stat-card-label {
  font-size: var(--ds-font-size-sm);
  color: var(--ds-color-gray-500);
  margin-bottom: var(--ds-space-xxs);
}
.ds-stat-card-value {
  font-size: var(--ds-font-size-2xl);
  font-weight: var(--ds-font-weight-bold);
  color: var(--ds-color-gray-900);
  line-height: var(--ds-line-height-tight);
}
.ds-stat-card-unit {
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-regular);
  color: var(--ds-color-gray-500);
  margin-left: var(--ds-space-xs);
}
/* Accent bar at bottom */
.ds-stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--ds-color-gray-200);
  transition: background 0.2s ease;
}
.ds-stat-card--primary::after { background: var(--ds-color-brand); }
.ds-stat-card--success::after { background: var(--ds-color-success); }
.ds-stat-card--info::after { background: var(--ds-color-info); }

/* -------------------------------------------------------------
   Person Card — employee card with emp-type border
   ------------------------------------------------------------- */
.ds-person-card {
  display: flex;
  align-items: center;
  gap: var(--ds-space-md);
  padding: var(--ds-space-md);
  background: var(--ds-color-bg);
  border: 1px solid var(--ds-color-gray-200);
  border-radius: var(--ds-radius-soft);
  box-shadow: var(--ds-shadow-sm);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-left-width 0.15s ease;
  border-left: 4px solid transparent;
}
.ds-person-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--ds-shadow-card);
  border-left-width: 6px;
}
/* Employee type border-left colors */
.ds-person-card--svnt { border-left-color: var(--ds-color-emp-svnt); }
.ds-person-card--gov  { border-left-color: var(--ds-color-emp-gov); }
.ds-person-card--per  { border-left-color: var(--ds-color-emp-per); }
.ds-person-card--local { border-left-color: var(--ds-color-emp-local); }

.ds-person-card-photo {
  width: 48px;
  height: 48px;
  border-radius: var(--ds-radius-pill);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ds-color-gray-100);
}
.ds-person-card--lg .ds-person-card-photo {
  width: 60px;
  height: 60px;
}
.ds-person-card-body {
  flex: 1;
  min-width: 0;
}
.ds-person-card-name {
  font-weight: var(--ds-font-weight-bold);
  font-size: var(--ds-font-size-base);
  color: var(--ds-color-gray-900);
  line-height: var(--ds-line-height-tight);
}
.ds-person-card-position {
  font-size: var(--ds-font-size-sm);
  color: var(--ds-color-gray-500);
  margin-top: var(--ds-space-xxs);
}
.ds-person-card-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--ds-space-xxs) var(--ds-space-sm);
  font-size: var(--ds-font-size-xs);
  border-radius: var(--ds-radius-pill);
  margin-top: var(--ds-space-xs);
}
.ds-person-card-badge--svnt {
  background: color-mix(in srgb, var(--ds-color-emp-svnt) 10%, transparent);
  color: var(--ds-color-emp-svnt);
}
.ds-person-card-badge--gov {
  background: color-mix(in srgb, var(--ds-color-emp-gov) 10%, transparent);
  color: var(--ds-color-emp-gov);
}
.ds-person-card-badge--per {
  background: color-mix(in srgb, var(--ds-color-emp-per) 10%, transparent);
  color: var(--ds-color-emp-per);
}

/* Vacant state */
.ds-person-card--vacant {
  opacity: 0.7;
}
.ds-person-card--vacant .ds-person-card-name {
  font-style: italic;
  color: var(--ds-color-gray-400);
}
.ds-person-card-photo--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ds-color-gray-100);
  color: var(--ds-color-gray-400);
  font-size: var(--ds-font-size-xl);
}

/* Dot indicator — ensure all sizing uses CSS not inline */
.ds-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--ds-radius-pill);
  margin-right: var(--ds-space-xs);
  flex-shrink: 0;
}
.ds-dot--lg {
  width: 10px;
  height: 10px;
}
.ds-dot-svnt, .ds-dot--svnt { background-color: var(--ds-color-emp-svnt); }
.ds-dot-gov,  .ds-dot--gov  { background-color: var(--ds-color-emp-gov); }
.ds-dot-per,  .ds-dot--per  { background-color: var(--ds-color-emp-per); }
.ds-dot-local, .ds-dot--local { background-color: var(--ds-color-emp-local); }

