/* Despacho visual refresh. IDs and behavior remain unchanged. */
#orders.view.active {
  position: relative;
  min-height: calc(100vh - var(--topbar-height, 112px));
  padding: 18px 24px 24px;
  overflow: auto;
  background: linear-gradient(180deg, #f8fbff 0%, #f6f8fc 100%);
}

#orders.view.active::before {
  content: "";
  position: absolute;
  right: -130px;
  bottom: -180px;
  width: 680px;
  height: 360px;
  border-radius: 58% 42% 0 0;
  background: radial-gradient(circle at 50% 50%, rgba(0, 87, 217, 0.06) 0 1.5px, transparent 1.75px) 0 0 / 12px 12px;
  pointer-events: none;
  z-index: 0;
}

#orders .order-layout,
#orders .order-tables {
  position: relative;
  z-index: 1;
}

#orders .order-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(520px, 0.88fr);
  gap: 18px;
  align-items: start;
}

#orders .order-tables {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(460px, 0.9fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

#orders .panel {
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid #dbe4f2;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 30px rgba(7, 26, 68, 0.06);
  overflow: hidden;
}

#orders .panel-heading {
  min-height: 0;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#orders .panel-heading h2 {
  margin: 0;
  color: #071a44;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0;
}

#orders #orderDropZone {
  width: 58%;
  min-width: 410px;
  min-height: 84px;
  margin: 0;
  padding: 16px 22px;
  display: grid;
  place-items: center;
  border: 1.5px dashed #8db5ff;
  border-radius: 3px;
  background: #fbfdff;
  box-shadow: none;
}

#orders #orderDropZone > span {
  position: relative;
  display: grid;
  gap: 5px;
  padding-left: 34px;
  color: #536487;
  font-size: 12px;
  line-height: 1.2;
  text-align: left;
  font-weight: 800;
}

#orders #orderDropZone > span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 22px;
  height: 22px;
  background: #536487;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpath d='M17 8 12 3 7 8'/%3E%3Cpath d='M12 3v12'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpath d='M17 8 12 3 7 8'/%3E%3Cpath d='M12 3v12'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

#orders #orderDropZone strong,
#orders #orderDropZone span span {
  color: #536487;
  font-size: 12px;
  font-weight: 800;
}

#orders #orderImportStatus {
  width: 100%;
  min-height: 30px;
  margin: 10px 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #536487;
  font-size: 12px;
  font-weight: 800;
}

#orders .active-orders-list {
  position: absolute;
  top: 43px;
  right: 16px;
  width: calc(42% - 28px);
  max-height: 92px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  overflow: auto;
  color: #536487;
  font-size: 12px;
  font-weight: 800;
}

#orders[data-dispatch-mode="multi"] .active-orders-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#orders .active-order-card {
  min-height: 76px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 3px 6px;
  border: 1px solid #b7cef3;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: none;
}

#orders .active-order-card.active-window {
  border-color: #1767d8;
  background: #eef8ff;
  box-shadow: inset 3px 0 0 #1767d8;
}

#orders .active-order-card strong {
  grid-column: 1 / -1;
  display: block;
  overflow: hidden;
  color: #071a44;
  font-size: 11px;
  line-height: 1.15;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#orders .active-order-card span {
  grid-column: 1;
  color: #536487;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 700;
}

#orders .active-order-card .mini-window-button {
  width: 44px;
  min-width: 44px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 900;
}

#orders .dispatch-details {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin: 0 0 10px;
}

#orders .dispatch-details label {
  display: grid;
  gap: 5px;
  color: #536487;
  font-size: 11px;
  line-height: 1.1;
  font-weight: 800;
}

#orders .dispatch-details input {
  width: 100%;
  height: 30px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #c8d8ef;
  border-radius: 3px;
  background: #ffffff;
  color: #071a44;
  font-size: 12px;
  font-weight: 800;
  box-shadow: none;
}

#orders .order-actions {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, 0.58fr);
  gap: 8px;
  margin: 0;
  align-items: stretch;
}

