/* =============================================================
   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 !important;
  white-space: nowrap;
  line-height: 1.5;
  height: auto;
}

a.ds-btn,
a.ds-btn:hover,
a.ds-btn:focus,
a.ds-btn:active {
  text-decoration: none !important;
  outline: none;
}



/* Ignore standard link style if there's an <a> element nested in a button */
.ds-btn a,
.ds-btn a:hover,
.ds-btn a:focus,
.ds-btn a:active {
  color: inherit !important;
  text-decoration: none !important;
  font-weight: inherit !important;
  outline: none;
}

/* .ds-btn-primary consolidated into the ADR-017 AAA block near end of file. */
/* .ds-btn-outline consolidated (deprecated) into the .ds-btn-secondary block below. */

.ds-btn-sm {
  padding: var(--ds-space-xs) 0.75rem;
  font-size: var(--ds-font-size-sm);
  /* 14px — bumped from 12px */
}

/* Default button size (ADR-027). Named to match --ds-font-size-base (16px).
   The <x-atoms.button> default emits .ds-btn-base, so buttons read at 16px on
   desktop and step down to 14px (--ds-font-size-sm) on tablet & mobile
   (below the lg breakpoint) for tighter small-screen layouts. Pass size="sm"
   to force 14px on every screen. */
.ds-btn-base {
  font-size: var(--ds-font-size-base);
}

@media (max-width: 991.98px) {
  .ds-btn-base {
    font-size: var(--ds-font-size-sm);
  }
}

.ds-btn-block {
  width: 100%;
}

/* -------------------------------------------------------------
   7. Tabs
   ------------------------------------------------------------- */
.ds-tabs-line {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--ds-color-gray-200) !important;
  margin-bottom: var(--ds-space-lg);
  padding-bottom: 0;
  background-color: transparent !important;
  border-radius: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  list-style: none;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  white-space: nowrap !important;
  flex-wrap: nowrap !important;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.ds-tabs-line::-webkit-scrollbar {
  display: none;
}

.ds-tabs-line .ds-tab-item {
  margin-bottom: 0 !important;
  display: inline-flex;
  flex-shrink: 0 !important;
}

