/* ── Layout ───────────────────────────────────────────────────────────────── */

.ps-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.ps-header-inner {
  max-width: 1200px;
}

/* ── Loading ──────────────────────────────────────────────────────────────── */

.ps-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: rgba(255,255,255,0.85);
  font-size: 0.95rem;
}

.ps-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ps-spin 0.8s linear infinite;
  margin-right: 0.75rem;
}

@keyframes ps-spin { to { transform: rotate(360deg); } }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */

.ps-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.ps-tab {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.9);
  transition: all 0.15s;
  font-family: inherit;
  font-size: 0.875rem;
}

.ps-tab:hover { background: rgba(255,255,255,0.28); }

.ps-tab.active {
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.2);
}

.ps-count {
  margin-left: 0.5rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  background: rgba(255,255,255,0.25);
}

.ps-tab:not(.active) .ps-count {
  background: rgba(255,255,255,0.2);
}

/* ── Controls ─────────────────────────────────────────────────────────────── */

.ps-controls {
  background: white;
  border-radius: 0.5rem;
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.ps-control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ps-control-group label {
  font-size: 0.875rem;
  color: #6b7280;
  white-space: nowrap;
}

.ps-control-group select {
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: white;
  color: #1f2937;
}

.ps-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #6b7280;
  cursor: pointer;
}

