/* File: /mte/assets/css/xgrid.css
   Purpose: Apple-inspired Orders table with clean layout and better contrast
   Depends: /assets/css/theme.css for color/spacing tokens
*/
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ---------- Container ---------- */
.xgrid-wrap {
  height: 100vh;
  width: 100%;
  overflow: auto;
  position: relative;

  /* Refined typography - Apple-style */
  font: 14px/1.47 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);

  /* Simplified sticky math - no legend by default */
  --toolbar-h: 44px;
  --legend-h: 36px;
  --header-top: var(--toolbar-h);
}

.xgrid-wrap.compact {
  --toolbar-h: 40px;
  --legend-h: 32px;
  font-size: 13px;
}

/* ---------- Clean Toolbar ---------- */
.xgrid-toolbar {
  position: sticky;
  top: 0;
  z-index: 1001;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  height: var(--toolbar-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

/* Left side - compact controls */
.xgrid-toolbar-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Right side - search */
.xgrid-toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Compact filter button */
.xgrid-filters-btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid #d1d5db;
  border-radius: 2px;
  background: #ffffff;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.xgrid-filters-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.xgrid-filters-btn.active {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

/* Filters dropdown */
.xgrid-filters-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1002;
  min-width: 220px;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 12px;
  display: none;
}

.xgrid-filters-dropdown.show {
  display: block;
}

.xgrid-filters-dropdown label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.xgrid-filters-dropdown select {
  width: 100%;
  height: 32px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  margin-bottom: 12px;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

.xgrid-filters-dropdown select:focus {
  outline: none;
  border-color: var(--brand-primary);
}

.xgrid-filters-dropdown select:last-child {
  margin-bottom: 0;
}

/* Legend toggle button */
.xgrid-legend-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-size: 14px;
  font-weight: 600;
}

.xgrid-legend-btn:hover {
  background: #f9fafb;
  color: #374151;
}

.xgrid-legend-btn.active {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

/* Export button as icon */
.xgrid-export-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-size: 16px;
  font-weight: 600;
}

.xgrid-export-btn:hover {
  background: #f9fafb;
  color: #111827;
}

/* Search input on the right - Apple style */
.xgrid-toolbar input[type="search"] {
  width: 200px;
  height: 32px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 16px;
  background: #f9fafb;
  font-size: 14px;
  transition: all 0.2s ease;
}

.xgrid-toolbar input[type="search"]:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(15, 58, 138, 0.1);
  width: 240px;
}

.xgrid-toolbar input[type="search"]::placeholder {
  color: #9ca3af;
}

