/* Legacy styles migrated from index.html for ongoing refactor */
.refresh-btn-mobile {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  margin-right: 8px;
}

.refresh-btn-mobile:hover {
  background: var(--primary-dark);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.refresh-btn-mobile:active {
  transform: scale(0.95);
  background: var(--primary-dark);
}

.refresh-btn-mobile:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.refresh-btn-mobile.loading {
  pointer-events: none;
  opacity: 0.8;
}

.refresh-btn-mobile.loading svg {
  animation: spin 1s linear infinite;
}

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

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Tooltip for refresh status */
.refresh-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--text-primary);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 1000;
}

.refresh-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.refresh-tooltip::before {
  content: '';
  position: absolute;
  top: -4px;
  right: 16px;
  width: 8px;
  height: 8px;
  background: var(--text-primary);
  transform: rotate(45deg);
}

/* Empty State */
.empty-orders {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 16px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  color: var(--text-tertiary);
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-subtitle {
  font-size: 14px;
  line-height: 1.5;
}

/* Search Modal */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
}

.search-modal.active {
  transform: translateY(0);
}

/* Sort Modal (bottom sheet) */
.sort-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: none;
  z-index: 1100;
}
.sort-modal.active {
  display: block;
}
.sort-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 12px 16px 16px;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.sort-modal.active .sort-sheet {
  transform: translateY(0);
}
.sort-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 12px;
}
.sort-title {
  font-weight: 600;
  font-size: 16px;
}
.sort-close {
  background: none;
  border: 0;
  padding: 8px;
  border-radius: 8px;
  color: var(--text-secondary);
}
.sort-section {
  margin: 8px 0 4px;
  color: var(--text-tertiary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sort-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sort-option {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  color: var(--text-primary);
}
.sort-option:active {
  transform: scale(0.98);
}
.sort-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 101;
}

.search-back-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-back-btn:active {
  background: var(--border-light);
  transform: scale(0.95);
}

.search-input-container {
  flex: 1;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 48px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  background: var(--background);
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  width: 20px;
  height: 20px;
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-tertiary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
}

.search-clear-btn.visible {
  display: flex;
}

/* Search Results */
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.search-suggestions {
  padding: 16px 0;
}

.suggestion-category {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--border-light);
  margin-bottom: 4px;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface);
}

.suggestion-item:hover,
.suggestion-item:active {
  background: var(--primary-light);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-icon {
  width: 40px;
  height: 40px;
  background: var(--border-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.suggestion-content {
  flex: 1;
  min-width: 0;
}

.suggestion-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-arrow {
  color: var(--text-tertiary);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Recent Searches */
.recent-searches {
  padding: 16px;
}

.recent-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.recent-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-item {
  background: var(--border-light);
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.recent-item:active {
  background: var(--primary-light);
  color: var(--primary);
}

/* Empty State */
.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-tertiary);
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-subtitle {
  font-size: 14px;
  line-height: 1.5;
}

/* Loading State */
.loading-state {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
}

/* Main Content */
.main-content-mobile {
  flex: 1;
  padding: 16px;
  padding-bottom: 80px; /* Space for bottom nav */
  max-width: 100vw;
  overflow-x: auto;
  overscroll-behavior-y: contain;
}

/* Quick Stats Cards - Stacked Vertically */
.quick-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

/* Overview Card */
.overview-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.overview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.overview-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.overview-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.overview-rate {
  background: #d1fae5;
  color: var(--success);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.overview-bar {
  position: relative;
  height: 10px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.overview-bar .bar-completed {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--success);
  opacity: 0.9;
}
.overview-bar .bar-partial {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  background: var(--warning);
  opacity: 0.9;
}
.overview-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.overview-metrics .metric {
  display: flex;
  flex-direction: column;
}
.overview-metrics .metric-label {
  font-size: 12px;
  color: var(--text-secondary);
}
.overview-metrics .metric-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-card-mobile {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stat-card-mobile:active {
  transform: scale(0.98);
}

.stat-card-mobile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
}

.stat-header-mobile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-title-mobile {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-badge {
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}

.stat-badge.warning {
  background: #fef3c7;
  color: var(--warning);
}

.stat-badge.success {
  background: #d1fae5;
  color: var(--success);
}

.stat-value-mobile {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 0 4px;
}

.section-icon {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Status Lists */
.status-section {
  margin-bottom: 32px;
}

.status-list-mobile {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.status-item-mobile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.2s ease;
  min-height: 64px; /* Ensure adequate touch target */
  position: relative;
  cursor: pointer;
}

.status-item-mobile:last-child {
  border-bottom: none;
}

.status-item-mobile:active {
  background: var(--primary-light);
  transform: scale(0.98);
}

.status-item-content {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.status-icon-mobile {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.status-label-mobile {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.status-count-mobile {
  background: var(--primary);
  color: white;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

/* Download Data Page Styles - Mobile Optimized */
.data-section {
  padding: 0;
  width: 100%;
  max-width: 100%;
}

/* List View Styles */
.pfi-summary-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .pfi-summary-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.pfi-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pfi-summary-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.pfi-summary-label {
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 600;
}

.pfi-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pfi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
  min-width: 0;
  max-width: 100%;
}

.pfi-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.pfi-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.pfi-card-status-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.pfi-card-status-block .pfi-date-pill {
  align-self: flex-end;
}

.pfi-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--border-light);
  color: var(--text-secondary);
  white-space: nowrap;
}

.pfi-status-badge.delivered {
  background: var(--success-light);
  color: var(--success);
}

.pfi-status-badge.in-transit,
.pfi-status-badge.transit {
  background: var(--warning-light);
  color: var(--warning);
}

.pfi-status-badge.awaiting-shipment,
.pfi-status-badge.pending {
  background: var(--info-light);
  color: var(--info);
}

.pfi-card-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.pfi-card-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.pfi-card-status-label {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-tertiary);
  margin-top: 6px;
}

/* When status badge is in the right header column, remove extra top margin */
.pfi-card-header-right .pfi-card-status-label {
  margin-top: 0;
}

.pfi-card-status-label.awaiting-shipment,
.pfi-card-status-label.pending {
  background: rgba(59, 130, 246, 0.18);
  color: var(--primary);
}

.pfi-card-status-label.delivered {
  background: rgba(16, 185, 129, 0.18);
  color: var(--success);
}

.pfi-card-status-label.in-transit,
.pfi-card-status-label.transit {
  background: rgba(59, 130, 246, 0.18);
  color: var(--primary);
}

.pfi-card-status-label.ordered {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.pfi-card-status-label.validation,
.pfi-card-status-label.validate {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.pfi-card-ref {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  overflow-wrap: break-word;
}

.pfi-card-supplier {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: break-word;
}

.pfi-card-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-tertiary);
}

.pfi-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pfi-card-meta span::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.6);
}


.pfi-card-body {
  display: grid;
  gap: 10px;
}

.pfi-card-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: break-word;
}


.pfi-card-item-block {
  display: grid;
  gap: 4px;
  margin-bottom: 4px;
}

.pfi-card-item-line {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.3;
}

.pfi-card-item-more {
  font-size: 12px;
  color: var(--text-tertiary);
}

.pfi-card-attributes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.pfi-card-attribute {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.pfi-card-attribute-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 600;
}

.pfi-card-attribute-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 520px) {
  .pfi-card-attributes .pfi-card-attribute:nth-child(2),
  .pfi-card-attributes .pfi-card-attribute:nth-child(3) {
    text-align: center;
  }

  .pfi-card-attributes .pfi-card-attribute:nth-child(4) {
    text-align: right;
  }
}

/* Keep quick metrics (QTY, TC, FT, AMOUNT) on one row even on small screens */
@media (max-width: 480px) {
  .pfi-card-attributes {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }
}

@media (max-width: 400px) {
  .pfi-card {
    padding: 10px 12px;
  }

  .pfi-card-attributes {
    gap: 6px;
  }

  .pfi-card-header {
    gap: 8px;
  }
}

.pfi-card-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.pfi-card-item-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pfi-card-item-meta span::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.45);
  opacity: 0.8;
}

.pfi-card-item-meta span:first-child::before {
  display: none;
}



.pfi-card-item-meta-lite span {
  white-space: nowrap;
}

.pfi-meta-dot {
  color: rgba(148, 163, 184, 0.6);
}

.pfi-chip-muted {
  background: var(--border-light);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
}

.pfi-quick-metrics {
  display: none;
}

.pfi-card-supplier-line {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 6px;
}

.pfi-card-brand-line {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.pfi-card-meta.detail {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  padding-top: 10px;
  margin-top: 12px;
}

.pfi-card-meta.detail span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pfi-card-meta.detail span::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.pfi-card-meta.detail span:first-child::before {
  display: none;
}

.pfi-card-dashboard {
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.96),
    rgba(15, 23, 42, 0.88)
  );
  border: 1px solid rgba(148, 163, 184, 0.12);
  box-shadow: 0 16px 34px rgba(2, 6, 23, 0.45);
  gap: 16px;
}

