


#order-flow-monitor.screen,
#order-flow-detail.screen {
  width: min(100%, 1320px);
  box-sizing: border-box;
  padding: 0 16px;
}

.order-flow-header {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.order-flow-table {
  width: 100%;
}

#order-flow-monitor .grid-wrap {
  padding-right: 4px;
}

.order-flow-table th:last-child,
.order-flow-table td:last-child {
  width: 56px;
  padding-right: 12px;
  text-align: center;
}

.flow-po {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.flow-po-yes { background: #e3f4e4; color: #2e7d32; }
.flow-po-no { background: #f1f3f7; color: #94a0b6; }
.flow-po-part { background: #fff3e0; color: #b9690e; }
.flow-po-complete { background: #e4eefc; color: #1c4fa0; }


.flow-na-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #f1f3f7;
  color: #94a0b6;
}

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}

.kpi-card {
  background: #fff;
  border: 1px solid #d6deea;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(15, 31, 60, 0.06);
}

.kpi-card .kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #061f9e;
  line-height: 1.1;
}

.kpi-card .kpi-label {
  margin-top: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5b6b85;
}

.order-flow-table td,
.order-flow-table th {
  vertical-align: middle;
}


/* Compact progress columns so the >> action stays inside the panel on desktop. */
.order-flow-table th:nth-child(5),
.order-flow-table th:nth-child(6),
.order-flow-table th:nth-child(7),
.order-flow-table td:nth-child(5),
.order-flow-table td:nth-child(6),
.order-flow-table td:nth-child(7) {
  width: 1%;
}

/* Supplier PO and Delivered: center header and values. */
.order-flow-table th:nth-child(3),
.order-flow-table th:nth-child(4),
.order-flow-table td:nth-child(3),
.order-flow-table td:nth-child(4) {
  text-align: center;
}

/* Long customer names wrap only when the panel runs out of room. */
.order-flow-table td:nth-child(2) {
  min-width: 200px;
  white-space: normal;
}

.flow-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 84px;
}

.flow-progress .flow-bar {
  flex: 1;
  min-width: 40px;
  height: 8px;
  border-radius: 6px;
  background: #e6ebf3;
  overflow: hidden;
}

.flow-progress .flow-bar > span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: #2e7d32;
}