/* Hidden/toggleable legend */
.xgrid-legend {
  position: sticky;
  top: var(--toolbar-h);
  z-index: 40;
  display: none; /* Hidden by default */
  gap: 16px;
  align-items: center;
  padding: 8px 16px;
  height: var(--legend-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.xgrid-legend.show {
  display: flex;
}

.xgrid-legend .sw {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  border: none;
}

/* Update header-top when legend is shown */
.xgrid-wrap.legend-visible {
  --header-top: calc(var(--toolbar-h) + var(--legend-h));
}

/* ---------- Better Contrast Table ---------- */
table.xgrid {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

/* Better cell styling with improved contrast */
.xgrid th,
.xgrid td {
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 48px;
  vertical-align: middle;
}

/* Remove left borders for cleaner look */
.xgrid th:first-child,
.xgrid td:first-child {
  border-left: none;
}

/* Alternating row colors for better contrast */
.xgrid tbody tr:nth-child(even) td {
  background: #f9fafb;
}

.xgrid tbody tr:nth-child(odd) td {
  background: #ffffff;
}

/* Better hover state */
.xgrid tbody tr:hover td {
  background: #f0f9ff !important;
}

.xgrid thead th {
  position: sticky;
  top: var(--header-top);
  z-index: 30;
  background: #f3f4f6;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border-bottom: 2px solid #d1d5db;
}

/* JS controls all column widths; keep this one explicit small column */
.xgrid thead th[data-col="respond_text"],
.xgrid td[data-field="respond_text"] {
  width: 40px;
  padding: 0 4px;
  text-align: center;
}

.xgrid-wrap.ultra .xgrid thead th[data-col="respond_text"],
.xgrid-wrap.ultra .xgrid td[data-field="respond_text"] {
  width: 36px;
  padding: 0 2px;
}

/* Refined SLA breach styling */
.xgrid tbody tr.sla-breached td {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
}

.xgrid tbody tr.sla-breached td:first-child {
  border-left: 3px solid #ef4444 !important;
}

/* Virtual scroll spacers */
.x-spacer td {
  border: none !important;
  padding: 0 !important;
  height: var(--spacer-h, 0px) !important;
  background: transparent !important;
}

/* Refined badge styling */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 6px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.025em;
  white-space: nowrap;
  line-height: 1.2;
}

/* Better placeholder styling for due dates */
td[data-field="due_date"].placeholder {
  font-style: italic;
  color: #9ca3af;
  position: relative;
}

td[data-field="due_date"].placeholder::before {
  content: 'Set date...';
  color: #9ca3af;
  font-weight: 400;
}

/* Refined link styling */
a.link-detail {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

a.link-detail:hover {
  color: #1e40af;
  text-decoration: underline;
}

/* ---------- Footer info ---------- */
.xgrid-info {
  text-align: center;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  background: #f9fafb;
  border-top: 1px solid var(--border);
}

/* ---------- Responsive adjustments ---------- */
@media (max-width: 1200px) {
  .xgrid thead th:nth-child(10),
  .xgrid td[data-field="progress_status"] {
    width: 180px;
  }

  .xgrid thead th:nth-child(2),
  .xgrid td[data-field="part_name"] {
    width: 200px;
  }
}

@media (max-width: 768px) {
  .xgrid-wrap {
    --toolbar-h: 40px;
    --legend-h: 32px;
  }

  .xgrid-toolbar {
    gap: 6px;
    padding: 6px 12px;
  }

  .xgrid-toolbar input[type="search"] {
    width: 160px;
    min-width: 120px;
  }

  .xgrid-toolbar input[type="search"]:focus {
    width: 180px;
  }

  .xgrid thead th:nth-child(3),
  .xgrid td[data-field="maker"] {
    width: 120px;
  }

  .xgrid thead th:nth-child(4),
  .xgrid td[data-field="machine_name"] {
    width: 130px;
  }

  .xgrid thead th:nth-child(9),
  .xgrid td[data-field="remark"] {
    width: 160px;
  }

  /* Stack toolbar controls on very small screens */
  .xgrid-toolbar-left {
    gap: 6px;
  }
}

@media (max-width: 640px) {
  .xgrid-toolbar {
    flex-direction: column;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }

  .xgrid-toolbar-left,
  .xgrid-toolbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .xgrid-toolbar input[type="search"] {
    flex: 1;
    width: auto;
    border-radius: 8px;
  }

  .xgrid-toolbar input[type="search"]:focus {
    width: auto;
  }
}

/* Dropdown arrow icon (ASCII only) */
.xgrid-filters-btn::after {
  content: 'v';
  font-size: 10px;
  opacity: 0.7;
}

.xgrid-filters-btn.active::after {
  content: '^';
}

/* Close dropdown when clicking outside */
.xgrid-filters-dropdown-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
}

.xgrid-filters-dropdown-backdrop.show {
  display: block;
}

/* actions inside filter dropdown */
.xgrid-filters-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.xgrid-filters-actions .btn {
  height: 30px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.xgrid-filters-actions .btn.apply {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}

.xgrid-filters-actions .btn.clear:hover {
  background: #f9fafb;
}

/* ==== ULTRA density overrides (left-align, zero fluff) ==== */
.xgrid-wrap.ultra {
  --toolbar-h: 34px;
  --legend-h: 26px;
  font-size: 10px; /* body */
}

.xgrid-wrap.ultra .xgrid-toolbar {
  padding: 4px 8px;
  height: var(--toolbar-h);
}

.xgrid-wrap.ultra .xgrid-toolbar input[type="search"] {
  height: 26px;
  padding: 4px 8px;
  width: 150px;
}
.xgrid-wrap.ultra .xgrid-toolbar input[type="search"]:focus { width: 180px; }

.xgrid-wrap.ultra .xgrid-filters-btn,
.xgrid-wrap.ultra .xgrid-legend-btn,
.xgrid-wrap.ultra .xgrid-export-btn {
  height: 26px; width: 26px; padding: 0 6px;
}

/* Table cells: tight but usable */
.xgrid-wrap.ultra table.xgrid th,
.xgrid-wrap.ultra table.xgrid td {
  padding: 2px 4px;
  height: 28px;
  line-height: 1.2;
  text-align: center;
  vertical-align: top;
}

/* Headers: small, not uppercase, no extra letter-spacing */
.xgrid-wrap.ultra thead th {
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  padding: 2px 4px;
}

/* Badges: smaller */
.xgrid-wrap.ultra .badge {
  padding: 1px 4px;
  font-size: 10px;
  border-radius: 4px;
}

/* Progress column often long; allow earlier truncation */
.xgrid-wrap.ultra td[data-field="progress_status"] { padding-right: 2px; }

/* No aging-below line in ultra mode */
.xgrid-wrap.ultra .aging-below { display: none !important; }

/* Narrower columns (more room for new ones) */
.xgrid-wrap.ultra td[data-field="part_name"]        { width: 80px; font-size: 10px;}
.xgrid-wrap.ultra td[data-field="maker"]            { width: 36px; font-size: 8px;}
.xgrid-wrap.ultra td[data-field="machine_name"]     { width: 110px; font-size: 10px;}
.xgrid-wrap.ultra td[data-field="machine_line"]     { width: 48px; font-size: 8px;}
.xgrid-wrap.ultra td[data-field="qty"]              { width: 8px; text-align: center; }
.xgrid-wrap.ultra td[data-field="pic"]              { width: 20px; font-size: 8px;}
.xgrid-wrap.ultra td[data-field="status_part"]      { width: 60px; font-size: 10px;}
.xgrid-wrap.ultra td[data-field="remark"]           { width: 92px; font-size: 10px;}
.xgrid-wrap.ultra td[data-field="progress_status"]  { width: 104px; font-size: 10px;}
.xgrid-wrap.ultra td[data-field="supplier"]         { width: 64px; }
.xgrid-wrap.ultra td[data-field="due_date"]         { width: 68px; font-size: 10px;}
.xgrid-wrap.ultra td[data-field="eta"]              { width: 66px; font-size: 10px;}
.xgrid-wrap.ultra td[data-field="respond_text"]     { width: 58px; font-size: 10px;}

/* Subtle borders so density does not look like a jail cell */
.xgrid-wrap.ultra .xgrid th,
.xgrid-wrap.ultra .xgrid td {
  border-right: 1px solid #eceff1;
  border-bottom: 1px solid #eceff1; 
}

.xgrid-wrap.ultra .xgrid th {
  text-align: center; 
}

/* SLA marker thinner */
.xgrid-wrap.ultra tbody tr.sla-breached td:first-child {
  border-left: 2px solid #ef4444 !important;
}

/* Supplier-as-date uses the same placeholder style */
td[data-field="supplier"].placeholder {
  font-style: italic;
  color: #9ca3af;
  position: relative;
}
td[data-field="supplier"].placeholder::before {
  content: 'Set date...';
  color: #9ca3af;
  font-weight: 400;
}

/* Only show hints for maintenance role */
body[data-role-maintenance="1"] td[data-field="due_date"].placeholder::before {
  content: 'Set date...';
  color: #9ca3af;
  font-weight: 400;
}
body[data-role-maintenance="1"] td[data-field="supplier"].placeholder::before {
  content: 'Set date...';
  color: #9ca3af;
  font-weight: 400;
}

/* ---------- Stage strip (9 tiny progress columns) ---------- */
/* Generic target so we do not depend on nth-child indexes */
.xgrid th[data-col^="st_"],
.xgrid td[data-field^="st_"] {
  width: 18px;
  min-width: 18px;
  padding: 0 !important;
  text-align: center;
}

/* Keep cells skinny + vertically centered */
.xgrid td.stage-cell {
  padding: 0 !important;
  vertical-align: middle;
  position: relative;
}

/* The little rectangle we render from JS (one active stage only) */
.stage-dot {
  display: inline-block;
  width: 14px;
  height: 10px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06) inset;
}

/* Stage headers */
.xgrid th[data-col^="st_"] {
  font-size: 10px;
  letter-spacing: 0;
}

/* Ultra density tweaks */
.xgrid-wrap.ultra .xgrid th[data-col^="st_"],
.xgrid-wrap.ultra .xgrid td[data-field^="st_"] {
  width: 16px;
  min-width: 16px;
  padding: 0 6px;
}

.xgrid-wrap.ultra .stage-dot {
  width: 10px;
  height: 8px;
  border-radius: 2px;
}

/* Stage columns: fill whole cell with the status color */
.xgrid td.stage-cell.active {
  background: var(--stage-bg) !important;
  color: var(--stage-fg) !important;
}
.xgrid tbody tr:hover td.stage-cell.active {
  background: var(--stage-bg) !important;
}
.xgrid tbody tr.sla-breached td.stage-cell.active {
  background: var(--stage-bg) !important;
}

/* Vertical date stack */
.xgrid td.stage-cell .stage-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  line-height: 1;
  font-weight: 700;
  pointer-events: none;
}
.xgrid td.stage-cell .stage-day { font-size: 10px; }
.xgrid td.stage-cell .stage-month { font-size: 10px; letter-spacing: 0.2px; }
.xgrid td.stage-cell .stage-dash {
  width: 70%;
  height: 1px;
  background: currentColor;
  margin: 2px 0;
}

/* Stop ellipsis on the tiny stage headers */
.xgrid thead th[data-col^="st_"] {
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 6px;
  font-weight: 600;
  font-size: 10px;
}

/* lock table row height for virtualization */
.xgrid-wrap.ultra table.xgrid tr,
.xgrid-wrap.ultra table.xgrid td {
  height: 28px;
  max-height: 28px;
  overflow: hidden;
}
.xgrid-wrap.ultra td[data-field="progress_status"] .aging-below {
  display: none !important;
}

/* --- Toolbar-left sizing overrides (append at end) --- */
.xgrid-wrap .xgrid-toolbar .xgrid-toolbar-left .xgrid-filters-btn,
.xgrid-wrap .xgrid-toolbar .xgrid-toolbar-left .xgrid-legend-btn,
.xgrid-wrap .xgrid-toolbar .xgrid-toolbar-left .xgrid-export-btn {
  height: 36px !important;
  border-radius: 18px !important;
  border-color: #d1d5db !important;
  background: #fff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

/* Filters = pill with text */
.xgrid-wrap .xgrid-toolbar .xgrid-toolbar-left .xgrid-filters-btn {
  width: auto !important;
  min-width: 88px !important;
  padding: 0 14px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  gap: 8px !important;
}

/* Icon buttons remain true squares */
.xgrid-wrap .xgrid-toolbar .xgrid-toolbar-left .xgrid-legend-btn,
.xgrid-wrap .xgrid-toolbar .xgrid-toolbar-left .xgrid-export-btn {
  width: 36px !important;
  padding: 0 !important;
}

/* Hover / active */
.xgrid-wrap .xgrid-toolbar .xgrid-toolbar-left > *:hover {
  background: #f9fafb !important;
  border-color: #cfd4dc !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.02) !important;
}
.xgrid-wrap .xgrid-toolbar .xgrid-toolbar-left > *.active {
  background: var(--brand-primary) !important;
  color: #fff !important;
  border-color: var(--brand-primary) !important;
}

/* Ultra density variant */
.xgrid-wrap.ultra .xgrid-toolbar .xgrid-toolbar-left .xgrid-filters-btn,
.xgrid-wrap.ultra .xgrid-toolbar .xgrid-toolbar-left .xgrid-legend-btn,
.xgrid-wrap.ultra .xgrid-toolbar .xgrid-toolbar-left .xgrid-export-btn {
  height: 30px !important;
  border-radius: 15px !important;
}
.xgrid-wrap.ultra .xgrid-toolbar .xgrid-toolbar-left .xgrid-legend-btn,
.xgrid-wrap.ultra .xgrid-toolbar .xgrid-toolbar-left .xgrid-export-btn {
  width: 30px !important;
}

/* Safe header normalization */
table.xgrid thead th {
  display: table-cell;       /* default */
  vertical-align: middle;    /* centers text vertically */
  height: 48px;              /* match body height */
  line-height: 1.2;          /* no huge line-height tricks */
  padding: 10px 12px;        /* same as body */
  box-sizing: border-box;
}

/* Stage headers: small text but same vertical metrics */
table.xgrid thead th[data-col^="st_"] {
  font-size: 10px;
  padding-left: 6px;
  padding-right: 6px;
  /* keep top/bottom padding same as others so they align */
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Ensure ALL headers in ultra mode have consistent padding */
.xgrid-wrap.ultra table.xgrid thead th {
  padding: 2px 4px !important;
}

/* Stage headers can still have their horizontal padding adjustments */
.xgrid-wrap.ultra table.xgrid thead th[data-col^="st_"] {
  padding-left: 6px !important;
  padding-right: 6px !important;
}

/* Nuclear option - force all headers to same height */
.xgrid-wrap.ultra table.xgrid thead th {
  padding: 2px 4px !important;
  height: 28px !important;
  box-sizing: border-box !important;
  vertical-align: middle !important;
}

/* Stage headers inherit same padding, only adjust horizontal */
.xgrid-wrap.ultra table.xgrid thead th[data-col^="st_"] {
  padding-left: 6px !important;
  padding-right: 6px !important;
}

.xgrid tbody tr[data-new],
.xgrid tbody tr[data-new-controls] { display: table-row; }

.xgrid tbody tr[data-new-controls] > td {
  white-space: normal !important;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
}

/* Part type column (free text) */
.xgrid thead th[data-col="part_type"],
.xgrid td[data-field="part_type"] {
  width: 72px;
}

/* Ultra density */
.xgrid-wrap.ultra td[data-field="part_type"] {
  width: 64px;
}

/* Inactive stage cell styling */
table.xgrid tbody tr td.stage-cell-inactive {
  font-size: 8px;
  font-weight: 500;
  color: #d1d5db;
  text-align: center;
  vertical-align: middle;
  background-color: #f4f4f5;
}

/* Price and Cost wrapping */
.xgrid td[data-field="price"],
.xgrid td[data-field="cost"] {
  white-space: normal;
  font-size: 9px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-overflow: clip;
}

.xgrid td[data-field="due_date"],
.xgrid td[data-field="eta"],
.xgrid td[data-field="supplier"],
.xgrid td[data-field="submitted_at"]{
  font-size: 8px;
}

/* Header text: allow two lines with consistent layout */
.xgrid th {
  white-space: normal !important;
  padding: 8px 6px;
  vertical-align: middle;
  text-align: center;
  height: 48px;
  min-height: 48px;
}

.xgrid th .th-wrapper {
  width: 100%;
  height: 100%;
}

.xgrid th .th-line {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-align: center;
}

/* Smaller font for stage columns */
.xgrid th[data-col^="st_"] .th-line {
  font-size: 10px;
}

/* Second line placeholder uses a plain space, hidden visually */
.xgrid th .th-line:last-child:empty::after {
  content: ' ';
  opacity: 0;
}

/* Unified wrapping rule for key columns */
.xgrid td[data-field="pic"],
.xgrid td[data-field="part_name"],
.xgrid td[data-field="maker"],
.xgrid td[data-field="part_type"],
.xgrid td[data-field="machine_name"],
.xgrid td[data-field="machine_line"] {
  line-height: 1.4em;
  min-height: 2.8em; /* 2 lines */
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  vertical-align: top;
  padding-top: 5px;
}

/* --- [ NEW ] BSD Column Styling --- */

/* Style for when BSD is active */
.xgrid td.bsd-active {
  background-color: #D1FAE5 !important; /* Pastel Green */
  color: #065F46;
  font-weight: 600;
  font-size: 11px;
}

/* Add pointer cursor for maintenance */
.xgrid td.bsd-clickable {
  cursor: pointer;
}

/* Hover effect for maintenance */
.xgrid td.bsd-clickable:not(.bsd-active):hover {
  background-color: #F0FDF4 !important;
}

/* BSD column: compact, medium weight */
table.xgrid tbody tr td[data-field="bsd"] {
  font-size: 8px;
  font-weight: 500;
    white-space: normal;     /* allow wrapping */
  overflow: visible;       /* don't clip */
  text-overflow: clip;     /* no ellipsis */
}