.pfi-card-dashboard .pfi-card-title .pfi-card-ref {
  font-size: 17px;
}

.pfi-card-dashboard .pfi-dashboard-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.pfi-card-dashboard .pfi-dashboard-footer span {
  background: rgba(148, 163, 184, 0.12);
  color: rgba(226, 232, 240, 0.85);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
}

.pfi-card-shipments {
  font-weight: 600;
  color: rgba(148, 163, 184, 0.85);
}

body.theme-light .pfi-card-shipments {
  color: #1f2937;
}

.pfi-date-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.16);
  color: rgba(226, 232, 240, 0.9);
  font-weight: 600;
  font-size: 11px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-align: right;
}

.pfi-quick-item {
  font-size: 13px;
  color: rgba(226, 232, 240, 0.78);
  font-weight: 600;
}

.pfi-quick-more {
  color: rgba(148, 163, 184, 0.75);
  font-weight: 500;
  margin-left: 6px;
  font-size: 12px;
}

.pfi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.pfi-card-title {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pfi-card-ref {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.pfi-card-supplier {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.pfi-card-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}


.pfi-card-chips {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pfi-card-chip-row {
  margin-top: 8px;
  gap: 6px;
}

.pfi-card-chip-row .pfi-chip {
  font-size: 11px;
  letter-spacing: 0.02em;
}

.pfi-card-chip-row .pfi-chip::before {
  display: none;
}

.pfi-card-chip-row .pfi-chip + .pfi-chip {
  border-left: none;
  padding-left: 0;
}

.pfi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border-radius: 0;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  background: transparent;
  color: var(--text-secondary);
  position: relative;
}

.pfi-chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  margin-right: 4px;
}

.pfi-chip + .pfi-chip {
  padding-left: 12px;
  border-left: 1px solid rgba(148, 163, 184, 0.25);
}

.pfi-chip.received {
  color: var(--success);
}

.pfi-chip.transit {
  color: var(--primary);
}

.pfi-chip.pending {
  color: var(--warning);
}

.pfi-chip.neutral {
  color: var(--text-secondary);
}

.pfi-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.pfi-card-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  flex: 1 1 0%;
  min-width: 68px;
  padding-right: 12px;
  text-align: left;
}

.pfi-card-stat:not(:first-child) {
  padding-left: 12px;
  border-left: 1px solid rgba(148, 163, 184, 0.16);
}

.pfi-card-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.pfi-card-stat-label {
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
}

.pfi-card-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.pfi-card-progress.is-idle .pfi-card-progress-bar {
  background: rgba(148, 163, 184, 0.12);
  opacity: 0.6;
}

.pfi-card-progress.is-idle .pfi-card-progress-text {
  color: rgba(148, 163, 184, 0.78);
}

.pfi-card-progress-bar {
  position: relative;
  height: 4px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
}

.pfi-card-progress-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: 999px;
}

.pfi-card-progress-segment.received {
  background: var(--success);
}

.pfi-card-progress-segment.transit {
  background: var(--primary);
}

.pfi-card-progress-text {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.pfi-card-items {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.pfi-card-item-name {
  font-weight: 600;
  color: var(--text-primary);
}

.pfi-card-item-qty {
  font-weight: 600;
}

.pfi-card-item-more {
  font-weight: 500;
  color: var(--text-tertiary);
}

.pfi-date-pill::before {
  content: attr(data-pill-label);
  color: inherit;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 1px;
}

.pfi-date-pill[data-pill-label='']::before,
.pfi-date-pill:not([data-pill-label])::before {
  content: none;
}

.pfi-quick-item {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

.pfi-overview-card {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.18),
    rgba(15, 118, 110, 0.18)
  );
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 16px;
}

@media (max-width: 400px) {
  .pfi-overview-card { padding: 12px; }
}

.pfi-overview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pfi-overview-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(15, 118, 110, 0.25);
  max-width: 100%;
  flex-shrink: 1;
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
}

body.theme-light .pfi-overview-chip {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.22);
}