.ds-tabs-line .ds-tab {
  padding: var(--ds-space-sm) var(--ds-space-md) !important;
  font-size: var(--ds-font-size-sm);
  font-weight: 500;
  color: var(--ds-color-gray-500) !important;
  cursor: pointer;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  background: none !important;
  font-family: var(--ds-font-family-sans-th);
  transition: all 0.2s ease-in-out;
  text-decoration: none !important;
  line-height: 1.5;
  border-radius: 0 !important;
  box-shadow: none !important;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

.ds-tabs-line .ds-tab:hover {
  color: var(--ds-color-gray-700) !important;
}

.ds-tabs-line .ds-tab.active {
  color: var(--ds-color-brand) !important;
  border-bottom: 2px solid var(--ds-color-brand) !important;
  font-weight: 600;
  background-color: transparent !important;
}

.ds-tabs-line .ds-tab i {
  margin-right: var(--ds-space-xs) !important;
}

/* -------------------------------------------------------------
   7b. Pill Tabs (v2 & pill variants)
   ------------------------------------------------------------- */
.ds-tabs,
.ds-tabs-pill {
  border-bottom: none !important;
  gap: var(--ds-space-sm) !important;
  background: var(--ds-color-gray-100) !important;
  border-radius: var(--ds-radius-pill, 999px) !important;
  padding: var(--ds-space-xs) !important;
  display: inline-flex !important;
  width: fit-content !important;
  list-style: none;
  max-width: 100% !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  white-space: nowrap !important;
  flex-wrap: nowrap !important;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.ds-tabs::-webkit-scrollbar,
.ds-tabs-pill::-webkit-scrollbar {
  display: none;
}

.ds-tabs-pill .ds-tab-item {
  margin-bottom: 0 !important;
  display: inline-flex;
  flex-shrink: 0 !important;
}

.ds-tabs .ds-tab,
.ds-tabs-pill .ds-tab {
  border-radius: var(--ds-radius-pill, 999px) !important;
  padding: var(--ds-space-sm) var(--ds-space-md) !important;
  font-size: var(--ds-font-size-sm);
  font-weight: 500;
  color: var(--ds-color-gray-500) !important;
  cursor: pointer;
  border: none !important;
  background: none !important;
  font-family: var(--ds-font-family-sans-th);
  transition: all 0.2s ease;
  text-decoration: none !important;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}

.ds-tabs .ds-tab:hover:not(.active),
.ds-tabs-pill .ds-tab:hover:not(.active) {
  background: var(--ds-color-gray-200) !important;
  color: var(--ds-color-gray-700) !important;
}

.ds-tabs .ds-tab.active,
.ds-tabs-pill .ds-tab.active {
  background: var(--ds-color-brand) !important;
  color: var(--ds-color-bg) !important;
  font-weight: 600;
  box-shadow: var(--ds-shadow-soft) !important;
}

.ds-tabs .ds-tab i,
.ds-tabs-pill .ds-tab i {
  margin-right: var(--ds-space-xs) !important;
}

.ds-tab .badge {
  font-size: var(--ds-font-size-xs, 12px) !important;
  padding: var(--ds-space-xs) var(--ds-space-sm) !important;
  margin-left: var(--ds-space-xs) !important;
  border-radius: var(--ds-radius-pill, 999px) !important;
  background: var(--ds-color-brand-light, #E5EEFF) !important;
  color: var(--ds-color-brand, #0773DF) !important;
  font-weight: 600 !important;
}

.ds-tab.active .badge {
  background: var(--ds-color-bg, #ffffff) !important;
  color: var(--ds-color-brand, #0773DF) !important;
}
/* -------------------------------------------------------------
   8. Breadcrumb
   ------------------------------------------------------------- */
.ds-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--ds-space-sm);
  padding: 0.5rem 0;
  padding-left: 0;
  font-size: var(--ds-font-size-sm);
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
}

/* 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 {
  display: inline-flex;
  align-items: center;
  padding: var(--ds-space-xs) 0.75rem;
  background: var(--ds-color-brand-light);
  border-radius: 999px;
  color: var(--ds-color-brand);
  text-decoration: none;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.ds-breadcrumb a:hover {
  background: var(--ds-color-brand-medium);
  color: var(--ds-color-brand-dark) !important;
  text-decoration: none;
}

.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 !important;
  font-size: var(--ds-font-size-sm);
  text-align: left;
}

.ds-table-soft thead th {
  background-color: var(--ds-color-brand-light, #eef7ff);
  color: var(--ds-color-brand-dark, #1f5f93);
  padding: 14px 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--ds-color-brand-medium, #dceaf7);
}

.ds-table-soft thead th:first-child {
  border-radius: var(--ds-radius-lg, 8px) 0 0 0;
}

.ds-table-soft thead th:last-child {
  border-radius: 0 var(--ds-radius-lg, 8px) 0 0;
}

.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),
.ds-table-soft tbody tr:nth-child(even) td {
  background-color: var(--ds-color-bg-alt, #f8f9fa);
}

.ds-table-soft tbody tr:hover,
.ds-table-soft tbody tr:hover td {
  background-color: color-mix(in srgb, var(--ds-color-brand) 3%, transparent);
}

/* Dynamic zebra striping hooks for tables with custom page slicing/filtering */
.ds-table-soft tbody tr.table-td1 td {
  background-color: var(--ds-color-bg-alt, #f8f9fa) !important;
}

.ds-table-soft tbody tr.table-td2 td {
  background-color: var(--ds-color-bg, #ffffff) !important;
}

.ds-table-soft tbody tr:hover td {
  background-color: color-mix(in srgb, var(--ds-color-brand) 3%, transparent) !important;
}

.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;
  /* Sprint UXUI: no bottom margin — keeps a radio group tight to its description. */
  margin-bottom: 0;
}

.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);
  /* Sprint UXUI: tighter vertical footprint (was --ds-space-sm) so a group hugs its description. */
  padding: var(--ds-space-xs) 0;
  user-select: none;
}

.ds-radio-soft input[type="radio"],
.ds-checkbox-soft input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  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 5px 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: 16px;
  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;
}

/* Sprint UXUI: horizontal spacing BETWEEN choices (gap above is the internal
   radio↔label gap). Soft variant only — legacy custom-control keeps Bootstrap spacing. */
.ds-radio-soft:not(:last-child),
.ds-checkbox-soft:not(:last-child) {
  margin-right: var(--ds-space-md);
}

/* =============================================================
   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 (deprecated) consolidated into the .ds-btn-secondary block. */

/* Duplicate Tabs block removed — styled in section 7b above */

/* -------------------------------------------------------------
   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-light, #eef7ff);
  border-bottom: 1px solid var(--ds-color-brand-medium, #dceaf7);
}

.ds-table-soft tbody tr:hover {
  background-color: color-mix(in srgb, var(--ds-color-brand) 3%, transparent);
}

.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 pill override block consolidated into section 8 above (Style Soft v4) */

/* -------------------------------------------------------------
   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).
   ============================================================ */

/* -------------------------------------------------------------
   User theme scope
   -------------------------------------------------------------
   ครอบหน้า/ส่วนฝั่งผู้ใช้ (/hr/manual user view, FAQ user view ฯลฯ) ให้ FOREGROUND
   accent (ตัวหนังสือ/ลิงก์/ปุ่ม primary) เป็นส้ม contrast-safe แทนน้ำเงิน โดย remap
   --ds-color-primary → --ds-color-user-accent ภายใน scope นี้เท่านั้น. ไม่แตะ
   --ds-color-brand (decorative/themeable ตาม --head_bg). display:contents = ตัวห่อ
   ให้ token cascade ลง children โดยไม่สร้างกล่อง (ไม่กระทบ flex/layout เดิม). */
.ds-theme-user {
  display: contents;
  --ds-color-primary: var(--ds-color-user-accent);
  --ds-color-primary-hover: var(--ds-color-user-accent-dark);
}

/* ---- Buttons: AAA fix + full variant set ---- */
.ds-btn-primary {
  background: var(--ds-color-primary) !important;
  color: var(--ds-color-bg) !important;
  font-weight: 700;
  border-radius: 999px;
}

.ds-btn-primary:not(:disabled):not(.disabled):hover {
  background: var(--ds-color-primary-hover) !important;
  color: var(--ds-color-bg) !important;
  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:not(:disabled):not(.disabled):hover {
    box-shadow: 0 4px 14px rgba(7, 115, 223, 0.35);
    background: var(--ds-color-primary-hover) !important;
  }
}

/* .ds-btn-secondary = blue (primary) outline button.
   .ds-btn-outline = DEPRECATED alias — kept ONLY so legacy call-sites
   (masterdata/organization/v2/*, org-node-card) keep rendering. It used to be a
   divergent brand-outline; now it renders identically to secondary. Use
   variant="secondary" for all new code; migrate remaining .ds-btn-outline sites
   then delete this alias. */
.ds-btn-secondary,
.ds-btn-outline {
  background: transparent !important;
  color: var(--ds-color-primary) !important;
  border: 1px solid var(--ds-color-primary) !important;
  border-radius: 999px;
}

.ds-btn-secondary:not(:disabled):not(.disabled):hover,
.ds-btn-outline:not(:disabled):not(.disabled):hover {
  /* Light-blue tint on hover (not the solid primary fill) so secondary stays
     visually distinct from the primary button. Text/border stay primary blue. */
  background: color-mix(in srgb, var(--ds-color-primary) 12%, white) !important;
  color: var(--ds-color-primary) !important;
  border-color: var(--ds-color-primary) !important;
}

@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .ds-btn-secondary:not(:disabled):not(.disabled):hover,
  .ds-btn-outline:not(:disabled):not(.disabled):hover {
    background: #e7f1fc !important;
  }
}

/* Option B: Outline with soft pastel bg (WCAG AAA/AA compliant colors) */
.ds-btn-success {
  background: var(--ds-color-success-bg) !important;
  color: var(--ds-color-success-text) !important;
  border: 1px solid var(--ds-color-success-border) !important;
  font-weight: 700;
}

.ds-btn-success:not(:disabled):not(.disabled):hover {
  background: color-mix(in srgb, var(--ds-color-success-bg) 90%, black) !important;
}

.ds-btn-save {
  background: var(--ds-color-primary) !important;
  color: var(--ds-color-bg) !important;
  font-weight: 700;
}

.ds-btn-save:not(:disabled):not(.disabled):hover {
  background: var(--ds-color-primary-hover) !important;
}

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

.ds-btn-danger:not(:disabled):not(.disabled):hover {
  background: var(--ds-color-danger-border) !important;
  color: var(--ds-color-danger-text-hover) !important;
  border-color: var(--ds-color-danger-border-hover) !important;
}

/* delete = ปุ่มทึบ (solid red + text ขาว) — เน้นการกระทำอันตราย/ลบ ต่างจาก danger (soft) */
.ds-btn-delete {
  background: var(--ds-color-danger) !important;
  color: var(--ds-color-bg) !important;
  border: 1px solid var(--ds-color-danger) !important;
  font-weight: 700;
}

.ds-btn-delete:not(:disabled):not(.disabled):hover {
  background: var(--ds-color-danger-dark) !important;
  border-color: var(--ds-color-danger-dark) !important;
  color: var(--ds-color-bg) !important;
}

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

.ds-btn-warning:not(:disabled):not(.disabled):hover {
  background: color-mix(in srgb, var(--ds-color-warning-bg) 90%, black) !important;
}

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

.ds-btn-info:not(:disabled):not(.disabled):hover {
  background: var(--ds-color-info-border) !important;
  color: var(--ds-color-info-text-hover) !important;
  border-color: var(--ds-color-info-border-hover) !important;
}

.ds-btn-dark {
  background: var(--ds-color-gray-900) !important;
  color: var(--ds-color-bg) !important;
  font-weight: 700;
}

.ds-btn-dark:not(:disabled):not(.disabled):hover {
  background: var(--ds-color-black) !important;
}

.ds-btn-light {
  background: var(--ds-color-gray-100) !important;
  color: var(--ds-color-gray-900) !important;
  border: 1px solid var(--ds-color-gray-200) !important;
}

.ds-btn-light:not(:disabled):not(.disabled):hover {
  background: var(--ds-color-gray-200) !important;
}

.ds-btn-cancel {
  background: var(--ds-color-bg) !important;
  color: var(--ds-color-gray-700) !important;
  border: 1px solid var(--ds-color-gray-300) !important;
}

.ds-btn-cancel:not(:disabled):not(.disabled):hover {
  background: var(--ds-color-gray-100) !important;
}

.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],
.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-badge-soft.is-info {
  background: var(--ds-color-info-bg);
  color: var(--ds-color-info-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: var(--ds-color-brand-dark);
}

/* 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;
}

a.ds-tag-soft {
  text-decoration: none;
}

a.ds-tag-soft:hover {
  text-decoration: underline;
  color: var(--ds-color-brand-dark);
}


/* ---- 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 nav {
  margin-bottom: 15px;
}

.ds-page-header .ds-subtitle {
  font-size: var(--ds-font-size-sm, 14px);
  color: var(--ds-color-gray-500);
  margin-top: var(--ds-space-xs, 4px);
}


.ds-page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ds-color-gray-900);
}

.ds-page-header h1 i {
  margin-right: 8px;
}

.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: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-bold);
  padding: 6px 10px;
  border-radius: 6px;
  white-space: normal;
  max-width: 320px;
  text-align: center;
  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;
}

/* Arrow pointing back at the anchor. x = --tip-arrow-x (set by ds-tooltip.js so
   it keeps pointing at the anchor after the bubble is clamped to the viewport;
   defaults to center pre-JS). data-side flips it: top bubble → arrow at bottom
   pointing down; bottom bubble → arrow at top pointing up. */
.ds-tip .tip::after {
  content: '';
  position: absolute;
  left: var(--tip-arrow-x, 50%);
  transform: translateX(-50%);
  border: 6px solid transparent;
}
.ds-tip .tip:not([data-side="bottom"])::after {
  top: 100%;
  border-top-color: var(--ds-color-gray-900);
}
.ds-tip .tip[data-side="bottom"]::after {
  bottom: 100%;
  border-bottom-color: var(--ds-color-gray-900);
}

/* Touch devices (no real hover) — don't trigger tooltips. Hover isn't possible,
   and "sticky hover" on tap would leave a bubble lingering over the tapped UI.
   aria-label on .ds-tip keeps the text available to assistive tech. (ADR-028) */
@media (hover: none), (pointer: coarse) {
  .ds-tip .tip { display: none; }
}

/* 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;
  overflow: hidden;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-body {
  overflow-y: auto;
}

.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) !important;
  text-decoration: none !important;
  transition: color 0.15s ease, text-decoration 0.15s ease;
  font-weight: 600;
}

.ds-link:hover {
  color: var(--ds-color-primary) !important;
  text-decoration: underline !important;
}

.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;
}

/* Switch on/off TEXT toggles with state — pure CSS, no JS. Default shows the OFF
   label; the checked switch reveals the ON label. Covers soft + legacy markup. */
.ds-switch-text--on {
  display: none;
}

.ds-switch-input:checked+.ds-switch-label .ds-switch-text--on,
.custom-switch .custom-control-input:checked~.custom-control-label .ds-switch-text--on {
  display: inline;
}

.ds-switch-input:checked+.ds-switch-label .ds-switch-text--off,
.custom-switch .custom-control-input:checked~.custom-control-label .ds-switch-text--off {
  display: none;
}

/* ---- 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);
}


/* ===== DS-wins layer (2026-06-11) =====
   Atom input/select คง .form-control ไว้เพื่อ select2 compat (ดู atoms/select.blade.php)
   แต่ theme เก่า style1.css โหลดหลัง design-system.css และประกาศ
   .form-control { font-size:18px; border-radius:5px; border:1px solid #CCC }
   + .form-control:focus { border:1px solid #01a9ac } → ทับ Style Soft ทุกหน้าแอปจริง
   (showcase ไม่โดนเพราะตัวอย่างไม่ติด .form-control)
   double-class = specificity 0-2-0 ชนะ 0-1-0 ของ theme โดยไม่ต้องใช้ !important */
.ds-input-soft.form-control,
.ds-select-soft.form-control {
  font-size: var(--ds-font-size-base);
  border: 1px solid var(--ds-color-gray-300);
  border-radius: var(--ds-radius-soft);
}

.ds-input-soft.form-control:focus {
  border: 1px solid 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);
  outline: none;
}

