/* ==========================================================================
   DELIVERY SCHEDULE & DISPATCH COMMAND CENTER
   Enterprise Matte Dark Design System (#0B0F14 / #111720 / #151C26 / #192231)
   High-Performance 11-Column Data Grid with Excel-Style Column Resizing
   ========================================================================== */

:root {
  --ds-bg-base: var(--bg-app, #0B0F14);
  --ds-bg-surface: var(--bg-surface, #111720);
  --ds-bg-surface-secondary: var(--bg-surface-secondary, #151C26);
  --ds-bg-surface-elevated: var(--bg-surface-elevated, #192231);
  --ds-bg-surface-hover: var(--bg-surface-hover, #1D2636);
  --ds-border: var(--border-subtle, rgba(255, 255, 255, 0.07));
  --ds-border-strong: var(--border-strong, rgba(255, 255, 255, 0.12));
  --ds-text-main: var(--text-primary, #F3F5F7);
  --ds-text-secondary: var(--text-secondary, #9AA5B5);
  --ds-text-muted: var(--text-muted, #667085);
  --ds-text-dim: var(--text-dim, #475467);
  --ds-accent: var(--accent, #d9778c);
}

/* Command Center Container */
.dispatch-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: #0c1017;
  color: #f1f5f9;
  min-height: calc(100vh - 44px);
  padding: 16px 20px 0 20px;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

/* ==========================================================================
   1. 4 REFINED ENTERPRISE KPI CARDS (Matching Screenshot Exactly)
   ========================================================================== */
.dispatch-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1200px) {
  .dispatch-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.dispatch-kpi-card {
  background-color: #131926;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.dispatch-kpi-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.kpi-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.kpi-icon-pink {
  background-color: rgba(219, 39, 119, 0.2);
  color: #ec4899;
}

.kpi-icon-green {
  background-color: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.kpi-icon-amber {
  background-color: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.kpi-icon-purple {
  background-color: rgba(168, 85, 247, 0.2);
  color: #a855f7;
}

.kpi-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-card-title {
  font-size: 12.5px;
  font-weight: 500;
  color: #94a3b8;
}

.kpi-card-value {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 2px 0;
}

.kpi-card-value .kpi-unit {
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
}

.kpi-card-value.text-amber-val {
  color: #f59e0b;
}

.kpi-card-sub {
  font-size: 11.5px;
  color: #64748b;
  margin-bottom: 2px;
}

.kpi-progress-bar-wrap {
  width: 100%;
  height: 3px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.kpi-progress-bar-fill {
  height: 100%;
  border-radius: 2px;
}

.kpi-bar-pink {
  background: linear-gradient(90deg, #ec4899, #db2777);
}

.kpi-bar-green {
  background: linear-gradient(90deg, #10b981, #059669);
}

.kpi-bar-amber {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

/* ==========================================================================
   2. ENTERPRISE FILTER TOOLBAR (Matching Screenshot Exactly)
   ========================================================================== */
.dispatch-filter-bar {
  background-color: #131926;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.filter-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar-right {
  display: flex;
  align-items: center;
}

.dispatch-search-box {
  position: relative;
  width: 170px;
}

.dispatch-search-box i {
  position: absolute;
  left: 10px;
  top: 10px;
  color: #94a3b8;
  font-size: 12px;
}

.dispatch-search-box input {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 7px 10px 7px 30px;
  color: #f1f5f9;
  font-size: 12.5px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.dispatch-search-box input:focus {
  border-color: rgba(255, 255, 255, 0.2);
}

.dispatch-search-box input::placeholder {
  color: #64748b;
}

.filter-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.filter-pill-btn {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 12px;
  color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  height: 34px;
}

.filter-pill-btn:hover {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.filter-pill-btn i {
  color: #94a3b8;
  font-size: 12px;
}

.status-circle-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #ffffff;
}

.filter-clear-btn {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 14px;
  color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.filter-clear-btn:hover {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

/* Google Sheets Sync Pill Button */
.sync-btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sync-btn-pill.syncing #syncIconRotate {
  animation: spinSync 1s linear infinite;
}

@keyframes spinSync {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.sync-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #10b981;
}

.sync-status-dot.checking {
  background-color: #f59e0b;
}

.sync-status-dot.offline {
  background-color: #ef4444;
}

.btn-pink-actions {
  background: linear-gradient(135deg, #ec4899, #db2777);
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  height: 34px;
  box-shadow: 0 4px 12px rgba(219, 39, 119, 0.3);
  transition: all 0.15s ease;
}

.btn-pink-actions:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(219, 39, 119, 0.4);
}

.filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  background-color: #171f2e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 4px;
  min-width: 170px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
  display: none;
}

.filter-dropdown-menu.open {
  display: block;
}

.filter-dropdown-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 12px;
  color: #cbd5e1;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-dropdown-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.filter-dropdown-item.active {
  background-color: rgba(219, 39, 119, 0.15);
  color: #ec4899;
  font-weight: 600;
}

/* Date Filter Dropdown Layout with Presets, Last 7 Days, and Custom Picker */
.date-filter-dropdown-menu {
  min-width: 250px;
  padding: 8px;
}

.date-filter-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.date-filter-divider {
  height: 1px;
  background-color: rgba(255, 255, 255, 0.08);
  margin: 8px 0;
}

.date-filter-days-title {
  font-size: 10.5px;
  font-weight: 600;
  color: #94a3b8;
  padding: 2px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.date-filter-days-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 140px;
  overflow-y: auto;
  margin-top: 4px;
}

.date-filter-day-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 5px 8px;
  font-size: 11.5px;
  color: #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.date-filter-day-btn:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.date-filter-day-btn.active {
  background-color: rgba(219, 39, 119, 0.15);
  color: #ec4899;
  font-weight: 600;
}

.custom-date-picker-box {
  background-color: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 8px;
}

.custom-date-title {
  font-size: 11px;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.custom-date-inputs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.date-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.date-input-group label {
  font-size: 10px;
  color: #94a3b8;
}

.custom-date-input {
  width: 100%;
  background-color: #0c1017;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 11px;
  color: #ffffff;
  outline: none;
  box-sizing: border-box;
}

.btn-custom-date-apply {
  width: 100%;
  background: linear-gradient(135deg, #ec4899, #db2777);
  border: none;
  border-radius: 4px;
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-custom-date-apply:hover {
  opacity: 0.9;
}

/* ==========================================================================
   3. 11-COLUMN DATA GRID (Sticky Header & Sticky Footer)
   ========================================================================== */
.dispatch-grid-container {
  background-color: #131926;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 210px);
  min-height: 480px;
}

.dispatch-grid-scroll {
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
}

.dispatch-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
  color: #f1f5f9;
}

/* STICKY TABLE HEADER: Remains locked to the top when scrolling */
.dispatch-table thead th {
  background-color: #171f2e;
  color: #94a3b8;
  font-weight: 500;
  font-size: 11.5px;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  text-align: left;
  vertical-align: middle;
  position: sticky;
  top: 0;
  z-index: 20;
  user-select: none;
}

.dispatch-table thead th:last-child {
  border-right: none;
}

.th-content {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.25;
}

.th-content.th-right {
  justify-content: flex-end;
}

.th-content.th-center {
  justify-content: center;
}

.th-sub {
  font-size: 10.5px;
  color: #64748b;
  font-weight: 400;
}

/* Draggable Column Resize Handle */
.col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 25;
}

.col-resize-handle:hover,
.col-resize-handle.active {
  background-color: #db2777;
}

.col-resize-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: #db2777;
  z-index: 50;
  pointer-events: none;
  display: none;
}

/* Table Body Rows */
.dispatch-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background-color 0.15s ease;
}

.dispatch-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02) !important;
}

.dispatch-table tbody tr.row-selected {
  background-color: rgba(219, 39, 119, 0.06) !important;
  position: relative;
}

.dispatch-table tbody tr.row-selected td:first-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: #db2777;
}

.dispatch-table td {
  padding: 12px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.dispatch-table td:last-child {
  border-right: none;
}

/* Checkbox Style */
.row-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.03);
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0;
  transition: all 0.15s ease;
}

.row-checkbox:checked {
  background-color: #db2777;
  border-color: #db2777;
}

.row-checkbox:checked::after {
  content: '✓';
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* Date Cell */
.date-cell-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.date-cell-wrap .date-main {
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
}

.date-cell-wrap .date-sub {
  font-size: 11px;
  color: #94a3b8;
}

/* Vehicle Cell */
.vehicle-cell-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.vehicle-icon-box {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background-color: rgba(219, 39, 119, 0.2);
  color: #ec4899;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  flex-shrink: 0;
  margin-top: 1px;
}

.vehicle-info-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.25;
}

.vehicle-num {
  font-size: 12.5px;
  font-weight: 700;
  color: #ffffff;
}

.vehicle-driver,
.vehicle-phone,
.vehicle-transport {
  font-size: 11px;
  color: #94a3b8;
}

/* Customer Cell */
.customer-cell-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.customer-name-text {
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.25;
}

/* Address Cell */
.address-cell-wrap {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.address-pin-icon {
  color: #94a3b8;
  font-size: 11px;
  margin-top: 2px;
  flex-shrink: 0;
}

.address-text-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.25;
}

.address-line,
.address-phone {
  font-size: 11px;
  color: #94a3b8;
}

/* Quantities */
.qty-cell-req {
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
}

.qty-cell-del {
  font-size: 12.5px;
  font-weight: 600;
  color: #10b981;
}

.qty-cell-due {
  font-size: 12.5px;
  font-weight: 600;
}

.qty-cell-due.is-zero {
  color: #ef4444;
}

.qty-cell-due.has-due {
  color: #f59e0b;
}

/* Labour Cell */
.labour-cell-wrap {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.labour-icon {
  color: #94a3b8;
  font-size: 11px;
  margin-top: 2px;
  flex-shrink: 0;
}

.labour-text-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.25;
}

.labour-group-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
}

.labour-person-name {
  font-size: 11px;
  color: #94a3b8;
}

/* Status Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.status-pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: currentColor;
}

.status-pill-delivered {
  background-color: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.status-pill-partial {
  background-color: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #f59e0b;
}

.status-pill-pending {
  background-color: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #94a3b8;
}

/* Actions */
.row-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
}

.btn-row-action {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.15s ease;
}

.btn-row-action:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* Table Footer / Pagination */
.dispatch-table-footer {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background-color: #131926;
  position: sticky;
  bottom: 0;
  z-index: 25;
  flex-shrink: 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.35);
}

.footer-entries-count {
  font-size: 12.5px;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
}

.footer-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: #94a3b8;
  flex-shrink: 0;
}

.pagination-select {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-page-nav {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #64748b;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
}

.btn-page-num.active {
  background-color: #db2777;
  border: none;
  color: #ffffff;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* ==========================================================================
   4. CONTEXTUAL FLOATING BULK ACTION TOOLBAR
   ========================================================================== */
.dispatch-bulk-toolbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  background-color: #131926;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}

.dispatch-bulk-toolbar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.bulk-count-pill {
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: #ffffff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bulk-action-btn {
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
}

.bulk-action-btn:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.bulk-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: transparent;
}

.bulk-action-btn.btn-clear-selection {
  color: #94a3b8;
  background: transparent;
  border-color: transparent;
  padding: 6px 10px;
}

.bulk-action-btn.btn-clear-selection:hover {
  color: #ffffff;
}

.bulk-tooltip-wrap {
  position: relative;
  display: inline-flex;
}

.bulk-tooltip-wrap .bulk-tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background-color: #000000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 110;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: opacity 0.15s ease;
}

.bulk-tooltip-wrap:hover .bulk-tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ==========================================================================
   7. DOCUMENT PREVIEW / CONFIRMATION MODAL
   ========================================================================== */
.doc-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.doc-preview-backdrop.hidden {
  display: none !important;
}

.doc-preview-card {
  background-color: var(--ds-bg-surface);
  border: 1px solid var(--ds-border-strong);
  border-radius: 8px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.doc-preview-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ds-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--ds-bg-surface-secondary);
}

.doc-preview-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ds-text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.doc-preview-body {
  padding: 16px;
  font-size: 12px;
  color: var(--ds-text-secondary);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.doc-preview-meta {
  background-color: var(--ds-bg-base);
  border: 1px solid var(--ds-border);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-preview-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
}

.doc-preview-meta-row strong {
  color: var(--ds-text-main);
}

.doc-preview-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--ds-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background-color: var(--ds-bg-surface-secondary);
}

/* ==========================================================================
   8. COLUMN MANAGER POPOVER
   ========================================================================== */
.column-picker-popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 60;
  background-color: var(--ds-bg-surface-elevated);
  border: 1px solid var(--ds-border-strong);
  border-radius: 6px;
  padding: 8px;
  min-width: 180px;
  box-shadow: var(--shadow-xl);
  display: none;
}

.column-picker-popover.open {
  display: block;
}

.column-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}

.column-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ds-text-secondary);
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.column-picker-item:hover {
  background-color: var(--ds-bg-surface-hover);
  color: var(--ds-text-main);
}

.column-picker-footer {
  border-top: 1px solid var(--ds-border);
  margin-top: 6px;
  padding-top: 6px;
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   9. ANOMALY DETECTION & MODALS
   ========================================================================== */
.anomaly-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  margin-top: 2px;
}

.anomaly-overdue {
  background-color: var(--amber-dark-bg);
  color: var(--amber-400);
  border: 1px solid var(--amber-border);
}

.anomaly-overweight {
  background-color: var(--red-dark-bg);
  color: var(--red-400);
  border: 1px solid var(--red-border);
}

/* Relational Modals */
.relational-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.relational-modal-backdrop.hidden {
  display: none !important;
}

.relational-modal-card {
  background-color: var(--ds-bg-surface);
  border: 1px solid var(--ds-border-strong);
  border-radius: 8px;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.relational-modal-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--ds-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--ds-bg-surface-secondary);
}

.relational-modal-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ds-text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.relational-modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.relational-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.relational-stat-card {
  background-color: var(--ds-bg-base);
  border: 1px solid var(--ds-border);
  border-radius: 4px;
  padding: 8px 12px;
}

.relational-stat-card .stat-title {
  font-size: 10px;
  color: var(--ds-text-muted);
  text-transform: uppercase;
  font-weight: 500;
}

.relational-stat-card .stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--ds-text-main);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