.pfi-overview-distribution {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.pfi-overview-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.pfi-overview-bar-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  transition: width 0.3s ease;
}

.pfi-overview-bar-segment.received {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.95), rgba(16, 185, 129, 0.85));
  z-index: 3;
}

.pfi-overview-bar-segment.transit {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.9), rgba(14, 116, 255, 0.8));
  z-index: 2;
}

.pfi-overview-bar-segment.pending {
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.85), rgba(251, 191, 36, 0.8));
  z-index: 1;
}

.pfi-overview-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

@media (max-width: 420px) {
  .pfi-overview-legend {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 6px;
  }
}

.pfi-overview-legend-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}

.pfi-overview-legend-item strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

@media (max-width: 400px) {
  .pfi-overview-legend-item strong { font-size: 15px; }
  .pfi-overview-chip { padding: 6px 10px; font-size: 12px; }
}

.pfi-overview-legend-item em {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.pfi-overview-legend-item.total strong {
  color: var(--text-primary);
}

.pfi-dashboard-content {
  display: grid;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.pfi-dashboard-cards {
  display: grid;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.pfi-card.pfi-card-dashboard { padding: 10px; gap: 8px; }

/* Compact spacing just for dashboard PFI cards */
.pfi-card-dashboard .pfi-card-body { gap: 6px; }
.pfi-card-dashboard .pfi-card-attributes { padding-top: 6px; margin-top: 8px; gap: 8px; }
.pfi-card-dashboard .pfi-card-attribute-label { font-size: 9px; }
.pfi-card-dashboard .pfi-card-attribute-value { font-size: 13px; }
.pfi-card-dashboard .pfi-card-chips { margin-top: 8px; padding: 4px 8px; gap: 8px; }
.pfi-card-dashboard .pfi-card-progress { margin-top: 8px; }
.pfi-card-dashboard .pfi-card-progress-bar { height: 4px; }
.pfi-card-dashboard .pfi-date-pill { font-size: 10px; padding: 3px 8px; border-radius: 8px; }
.pfi-card-dashboard .pfi-card-header-right { gap: 4px; }
.pfi-card-dashboard .pfi-card-ref, .pfi-card-dashboard .pfi-card-item-name { font-size: 14px; }

.pfi-card-dashboard .pfi-card-chips {
  gap: 6px;
}

.pfi-card-dashboard .pfi-card-items,
.pfi-card-dashboard .pfi-card-item-more {
  display: none;
}

.pfi-dashboard-footer {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 12px;
}

.pfi-dashboard-footer span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--border-light);
  border-radius: 999px;
  padding: 4px 8px;
  font-weight: 600;
}

.theme-light .pfi-dashboard-footer span {
  background: rgba(226, 232, 240, 0.95);
  border: 1px solid #cbd5e1;
  color: #1f2937;
}

/* PFI Progress Table (Dashboard + List View) */
.panel-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.pfi-progress-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 680px;
}

.pfi-progress-row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(160px, 2fr) minmax(
      200px,
      2fr
    ) minmax(100px, 1fr) minmax(100px, 1fr) minmax(90px, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.pfi-progress-row-head {
  border: none;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  padding: 0 4px;
}

.pfi-progress-row-head span {
  padding: 0 12px;
}

.pfi-progress-row + .pfi-progress-row {
  margin-top: 4px;
}

.pfi-progress-refwrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pfi-progress-ref {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--primary);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.pfi-progress-ref:hover,
.pfi-progress-ref:focus {
  text-decoration: underline;
}

.pfi-progress-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pfi-progress-supplier {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.pfi-progress-category {
  font-size: 12px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.pfi-progress-tc {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pfi-progress-bar {
  position: relative;
  height: 5px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
}

.pfi-progress-bar-arrived {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--success);
}

.pfi-progress-bar-transit {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--primary);
}

.pfi-progress-total {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.pfi-progress-popover {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 12px);
  min-width: 170px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 20;
}

.pfi-progress-tc:hover .pfi-progress-popover,
.pfi-progress-tc:focus-within .pfi-progress-popover {
  display: block;
}

.pfi-progress-popover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.pfi-progress-popover-row:last-child {
  margin-bottom: 0;
}

.pfi-progress-popover-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pfi-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.pfi-progress-dot.received {
  background: var(--success);
}

.pfi-progress-dot.transit {
  background: var(--primary);
}

.pfi-progress-dot.pending {
  background: var(--warning);
}

.pfi-progress-shipments {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.pfi-progress-table .panel-empty {
  margin: 0;
}

@media (max-width: 1024px) {
  .pfi-progress-table {
    min-width: 540px;
  }
  .pfi-progress-row {
    grid-template-columns: minmax(170px, 2fr) minmax(150px, 2fr) minmax(
        190px,
        2fr
      ) minmax(90px, 1fr) minmax(90px, 1fr) minmax(80px, 1fr);
    padding: 12px;
  }
}

@media (max-width: 768px) {
  .pfi-progress-table {
    min-width: 100%;
  }
  .pfi-progress-row {
    grid-template-columns: minmax(160px, 2fr) minmax(140px, 2fr) minmax(
        180px,
        2fr
      ) minmax(80px, 1fr) minmax(80px, 1fr) minmax(70px, 1fr);
    padding: 12px 10px;
  }
  .pfi-progress-row-head span {
    padding: 0 8px;
  }
}

/* PFI Detail Modal */
.pfi-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
}

.pfi-detail-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 12, 20, 0.6);
  opacity: 0;
  transition: opacity 0.32s ease;
}

.pfi-detail-modal.is-open {
  pointer-events: auto;
}

.pfi-detail-modal.is-open .pfi-detail-overlay {
  opacity: 1;
}

.pfi-detail-modal.is-open .pfi-detail-content {
  transform: translateY(0);
}

.pfi-detail-content {
  position: relative;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.97),
    rgba(15, 23, 42, 0.92)
  );
  border-radius: 24px 24px 0 0;
  width: min(720px, 100vw);
  max-height: min(88vh, 720px);
  overflow-y: auto;
  box-shadow: 0 -12px 36px rgba(2, 6, 23, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-bottom: none;
  z-index: 1001;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.33, 1, 0.68, 1);
  pointer-events: auto;
}

.pfi-sheet-handle {
  width: 48px;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.38);
  margin: 12px auto 4px;
}