.ds-select-soft.form-control:focus {
  border: 1px solid var(--ds-color-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-color-brand) 35%, transparent);
  outline: none;
}

/* ── Icon Button atom (ADR-019 create-in-DS-first; exemplar FAQ admin, 2026-06-11) ── */
.ds-icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ds-radius-md);
  border: 1px solid var(--ds-color-border);
  background: var(--ds-color-bg);
  color: var(--ds-color-text-muted);
  cursor: pointer;
  padding: 0;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.ds-icon-btn:hover {
  border-color: var(--ds-color-brand, var(--ds-color-primary));
  color: var(--ds-color-brand, var(--ds-color-primary));
  background: color-mix(in srgb, var(--ds-color-brand, var(--ds-color-primary)) 8%, var(--ds-color-bg, #ffffff));
}

.ds-icon-btn--sm {
  width: 30px;
  height: 30px;
}

.ds-icon-btn--primary {
  border-color: var(--ds-color-brand, var(--ds-color-primary));
  color: var(--ds-color-brand, var(--ds-color-primary));
}

.ds-icon-btn--danger:hover {
  border-color: var(--ds-color-danger);
  color: var(--ds-color-danger);
  background: color-mix(in srgb, var(--ds-color-danger) 10%, var(--ds-color-bg, #ffffff));
}

.ds-icon-btn--success {
  background: var(--ds-color-success);
  border-color: var(--ds-color-success);
  color: var(--ds-color-bg);
}

.ds-icon-btn--success:hover {
  opacity: .9;
}

.ds-icon-btn--secondary:hover {
  border-color: var(--ds-color-text-muted);
  color: var(--ds-color-text);
  background: var(--ds-color-bg-alt);
}

.ds-icon-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Pagination (client-side, Style Soft skin บน Bootstrap structure) ── */
.ds-pagination {
  gap: var(--ds-space-xxs);
}

.ds-pagination .page-link {
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text);
  background: var(--ds-color-bg);
  margin: 0 2px;
  min-width: 36px;
  text-align: center;
}

.ds-pagination .page-link:hover {
  color: var(--ds-color-brand, var(--ds-color-primary));
  background: var(--ds-color-bg-alt);
}

.ds-pagination .page-item.active .page-link {
  background: var(--ds-color-brand, var(--ds-color-primary));
  border-color: var(--ds-color-brand, var(--ds-color-primary));
  color: var(--ds-color-bg);
}

.ds-pagination .page-item.disabled .page-link {
  opacity: .45;
  pointer-events: none;
}

/* ==============================================================
   Molecule: Multi-select
   ============================================================== */
.ds-multi-select-wrapper {
  position: relative !important;
}

.ds-multi-select-container.form-control {
  min-height: 48px;
  height: auto;
  cursor: text;
  border: 1.5px solid var(--ds-color-info-border);
  border-radius: var(--ds-radius-soft);
  padding: 4px 12px;
  font-size: var(--ds-font-size-base);
  line-height: normal;
  background: var(--ds-color-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ds-multi-select-wrapper.focus .ds-multi-select-container.form-control {
  border-color: var(--ds-color-brand);
  box-shadow: 0 0 0 4px var(--ds-color-brand-light);
}

.ds-multi-select-search-input {
  border: 0;
  outline: none;
  min-width: 80px;
  height: 30px;
  line-height: 30px;
  background: transparent;
}

.ds-multi-select-dropdown {
  position: absolute !important;
  z-index: 99999 !important;
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  top: 100%;
  left: 0;
  margin-top: 4px;
  border-radius: var(--ds-radius-soft);
  border: 1px solid var(--ds-color-info-border);
  background: var(--ds-color-bg);
  box-shadow: var(--ds-shadow-soft);
}

.ds-multi-select-option-item {
  cursor: pointer;
  padding: 8px 12px;
  transition: background 0.15s ease;
  color: var(--ds-color-black, #000000);
}

.ds-multi-select-option-item:hover {
  background: var(--ds-color-brand-light);
  color: var(--ds-color-brand-dark);
}

.ds-multi-select-option-item.selected {
  background: var(--ds-color-info-bg);
  font-weight: var(--ds-font-weight-bold);
}

.ds-multi-select-no-results {
  font-size: var(--ds-font-size-xs);
}

.ds-multi-select-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ─────────────────────────────────────────────────────────────────
   List Picker Organism (Global Design System Styles)
   ───────────────────────────────────────────────────────────────── */

/* Label row: flex so the (+) button aligns inline */
.ds-list-picker__label {
  display: flex;
  align-items: center;
  gap: var(--ds-space-xs);
  color: var(--ds-color-text);
  font-size: var(--ds-font-size-base);
  font-weight: var(--ds-font-weight-medium);
  margin-bottom: var(--ds-space-sm);
  flex-wrap: wrap;
}

/* The (+) trigger button — styled as an icon-only action, no border */
.ds-list-picker__add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  margin-left: var(--ds-space-xs);
  border: none;
  background: transparent;
  color: var(--ds-color-brand, var(--head_bg, #0094FF));
  font-size: var(--ds-font-size-lg);
  /* 18px — balanced with label */
  cursor: pointer;
  border-radius: var(--ds-radius-md);
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.ds-list-picker__add-btn:hover,
.ds-list-picker__add-btn:focus {
  color: var(--ds-color-brand-dark, #006ecc);
  background-color: var(--ds-color-brand-light, rgba(0, 148, 255, 0.1));
  outline: none;
}

.ds-list-picker__add-btn:focus-visible {
  outline: 2px solid var(--ds-color-brand, #0094FF);
  outline-offset: 2px;
}

/* The list container */
.ds-list-picker__list {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-xs);
  width: 100%;
}

/* Each selected item row */
.ds-list-picker__item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding-top: var(--ds-spacing-xs);
  /* 5px — matches p-t-5 */
}

/* Card-style layout for selected items (looks premium, matches file uploads) */
.ds-list-picker__item-card {
  display: flex;
  align-items: center;
  padding: var(--ds-space-sm) var(--ds-space-md);
  background: var(--ds-color-bg-alt, #F8F9FA);
  border: 1px solid var(--ds-color-border, #DEE2E6);
  border-radius: var(--ds-radius-md, 8px);
  gap: var(--ds-space-md);
  box-shadow: var(--ds-shadow-xs);
  transition: all 0.15s ease;
  width: 100%;
}

.ds-list-picker__item-card:hover {
  border-color: var(--ds-color-brand, #0094FF);
  background-color: var(--ds-color-bg, #FFF);
  box-shadow: var(--ds-shadow-sm);
}

.ds-list-picker__item-icon {
  color: var(--ds-color-text-muted, #888);
  font-size: 1.25rem;
  flex-shrink: 0;
}

.ds-list-picker__item-info {
  flex: 1;
  min-width: 0;
}

.ds-list-picker__item-name {
  font-size: var(--ds-font-size-base, 14px);
  font-weight: var(--ds-font-weight-medium, 500);
  color: var(--ds-color-text, #333);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* Delete (×) button */
.ds-list-picker__delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ds-color-text-muted, #888);
  font-size: var(--ds-font-size-xl, 20px);
  cursor: pointer;
  border-radius: var(--ds-radius-md, 4px);
  transition: color 0.15s ease, background-color 0.15s ease;
  flex-shrink: 0;
}

.ds-list-picker__delete-btn:hover,
.ds-list-picker__delete-btn:focus {
  color: var(--ds-color-danger, #DC3545);
  background-color: var(--ds-color-danger-bg, rgba(220, 53, 69, 0.1));
  outline: none;
}

.ds-list-picker__delete-btn:focus-visible {
  outline: 2px solid var(--ds-color-danger, #DC3545);
  outline-offset: 2px;
}

/* ── Organization Modal Table Row (matching FAQ category modal row) ── */
.org-modal__row {
  transition: background-color 0.15s ease;
}

.org-modal__row:hover {
  background-color: var(--ds-color-brand-light, rgba(0, 148, 255, 0.08)) !important;
}

/* ── Search Wrapper for design system input component ── */
.ds-search-wrapper {
  position: relative;
  width: 100%;
}

.ds-search-wrapper .ds-input-soft {
  padding-left: 38px !important;
}

.ds-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ds-color-text-muted, #888);
  pointer-events: none;
  z-index: 2;
  font-size: var(--ds-font-size-base, 14px);
}

/* ── Circle Checkbox Variant (looks like radio but functions as checkbox) ── */
.ds-checkbox-soft--circle input[type="checkbox"] {
  border-radius: 50% !important;
}

.ds-checkbox-soft--circle input[type="checkbox"]:checked {
  background-image: none !important;
  background-color: var(--ds-color-bg, #FFF) !important;
  box-shadow: inset 0 0 0 4px var(--ds-color-brand, #0094FF) !important;
  border-color: var(--ds-color-brand, #0094FF) !important;
}

/* ── Select2 Autocomplete Custom Styles (matches .ds-select-soft) ── */
select.select2-autocomplete+.select2-container,
.select2-container.ds-select2-container {
  display: block;
  width: 100% !important;
}

select.select2-autocomplete+.select2-container .select2-selection--single,
.select2-container.ds-select2-container .select2-selection--single {
  display: block !important;
  width: 100% !important;
  border-radius: var(--ds-radius-lg, 8px) !important;
  border: 1px solid var(--ds-color-filter-border, #d8e6f5) !important;
  background-color: var(--ds-color-bg, #ffffff) !important;
  min-height: 42px !important;
  height: 42px !important;
  transition: border-color .15s ease, box-shadow .15s ease !important;
  position: relative !important;
}

/* Align text vertically inside 42px box */
select.select2-autocomplete+.select2-container .select2-selection--single .select2-selection__rendered,
.select2-container.ds-select2-container .select2-selection--single .select2-selection__rendered {
  display: block !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  height: 40px !important;
  line-height: 40px !important;
  padding: 0 3.5rem 0 0.75rem !important;
  color: var(--ds-color-filter-text, #334155) !important;
  font-size: var(--ds-font-size-sm, 14px) !important;
}

/* Style placeholder / selection rendered when empty */
select.select2-autocomplete+.select2-container .select2-selection--single .select2-selection__placeholder,
.select2-container.ds-select2-container .select2-selection--single .select2-selection__placeholder {
  color: var(--ds-color-gray-400) !important;
  line-height: 40px !important;
}

/* Style clear button (x icon) and add margin-right to text label */
select.select2-autocomplete+.select2-container .select2-selection--single .select2-selection__clear,
.select2-container.ds-select2-container .select2-selection--single .select2-selection__clear {
  position: absolute !important;
  right: 2.2rem !important;
  top: 45% !important;
  transform: translateY(-50%) !important;
  margin: 0 !important;
  color: var(--ds-color-gray-400) !important;
  font-size: 1.15rem !important;
  cursor: pointer !important;
  transition: color 0.15s ease !important;
  line-height: 1 !important;
  z-index: 2 !important;
}

select.select2-autocomplete+.select2-container .select2-selection--single .select2-selection__clear:hover,
.select2-container.ds-select2-container .select2-selection--single .select2-selection__clear:hover {
  color: var(--ds-color-danger) !important;
}

/* Custom dropdown arrow like .ds-select-soft */
select.select2-autocomplete+.select2-container .select2-selection--single .select2-selection__arrow,
.select2-container.ds-select2-container .select2-selection--single .select2-selection__arrow {
  height: 40px !important;
  width: 2.5rem !important;
  right: 0 !important;
  top: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
}

select.select2-autocomplete+.select2-container .select2-selection--single .select2-selection__arrow b,
.select2-container.ds-select2-container .select2-selection--single .select2-selection__arrow b {
  display: none !important;
  /* Hide default Select2 CSS arrow */
}

/* Add custom SVG arrow to match .filter-select */
select.select2-autocomplete+.select2-container .select2-selection--single .select2-selection__arrow::after,
.select2-container.ds-select2-container .select2-selection--single .select2-selection__arrow::after {
  content: "" !important;
  position: absolute !important;
  inset: 0 !important;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%235B6B7E' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 12px 8px !important;
}

/* Focus and Open States */
select.select2-autocomplete+.select2-container.select2-container--focus .select2-selection--single,
select.select2-autocomplete+.select2-container.select2-container--open .select2-selection--single,
.select2-container.ds-select2-container.select2-container--focus .select2-selection--single,
.select2-container.ds-select2-container.select2-container--open .select2-selection--single {
  border-color: var(--ds-color-brand) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-color-brand) 35%, transparent) !important;
  outline: none !important;
}

/* Disabled State */
select.select2-autocomplete:disabled+.select2-container .select2-selection--single,
.select2-container.ds-select2-container.select2-container--disabled .select2-selection--single {
  background-color: var(--ds-color-gray-100) !important;
  color: var(--ds-color-gray-500) !important;
  cursor: not-allowed !important;
}

.select2-container.ds-select2-container.select2-container--disabled .select2-selection--single .select2-selection__rendered,
.select2-container.ds-select2-container.select2-container--disabled .select2-selection--single .select2-selection__placeholder {
  color: var(--ds-color-gray-500) !important;
}

/* Invalid State */
select.is-invalid+.select2-container .select2-selection--single,
select.select2-autocomplete.is-invalid+.select2-container .select2-selection--single {
  border-color: var(--ds-color-danger) !important;
}

/* Ensure details tag content wraps cleanly */
details.ds-more {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

details.ds-more .ds-more-content {
  display: block;
  width: 100%;
  min-width: 0;
}

.ds-variant {
  width: 100%;
}

/* ==============================================================
   uxui graft (PR #299) — components present on uxui/faq-news-demo
   but absent from demo's design-system.css. Required by
   x-atoms.icon-button (circle/info/warning) + FAQ/announcement
   toolbar + warning tag. Appended to avoid regressing either side.
   ============================================================== */

/* ── icon-button action color + circle variants ── */
/* ── Action Color Variants (Square/Outline) ── */
.ds-icon-btn--info {
  border-color: var(--ds-color-action-view);
  color: var(--ds-color-action-view);
}

.ds-icon-btn--info:hover {
  border-color: var(--ds-color-action-view-hover);
  color: var(--ds-color-action-view-hover);
  background: color-mix(in srgb, var(--ds-color-action-view) 8%, var(--ds-color-bg, #ffffff));
}

.ds-icon-btn--warning {
  border-color: var(--ds-color-action-edit);
  color: var(--ds-color-action-edit);
}

.ds-icon-btn--warning:hover {
  border-color: var(--ds-color-action-edit-hover);
  color: var(--ds-color-action-edit-hover);
  background: color-mix(in srgb, var(--ds-color-action-edit) 8%, var(--ds-color-bg, #ffffff));
}

.ds-icon-btn--danger {
  border-color: var(--ds-color-action-delete);
  color: var(--ds-color-action-delete);
}

.ds-icon-btn--danger:hover {
  border-color: var(--ds-color-action-delete-hover);
  color: var(--ds-color-action-delete-hover);
  background: color-mix(in srgb, var(--ds-color-action-delete) 10%, var(--ds-color-bg, #ffffff));
}

/* ── Circle Variant (Filled) ── */
.ds-icon-btn--circle {
  width: 40px;
  height: 40px;
  border-radius: var(--ds-radius-pill, 9999px);
  border: none;
  color: #fff !important;
}

.ds-icon-btn--circle i {
  font-size: 16px;
  color: #fff !important;
}

.ds-icon-btn--circle.ds-icon-btn--info {
  background-color: var(--ds-color-action-view);
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--info:hover {
  background-color: var(--ds-color-action-view-hover);
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--warning {
  background-color: var(--ds-color-action-edit);
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--warning:hover {
  background-color: var(--ds-color-action-edit-hover);
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--danger {
  background-color: var(--ds-color-action-delete);
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--danger:hover {
  background-color: var(--ds-color-action-delete-hover);
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--primary {
  background-color: var(--ds-color-brand, var(--ds-color-primary));
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--primary:hover {
  background-color: var(--ds-color-brand-dark, var(--ds-color-primary-hover));
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--success {
  background-color: var(--ds-color-success);
  color: #fff;
}

.ds-icon-btn--circle.ds-icon-btn--success:hover {
  opacity: 0.9;
  color: #fff;
}

.ds-icon-btn--circle-outline {
  width: 40px;
  height: 40px;
  border-radius: var(--ds-radius-pill, 9999px);
  border: 1px solid currentColor;
  background-color: var(--ds-color-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.ds-icon-btn--circle-outline i {
  font-size: 16px;
  color: inherit !important;
}

.ds-icon-btn--circle-outline.ds-icon-btn--warning {
  border-color: var(--ds-color-action-edit);
  color: var(--ds-color-action-edit) !important;
}

.ds-icon-btn--circle-outline.ds-icon-btn--warning:hover {
  border-color: var(--ds-color-action-edit-hover);
  color: var(--ds-color-action-edit-hover) !important;
  background-color: color-mix(in srgb, var(--ds-color-action-edit) 8%, var(--ds-color-bg, #ffffff));
}



/* ── warning tag variant ── */
.ds-tag-soft.ds-tag-warning {
  background: var(--ds-color-warning-bg);
  color: var(--ds-color-warning-text);
}

a.ds-tag-soft.ds-tag-warning:hover {
  color: var(--ds-color-warning-text);
}

/* -------------------------------------------------------------
   Toolbar — generic layout container for filters & search
   ------------------------------------------------------------- */
.ds-toolbar {
  position: relative;
  /* anchor for the top-right .ds-toolbar__clear button */
  display: flex;
  flex-direction: row;
  /* flex-end so a search box (no label) bottom-aligns with labeled filter
     form-groups (:toolbar variant) that are taller by one label line. */
  align-items: flex-end;
  gap: var(--ds-space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--ds-space-md);
  padding: var(--ds-space-md);
  background: var(--ds-color-bg);
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-sm);
}

.ds-toolbar--clearable {
  padding-top: calc(var(--ds-space-md) + var(--ds-space-lg)) !important;
}

.ds-toolbar__clear {
  position: absolute;
  top: var(--ds-space-xs);
  right: var(--ds-space-sm);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--ds-space-sm);
  font-size: var(--ds-font-size-sm);
  line-height: 1.4;
  color: var(--ds-color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, opacity 0.15s ease;
}

/* Underline only the label text, not the leading icon. */
.ds-toolbar__clear span {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ds-toolbar__clear:hover:not(:disabled),
.ds-toolbar__clear:focus-visible:not(:disabled) {
  color: var(--ds-color-danger, #d33);
}

.ds-toolbar__clear:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ds-toolbar__clear:disabled span {
  text-decoration: none;
  /* disabled reads as not clickable */
}

@media (min-width: 992px) {
  .ds-toolbar {
    flex-wrap: nowrap;
  }
}

.ds-toolbar__search {
  flex: 1 1 200px !important;
  min-width: 160px !important;
  width: auto !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: stretch !important;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-soft);
  overflow: hidden;
  background: var(--ds-color-bg);
  height: 38px;
}

.ds-toolbar__search-input-wrapper {
  position: relative;
  width: 100% !important;
  height: inherit;
  display: flex;
  align-items: center;
  min-width: 0;
}

.ds-toolbar__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ds-color-text-muted);
  pointer-events: none;
  z-index: 1;
}

.ds-toolbar__input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  width: 100% !important;
  max-width: 100% !important;
  padding: 8px 12px 8px 36px !important;
  line-height: normal !important;
}

.ds-toolbar__search .ds-toolbar__search-btn.ds-btn {
  border-radius: 0 var(--ds-radius-soft) var(--ds-radius-soft) 0 !important;
  height: 38px !important;
  margin: 0 !important;
  border: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 var(--ds-space-md) !important;
  font-size: var(--ds-font-size-base) !important;
  line-height: 1 !important;
  background-color: var(--ds-color-brand, var(--ds-color-primary)) !important;
  color: #fff !important;
  white-space: nowrap !important;
  box-shadow: none !important;
}

.ds-toolbar__search-btn:hover {
  background-color: var(--ds-color-brand-active, var(--ds-color-primary)) !important;
}

.ds-toolbar__select {
  width: auto;
  min-width: 120px !important;
  max-width: 220px !important;
  flex: 1 1 140px !important;
  border: 1px solid var(--ds-color-border) !important;
  border-radius: var(--ds-radius-soft);
  background-color: var(--ds-color-bg);
  color: var(--ds-color-text);
  padding-right: 2.5rem;
  cursor: pointer;
  text-overflow: ellipsis !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}

.ds-toolbar__select--compact {
  min-width: 100px !important;
  max-width: 150px !important;
  flex: 0 1 110px !important;
}

.ds-toolbar__action {
  white-space: nowrap;
}

.ds-toolbar .select2-container {
  min-width: 180px;
}

.ds-toolbar .select2-container--default .select2-selection--single {
  height: 38px;
  border: 1px solid var(--ds-color-border) !important;
  border-radius: var(--ds-radius-soft);
  background-color: var(--ds-color-bg) !important;
}

.ds-toolbar .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--ds-color-text);
  line-height: 36px;
  padding-left: var(--ds-space-sm);
}

.ds-toolbar .select2-container--default .select2-selection--single .select2-selection__arrow {
  top: 7px;
}

@media (max-width: 991px) {
  .ds-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .ds-toolbar__search {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  .ds-toolbar__select,
  .ds-toolbar__select--compact {
    flex: 1 1 140px !important;
    width: auto !important;
    min-width: 120px !important;
    max-width: none !important;
  }

  /* Stacked layout: the search box goes full-width and sits directly under the
     corner clear button. The base clearable top strip (md + sm) leaves it almost
     touching, so widen the strip here to give a comfortable, tappable gap. */
  .ds-toolbar--clearable {
    padding-top: calc(var(--ds-space-md) + var(--ds-space-lg)) !important;
  }
}

/* Universal Fix: ปิดการแสดงผลพื้นหลังสีเทาและกรอบสไตล์กล่องทั้งหมดของ Form Group ทั้งแอปพลิเคชัน */
.ds-form-group,
.ds-form-group .form-custom {
  background-color: transparent !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.ds-form-group .form-custom:hover,
.ds-form-group .form-custom:focus,
.ds-form-group .form-custom:active {
  border: none !important;
  box-shadow: none !important;
}

/* ============================================================
   Form Group — unified spacing rhythm (Sprint UXUI)
   The wrapper is BOTH col-sm-* (padding +15px = gutter) AND .row (margin -15px).
   Neutralize the .row negative margin so a field never bleeds outside its
   container (modal-body) while the column gutter is preserved; add one tokenized
   vertical rhythm; collapse the nested-column double gutter so label + input span
   the column and align with sibling components.
   ============================================================ */
.ds-form-group.row {
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  /* inter-field gap = 10px (sm+xxs): md read too wide next to the ~30px column gutter. */
  margin-bottom: calc(var(--ds-space-sm) + var(--ds-space-xxs));
}

/* Collapse nested-column gutters INSIDE the field so content spans the column and
   lines up with the container edge. Descendant selector → OUTER col-sm-* excluded,
   so the between-column gutter stays intact. */
.ds-form-group.row [class*="col-"] {
  padding-left: 0;
  padding-right: 0;
}

/* One label→input gap for every field. */
.ds-form-group .col-form-label {
  padding-top: 0;
  padding-bottom: var(--ds-space-xs);
  margin-bottom: 0;
}

/* Help/description text hugs its control so the field reads as ONE group. */
.ds-form-group .form-text {
  margin-top: var(--ds-space-xs);
  margin-bottom: 0;
}

/* ============================================================
   Form Group — filter/sorting variant (ADR-013 Amendment 4)
   A form-group used as a filter/sorting control in a toolbar. Applies via the
   :toolbar prop (.ds-form-group--toolbar modifier) OR automatically to any
   form-group placed inside <x-molecules.toolbar> (.ds-toolbar .ds-form-group).
   Neutralizes the Bootstrap grid + vertical rhythm so the label sits muted above
   a full-width control, aligned in the flex toolbar row. Ported from the former
   per-page override in faq-redesign.css so every filter bar shares one style.
   Selectors keep specificity >= the base .ds-form-group rules and are placed
   AFTER them so they win.
   ============================================================ */
.ds-form-group--toolbar,
.ds-toolbar .ds-form-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  /* label -> control */
  /* basis 0 so filters distribute EVENLY (content-based `auto` lets a select with
     long options blow up wider than its siblings). min-width keeps labels readable. */
  flex: 1 1 0;
  min-width: 120px;
  margin-bottom: 0 !important;
  /* kill ds-form-group + bootstrap form-group rhythm */
}

.ds-form-group--toolbar .col-form-label,
.ds-toolbar .ds-form-group .col-form-label {
  /* (0,3,0) beats base .ds-form-group .col-form-label (0,2,0) */
  padding: 0;
  margin-bottom: 0;
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-medium);
  color: var(--ds-color-text-muted);
}

.ds-form-group--toolbar [class*="col-"],
.ds-toolbar .ds-form-group [class*="col-"] {
  /* flush: drop nested column gutters */
  padding-left: 0;
  padding-right: 0;
  max-width: 100%;
  /* Neutralize Bootstrap .col-sm-* `flex: 0 0 100%`. In this flex COLUMN that
     100% is read along the main (vertical) axis, so label + control both claim
     the full group height and OVERLAP whenever the group height is definite
     (e.g. a toolbar with align-items:stretch below 992px). Size by content. */
  flex: 0 0 auto !important;
}

/* Control sizing so the variant is self-contained (ported from the old
   .faq-toolbar__group .ds-toolbar__select rule). The base .ds-toolbar__select
   pins width/flex with !important, so the variant must too — otherwise the select
   caps at 220px and leaves a gap when its form-group grows to fill the row. */
.ds-form-group--toolbar .ds-toolbar__select,
.ds-toolbar .ds-form-group .ds-toolbar__select {
  height: 38px !important;
  width: 100% !important;
  max-width: none !important;
  min-width: 0 !important;
  flex: none !important;
  /* select is a block child of the col wrapper, not a flex item */
}

/* Responsive: on narrow screens stack the filter form-groups full-width so they
   line up evenly instead of the uneven 2-per-row + orphan wrap. Higher
   specificity than the legacy .faq-toolbar__group basis so both FAQ + generic
   toolbars behave the same. */
@media (max-width: 991px) {

  .ds-toolbar .ds-form-group--toolbar,
  .ds-toolbar .ds-form-group {
    flex: 1 1 100% !important;
    /* beat legacy .faq-toolbar__group { flex: 1 1 140px !important } */
    width: 100% !important;
  }
}

/* ============================================================
   PICKER FIELD (ADR-013 Amendment 5) — the "manageable field" standard.
   A readonly display input + trigger button that opens a modal to
   select/manage a list item. Global style so every <x-molecules.picker-field>
   looks identical. Emitted by form-group :input-group input-group-class="ds-picker-field",
   so we scope on `.input-group.ds-picker-field` to win over Bootstrap defaults.
   ============================================================ */
.input-group.ds-picker-field {
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--ds-space-sm);
}

.input-group.ds-picker-field .ds-picker-field__display,
.input-group.ds-picker-field .ds-picker-field__display:read-only {
  /* the display input stretches; override Bootstrap .input-group .form-control width:1% */
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  /* The field is readonly (value is chosen via the modal) but it is NOT disabled —
     it opens a picker on click. Present it as a NORMAL, clickable input (white bg,
     normal text, pointer), NOT the greyed-out readonly look. The :read-only selector
     is required to beat the global `.ds-input-soft:read-only` rule that would otherwise
     paint it gray-100 + muted text + not-allowed (making it look disabled). */
  cursor: pointer;
  background-color: var(--ds-color-bg);
  color: var(--ds-color-text);
}

.input-group.ds-picker-field .ds-picker-field__btn {
  flex: 0 0 auto;
  white-space: nowrap;
  /* Layout only. Colour comes from variant="secondary" (blue outline) so the
     "เลือก" button matches the other secondary buttons (จัดการหมวดหมู่/เพิ่มหมวดหมู่)
     per client request. .ds-btn-secondary uses !important, so no colour is set
     here. (Was a deliberate neutral-grey "FAQ look" — reversed 2026-07-10.) */
}

/* -------------------------------------------------------------
   Premium Form Shell — extracted from masterdata/roadmap_manage/create
   (ADR-019 Component-First: single source of truth for the premium
   form look shared by roadmap + announcement forms; tokens only).
   Used by: <x-organisms.premium-form-shell>, hr/announcement/create.
   ------------------------------------------------------------- */
.ds-premium-card {
  background: var(--ds-color-bg);
  border-radius: 12px;
  border: none;
  box-shadow: none;
  transition: all 0.3s ease;
  overflow: hidden;
}

.ds-premium-header {
  background: color-mix(in srgb, var(--ds-color-brand) 10%, var(--ds-color-bg));
  padding: 25px 30px;
  color: var(--ds-color-brand-dark);
  position: relative;
  /* หัวการ์ดชิดขอบบน + มุมบนซ้าย/ขวามนเท่ากับการ์ด (12px) — ไม่ให้มุมเหลี่ยม
     โผล่เหนือมุมมนของ .ds-premium-card (เดิม padding-top:15px ดันหัวลงจนมุมเป็นเหลี่ยม) */
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.ds-premium-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(135deg, var(--ds-color-brand), var(--ds-color-brand-dark));
}

.ds-premium-title {
  font-family: 'Outfit', 'Sarabun', sans-serif;
  font-weight: 700;
  font-size: 24px;
  margin-bottom: 5px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--ds-color-brand), var(--ds-color-brand-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.ds-premium-subtitle {
  font-weight: 400;
  font-size: 14px;
  opacity: 0.9;
  color: var(--ds-color-text-muted);
  margin: 0;
}

/* Section heading — premium modifier (opt-in; does NOT override the
   default .ds-section-heading used by org step2/step5 + showcase). */
.ds-section-heading--premium {
  border-bottom: none;
  border-left: 5px solid var(--ds-color-brand);
  padding-left: 15px;
  padding-bottom: 0;
}

.ds-section-heading--premium .ds-section-heading-title {
  color: var(--ds-color-brand-dark);
}

.ds-section-heading--premium .ds-section-heading-icon {
  width: auto;
  height: auto;
  background: transparent;
  color: var(--ds-color-brand);
  border-radius: 0;
}

/* Premium form controls */
.ds-form-label {
  font-weight: 500;
  color: var(--ds-color-text-muted);
  margin-bottom: 8px;
  display: block;
  font-size: 15px;
}

.ds-form-control,
.ds-premium-card .form-control,
.ds-premium-card input[type="text"],
.ds-premium-card select {
  border-radius: 12px;
  /* !important + .ds-premium-card scope: overrides the legacy global
     `.form-custom .form-control { border: 0 !important }` from layouts/app.blade.php
     for premium forms only, without touching that page-global rule. */
  border-width: 1.5px !important;
  border-style: solid !important;
  border-color: color-mix(in srgb, var(--ds-color-brand) 25%, var(--ds-color-border)) !important;
  padding: 12px 16px;
  font-size: 15px;
  height: auto;
  transition: all 0.2s ease;
  background-color: var(--ds-color-bg) !important;
  width: 100%;
}

.ds-form-control:focus,
.ds-premium-card .form-control:focus,
.ds-premium-card input[type="text"]:focus,
.ds-premium-card select:focus {
  border-color: var(--ds-color-brand) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ds-color-brand) 15%, transparent);
  outline: none;
}

/* Neutralize the legacy grey field-wrapper box (.form-custom { background:#f5f5f5;
   border-radius:8px } from layouts/app.blade.php) inside premium forms — fields sit
   clean on the white card, framed only by their own premium input border. */
.ds-premium-card .form-custom {
  background: transparent !important;
  border: none !important;
  border-radius: 0;
  padding: 0;
}

/* กัน "กรอบฟ้า" ตอน hover/focus บนกล่อง field: กฎ legacy `.form-custom:hover {
   border: 1px solid var(--head_bg) }` (layouts/app.blade.php) มี specificity (0,2,0)
   เท่ากับ `.ds-premium-card .form-custom` จึงชนะตาม source order ตอน hover.
   ยก specificity เป็น (0,3,0) ด้วยการเติม :hover/:focus/:active ให้ชนะแน่นอน —
   field ในการ์ด premium ไม่ต้องมีกรอบกล่อง (มีกรอบที่ input เองอยู่แล้ว). */
.ds-premium-card .form-custom:hover,
.ds-premium-card .form-custom:focus,
.ds-premium-card .form-custom:active {
  border: none !important;
  box-shadow: none !important;
  color: inherit !important;
}

/* Label ของ field แบบ raw .form-custom (เช่น วันที่แสดงผล/สิ้นสุด) ให้สีเดียวกับ label
   ของ field อื่นที่ผ่าน form-group (.ds-form-group .col-form-label = gray-700). เดิม label
   สืบสี var(--head_bg) มาจากกฎ legacy `.form-custom { color: var(--head_bg) }` เลยเป็นสีฟ้า. */
.ds-premium-card .form-custom .col-form-label {
  color: var(--ds-color-gray-700);
}

select.ds-form-control,
.ds-premium-card select {
  --select-chevron-color: var(--ds-color-gray-500);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--select-chevron-color) 50%),
    linear-gradient(135deg, var(--select-chevron-color) 50%, transparent 50%);
  background-repeat: no-repeat;
  background-position: calc(100% - 17px) center, calc(100% - 12px) center;
  background-size: 5px 5px, 5px 5px;
  padding-right: 32px;
  cursor: pointer;
}

select.ds-form-control:focus {
  --select-chevron-color: var(--ds-color-primary);
}

/* Form footer actions — separator between content and the action group
   (mirrors .faq-create-box__actions in faq-redesign.css). */
.ds-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ds-space-sm);
  margin-top: var(--ds-space-lg);
  padding-top: var(--ds-space-lg);
  border-top: 1px solid var(--ds-color-border);
}

/* -------------------------------------------------------------
   Premium form rhythm — group fields within a section, separate
   sections clearly so users can scan headings. Vertical spacing
   is owned here so the announcement form stays token-driven.
   ------------------------------------------------------------- */
/* Clear gap ABOVE each section heading (separates topics) … */
.ds-premium-card .ds-section-heading--premium {
  margin-top: var(--ds-space-xl);
  margin-bottom: var(--ds-space-md);
}
/* … except the first heading, which hugs the header. */
.ds-premium-card form > .ds-section-heading--premium:first-of-type {
  margin-top: 0;
}
/* Tighter, even spacing BETWEEN fields inside the same section. */
.ds-premium-card .ds-form-group {
  margin-bottom: var(--ds-space-sm);
}
.ds-premium-card .ds-field-row {
  margin-bottom: 0;
}
/* Radio/switch options: comfortable inline spacing, no grey wrapper. */
.ds-premium-card .ds-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-xs) var(--ds-space-lg);
  padding-top: var(--ds-space-xs);
}
/* Readonly field shown as disabled (e.g. auto-managed sequence) — overrides the
   premium white-bg rule (.ds-premium-card input[type="text"], specificity 0-2-1)
   so the higher-specificity selector below wins and the field reads as disabled. */
.ds-premium-card input[type="text"].ds-field-readonly,
.ds-premium-card .ds-field-readonly {
  background: var(--ds-color-gray-200) !important;
  border-color: var(--ds-color-gray-200) !important;
  color: var(--ds-color-gray-500) !important;
  cursor: not-allowed;
}

/* Inline field rows — fields share one line when there is room, reflow on small
   screens (flex-wrap). Replaces the equal-column grid for the type/urgency and
   category/series rows so options are not cramped into 2×2. */
.ds-premium-card .ds-inline-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  /* ช่องว่างแนวนอนที่เห็นระหว่าง fields = Bootstrap col gutter (15px ต่อข้าง = 30px)
     + column-gap นี้ → xxs(2px) ให้รวม ~32px "อยู่กลุ่มเดียวกัน"; row-gap = md(16px)
     สำหรับตอน wrap ขึ้นบรรทัดใหม่. */
  gap: var(--ds-space-md) var(--ds-space-xxs);
}

/* Category picker & series-name — grow to fill the row instead of clustering
   left. Capped so a single field never sprawls to the full width. */
.ds-premium-card .ds-field-picker {
  flex: 1 1 200px;
  min-width: 190px;
  max-width: 520px;
}

/* Sequence field — narrow, auto-managed */
.ds-premium-card .ds-field-seq {
  flex: 0 0 130px;
  width: 130px;
}

/* Radio field (ประเภท / ความด่วน) — content width, never shrinks, so its options
   stay on one line and the whole field wraps as a unit when the row is too narrow.
   max-width caps it to the container on mobile so the options wrap instead of
   overflowing off-screen. */
.ds-premium-card .ds-field-radio {
  /* Fixed width so both leading radio columns (ประเภท / ความด่วน) match → the field after
     them (หมวดหมู่ข่าว on row 1, ข่าวต่อเนื่อง on row 2) starts at the same left edge on
     every row, at ALL widths — not only desktop. 32rem clears the widest group (ประเภท).
     max-width:100% lets the column drop to full width on narrow screens, so the options
     wrap and the following field falls to a new line instead of overflowing. */
  flex: 0 0 32rem;
  max-width: 100%;
}

/* Below ~800px there is no longer room for the radio column PLUS a field beside it, so
   stack everything: full-width radio column pushes the following field (and the series
   name/seq) onto their own lines. Prevents the lopsided in-between state where the wider
   picker wraps but the narrow switch stays inline. */
@media (max-width: 800px) {
  .ds-premium-card .ds-field-radio {
    flex-basis: 100%;
  }
}

/* Wrapper only groups name+seq for JS show/hide — transparent to flexbox so both
   fields join the main .ds-inline-fields row and share its spacing / grow. */
.ds-premium-card .ds-series-extra {
  display: contents;
}

/* -------------------------------------------------------------
   select2 widgets inside the premium form.
   layouts/app globally runs $("select.form-control").select2(), which hides
   the native <select> (that .ds-form-control styles) and renders its own box
   with select2's DEFAULT theme (4px radius, grey border) — so dropdowns looked
   unlike the premium text inputs AND unlike the DS select. Re-skin the select2
   box to match .ds-form-control (12px radius, brand border, 48px), token-only.
   ------------------------------------------------------------- */
.ds-premium-card .select2-container {
  width: 100% !important;
}
.ds-premium-card .select2-container .select2-selection--single {
  display: flex !important;
  align-items: center !important;
  height: 48px !important;
  border-radius: 12px !important;
  border: 1.5px solid color-mix(in srgb, var(--ds-color-brand) 25%, var(--ds-color-border)) !important;
  background-color: var(--ds-color-bg) !important;
}
.ds-premium-card .select2-container .select2-selection--single .select2-selection__rendered {
  /* center the single-line value (incl. Thai upper/lower marks) in the 48px box.
     select2 ships the rendered span with ~8px vertical padding + line-height:normal,
     which — even inside the align-items:center flex — pushed the glyph line to the
     TOP of the padded box. Zero the padding; 52px line box optically centers the
     ascent-heavy Thai glyphs in the 48px control (measured offset ≈ 0). */
  line-height: 52px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  padding-left: 16px !important;
  color: var(--ds-color-text) !important;
}
.ds-premium-card .select2-container .select2-selection--single .select2-selection__arrow {
  height: 46px !important;
  width: 2.5rem !important;
  top: 0 !important;
  right: 4px !important;
  background: transparent !important;
  border-radius: 0 !important;
}
/* Replace the app's blue-circle arrow with the DS clean chevron (matches .ds-select-soft). */
.ds-premium-card .select2-container .select2-selection--single .select2-selection__arrow b {
  display: none !important;
}
.ds-premium-card .select2-container .select2-selection--single .select2-selection__arrow::after {
  content: "" !important;
  position: absolute !important;
  inset: 0 !important;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%235B6B7E' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 12px 8px !important;
}
.ds-premium-card .select2-container--open .select2-selection--single,
.ds-premium-card .select2-container--focus .select2-selection--single {
  border-color: var(--ds-color-brand) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ds-color-brand) 15%, transparent) !important;
}

/* -------------------------------------------------------------
   Native <select> (data-select2-off) inside premium forms.
   `.ds-premium-card .form-control` sets padding:12px 16px, which leaves only a
   ~22px content box, but `.ds-select-soft` declares line-height:46px — the 46px
   line box overflowed the 22px content area, so the selected text (esp. Thai
   marks) was clipped at the top & bottom edge ("ตกขอบ"). Reset to the natural
   line height so the value centers within the padded 48px control.
   ------------------------------------------------------------- */
.ds-premium-card select.ds-select-soft {
  line-height: normal !important;
}

/* -------------------------------------------------------------
   Audience & access row (announcement create / edit).
   Line 1  = the two "กลุ่มผู้รับข้อมูล" selects (fill the row equally, stack on
             narrow screens).
   Line 2  = #field_audi — the org-unit fields that appear after choosing a group.
             They drop onto their OWN line (the org-name options are long and were
             truncated when crammed beside the receiver selects) and follow
             explicit, predictable responsive counts: 4 per row on wide desktop,
             2 on laptop/tablet, 1 on phones.
   ------------------------------------------------------------- */
.ds-premium-card .ds-audience-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  /* ช่องว่างแนวนอน ~32px = col gutter (30px) + column-gap xxs(2px); row-gap md(16px). */
  gap: var(--ds-space-md) var(--ds-space-xxs);
}
/* Line 1 — receiver selects grow to fill equally; min-width:0 lets a long value
   truncate instead of forcing the field wider than its share. */
.ds-premium-card .ds-audience-fields > .ds-audience-field {
  flex: 1 1 240px;
  min-width: 0;
}

/* Line 2 wrapper — full-width flex row of its own, forced below line 1. */
.ds-premium-card #field_audi {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  /* ช่องว่างแนวนอน ~32px = col gutter (30px) + column-gap xxs(2px); row-gap md(16px). */
  gap: var(--ds-space-md) var(--ds-space-xxs);
}
/* no group chosen yet → no dynamic fields → don't reserve an empty line
   (:has → matches the codebase's modern-CSS baseline, cf. color-mix usage). */
.ds-premium-card #field_audi:not(:has(> .ds-audience-field)) {
  display: none;
}
/* Dynamic org-unit fields — 4 per row (wide desktop) by default. flex-grow fills
   the row exactly; the basis only sets the wrap threshold. min-width:0 → equal
   columns even with long, truncating option text. */
.ds-premium-card #field_audi > .ds-audience-field {
  flex: 1 1 calc(25% - var(--ds-space-md));
  min-width: 0;
}
/* ≤ xl: 2 per row (laptop / tablet) — gives long org names noticeably more width. */
@media (max-width: 1199.98px) {
  .ds-premium-card #field_audi > .ds-audience-field {
    flex-basis: calc(50% - var(--ds-space-md) / 2);
  }
}
/* < md: 1 per row (phones) — each field spans the full width. */
@media (max-width: 767.98px) {
  .ds-premium-card #field_audi > .ds-audience-field {
    flex-basis: 100%;
  }
}
/* NOTE: keep the Bootstrap `.col-sm-12` gutter (~15px) on the field label/control
   — every other section (`.ds-inline-fields`, date/title rows) carries it, so the
   audience content lines up with ประเภท/หมวดหมู่ above. Collapsing it here shifted
   this row 15px to the left. */
/* the flex gap owns the row rhythm — drop the form-group's own bottom margin */
.ds-premium-card .ds-audience-fields .ds-form-group {
  margin-bottom: 0;
}