#orders .order-actions button {
  height: 32px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 900;
  box-shadow: none;
}

#orders #prepareOrderBtn {
  background: #ef1736;
  border-color: #ef1736;
  color: #ffffff;
}

#orders #clearOrderBtn {
  border: 1px solid #ff9aa9;
  background: #fff7f8;
  color: #ef1736;
}

#orders #orderPhoneBtn,
#orders #printPickListBtn,
#orders #printMapBtn,
#orders #printLabelBtn {
  background: #f3f8ff;
  border-color: #c8d8ef;
  color: #09265a;
}

#orders #orderPhoneBtn {
  position: relative;
}

#orders #orderPhoneBtn::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-right: 7px;
  display: inline-block;
  vertical-align: -2px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.07 0l2.83-2.83a5 5 0 0 0-7.07-7.07L11 4.93'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.07 0L4.1 13.83a5 5 0 0 0 7.07 7.07L13 19.07'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.07 0l2.83-2.83a5 5 0 0 0-7.07-7.07L11 4.93'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.07 0L4.1 13.83a5 5 0 0 0 7.07 7.07L13 19.07'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

#orders #orderScanStatus {
  min-height: 30px;
  margin: 10px 0 0;
  padding: 0 10px;
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: #536487;
  font-size: 12px;
  font-weight: 700;
}

#orders .dispatch-map {
  margin: 0;
  padding: 10px;
  border: 2px solid #1f2937;
  border-radius: 0;
  background: #eef2f5;
  overflow: hidden;
}

#orders .warehouse-grid {
  display: grid;
  grid-template-columns: 66px repeat(4, minmax(62px, 1fr)) 70px 46px 46px;
  grid-auto-rows: 24px;
  gap: 4px;
  align-items: stretch;
}

#orders .warehouse-grid > * {
  min-width: 0;
}

#orders .map-row-label {
  color: #09265a;
  font-size: 12px;
  line-height: 1.05;
  font-weight: 900;
}

#orders .map-row-label span {
  color: #31527e;
  font-size: 10px;
  font-weight: 800;
}

#orders .shelf-zone {
  min-height: 0;
  height: 100%;
  padding: 0;
  border: 1.5px solid #1e4f82;
  border-radius: 0;
  background: #eaf6ff;
  color: #071a44;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 0.95;
  font-weight: 900;
  box-shadow: inset 0 0 0 2px rgba(30, 79, 130, 0.12);
}

#orders .shelf-zone span {
  margin: 0;
  color: #071a44;
  font-size: 9px;
  line-height: 0.95;
  font-weight: 800;
}

#orders .shelf-zone.target {
  border-color: #ef1736;
  background: #fff0f2;
  color: #ef1736;
  box-shadow: inset 0 0 0 2px rgba(239, 23, 54, 0.12);
}

#orders .shelf-zone.target span {
  color: #ef1736;
}

#orders .shelf-zone.target::after {
  width: 18px;
  height: 18px;
  top: -8px;
  right: -8px;
  font-size: 10px;
  background: #ef1736;
}

#orders .aisle-label {
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
  border-top: 1px dashed #ffffff;
  border-bottom: 1px dashed #ffffff;
  color: #4b5563;
  font-size: 11px;
  font-weight: 900;
}

#orders .map-room,
#orders .main-aisle {
  min-height: 46px;
  border-radius: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
}

#orders .map-room.receiving {
  border: 1px solid #a8d9b3;
  background: #eef9ea;
  color: #2f7d22;
}

#orders .main-aisle {
  border: 1px dashed #9db8dd;
  background: #f8fbff;
  color: #09265a;
}

#orders .map-room.dispatch {
  border: 1px solid #f0c76d;
  background: #fff7e4;
  color: #c66a00;
}