.pfi-detail-header {
  padding: 14px 24px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.pfi-detail-header h2 {
  font-size: 21px;
  font-weight: 700;
  color: rgba(244, 247, 254, 0.95);
  margin: 0 0 6px;
}
.pfi-detail-heading p {
  color: rgba(148, 163, 184, 0.9);
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.pfi-detail-submeta {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(148, 163, 184, 0.75);
}

.pfi-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.pfi-copy-btn {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: transparent;
  color: rgba(244, 247, 254, 0.9);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border 0.2s ease;
}

.pfi-copy-btn:hover,
.pfi-copy-btn.copied {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.5);
}

.pfi-detail-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.pfi-detail-body {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.pfi-detail-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pfi-detail-section h3 {
  font-size: 15px;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.9);
  margin: 0;
}

.pfi-detail-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pfi-detail-chip-row,
.pfi-detail-chip-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pfi-detail-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.15);
  color: rgba(226, 232, 240, 0.9);
}

.pfi-detail-chip-row .pfi-chip.received {
  background: rgba(34, 197, 94, 0.2);
  color: rgba(34, 197, 94, 0.95);
}

.pfi-detail-chip-row .pfi-chip.transit {
  background: rgba(148, 163, 184, 0.18);
  color: rgba(226, 232, 240, 0.9);
}

.pfi-detail-chip-row .pfi-chip.pending {
  background: rgba(148, 163, 184, 0.18);
  color: rgba(226, 232, 240, 0.9);
}

/* Segmented stepper (details modal) */
.pfi-stepper {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: start;
  gap: 0;
  /* Top padding equals top breathing spacing before circles */
  --pfi-step-size: 28px;      /* circle diameter */
  --pfi-track-h: 6px;         /* bar thickness */
  --pfi-gutter: 10px;         /* inner left/right padding */
  --pfi-pad-top: 14px;        /* padding before the circles */
  padding: var(--pfi-pad-top) 6px 18px;
}


.pfi-stepper .pfi-track {
  position: absolute;
  top: 0;
  left: 0;
  height: var(--pfi-track-h);
  width: 0;
  background: transparent;
  border-radius: 999px;
  z-index: 0;
}

.pfi-stepper .pfi-track-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: var(--pfi-track-h);
  width: 0;
  background: var(--success);
  border-radius: 999px;
  z-index: 1;
}

.pfi-step {
  position: relative;
  display: grid;
  grid-template-rows: var(--pfi-step-size) auto;
  align-items: start;
  justify-items: center;
  gap: 8px;
  padding: 0 6px 14px 6px;
  text-align: center;
  background: transparent;
  border: none;
  min-width: 0;
  z-index: 1;
}

.pfi-step.is-first.is-last {
  justify-content: center;
}

/* old connectors hidden for segmented mode */
.pfi-step-connector { display: none !important; }

.pfi-step.is-first .pfi-step-connector {
  left: 50%;
}

.pfi-step.is-last .pfi-step-connector {
  right: 50%;
}

.pfi-step.is-first.is-last .pfi-step-connector {
  display: none;
}

.pfi-step-index {
  width: var(--pfi-step-size);
  height: var(--pfi-step-size);
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.2);
  color: rgba(226, 232, 240, 0.85);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2; /* ensure circles overlay the bar */
}

.pfi-step[data-step-state='current'] .pfi-step-index {
  background: rgba(34, 197, 94, 0.9);
  color: rgba(15, 23, 42, 0.95);
  border-color: rgba(34, 197, 94, 0.9);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.22);
}

.pfi-step[data-step-state='complete'] .pfi-step-index {
  background: rgba(34, 197, 94, 0.7);
  color: rgba(15, 23, 42, 0.92);
  border-color: rgba(34, 197, 94, 0.7);
}

.pfi-step-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 120px;
  margin-top: 12px;  /* Increased margin to accommodate track bar */
}

.pfi-step-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.9);
}

.pfi-step-meta {
  font-size: 10px;
  color: rgba(148, 163, 184, 0.72);
}

.pfi-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.pfi-summary-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pfi-summary-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(148, 163, 184, 0.78);
}
.pfi-summary-value {
  font-size: 20px;
  font-weight: 700;
  color: rgba(244, 247, 254, 0.95);
}
.pfi-summary-meta {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.75);
}

.pfi-table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.pfi-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: rgba(226, 232, 240, 0.92);
}

.pfi-items-table thead {
  background: rgba(30, 41, 59, 0.55);
}

.pfi-items-table th,
.pfi-items-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.pfi-items-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(148, 163, 184, 0.78);
}

.pfi-items-table td:not(:first-child) {
  white-space: nowrap;
}

.pfi-items-table td:first-child {
  min-width: 190px;
}

.pfi-item-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-weight: 600;
}

.pfi-item-cell span {
  font-size: 11px;
  font-weight: 500;
  color: rgba(148, 163, 184, 0.7);
}

.pfi-item-cell span:empty {
  display: none;
}

.pfi-empty {
  text-align: center;
  padding: 16px;
  color: rgba(148, 163, 184, 0.75);
  font-size: 13px;
}

.pfi-essentials-columns {
  display: flex;
  gap: 20px;
}
.pfi-essentials-column {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pfi-essentials-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
.pfi-essentials-label {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.72);
}
.pfi-essentials-value {
  font-size: 15px;
  font-weight: 600;
  color: rgba(244, 247, 254, 0.94);
}

.pfi-detail-subgrid {
  display: grid;
  gap: 16px;
}

@media (min-width: 640px) {
  .pfi-detail-subgrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Shipment schedule rows */
.pfi-schedule-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pfi-schedule-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.pfi-schedule-row:last-child {
  border-bottom: 0;
}
.pfi-schedule-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.4);
  flex-shrink: 0;
}
.pfi-schedule-dot[data-stage='livraison'],
.pfi-schedule-dot[data-stage='delivered'] {
  background: rgba(34, 197, 94, 0.85);
}
.pfi-schedule-dot[data-stage='validation'] {
  background: rgba(234, 179, 8, 0.9);
}
.pfi-schedule-dot[data-stage='shipped'],
.pfi-schedule-dot[data-stage='in-transit'] {
  background: rgba(59, 130, 246, 0.7);
}
.pfi-schedule-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 98px;
}
.pfi-schedule-label {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.65);
}
.pfi-schedule-value {
  font-size: 14px;
  font-weight: 600;
  color: rgba(244, 247, 254, 0.95);
}
.pfi-schedule-sub {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.75);
}
.pfi-schedule-group--eta {
  margin-left: auto;
  min-width: 110px;
}


/* Light theme overrides */
body.theme-light {
  background: #f1f5f9;
  color: #0f172a;
}