.flow-progress.flow-red .flow-bar > span { background: #d32f2f; }
.flow-progress.flow-orange .flow-bar > span { background: #ef8c00; }
.flow-progress.flow-green .flow-bar > span { background: #2e7d32; }

.flow-progress .flow-pct {
  font-size: 12px;
  font-weight: 600;
  color: #34425c;
  min-width: 32px;
  text-align: right;
}

.flow-progress.flow-na .flow-pct { color: #9aa6bb; }


.flow-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #eef1f6;
  color: #4a5874;
}

.flow-status.s-delivered,
.flow-status.s-closed { background: #e3f4e4; color: #2e7d32; }
.flow-status.s-partially-delivered { background: #fff2dd; color: #b86a00; }
.flow-status.s-workshop { background: #e3edfb; color: #1b5fc4; }
.flow-status.s-packing { background: #f1e9fb; color: #6a3fb0; }
.flow-status.s-procurement { background: #fdeef0; color: #c0445a; }
.flow-status.s-not-started { background: #eef1f6; color: #6b7895; }

.flow-open {
  border: none;
  background: #061f9e;
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
}

.flow-open:hover { background: #0a2bd0; }


.order-flow-detail-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 4px 14px;
}

.order-flow-detail-body table {
  width: 100%;
  border-collapse: collapse;
}

.order-flow-detail-body th,
.order-flow-detail-body td {
  padding: 8px 12px;
  text-align: left;
}

.flow-detail-section {
  padding: 0 4px;
}

.order-flow-status-table th,
.order-flow-status-table td {
  padding: 6px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.order-flow-status-table .flow-measure {
  margin-top: 2px;
  font-size: 11px;
  font-style: italic;
  color: #64748b;
  white-space: normal;
}

.order-flow-status-table .flow-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.flow-open-ws { background: #b86a00; }
.flow-open-ws:hover { background: #d27c00; }
.flow-open-dlv { background: #061f9e; }
.flow-open-dlv:hover { background: #0a2bd0; }

.flow-actions-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #5b6b85;
  margin: 0 0 4px;
}

.flow-actions-legend .flow-open {
  padding: 1px 7px;
  font-size: 11px;
  cursor: default;
}

.flow-detail-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px 12px;
  background: #fff;
  border: 1px solid #d6deea;
  border-radius: 12px;
  padding: 10px 16px;
}

.flow-detail-info .field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7895;
}

.flow-detail-info .field-value {
  font-size: 15px;
  font-weight: 600;
  color: #1f2c46;
  margin-top: 2px;
}

.flow-timeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.flow-timeline .flow-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.flow-timeline .flow-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c4cedd;
}

.flow-timeline .flow-step.done .flow-dot { background: #2e7d32; }
.flow-timeline .flow-step.active .flow-dot { background: #ef8c00; }
.flow-timeline .flow-step.done { color: #2e7d32; }
.flow-timeline .flow-step.active { color: #b86a00; }
.flow-timeline .flow-step.pending { color: #9aa6bb; }

.flow-timeline .flow-arrow { color: #b3bdce; }

.flow-detail-section h2 {
  font-size: 15px;
  color: #061f9e;
  margin: 0 0 4px;
}

.flow-detail-section .flow-empty {
  color: #8b97ad;
  font-size: 13px;
  padding: 6px 0;
}


#order-flow-monitor-host {
  display: contents;
}

#order-flow-monitor.order-flow-active-fallback,
#order-flow-detail.order-flow-active-fallback {
  display: block;
}

body:has(#order-flow-monitor.order-flow-active-fallback) .dashboard,
body:has(#order-flow-detail.order-flow-active-fallback) .dashboard {
  display: none;
}


/* Order Flow Monitor header layout: keep filters and Help/Close from overlapping. */
#order-flow-monitor .order-flow-header {
  padding-right: 18px;
}

#order-flow-monitor .order-flow-header > div:first-child {
  flex: 1 1 340px;
  min-width: 280px;
}

#order-flow-monitor .order-flow-header > .search-fields {
  flex: 1 1 600px;
  min-width: 560px;
  max-width: 720px;
  grid-template-columns: auto minmax(240px, 1fr) auto minmax(155px, 190px) auto;
}

#order-flow-monitor .order-flow-header > .utility-actions.customer-actions {
  position: static !important;
  inset: auto !important;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: auto;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 0;
  align-self: center;
  overflow: visible;
}

#order-flow-monitor .order-flow-header > .utility-actions.customer-actions .exit-button {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  margin: 0;
}

#order-flow-monitor .order-flow-header > .utility-actions.customer-actions .help-button {
  white-space: nowrap;
}

/* Order Flow Detail: keep Print/Reports on the same top row as the close button. */
#order-flow-detail .order-flow-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  box-sizing: border-box;
  align-items: center;
  justify-content: stretch;
  gap: 12px;
  padding-top: 4px;
  padding-right: 0;
  padding-bottom: 8px;
}

#order-flow-detail .order-flow-header > .screen-title {
  min-width: 0;
  margin: 0;
}

#order-flow-detail .order-flow-header > .order-flow-detail-actions {
  position: static !important;
  inset: auto !important;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 8px;
  width: max-content;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 0;
  overflow: visible;
}

#order-flow-detail .order-flow-header > .order-flow-detail-actions .small-button:not(.exit-button) {
  min-width: 118px;
  white-space: nowrap;
}

#order-flow-detail .order-flow-header > .order-flow-detail-actions .exit-button {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  margin: 0;
}

@media (max-width: 640px) {
  #order-flow-detail .order-flow-header {
    gap: 8px;
  }

  #order-flow-detail .order-flow-header > .order-flow-detail-actions {
    gap: 6px;
  }

  #order-flow-detail .order-flow-header > .order-flow-detail-actions .small-button:not(.exit-button) {
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
    font-size: 11px;
  }
}

@media (max-width: 1120px) and (min-width: 768px) {
  #order-flow-monitor .order-flow-header > div:first-child {
    flex: 1 1 auto;
  }

  #order-flow-monitor .order-flow-header > .search-fields {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  #order-flow-monitor .order-flow-header > .utility-actions.customer-actions {
    margin-left: auto;
  }
}


/* Order Flow Monitor parent/detail transition guards. */
body:has(#order-flow-detail:target) #order-flow-monitor {
  display: none !important;
}

body:has(#order-flow-monitor:target) #order-flow-detail.order-flow-active-fallback,
body:has(#order-flow-monitor.order-flow-active-fallback) #order-flow-detail.order-flow-active-fallback {
  display: none !important;
}




/* Order Flow Detail packing remarks. */
#order-flow-detail .flow-packing-remarks {
  margin-top: 0;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#order-flow-detail .flow-packing-remarks-title {
  margin-bottom: 4px;
  color: #6b5300;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#order-flow-detail .flow-packing-remarks-input {
  width: 100%;
  min-height: 56px;
  box-sizing: border-box;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid #c9d7df;
  border-radius: 8px;
  background: #fff;
  color: #1f2c46;
  font: inherit;
  line-height: 1.35;
}

#order-flow-detail .flow-packing-remarks-input[readonly] {
  background: #f5f7f9;
  color: #657184;
}

#order-flow-detail .flow-packing-remarks-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 14px;
  margin-top: 3px;
}

#order-flow-detail .flow-packing-remarks-readonly,
#order-flow-detail .flow-packing-remarks-status {
  color: #6b7895;
  font-size: 12px;
}

#order-flow-detail .flow-packing-remarks-status.error {
  color: #b42318;
}