#orders .warehouse-grid > :nth-child(1) { grid-column: 1; grid-row: 1; }
#orders .warehouse-grid [data-zone="A-A1"] { grid-column: 2 / 4; grid-row: 1; }
#orders .warehouse-grid [data-zone="A-A2"] { grid-column: 4 / 6; grid-row: 1; }
#orders .warehouse-grid > :nth-child(4) { grid-column: 1 / 6; grid-row: 2; }
#orders .warehouse-grid > :nth-child(5) { grid-column: 6; grid-row: 2 / 4; }
#orders .warehouse-grid [data-zone="B-B1"] { grid-column: 7; grid-row: 2 / 4; }
#orders .warehouse-grid [data-zone="B-B2"] { grid-column: 8; grid-row: 2 / 4; }
#orders .warehouse-grid > :nth-child(8) { grid-column: 1 / 6; grid-row: 4; }
#orders .warehouse-grid > :nth-child(9) { grid-column: 6; grid-row: 4 / 6; }
#orders .warehouse-grid [data-zone="C-C1"] { grid-column: 7; grid-row: 4 / 6; }
#orders .warehouse-grid [data-zone="C-C2"] { grid-column: 8; grid-row: 4 / 6; }
#orders .warehouse-grid > :nth-child(12) { grid-column: 1 / 6; grid-row: 6; }
#orders .warehouse-grid > :nth-child(13) { grid-column: 6; grid-row: 6 / 8; }
#orders .warehouse-grid [data-zone="D-D1"] { grid-column: 7; grid-row: 6 / 8; }
#orders .warehouse-grid [data-zone="D-D2"] { grid-column: 8; grid-row: 6 / 8; }
#orders .warehouse-grid > :nth-child(16) { grid-column: 1 / 6; grid-row: 8; }
#orders .warehouse-grid > :nth-child(17) { grid-column: 6; grid-row: 8 / 10; }
#orders .warehouse-grid [data-zone="E-E1"] { grid-column: 7; grid-row: 8 / 10; }
#orders .warehouse-grid [data-zone="E-E2"] { grid-column: 8; grid-row: 8 / 10; }
#orders .warehouse-grid .map-room.receiving { grid-column: 1 / 4; grid-row: 10 / 12; }
#orders .warehouse-grid .main-aisle { grid-column: 4 / 7; grid-row: 10 / 12; }
#orders .warehouse-grid .map-room.dispatch { grid-column: 7 / 9; grid-row: 10 / 12; }

#orders #orderMapLegend {
  min-height: 36px;
  margin: 10px 0 0;
  padding: 0 14px;
  display: flex;
  align-items: center;
  border: 1px solid #dbe4f2;
  border-radius: 5px;
  background: #ffffff;
  color: #536487;
  font-size: 12px;
  font-weight: 800;
}

#orders .order-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

#orders .order-metric {
  position: relative;
  min-height: 64px;
  padding: 12px 44px 10px 14px;
  border: 1px solid #dbe4f2;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(7, 26, 68, 0.04);
}

#orders .order-metric::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  background: var(--order-metric-color, #1767d8);
  -webkit-mask: var(--order-metric-icon) center / contain no-repeat;
  mask: var(--order-metric-icon) center / contain no-repeat;
}

#orders .order-metric:nth-child(1) {
  --order-metric-color: #1767d8;
  --order-metric-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21 8-9-5-9 5 9 5 9-5Z'/%3E%3Cpath d='M3 8v8l9 5 9-5V8'/%3E%3Cpath d='M12 13v8'/%3E%3C/g%3E%3C/svg%3E");
}

#orders .order-metric:nth-child(2) {
  --order-metric-color: #22c55e;
  --order-metric-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/g%3E%3C/svg%3E");
}

#orders .order-metric:nth-child(3) {
  --order-metric-color: #f97316;
  --order-metric-icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/g%3E%3C/svg%3E");
}

#orders .order-metric span {
  display: block;
  margin: 0 0 6px;
  color: #536487;
  font-size: 11px;
  font-weight: 800;
}

#orders .order-metric strong {
  display: block;
  margin: 0;
  color: #071a44;
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
}

