/* ═══ Orders — gọn kiểu Apple: tab trạng thái, thẻ số liệu, thanh công cụ, lọc Case ═══ */

/* ── Tab trạng thái: ẩn tab 0 đơn, viên gọn, số đếm chữ xám ── */
#ordersView #statusTabs { gap: 4px !important; padding: 2px 0 8px !important; scrollbar-width: none; }
#ordersView #statusTabs::-webkit-scrollbar { display: none; }
#ordersView #statusTabs button.is-zero { display: none !important; }
#ordersView #statusTabs button {
  height: 32px !important; padding: 0 13px !important; background: transparent !important; box-shadow: none !important;
  color: #1d1d1f !important; font-size: 13.5px !important; font-weight: 500 !important; transition: background .15s;
}
#ordersView #statusTabs button:hover { background: rgba(0, 0, 0, .05) !important; }
#ordersView #statusTabs button b { min-width: 0 !important; margin-left: 6px; padding: 0 !important; background: transparent !important; color: #86868b !important; font-weight: 500 !important; font-variant-numeric: tabular-nums; }
#ordersView #statusTabs button.selected { background: #1d1d1f !important; color: #fff !important; }
#ordersView #statusTabs button.selected b { color: rgba(255, 255, 255, .65) !important; }
@media (min-width: 761px) { #ordersView #statusTabs { flex-wrap: wrap !important; overflow: visible !important; } }

/* ── Hạn D+1 + sắp xếp: 1 dòng mảnh ── */
#ordersView .sla-bar { margin: 0 0 10px !important; gap: 6px !important; }
#ordersView .sla-chip { height: 28px !important; padding: 0 11px !important; font-size: 12.5px !important; }

/* ── Thẻ số liệu: 5 thẻ cùng hàng · chấm màu + số lớn bên phải ── */
@media (min-width: 761px) {
  #ordersView .order-range-summary { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; gap: 10px !important; margin-bottom: 14px !important; }
  #ordersView .order-range-summary > article { display: none !important; }
}
#ordersView .order-range-summary .ops-card {
  display: grid !important; grid-template-columns: minmax(0, 1fr) auto !important; grid-template-areas: "label num" "sub num";
  align-items: center !important; column-gap: 10px !important; row-gap: 3px !important; padding: 12px 14px !important; border-radius: 14px !important; text-align: left;
}
#ordersView .order-range-summary .ops-card span { grid-area: label; display: flex; align-items: center; gap: 7px; color: #1d1d1f !important; font-size: 13px !important; font-weight: 600 !important; }
#ordersView .order-range-summary .ops-card span::before { content: ""; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, #86868b); }
#ordersView .order-range-summary .ops-card strong { grid-area: num; color: var(--num, #1d1d1f) !important; font-size: 24px !important; font-variant-numeric: tabular-nums; }
#ordersView .order-range-summary .ops-card small { grid-area: sub; padding-left: 14px; font-size: 11.5px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ordersView .ops-overdue { --dot: #ff3b30; --num: #d70015; }
#ordersView .ops-design { --dot: #ff9f0a; --num: #c93400; }
#ordersView .ops-production { --dot: #5e5ce6; }
#ordersView .ops-shipping { --dot: #0071e3; --num: #0071e3; }
#ordersView .ops-case { --dot: #c7c7cc; --num: #86868b; }
#ordersView .order-range-summary .ops-case.has-case { --dot: #ff3b30; --num: #d70015; background: #fff4f3 !important; box-shadow: inset 0 0 0 1px rgba(255, 59, 48, .28), 0 4px 14px rgba(255, 59, 48, .08) !important; }
#ordersView .ops-case.has-case span::before { animation: case-pulse 1.6s ease-in-out infinite; }
@keyframes case-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, .45); } 50% { box-shadow: 0 0 0 5px rgba(255, 59, 48, 0); } }