body.theme-light .mobile-app,
body.theme-light .page,
body.theme-light .main-content-mobile {
  background: #f8fafc;
  color: #0f172a;
}

body.theme-light .mobile-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

body.theme-light .panel-card,
body.theme-light .snapshot-card,
body.theme-light .overview-card,
body.theme-light .pfi-card,
body.theme-light .panel-stat,
body.theme-light .pfi-card-dashboard,
body.theme-light .order-card {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

body.theme-light .ordered-summary-metric {
  background: rgba(241, 245, 249, 0.9);
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

body.theme-light .pfi-overview-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.12);
}

body.theme-light .panel-card h3,
body.theme-light .overview-title,
body.theme-light .snapshot-card span,
body.theme-light .panel-stat-text,
body.theme-light .panel-stat-count,
body.theme-light .pfi-card-item-name {
  color: #0f172a;
}

body.theme-light .panel-stat-meta,
body.theme-light .pfi-card-item-meta,
body.theme-light .panel-chip,
body.theme-light .panel-chip-button,
body.theme-light .panel-chip span {
  color: #475569;
}

body.theme-light .pfi-card-supplier-line {
  color: #1f2937;
}

body.theme-light .pfi-card-brand-line,
body.theme-light .pfi-card-meta.detail {
  color: #64748b;
}

body.theme-light .pfi-card-meta.detail {
  border-top-color: #e2e8f0;
}

body.theme-light .pfi-card-attributes {
  border-top-color: #e2e8f0;
}

body.theme-light .pfi-card-item-line {
  color: #475569;
}

body.theme-light .pfi-card-item-more {
  color: #94a3b8;
}

body.theme-light .pfi-card-attribute-label {
  color: #94a3b8;
}

body.theme-light .pfi-card-attribute-value {
  color: #0f172a;
}

body.theme-light .pfi-card-status-label {
  background: rgba(148, 163, 184, 0.22);
  color: #475569;
}

body.theme-light .pfi-card-status-label.awaiting-shipment,
body.theme-light .pfi-card-status-label.pending {
  background: rgba(59, 130, 246, 0.18);
  color: #1d4ed8;
}

body.theme-light .pfi-card-status-label.delivered {
  background: rgba(34, 197, 94, 0.18);
  color: #047857;
}

body.theme-light .pfi-card-status-label.in-transit,
body.theme-light .pfi-card-status-label.transit {
  background: rgba(59, 130, 246, 0.18);
  color: #1d4ed8;
}

body.theme-light .pfi-card-status-label.ordered {
  background: rgba(245, 158, 11, 0.2);
  color: #b45309;
}

body.theme-light .pfi-card-status-label.validation,
body.theme-light .pfi-card-status-label.validate {
  background: rgba(245, 158, 11, 0.2);
  color: #b45309;
}

body.theme-light .pfi-card-attribute-value {
  color: #0f172a;
}

body.theme-light .pfi-card-attribute-label {
  color: #94a3b8;
}

body.theme-light .pfi-card-attribute-value {
  color: #0f172a;
}

body.theme-light .pfi-card-ref {
  color: #0f172a;
}

body.theme-light .pfi-card-supplier {
  color: #0f172a;
  font-weight: 600;
}

body.theme-light .pfi-card-meta {
  color: #1f2937;
  font-weight: 600;
}

body.theme-light .pfi-card-meta span {
  color: #1f2937;
  font-size: 11px;
}

body.theme-light .pfi-card-meta span::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.65;
}

body.theme-light .pfi-card-meta span::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.6;
}

body.theme-light .pfi-card-item-meta span::before,
body.theme-light .pfi-card-meta.detail span::before {
  background: rgba(148, 163, 184, 0.45);
}

body.theme-light .pfi-card-item-meta {
  color: #475569;
  font-weight: 500;
}

body.theme-light .pfi-detail-content {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom: none;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}

body.theme-light .pfi-detail-header h2,
body.theme-light .pfi-detail-header p {
  color: #0f172a;
}

body.theme-light .pfi-detail-submeta {
  color: #475569;
}

body.theme-light .pfi-detail-chip {
  background: rgba(59, 130, 246, 0.08);
  color: #1e40af;
}

body.theme-light .pfi-detail-chip-row .pfi-chip.received {
  background: rgba(34, 197, 94, 0.15);
  color: #047857;
}

body.theme-light .pfi-detail-chip-row .pfi-chip.transit {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

body.theme-light .pfi-detail-chip-row .pfi-chip.pending {
  background: rgba(234, 179, 8, 0.18);
  color: #b45309;
}

body.theme-light .pfi-step-index {
  background: rgba(226, 232, 240, 0.9);
  color: #0f172a;
  box-shadow: none;
}

body.theme-light .pfi-step[data-step-state='complete'] .pfi-step-index {
  background: rgba(34, 197, 94, 0.9);
  color: #0f172a;
}

body.theme-light .pfi-step[data-step-state='current'] .pfi-step-index {
  background: rgba(34, 197, 94, 0.95);
  color: #0f172a;
  box-shadow: 0 8px 18px rgba(34, 197, 94, 0.25);
}

body.theme-light .pfi-step-label {
  color: #0f172a;
}

body.theme-light .pfi-step-meta {
  color: #475569;
}

body.theme-light .pfi-summary-label {
  color: #64748b;
}

body.theme-light .pfi-summary-value {
  color: #0f172a;
}

body.theme-light .pfi-summary-meta {
  color: #475569;
}

body.theme-light .pfi-essentials-label {
  color: #64748b;
}

body.theme-light .pfi-essentials-value {
  color: #0f172a;
}

body.theme-light .pfi-overview-bar {
  background: rgba(226, 232, 240, 0.85);
  border-color: rgba(203, 213, 225, 0.9);
}

body.theme-light .pfi-overview-legend-item {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
  color: #475569;
}

body.theme-light .pfi-overview-legend-item em {
  color: #64748b;
}

body.theme-light .pfi-overview-legend-item.total strong {
  color: #0f172a;
}

body.theme-light .pfi-detail-body,
body.theme-light .pfi-section h3,
body.theme-light .pfi-section,
body.theme-light .pfi-detail-submeta,
body.theme-light .pfi-metric-label {
  color: inherit;
}

.theme-light .mobile-header,
.theme-light .mobile-app,
.theme-light .page,
.theme-light .main-content-mobile,
.theme-light .dashboard-panel-wrapper,
.theme-light .dashboard-carousel,
.theme-light .dashboard-slide-inner,
.theme-light .page#ordersPage,
.theme-light .page#dashboardPage {
  background: #f8fafc;
  color: #0f172a;
}