.ps-rush-label { color: #dc2626; font-weight: 500; }

/* ── Actions Bar ──────────────────────────────────────────────────────────── */

.ps-actions {
  background: white;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.ps-selection-info { font-size: 0.875rem; color: #6b7280; }

.ps-text-btn {
  font-size: 0.875rem;
  color: #3b82f6;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.ps-text-btn:hover { text-decoration: underline; }

.ps-spacer { flex: 1; }

.ps-btn {
  padding: 0.45rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-size: 0.875rem;
  transition: background 0.15s;
  white-space: nowrap;
}

.ps-btn:disabled { background: #e5e7eb; color: #9ca3af; cursor: not-allowed; }

.ps-btn-blue      { background: #3b82f6; color: white; }
.ps-btn-blue:not(:disabled):hover { background: #2563eb; }

.ps-btn-green     { background: #22c55e; color: white; }
.ps-btn-green:not(:disabled):hover { background: #16a34a; }

.ps-btn-gray      { background: #6b7280; color: white; }
.ps-btn-gray:not(:disabled):hover { background: #4b5563; }

.ps-btn-gray-light { background: #d1d5db; color: #374151; }
.ps-btn-gray-light:not(:disabled):hover { background: #9ca3af; }

/* Order filter input (inside controls bar) */
.ps-order-input {
  width: 120px;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: white;
  color: #1f2937;
}
.ps-order-input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }

/* Order filter indicator bar */
.ps-order-filter-bar {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ps-clear-filter-btn {
  margin-left: auto;
  font-size: 0.8rem;
  color: #1d4ed8;
  background: rgba(59,130,246,0.1);
  border: 1px solid #bfdbfe;
  border-radius: 0.375rem;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.ps-clear-filter-btn:hover { background: rgba(59,130,246,0.2); }

.ps-reassign-group { display: flex; align-items: center; gap: 0.5rem; }
.ps-reassign-group select {
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  background: white;
}

/* ── Queue Header ─────────────────────────────────────────────────────────── */

.ps-queue-header {
  color: white;
  border-radius: 0.5rem 0.5rem 0 0;
  padding: 0.75rem 1rem;
}

.ps-queue-header h2 { font-size: 1.125rem; font-weight: 600; }
.ps-queue-header p  { font-size: 0.875rem; opacity: 0.9; }

/* ── Queue List ───────────────────────────────────────────────────────────── */

.ps-queue-list {
  background: white;
  border-radius: 0 0 0.5rem 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  margin-bottom: 1rem;
}

.ps-queue-item {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  transition: background 0.15s;
  position: relative;
}

.ps-queue-item:last-child { border-bottom: none; }
.ps-queue-item:hover { background: #f9fafb; }
.ps-queue-item.completed { opacity: 0.5; background: #f9fafb; }
.ps-queue-item.rush { border-left: 4px solid #ef4444; background: #fef2f2; }
.ps-queue-item.rush:hover { background: #fee2e2; }
.ps-queue-item.drag-over { border-top: 2px solid #3b82f6; }
.ps-queue-item.dragging  { opacity: 0.5; }

/* P1 tooltip */
.ps-p1-tooltip {
  display: none;
  position: absolute;
  left: 4.625rem;
  top: 100%;
  z-index: 10;
  background: #1f2937;
  color: white;
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  line-height: 1.5;
  pointer-events: auto;
}

.ps-queue-item:hover .ps-p1-tooltip { display: block; }

.ps-p1-name {
  font-weight: 600;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #4b5563;
  padding-bottom: 0.375rem;
}

.ps-p1-row { margin-top: 0.25rem; }
.ps-p1-lbl { color: #9ca3af; }

/* Item internals */
.ps-drag-handle { cursor: move; color: #9ca3af; padding: 0.125rem; flex-shrink: 0; }

.ps-item-checkbox { width: 1.25rem; height: 1.25rem; margin-top: 0.2rem; flex-shrink: 0; cursor: pointer; }

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

.ps-item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.ps-order-link {
  font-family: monospace;
  font-weight: 600;
  color: #3b82f6;
  text-decoration: none;
}
.ps-order-link:hover { text-decoration: underline; }

.ps-customer { font-weight: 500; color: #1f2937; }

/* Badges */
.ps-rush-badge      { background: #ef4444;  color: white;   font-size: 0.72rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 0.25rem; text-transform: uppercase; }
.ps-completed-badge { background: #dcfce7;  color: #166534; font-size: 0.72rem; font-weight: 500; padding: 0.1rem 0.45rem; border-radius: 0.25rem; }
.ps-operator-badge  { background: #fef3c7;  color: #92400e; font-size: 0.72rem; font-weight: 500; padding: 0.1rem 0.45rem; border-radius: 0.25rem; }
.ps-reassigned-badge { background: #e0e7ff; color: #3730a3; font-size: 0.72rem; font-weight: 500; padding: 0.1rem 0.45rem; border-radius: 0.25rem; }
.ps-unknown-badge   { background: #fee2e2;  color: #991b1b; font-size: 0.72rem; font-weight: 500; padding: 0.1rem 0.45rem; border-radius: 0.25rem; }

/* Due dates */
.ps-due-dates {
  margin-left: auto;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ps-due-sep   { color: #d1d5db; }
.ps-due-late     { color: #dc2626; font-weight: 600; }
.ps-due-today    { color: #ea580c; font-weight: 600; }
.ps-due-tomorrow { color: #ca8a04; }
.ps-due-normal   { color: #6b7280; }

/* Item details row */
.ps-item-details {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  flex-wrap: wrap;
}

.ps-sku          { font-family: monospace; background: #f3f4f6; padding: 0.1rem 0.45rem; border-radius: 0.25rem; color: #374151; font-size: 0.82rem; }
.ps-material-tag { background: #e0e7ff; color: #3730a3; padding: 0.1rem 0.45rem; border-radius: 0.25rem; font-size: 0.75rem; font-weight: 500; }
.ps-product      { color: #6b7280; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-quantity     { font-weight: 500; }

.ps-restore-btn {
  font-size: 0.75rem;
  color: #3b82f6;
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}
.ps-restore-btn:hover { text-decoration: underline; }

.ps-empty {
  padding: 3rem;
  text-align: center;
  color: #6b7280;
}

/* ── Summary ──────────────────────────────────────────────────────────────── */

.ps-summary {
  background: white;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.ps-summary h3 {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.5rem;
}

.ps-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  font-size: 0.875rem;
}

.ps-summary-item { display: flex; align-items: center; gap: 0.5rem; }

.ps-summary-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

.ps-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: #1f2937;
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.25s;
  font-size: 0.9rem;
  pointer-events: none;
}
.ps-toast.show { opacity: 1; }

/* ── Modals ───────────────────────────────────────────────────────────────── */

.ps-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.ps-modal {
  background: white;
  border-radius: 0.5rem;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}

.ps-modal-header {
  padding: 1rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ps-modal-header h2 { font-size: 1.1rem; font-weight: 600; }
.ps-modal-actions   { display: flex; gap: 0.5rem; }
.ps-modal-body      { padding: 1.25rem; }

/* Sub-task completion modal */
.ps-subtask-modal { max-width: 480px; }
.ps-subtask-modal .ps-modal-body p {
  margin-bottom: 1.25rem;
  font-size: 0.975rem;
  line-height: 1.5;
  color: #1f2937;
}
.ps-subtask-modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* Warning box */
.ps-warning-box {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}
.ps-warning-box h4 { color: #92400e; font-weight: 600; margin-bottom: 0.25rem; }
.ps-warning-box p  { color: #a16207; font-size: 0.875rem; margin-bottom: 0.5rem; }

/* ── Print styles ─────────────────────────────────────────────────────────── */

.print-header         { border-bottom: 2px solid black; padding-bottom: 1rem; margin-bottom: 1rem; }
.print-header-row     { display: flex; justify-content: space-between; align-items: flex-start; }
.print-title          { font-size: 1.5rem; font-weight: 700; }
.print-tech           { color: #6b7280; }
.print-meta           { text-align: right; }
.print-materials      { margin-top: 0.5rem; }
.print-warning        { color: #ca8a04; font-size: 0.875rem; font-weight: 500; margin-top: 0.25rem; }

.print-item           { border: 1px solid #e5e7eb; border-radius: 0.375rem; padding: 0.75rem; margin-bottom: 0.5rem; }
.print-item-row       { display: flex; gap: 0.5rem; align-items: flex-start; }
.print-item-num       { color: #9ca3af; font-family: monospace; font-size: 0.875rem; width: 1.5rem; flex-shrink: 0; }
.print-item-content   { flex: 1; }
.print-item-grid      { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; font-size: 0.875rem; }
.print-item-field label  { color: #6b7280; font-size: 0.75rem; display: block; }
.print-item-field span   { display: block; }
.print-item-field.span-2 { grid-column: span 2; }

.notes-section { border-top: 2px solid black; padding-top: 1rem; margin-top: 1rem; }
.notes-section h3 { font-weight: 600; margin-bottom: 0.5rem; }
.notes-box { border: 1px solid #d1d5db; border-radius: 0.375rem; min-height: 6rem; padding: 0.5rem; }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area  { position: absolute; left: 0; top: 0; width: 100%; padding: 1rem; }
  .no-print    { display: none !important; }
  .print-item  { break-inside: avoid; }
}