/* ── Thanh công cụ: lọc bên trái · làm mới, menu Xưởng, Gửi đơn bên phải ── */
#ordersView .filters > .tb-spacer { display: block !important; flex: 1 1 auto; min-width: 8px; }
#ordersView .filters > #clearOrderFilters { border-color: transparent !important; background: transparent !important; color: #0071e3 !important; font-weight: 600 !important; }
#ordersView .filters > #clearOrderFilters:hover { background: #eef5ff !important; }
#ordersView .filters > #clearOrderFilters[hidden] { display: none !important; }
#ordersView .tb-menu { position: relative; flex: 0 0 auto; }
#ordersView .tb-menu-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 14px; border: 1px solid #e5e5ea; border-radius: 980px;
  background: #fff; color: #1d1d1f; font: 500 12.5px -apple-system, "Be Vietnam Pro", Inter, sans-serif; cursor: pointer; white-space: nowrap;
}
#ordersView .tb-menu-btn::after { content: ""; width: 10px; height: 10px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; transition: transform .15s; }
#ordersView .tb-menu-btn:hover, #ordersView .tb-menu-btn.open { background: #f5f5f7; border-color: #d2d2d7; }
#ordersView .tb-menu-btn.open::after { transform: rotate(180deg); }
#ordersView .tb-pop {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; display: grid; gap: 2px; width: 320px; padding: 6px;
  border-radius: 14px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 12px 32px rgba(0, 0, 0, .14);
}
#ordersView .tb-pop[hidden] { display: none; }
#ordersView .filters { position: relative; z-index: 40; }
#ordersView .tb-pop button { display: grid !important; gap: 2px; width: 100% !important; height: auto !important; min-height: 0 !important; padding: 9px 12px !important; line-height: 1.3 !important; white-space: normal !important; border: 0; border-radius: 10px; background: transparent; color: #1d1d1f; text-align: left; cursor: pointer; }
#ordersView .tb-pop button[hidden] { display: none; }
#ordersView .tb-pop button:hover { background: #f2f2f5; }
#ordersView .tb-pop button:disabled { opacity: .5; cursor: progress; }
#ordersView .tb-pop b { font-size: 13.5px; font-weight: 600; }
#ordersView .tb-pop small { color: #86868b; font-size: 12px; line-height: 1.35; }
@media (max-width: 760px) { #ordersView .filters > .tb-spacer { display: none !important; } #ordersView .tb-pop { position: fixed; top: auto; right: 12px; left: 12px; bottom: 84px; width: auto; } }

/* ── Cột Case: tiêu đề bấm để lọc + số case ── */
#ordersView .th-case { display: inline-flex; align-items: center; gap: 6px; }
#ordersView .th-case b { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ff3b30; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
#ordersView .th-case.on { color: #d70015 !important; }
#ordersView .order-case.case-open { white-space: nowrap; }

/* ── Thanh bên: nhắc case ── */
.quick-urgent.quick-case { margin-top: 8px; }
.quick-urgent.quick-case b { color: #d70015; }

/* ── Ô lọc Team / Vendor: gọn như ô Shop ── */
#ordersView .filters :is(.ux-team-filter, .ux-vendor-filter) select { max-width: 190px !important; }

/* Huỷ đơn */
#ordersView .order-status.cancelled { background: #f2f2f5 !important; color: #8e8e93 !important; text-decoration: line-through; }
#ordersView .ux-cancel { display: block; margin-top: 3px; color: #8e8e93; font-size: 11.5px; }
#orderSelectionBar .bulk-cancel { color: #d70015 !important; border-color: #ffd0cc !important; }
#orderSelectionBar .bulk-restore { color: #0071e3 !important; }
#orderSelectionBar .bulk-cancel[hidden], #orderSelectionBar .bulk-restore[hidden] { display: none !important; }
dialog .cancel-form .cancel-note { margin: 0 0 10px; color: #3a3a3c; font-size: 13.5px; line-height: 1.5; }
dialog .cancel-form .cancel-warn { margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; background: #fff4e5; color: #8a4b00; font-size: 13px; }
dialog .cancel-form .cancel-check { display: flex !important; align-items: center; gap: 8px; margin-top: 10px; }
dialog .cancel-form .cancel-check input { width: 18px; height: 18px; min-height: 0 !important; }
dialog.dialog .cancel-form menu .danger-fill { border-color: #d70015 !important; background: #d70015 !important; color: #fff !important; }
#ordersView .ux-money-off small { color: #8e8e93; font-size: 12px; line-height: 1.4; }

/* Chi phí làm lại */
#ordersView .ux-money .ux-extra span, #ordersView .ux-money .ux-extra b { color: #c93400 !important; }
#ordersView .vendor-bar .extra-cost-btn { color: #c93400 !important; }
dialog .xc-form .xc-note { margin: 0 0 10px; color: #3a3a3c; font-size: 13.5px; line-height: 1.5; }
dialog .xc-form .xc-list { display: grid; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
dialog .xc-form .xc-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: #fff4e5; }
dialog .xc-form .xc-list li span { display: grid; flex: 1; gap: 1px; min-width: 0; }
dialog .xc-form .xc-list b { font-size: 13.5px; } dialog .xc-form .xc-list small { color: #86868b; font-size: 12px; }
dialog .xc-form .xc-list strong { color: #c93400; font-variant-numeric: tabular-nums; }
dialog .xc-form .xc-del { width: 26px; height: 26px !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; background: transparent !important; color: #aeaeb2 !important; font-size: 18px !important; cursor: pointer; }
dialog .xc-form .xc-grid { grid-template-columns: 1fr 1fr !important; }
dialog .xc-form .xc-full { grid-column: 1 / -1; }