.theme-light .dashboard-tab,
.theme-light .dashboard-tab[aria-selected='true'] {
  color: #0f172a;
}

.theme-light .dashboard-tab[aria-selected='true'] {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.4);
}

.theme-light .dashboard-tab[aria-selected='false'] {
  background: rgba(226, 232, 240, 0.6);
  border-color: rgba(203, 213, 225, 0.7);
}

.theme-light .overview-bar,
.theme-light .snapshot-range-btn,
.theme-light .overview-range-btn {
  background: rgba(203, 213, 225, 0.35);
}

.theme-light .snapshot-range-btn[aria-pressed='true'],
.theme-light .overview-range-btn[aria-pressed='true'] {
  background: rgba(59, 130, 246, 0.16);
  color: #1d4ed8;
}

.theme-light .order-card,
.theme-light .panel-stat,
.theme-light .panel-card {
  border-color: rgba(226, 232, 240, 0.9);
}

.theme-light .order-card .order-number,
.theme-light .order-card .order-title,
.theme-light .order-card .order-quick-info {
  color: #0f172a;
}

.theme-light .order-card .order-metric .metric-label,
.theme-light .order-card .order-supplier,
.theme-light .order-card .order-reference,
.theme-light .order-card .order-date,
.theme-light .order-details .detail-label,
.theme-light .order-details .detail-value {
  color: #475569;
}

.theme-light .orders-summary,
.theme-light .orders-filters,
.theme-light .orders-filters .filter-chip {
  background: #ffffff;
  color: #0f172a;
}

.theme-light .filter-chip.active {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
}

.theme-light .search-modal,
.theme-light .search-header,
.theme-light .search-results,
.theme-light .suggestion-item,
.theme-light .recent-searches,
.theme-light .recent-item,
.theme-light .search-input {
  background: #ffffff;
  color: #0f172a;
  border-color: #e2e8f0;
}

.theme-light .search-input:focus {
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.theme-light .suggestion-category {
  background: rgba(226, 232, 240, 0.6);
  color: #475569;
}

.theme-light .recent-title,
.theme-light .suggestion-content .suggestion-title {
  color: #0f172a;
}

.theme-light .suggestion-subtitle {
  color: #64748b;
}

.theme-light .search-modal.active {
  background: rgba(241, 245, 249, 0.96);
}

.theme-light .sort-modal {
  background: rgba(15, 23, 42, 0.18);
}

.theme-light .sort-sheet {
  background: #ffffff;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -12px 24px rgba(15, 23, 42, 0.12);
}

.theme-light .search-results .empty-state,
.theme-light .search-results .loading-state {
  color: #475569;
}

.theme-light .filter-chip,
.theme-light .recent-item,
.theme-light .suggestion-item {
  color: #0f172a;
}

.theme-light .snapshot-card .overview-title,
.theme-light .snapshot-card .overview-meta {
  color: #0f172a;
}

.theme-light .overview-meta,
.theme-light .panel-chip {
  color: #64748b;
}

.theme-light .panel-stat {
  background: #ffffff;
  border: 1px solid #dde4f1;
  color: #0f172a;
}

.theme-light .panel-stat-count {
  background: rgba(59, 130, 246, 0.16);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.24);
}

.theme-light .panel-trade-row,
.theme-light .panel-container-card {
  background: #ffffff;
  border: 1px solid #dde4f1;
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.08);
}

.theme-light .panel-trade-count {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.theme-light .panel-container-pill {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.22);
}

.theme-light .panel-container-meta span {
  color: #475569;
}

.theme-light .panel-container-meta strong {
  color: #0f172a;
}

.theme-light .pfi-date-pill {
  background: rgba(148, 163, 184, 0.22);
  color: #1f2937;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.28);
}

.theme-light .pfi-quick-item {
  color: #1e293b;
}

.theme-light .pfi-quick-more {
  color: #475569;
}

body.theme-light .pfi-detail-chip-stack .pfi-detail-chip {
  background: rgba(148, 163, 184, 0.16);
  color: #475569;
}

body.theme-light .pfi-table-wrapper {
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

body.theme-light .pfi-items-table {
  color: #0f172a;
}

body.theme-light .pfi-items-table thead {
  background: #f1f5f9;
  color: #475569;
}

body.theme-light .pfi-items-table td,
body.theme-light .pfi-items-table th {
  border-color: #e2e8f0;
}

body.theme-light .pfi-item-cell span {
  color: #64748b;
}

body.theme-light .pfi-schedule-label {
  color: #64748b;
}

body.theme-light .pfi-schedule-value {
  color: #0f172a;
}

body.theme-light .pfi-schedule-sub {
  color: #475569;
}

body.theme-light .pfi-schedule-dot {
  background: rgba(148, 163, 184, 0.6);
}

body.theme-light .pfi-schedule-dot[data-stage='livraison'],
body.theme-light .pfi-schedule-dot[data-stage='delivered'] {
  background: #16a34a;
}

body.theme-light .pfi-schedule-dot[data-stage='validation'] {
  background: #f59e0b;
}

body.theme-light .pfi-schedule-dot[data-stage='shipped'],
body.theme-light .pfi-schedule-dot[data-stage='in-transit'] {
  background: #2563eb;
}

body.theme-light .panel-chip,
body.theme-light .panel-chip-button,
body.theme-light .panel-chip span,
body.theme-light .panel-chip-button span {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

body.theme-light .panel-chip-button {
  border-color: rgba(59, 130, 246, 0.25);
  box-shadow: none;
}

body.theme-light .panel-chip-button:hover {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.16);
}

body.theme-light .panel-chip-button svg {
  color: #1d4ed8;
}

body.theme-light .pfi-detail-overlay {
  background: rgba(15, 23, 42, 0.35);
}

body.theme-light .panel-stat-count,
body.theme-light .order-supplier,
body.theme-light .order-title,
body.theme-light .order-number {
  color: #0f172a;
}

body.theme-light .order-card {
  border: 1px solid #e2e8f0;
}

body.theme-light #dashboardPage {
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-elevated: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --border: #e2e8f0;
  --border-light: #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  color-scheme: light;
}

body.theme-light #dashboardPage .mobile-header {
  background: rgba(248, 250, 252, 0.94);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
}

body.theme-light #dashboardPage .dashboard-tabs {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

body.theme-light #dashboardPage .dashboard-tab {
  color: #475569;
}

body.theme-light #dashboardPage .dashboard-tab[aria-selected='true'] {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