.relational-ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.relational-ledger-table th {
  background-color: var(--ds-bg-base);
  color: var(--ds-text-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--ds-border);
  text-align: left;
  font-size: 11px;
}

.relational-ledger-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--ds-border);
  color: var(--ds-text-secondary);
}

/* Dispatch Automation Modals */
.dispatch-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 105;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dispatch-modal-backdrop.hidden {
  display: none !important;
}

.dispatch-modal-box {
  background-color: var(--ds-bg-surface);
  border: 1px solid var(--ds-border-strong);
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.dispatch-modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ds-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--ds-bg-surface-secondary);
}

.dispatch-modal-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ds-text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dispatch-modal-body {
  padding: 16px;
  overflow-y: auto;
}

.dispatch-modal-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--ds-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background-color: var(--ds-bg-surface-secondary);
}

/* Action Popover Menu */
.action-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.action-menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  background-color: var(--ds-bg-surface-elevated);
  border: 1px solid var(--ds-border-strong);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 180px;
  box-shadow: var(--shadow-xl);
  display: none;
}

.action-menu-popover.open {
  display: block;
}

.action-menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 11.5px;
  color: var(--ds-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.action-menu-item:hover {
  background-color: var(--ds-bg-surface-hover);
  color: var(--ds-text-main);
}

/* Delta Reconciliation Surgical Highlight */
@keyframes rowDeltaFlash {
  0% {
    background-color: rgba(16, 185, 129, 0.3) !important;
  }
  100% {
    background-color: transparent;
  }
}

.row-delta-flash {
  animation: rowDeltaFlash 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes rowRollbackFlash {
  0% {
    background-color: rgba(244, 63, 94, 0.3) !important;
  }
  100% {
    background-color: transparent;
  }
}

.row-rollback-flash {
  animation: rowRollbackFlash 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* ==========================================================================
   HALF-A4 ENTERPRISE FACTORY SLIP STYLES (EXACT 2-UP PRINT ON A4 PAPER)
   ========================================================================== */
.printable-slip-area {
  background: #ffffff !important;
  color: #000000 !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.slip-two-up-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.factory-slip-sheet {
  background: #ffffff;
  color: #000000;
  padding: 10px 14px;
  border-radius: 4px;
  border: 1.5px solid #000000;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-size: 11px;
  line-height: 1.3;
  box-sizing: border-box;
}

.slip-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #000000;
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.slip-brand-col {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slip-logo-img {
  height: 24px;
  width: auto;
  object-fit: contain;
}

.slip-company-name {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #000000;
  line-height: 1.15;
}

.slip-doc-type-title {
  font-size: 10.5px;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.slip-plant-sub {
  font-size: 9px;
  color: #64748b;
}

.slip-serial-col {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
}

.slip-copy-badge {
  display: inline-block;
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 5px;
  border: 1px solid #000000;
  border-radius: 2px;
  text-transform: uppercase;
  margin-bottom: 2px;
  background: #f1f5f9;
  color: #0f172a;
}

.slip-meta-table {
  width: 100%;
  margin: 4px 0;
  border-collapse: collapse;
}

.slip-meta-table td {
  padding: 2px 0;
  font-size: 11px;
  vertical-align: top;
}

.slip-meta-table td:first-child {
  width: 130px;
  color: #475569;
  font-weight: 600;
}

.slip-meta-table td:last-child {
  color: #000000;
}

.slip-product-box {
  border: 1.5px solid #000000;
  padding: 6px 10px;
  margin: 6px 0;
  background-color: #f8fafc;
  border-radius: 4px;
}

.slip-signature-row {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 4px;
}

.slip-signature-box {
  width: 135px;
  border-top: 1px solid #000000;
  text-align: center;
  font-size: 10px;
  color: #334155;
  padding-top: 3px;
  font-weight: 600;
}

.qr-pass-container {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px dashed #000000;
  padding: 6px 10px;
  margin: 6px 0;
  border-radius: 4px;
}

.slip-cut-divider {
  border-top: 1.5px dashed #94a3b8;
  margin: 6px 0;
  text-align: center;
  position: relative;
}

.slip-cut-divider span {
  background: #ffffff;
  padding: 0 8px;
  font-size: 9px;
  color: #64748b;
  position: relative;
  top: -8px;
  font-family: 'JetBrains Mono', monospace;
}

/* Print Rules: Exact 2-up on A4 Sheet (2 documents on 1 page) */
@media print {
  @page {
    size: A4 portrait;
    margin: 4mm 6mm;
  }
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
    text-rendering: geometricPrecision !important;
    -webkit-font-smoothing: antialiased !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  body * {
    visibility: hidden;
  }
  .printable-slip-area,
  .printable-slip-area * {
    visibility: visible;
  }
  .printable-slip-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }
  .slip-two-up-wrapper {
    gap: 3mm !important;
    page-break-inside: avoid !important;
  }
  .factory-slip-sheet {
    height: 137mm !important;
    max-height: 137mm !important;
    overflow: hidden !important;
    box-shadow: none !important;
    border: 2px solid #000000 !important;
    border-radius: 4px !important;
    padding: 7px 12px !important;
    page-break-inside: avoid !important;
    background: #ffffff !important;
    color: #000000 !important;
    box-sizing: border-box !important;
  }
  .slip-cut-divider {
    display: block !important;
    margin: 2mm 0 !important;
    border-top: 1.5px dashed #000000 !important;
  }
  .slip-cut-divider span {
    background: #ffffff !important;
    color: #000000 !important;
    font-weight: 700 !important;
    font-size: 9px !important;
    padding: 0 6px !important;
  }
  .modal-backdrop,
  .dispatch-modal-backdrop,
  .app-header,
  .app-sidebar,
  .dispatch-modal-footer,
  .dispatch-modal-header {
    display: none !important;
  }
}