#orders .order-table-wrap,
#orders .packing-boards {
  max-height: 275px;
  overflow: auto;
  border: 1px solid #dbe4f2;
  border-radius: 8px;
  background: #ffffff;
}

#orders[data-dispatch-mode="multi"] .order-table-wrap,
#orders[data-dispatch-mode="multi"] .packing-boards {
  max-height: 300px;
}

#orders .order-table-wrap table,
#orders .packing-board-table {
  width: 100%;
  min-width: 640px;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
}

#orders .order-table-wrap th,
#orders .order-table-wrap td,
#orders .packing-board-table th,
#orders .packing-board-table td {
  height: 28px;
  padding: 4px 10px;
  border: 0;
  border-bottom: 1px solid #e8eef7;
  color: #071a44;
  font-size: 11px;
  line-height: 1.15;
  vertical-align: middle;
  background: #ffffff;
}

#orders .order-table-wrap th,
#orders .packing-board-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 30px;
  background: linear-gradient(180deg, #f8fbff 0%, #edf4ff 100%);
  color: #09265a;
  font-size: 10.5px;
  font-weight: 900;
  text-transform: none;
}

#orders .order-table-wrap tbody tr:last-child td,
#orders .packing-board-table tbody tr:last-child td {
  border-bottom: 0;
}

#orders .order-line-status.pending td,
#orders .order-line-status.pending:nth-child(even) td,
#orders .order-line-status.ok td,
#orders .order-line-status.ok:nth-child(even) td {
  background: #ffffff;
  color: #071a44;
  font-weight: 800;
}

#orders .pick-check-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #071a44;
  font-size: 10px;
  font-weight: 800;
}

#orders .pick-check-label input {
  width: 15px;
  height: 15px;
  min-height: 15px;
  margin: 0;
  accent-color: #22c55e;
}

#orders .badge {
  min-width: 70px;
  min-height: 20px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: #fff1d6;
  color: #d97706;
  font-size: 10px;
  font-weight: 900;
}

#orders .badge.ok {
  background: #dcfce7;
  color: #15803d;
}

#orders .packing-boards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

#orders[data-dispatch-mode="multi"] .packing-boards {
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  overflow-x: auto;
  overflow-y: hidden;
}

#orders .packing-board {
  min-height: 0;
  padding: 12px;
  border: 1px solid #dbe4f2;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(7, 26, 68, 0.04);
}

#orders .packing-board-head {
  margin: 0 0 8px;
  padding: 0 0 8px;
  border-bottom: 1px solid #dbe4f2;
}

#orders .packing-board-head strong {
  color: #071a44;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 900;
}

#orders .packing-board-head span {
  margin-top: 4px;
  color: #536487;
  font-size: 10.5px;
  font-weight: 700;
}

#orders .packing-board-lines {
  max-height: 206px;
  overflow: auto;
}

#orders[data-dispatch-mode="multi"] .packing-board-lines {
  max-height: 178px;
}

#orders[data-dispatch-mode="multi"] .packing-board-table {
  min-width: 390px;
}

#orders[data-dispatch-mode="multi"] .packing-board-table th,
#orders[data-dispatch-mode="multi"] .packing-board-table td {
  padding: 4px 7px;
  font-size: 10px;
}

@media (max-width: 1400px) {
  #orders.view.active {
    padding: 16px 20px 22px;
  }

  #orders .order-layout {
    grid-template-columns: minmax(0, 1.16fr) minmax(470px, 0.84fr);
    gap: 14px;
  }

  #orders .order-tables {
    gap: 14px;
  }

  #orders #orderDropZone {
    min-width: 360px;
  }

  #orders .active-orders-list {
    width: calc(42% - 24px);
  }

  #orders .warehouse-grid {
    grid-template-columns: 58px repeat(4, minmax(54px, 1fr)) 62px 40px 40px;
    grid-auto-rows: 21px;
    gap: 3px;
  }

  #orders .shelf-zone {
    font-size: 11px;
  }

  #orders .shelf-zone span {
    font-size: 8px;
  }
}