body.theme-light #dashboardPage .dashboard-tab[aria-selected='false'] {
  background: rgba(226, 232, 240, 0.65);
  color: #1e293b;
}

body.theme-light #dashboardPage .dashboard-tab-subtitle {
  color: #64748b;
}

body.theme-light #dashboardPage .overview-card,
body.theme-light #dashboardPage .snapshot-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 22px 36px rgba(15, 23, 42, 0.12);
  color: #0f172a;
}

body.theme-light #dashboardPage .overview-rate {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

body.theme-light #dashboardPage .snapshot-chip {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.22);
}

body.theme-light #shippedDashboardPage,
body.theme-light #pfiDashboardPage {
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-elevated: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --border: #e2e8f0;
  --border-light: #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  color-scheme: light;
}

body.theme-light #shippedDashboardPage .mobile-header,
body.theme-light #pfiDashboardPage .mobile-header {
  background: rgba(248, 250, 252, 0.94);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
}

body.theme-light #shippedDashboardPage .page-title-mobile,
body.theme-light #pfiDashboardPage .page-title-mobile {
  color: #0f172a;
}

body.theme-light #shippedDashboardPage .dashboard-tabs,
body.theme-light #pfiDashboardPage .dashboard-tabs {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

body.theme-light #shippedDashboardPage .dashboard-tab,
body.theme-light #pfiDashboardPage .dashboard-tab {
  color: #475569;
}

body.theme-light #shippedDashboardPage .dashboard-tab[aria-selected='true'],
body.theme-light #pfiDashboardPage .dashboard-tab[aria-selected='true'] {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

body.theme-light #shippedDashboardPage .dashboard-tab[aria-selected='false'],
body.theme-light #pfiDashboardPage .dashboard-tab[aria-selected='false'] {
  background: rgba(226, 232, 240, 0.65);
  color: #1e293b;
}

body.theme-light #shippedDashboardPage .dashboard-tab-subtitle,
body.theme-light #pfiDashboardPage .dashboard-tab-subtitle {
  color: #64748b;
}

body.theme-light #shippedDashboardPage .snapshot-chip,
body.theme-light #pfiDashboardPage .snapshot-chip {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.22);
}

body.theme-light .snapshot-metric {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

body.theme-light #dashboardPage .header-right .search-btn-mobile,
body.theme-light #dashboardPage .header-right .prototype-demo-btn-mobile {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}

body.theme-light .prototype-demo-btn-mobile:hover,
body.theme-light .prototype-demo-btn-mobile:focus {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.25);
}

body.theme-light #dashboardPage .logo-mobile {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(148, 163, 184, 0.3);
}

body.theme-light #dashboardPage .main-content-mobile {
  background: transparent;
}

body.theme-light .snapshot-range-btn,
body.theme-light .overview-range-btn {
  background: rgba(226, 232, 240, 0.65);
  color: #475569;
}

body.theme-light .snapshot-range-btn[aria-pressed='true'],
body.theme-light .overview-range-btn[aria-pressed='true'] {
  background: rgba(59, 130, 246, 0.16);
  color: #1d4ed8;
}

body.theme-light .snapshot-metric,
body.theme-light .pfi-card {
  background: #ffffff;
  border: 1px solid #dce3f0;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
}

body.theme-light .pfi-card-meta {
  color: #1f2937;
}

body.theme-light .pfi-card-chips {
  background: rgba(226, 232, 240, 0.9);
  border-color: #d7e0ea;
}

body.theme-light .pfi-chip,
body.theme-light .pfi-chip-muted {
  color: #475569;
}

body.theme-light .pfi-chip.received {
  color: #047857;
}

body.theme-light .pfi-chip.transit {
  color: #1d4ed8;
}

body.theme-light .pfi-chip.pending {
  color: #b45309;
}

body.theme-light .pfi-chip.neutral {
  color: #475569;
}

body.theme-light .pfi-card-stats {
  border-top: 1px solid #e2e8f0;
}

body.theme-light .pfi-card-stat-label {
  color: #64748b;
}

body.theme-light .pfi-card-item-meta {
  color: #475569;
}

body.theme-light .pfi-card-body .pfi-card-meta.detail {
  border-top-color: #e2e8f0;
  color: #64748b;
}

body.theme-light .pfi-quick-header span,
body.theme-light .pfi-quick-values span {
  color: #0f172a;
}

body.theme-light .pfi-quick-progress-track {
  background: rgba(226, 232, 240, 0.85);
}

body.theme-light .pfi-quick-progress-fill {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.9), rgba(59, 130, 246, 0.65));
}

body.theme-light .pfi-card-item-meta-lite {
  opacity: 1;
}

body.theme-light .pfi-card-progress-bar {
  background: rgba(226, 232, 240, 0.85);
}

body.theme-light .pfi-card-progress-text {
  color: #1f2937;
}

body.theme-light .pfi-card-progress.is-idle .pfi-card-progress-text {
  color: #0f172a;
  font-weight: 600;
}

body.theme-light .pfi-card-meta span {
  color: #1f2937;
  font-size: 11px;
}

body.theme-light .pfi-card-meta span::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.65;
}

.pfi-detail-closebtn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.16);
  color: rgba(226, 232, 240, 0.9);
  font-size: 18px;
  cursor: pointer;
}

.pfi-detail-closebtn:hover {
  background: rgba(59, 130, 246, 0.35);
}

body.theme-light .pfi-detail-closebtn {
  background: rgba(226, 232, 240, 0.85);
  color: #475569;
  border: 1px solid rgba(203, 213, 225, 0.9);
}

body.theme-light .pfi-detail-closebtn:hover {
  background: rgba(148, 163, 184, 0.45);
}

.pfi-detail-empty {
  font-size: 12px;
  color: var(--text-tertiary);
}

.pfi-detail-subgrid {
  display: grid;
  gap: 16px;
}

@media (min-width: 640px) {
  .pfi-detail-subgrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.pfi-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.pfi-detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pfi-detail-label {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.7);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pfi-detail-value {
  font-size: 13px;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.9);
}

.pfi-detail-items {
  display: grid;
  gap: 12px;
}

.pfi-detail-item-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--background);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pfi-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.pfi-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.pfi-item-brand {
  font-size: 12px;
  color: var(--text-secondary);
}

.pfi-item-status {
  display: flex;
}

.pfi-item-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--border-light);
  color: var(--text-secondary);
}

.pfi-item-chip.received {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.pfi-item-chip.partial {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
}

.pfi-item-chip.pending {
  background: rgba(234, 179, 8, 0.18);
  color: var(--warning);
}

.pfi-item-qty-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.pfi-item-qty {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 80px;
}

.pfi-qty-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.pfi-qty-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 16px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.empty-subtitle {
  font-size: 14px;
  line-height: 1.5;
}

/* Loading and Error States */
.loading-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 16px;
  text-align: center;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-light);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

.loading-text {
  font-size: 16px;
  font-weight: 500;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.error-message {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 16px;
}

.retry-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.retry-btn:hover {
  background: var(--primary-dark);
}

.retry-btn:active {
  transform: scale(0.95);
}

.data-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.data-card h3 {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.data-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-direction: column;
  width: 100%;
}

@media (min-width: 480px) {
  .data-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.fetch-btn,
.download-btn {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 480px) {
  .fetch-btn,
  .download-btn {
    flex: 1;
    min-width: 140px;
    width: auto;
  }
}

.fetch-btn {
  background: var(--primary);
  color: white;
}

.fetch-btn:hover {
  background: var(--primary-dark);
}

.fetch-btn:active {
  transform: scale(0.95);
  opacity: 0.9;
}

.download-btn {
  background: var(--success);
  color: white;
}

.download-btn:hover {
  background: #059669;
}

.download-btn:active {
  transform: scale(0.95);
  opacity: 0.9;
}

/* Hide download button on mobile */
@media (max-width: 768px) {
  .nav-item-mobile[onclick="showPage('download-data')"] {
    display: none !important;
  }
}

.status-display {
  padding: 10px 12px;
  background: var(--background);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-family: monospace;
  word-wrap: break-word;
  line-height: 1.4;
}

/* Bottom Navigation */
.bottom-nav {
  display: none !important; /* Hidden per request */
}

.nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

.nav-item-mobile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 12px;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: all 0.2s ease;
  min-width: 60px;
  min-height: 48px;
  justify-content: center;
  cursor: pointer;
}

.nav-item-mobile.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-item-mobile:active {
  transform: scale(0.95);
}

.nav-item-mobile:focus-visible,
.filter-chip:focus-visible,
.status-item-mobile:focus-visible,
.order-card:focus-visible,
.search-back-btn:focus-visible,
.back-btn-mobile:focus-visible,
.search-btn-mobile:focus-visible,
.refresh-btn-mobile:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

.nav-icon {
  width: 24px;
  height: 24px;
}

.nav-label {
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

/* Loading States */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Skeleton loading for orders */
.skeleton-list {
  padding: 12px;
}
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin: 12px;
  box-shadow: var(--shadow-sm);
}
.skeleton-line {
  height: 12px;
  background: linear-gradient(
    90deg,
    var(--border-light),
    #f5f7fb,
    var(--border-light)
  );
  background-size: 200% 100%;
  border-radius: 6px;
  margin: 8px 0;
  animation: shimmer 1.2s infinite;
}
.skeleton-line.short {
  width: 40%;
}
.skeleton-line.medium {
  width: 70%;
}
.skeleton-line.long {
  width: 90%;
}
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card-mobile,
.status-list-mobile {
  animation: fadeInUp 0.4s ease-out;
}

/* Responsive Adjustments */
@media (min-width: 390px) {
  .stat-card-mobile {
    padding: 24px;
  }

  .stat-value-mobile {
    font-size: 36px;
  }
}

@media (min-width: 768px) {
  .mobile-app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .main-content-mobile {
    padding: 24px;
    padding-bottom: 100px;
  }
}

/* Dark mode support */
/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --text-secondary: #000000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .stat-card-mobile,
  .status-list-mobile,
  .status-item-mobile,
  .search-btn-mobile,
  .refresh-btn-mobile,
  .nav-item-mobile {
    animation: none;
    transition: none;
  }
}

/* Safe area insets for newer phones */
@supports (padding: max(0px)) {
  .mobile-header {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .bottom-nav {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    /* Ensure it covers the entire bottom area including safe zone */
    margin-bottom: calc(-1 * env(safe-area-inset-bottom));
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  /* Ensure body extends to cover safe areas */
  body {
    padding-bottom: 0;
    margin-bottom: 0;
  }
}

/* Additional iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .mobile-app {
    height: -webkit-fill-available;
    min-height: -webkit-fill-available;
  }

  .bottom-nav {
    bottom: 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
  }
}

/* --- Improved PFI Filters --- */
.pfi-filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 12px;
}
.pfi-filters-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.pfi-filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pfi-filter-field label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pfi-select {
  -webkit-appearance: none;
  appearance: none;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 10px;
  font-size: 13px;
}
.pfi-search-field {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 10px;
  position: relative;
}
.pfi-search-field input {
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  width: 100%;
  font-size: 13px;
}
.pfi-search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  flex: 0 0 18px;
}
/* Clear button for PFI search */
.pfi-search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--text-tertiary);
  color: white;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.pfi-search-clear-btn.visible { display: flex; }
@media (max-width: 420px) {
  .pfi-filters-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* --- Card visual tweaks --- */
.pfi-card {
  border-radius: 12px;
}
.pfi-header {
  align-items: flex-start;
}
.pfi-supplier {
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 2px;
}
.pfi-tc-overview .pfi-chip {
  font-size: 12px;
}
.pfi-items-overview {
  line-height: 1.2;
}

.price-details {
  margin-top: 12px;
  border-top: 1px solid var(--border-light);
}

.order-details .price-details {
  grid-column: 1 / -1;
}

.order-card:not(.expanded) .price-details {
  display: none;
}

.price-details-header,
.price-details-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.price-details-header {
  padding: 12px 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.price-details-body {
  display: flex;
  flex-direction: column;
}

.price-details-row {
  padding: 10px 0;
  border-top: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-primary);
}

.price-details-row:first-child {
  border-top: none;
}

.price-col {
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
  white-space: nowrap;
}

.price-col.price-item {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  white-space: normal;
  font-size: 13px;
  line-height: 1.3;
}

.price-col.price-qty,
.price-col.price-act,
.price-col.price-dec {
  flex: 0 0 72px;
  text-align: right;
  color: var(--text-secondary);
}

@media (max-width: 480px) {
  .price-col.price-qty,
  .price-col.price-act,
  .price-col.price-dec {
    flex-basis: 64px;
  }
}
.pfi-card-meta span::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.6);
}
.pfi-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: rgba(226, 232, 240, 0.92);
}
.pfi-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  color: rgba(15, 23, 42, 0.95);
  font-weight: 700;
  font-size: 12px;
}
.pfi-step-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
