/* ═══════════════════════════════════════════════════════════════════════════
   CSS — ORDERS & FULFILLMENT DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --accent: #2563eb;
  --focus: rgba(179, 229, 252, 0.7);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
/* Remove number input spinners globally */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ───────────────────────────────────────── */
.admin-header {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 16px 24px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-badge {
  font-size: 10px;
  padding: 3px 8px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: #94a3b8;
  position: relative;
}
.header-nav-link {
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all 0.15s;
}
.header-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.admin-avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.admin-avatar-btn:hover {
  border-color: rgba(255, 255, 255, 0.5);
}
.admin-avatar-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.admin-menu-dropdown {
  position: absolute;
  top: 44px;
  right: 0;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 15px 40px rgba(15, 23, 42, 0.18);
  min-width: 220px;
  display: none;
  z-index: 200;
  overflow: hidden;
}
.admin-menu-dropdown.open {
  display: block;
}
.admin-menu-profile {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.profile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.profile-email {
  font-size: 12px;
  color: var(--muted);
}
.profile-role {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  margin-top: 4px;
  background: #eff6ff;
  color: var(--accent);
  border-radius: 4px;
  font-weight: 600;
}
.admin-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}
.admin-menu-item:hover {
  background: #f8fafc;
}
.admin-menu-item.danger {
  color: #dc2626;
}
.admin-menu-item.danger:hover {
  background: #fef2f2;
}

/* ── REPORTS DROPDOWN ────────────────────────────── */
.reports-dropdown-wrap {
  position: relative;
  display: inline-flex;
}
.reports-dropdown-btn {
  color: #94a3b8;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.reports-dropdown-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
.reports-dropdown-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.reports-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  min-width: 200px;
  display: none;
  z-index: 300;
  overflow: hidden;
}
.reports-dropdown-menu.open {
  display: block;
}
.reports-dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}
.reports-dropdown-menu button:hover {
  background: #f8fafc;
}
.reports-dropdown-menu button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.reports-dropdown-menu .rpt-icon {
  font-size: 15px;
  flex-shrink: 0;
}
.reports-dropdown-menu .rpt-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.reports-dropdown-menu .rpt-title {
  font-weight: 600;
  font-size: 13px;
}
.reports-dropdown-menu .rpt-desc {
  font-size: 11px;
  color: var(--muted);
}

/* ── REPORT MODAL ────────────────────────────────── */
.report-modal-body {
  padding: 20px;
}
.report-field-group {
  margin-bottom: 16px;
}
.report-field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}
.report-field-group select,
.report-field-group input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s;
}
.report-field-group select:focus,
.report-field-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}
.report-field-row {
  display: flex;
  gap: 12px;
}
.report-field-row .report-field-group {
  flex: 1;
}
.report-progress {
  text-align: center;
  padding: 20px 0;
  color: var(--muted);
  font-size: 13px;
}
.report-progress .spinner {
  margin: 0 auto 10px;
}

/* ── TABS ─────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 59px;
  z-index: 99;
}
.admin-tab {
  padding: 8px 18px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  font-family: inherit;
  transition: all 0.15s;
}
.admin-tab:hover {
  background: #f1f5f9;
  color: var(--text);
}
.admin-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.admin-tab.active {
  background: var(--accent);
  color: #fff;
}

/* ── CONTENT ──────────────────────────────────────── */
.admin-content {
  padding: 0 24px 40px;
}
.view {
  display: none;
}
.view.active {
  display: block;
}

/* ── TOOLBAR ──────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-wrap::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}
.search-wrap input[type="search"] {
  padding: 8px 12px 8px 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  min-width: 220px;
  transition: border-color 0.15s;
}
.search-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.toolbar input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  min-width: 220px;
  transition: border-color 0.15s;
}
.toolbar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}
.toolbar-spacer {
  flex: 1;
}

/* ── FILTER BUTTONS ───────────────────────────────── */
.filter-group {
  display: flex;
  gap: 0;
}
.filter-btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.15s;
}
.filter-btn:first-child {
  border-radius: 8px 0 0 8px;
}
.filter-btn:last-child {
  border-radius: 0 8px 8px 0;
}
.filter-btn:not(:first-child) {
  margin-left: -1px;
}
.filter-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}
.filter-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}
.filter-btn.active-blue {
  background: #eff6ff;
  color: var(--accent);
  border-color: var(--accent);
  z-index: 1;
}
.filter-btn.active-amber {
  background: #fffbeb;
  color: #d97706;
  border-color: #f59e0b;
  z-index: 1;
}
.filter-btn.active-green {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #22c55e;
  z-index: 1;
}

/* ── BUTTONS ──────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  background: #fff;
  color: var(--text);
}
.btn:hover {
  background: #f8fafc;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #1d4ed8;
}
.btn-primary:disabled {
  background: var(--accent);
  opacity: 0.5;
}
.btn-success {
  background: #22c55e;
  color: #fff;
  border-color: #22c55e;
}
.btn-success:hover {
  background: #16a34a;
}
.btn-success:disabled {
  background: #22c55e;
  opacity: 0.5;
}
.btn-danger {
  background: rgba(239, 83, 80, 0.08);
  color: rgba(153, 27, 27, 0.95);
  border-color: rgba(239, 83, 80, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 83, 80, 0.15);
}
.btn-danger:disabled {
  opacity: 0.5;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}
.btn-xs {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 6px;
}
.btn-ghost {
  background: none;
  border-color: transparent;
}
.btn-ghost:hover {
  background: #f1f5f9;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── DATA TABLE ───────────────────────────────────── */
.data-table-wrap {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: auto;
  box-shadow: var(--shadow);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover {
  background: #f1f5f9;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
  vertical-align: middle;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}
.data-table tbody tr:nth-child(even) {
  background: #fafbfd;
}
.data-table tbody tr:hover {
  background: #eff6ff;
}
.data-table .cell-primary {
  font-weight: 500;
  color: var(--text);
}
.data-table .cell-secondary {
  font-size: 12px;
  color: var(--muted);
}
.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.data-table .center {
  text-align: center;
}
.sort-arrow {
  font-size: 10px;
  margin-left: 3px;
  opacity: 0.4;
}
th.sorted .sort-arrow {
  opacity: 1;
}

/* Totals row */
.data-table tfoot {
  position: sticky;
  bottom: 0;
  z-index: 1;
}
.data-table tr.totals-row td {
  font-weight: 700;
  background: #f0f4f8;
  border-top: 2px solid var(--accent);
  color: var(--text);
  font-size: 13px;
}

/* ── STATUS BADGES ────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.st-open {
  background: #eff6ff;
  color: #2563eb;
}
.status-badge.st-hold {
  background: #fef3c7;
  color: #d97706;
}
.status-badge.st-estimate {
  background: #f3e8ff;
  color: #9333ea;
}
.status-badge.st-needs-invoice {
  background: #fce7f3;
  color: #db2777;
}
.status-badge.st-waiting-payment {
  background: #fff7ed;
  color: #ea580c;
}
.status-badge.st-waiting-ship {
  background: #ecfdf5;
  color: #059669;
}
.status-badge.st-packing {
  background: #e0f2fe;
  color: #0284c7;
}
.status-badge.st-booked {
  background: #dbeafe;
  color: #1d4ed8;
}
.status-badge.st-done {
  background: #dcfce7;
  color: #16a34a;
}

/* ── PIPELINE BAR ────────────────────────────────── */
/* ── UNIFIED PIPELINE ──────────────────────────────── */
.unified-pipeline {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin: 16px 0 12px;
  flex-wrap: wrap;
}
.up-group {
  flex: 1;
  min-width: 140px;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition:
    opacity 0.2s,
    transform 0.15s;
}
.up-group.dimmed {
  opacity: 0.4;
  transform: scale(0.97);
}
.up-group.active {
  border-color: var(--group-color, var(--accent));
  box-shadow: 0 0 0 1px var(--group-color, var(--accent));
}
.up-group-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 16px 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.up-group-header:hover {
  background: #f8fafc;
}
.up-group-count {
  font-size: 26px;
  font-weight: 700;
  color: var(--group-color, var(--text));
  line-height: 1;
}
.up-group-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.up-group-stages {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 12px 12px;
}
.up-stage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--stage-color, var(--muted));
  transition: all 0.15s;
  user-select: none;
}
.up-stage:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
}
.up-stage.active {
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px var(--stage-color);
  transform: scale(1.08);
}
.up-stage.dimmed {
  opacity: 0.3;
  transform: scale(0.93);
}
.up-stage-count {
  font-size: 13px;
  font-weight: 800;
}
.up-stage-label {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.85;
}
.up-total {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 80px;
  padding: 12px 16px;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.up-total:hover {
  border-color: var(--accent);
}
.up-total.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.up-total .up-group-count {
  color: var(--text);
}
.up-total .up-group-label {
  margin-top: 2px;
}

.pay-badge {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.pay-badge.pay-paid {
  background: #dcfce7;
  color: #16a34a;
}
.pay-badge.pay-po {
  background: #dbeafe;
  color: #2563eb;
}
.pay-badge.pay-free {
  background: #f0f9ff;
  color: #0369a1;
}
.pay-badge.pay-replacement {
  background: #f5f3ff;
  color: #7c3aed;
}
.pay-badge.pay-not-paid {
  background: #fee2e2;
  color: #dc2626;
}

/* ── ZERO QUANTITY ──────────────────────────────────── */
.zero-qty {
  color: var(--muted);
  opacity: 0.4;
  font-weight: 400;
}

/* ── MODAL ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  z-index: 1100;
  overflow-y: auto;
}
.modal-backdrop.open {
  display: flex;
}
.modal {
  width: 820px;
  max-width: 100%;
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
  margin: 32px auto;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.2s ease;
}
.modal.modal-lg {
  width: 1100px;
}
.modal.modal-full {
  width: 96vw;
  max-width: 900px;
  max-height: 92vh;
  margin: 20px auto;
}
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(to bottom, rgba(246, 247, 251, 0.7), rgba(255, 255, 255, 0));
  flex-shrink: 0;
}
.modal-head .title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}
.modal-head .h1 {
  font-size: 17px;
  font-weight: 800;
}
.modal-head .h2 {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60vw;
}
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-footer-split {
  justify-content: space-between;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.modal-close:hover {
  background: #f1f5f9;
}
.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── FORM SECTIONS ────────────────────────────────── */
.form-section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.form-section-head {
  padding: 10px 14px;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
}
.form-section-head:hover {
  background: #f1f5f9;
}
.form-section-head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.form-section-head .chevron {
  font-size: 14px;
  color: var(--muted);
  transition: transform 0.2s;
}
.form-section.collapsed .form-section-body {
  display: none;
}
.form-section.collapsed .chevron {
  transform: rotate(-90deg);
}
.form-section-body {
  padding: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.form-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.form-group.full {
  grid-column: 1 / -1;
}
.form-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}
.form-group textarea {
  resize: vertical;
  min-height: 60px;
}
.form-group input[type="checkbox"] {
  width: auto;
}
.form-group input[readonly] {
  background: #f8fafc;
  color: var(--muted);
}
.form-group .currency-input {
  text-align: right;
}

/* ── MODAL TABS ──────────────────────────────────── */
.modal-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  flex-shrink: 0;
}
.modal-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.modal-tab:hover {
  color: var(--text);
}
.modal-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.order-tab-panel {
  display: none;
}
.order-tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* ── ORDER DIALOG LAYOUT ────────────────────────── */
.order-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.order-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 12px;
}
.order-fieldset legend {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 6px;
}
.order-fieldset .form-grid {
  gap: 8px 12px;
}
.order-fin-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 6px;
}
.order-fin-total .total-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.order-fin-total .total-value {
  font-size: 20px;
  font-weight: 800;
}
.order-ddu-ddp {
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
  min-height: 16px;
  margin-top: 2px;
}
.order-fin-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.order-fin-btns .btn {
  width: 100%;
  justify-content: center;
}
.btn-amber {
  background: #d97706;
  color: #fff;
  border-color: #d97706;
}
.btn-amber:hover {
  background: #b45309;
}
.btn-amber:disabled {
  background: #d97706;
  opacity: 0.5;
}
.order-fin-links {
  margin-top: 8px;
}
.order-fin-links a {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
  transition: color 0.15s;
}
.order-fin-links a:hover {
  color: #1d4ed8;
}
.order-fin-links a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.order-fin-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  min-height: 16px;
}
.order-products-scroll {
  max-height: 440px;
  overflow-y: auto;
}
.order-addr-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.order-cust-display {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.order-cust-display .cust-name {
  font-size: 14px;
  font-weight: 700;
}
.order-cust-display .cust-company {
  font-size: 13px;
  color: var(--muted);
}

/* ── PURCHASE INPUT SECTIONS ─────────────────────── */
.purchase-section {
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}
.purchase-section:last-child {
  border-bottom: none;
}
.purchase-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.purchase-header .sec-title {
  font-size: 12px;
  font-weight: 700;
  color: #2e7d32;
}
.purchase-header .sec-hint {
  font-size: 10px;
  font-style: italic;
  color: var(--muted);
  margin-left: 8px;
}
.purchase-add {
  font-size: 11px;
  padding: 2px 8px;
  border: none;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
.purchase-add:hover {
  background: #c8e6c9;
}
.purchase-add:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.purchase-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.purchase-row input[type="number"] {
  width: 44px;
  padding: 4px 4px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
}
.purchase-row select {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  width: auto;
  max-width: 120px;
}
.purchase-row .row-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.purchase-row .row-x {
  font-size: 11px;
  color: var(--muted);
}
.purchase-remove {
  font-size: 14px;
  color: #ccc;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.purchase-remove:hover {
  color: #dc2626;
}
.purchase-remove:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.purchase-sep {
  border-top: 1px solid #e2e8f0;
  margin: 8px 0;
}
.purchase-static {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.purchase-static .static-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.purchase-static input[type="number"] {
  width: 38px;
  padding: 3px 2px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
}

/* ── INLINE PRICES SUMMARY ──────────────────────── */
.inline-prices {
  margin-top: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 11px;
}
.inline-prices-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.inline-prices-title {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
}
.inline-prices-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.inline-prices-badge.reseller {
  background: #fef3c7;
  color: #92400e;
}
.inline-prices-badge.comp {
  background: #dcfce7;
  color: #166534;
}
.inline-prices-table {
  width: 100%;
  border-collapse: collapse;
}
.inline-prices-table td {
  padding: 2px 0;
  vertical-align: top;
}
.inline-prices-table .ip-desc {
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inline-prices-table .ip-qty {
  text-align: center;
  color: var(--muted);
  width: 24px;
}
.inline-prices-table .ip-price {
  text-align: right;
  color: var(--muted);
  width: 60px;
}
.inline-prices-table .ip-total {
  text-align: right;
  font-weight: 500;
  width: 70px;
}
.inline-prices-table .comp-row .ip-price {
  color: #16a34a;
  font-weight: 600;
}
.inline-prices-table .comp-row .ip-total {
  color: #16a34a;
}
.inline-prices-charges {
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid #e2e8f0;
}
.ip-charge-row {
  display: flex;
  justify-content: space-between;
  padding: 1px 0;
  color: var(--muted);
  font-size: 11px;
}
.ip-charge-row:first-child {
  font-weight: 500;
  color: var(--text);
}
.inline-prices-subtotal {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 12px;
}

/* ── QBO CUSTOMER SEARCH & INFO ──────────────────── */
.qbo-search-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}
.qbo-search-bar input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
}
.qbo-search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}
.qbo-results-wrap {
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  display: none;
}
.qbo-results-wrap.visible {
  display: block;
}
.qbo-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.qbo-results-table th {
  padding: 4px 8px;
  background: #f8fafc;
  font-weight: 600;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
.qbo-results-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #f8fafc;
  cursor: pointer;
}
.qbo-results-table tr:hover td {
  background: #eff6ff;
}
.qbo-linked {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 8px;
  font-size: 12px;
  color: #16a34a;
  font-weight: 600;
}
.qbo-linked .unlink-btn {
  font-size: 11px;
  color: #dc2626;
  cursor: pointer;
  border: none;
  background: none;
  padding: 2px 6px;
  border-radius: 4px;
}
.qbo-linked .unlink-btn:hover {
  background: #fef2f2;
}
.qbo-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 11px;
  padding: 6px 0;
  border-top: 1px solid #f1f5f9;
  margin-top: 4px;
}
.qbo-info-row .info-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.qbo-info-row .info-label {
  font-weight: 700;
  color: var(--muted);
}
.qbo-info-row .info-value {
  color: var(--muted);
}
.qbo-info-row .info-value.distributor {
  color: #d97706;
  font-weight: 600;
}
.qbo-info-row .info-value.exempt {
  color: #16a34a;
}
.qbo-info-row .info-value.taxable {
  color: #dc2626;
}
.qbo-addr-btns {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

/* ── CONTEXT MENU ─────────────────────────────────── */
.ctx-menu {
  position: fixed;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  min-width: 180px;
  z-index: 2000;
  padding: 4px;
  display: none;
}
.ctx-menu.open {
  display: block;
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: background 0.15s;
}
.ctx-item:hover {
  background: #f1f5f9;
}
.ctx-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.ctx-item.danger {
  color: #dc2626;
}
.ctx-item.danger:hover {
  background: #fef2f2;
}
.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── TOAST ────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  max-width: 400px;
  text-align: center;
}
.toast.show {
  opacity: 1;
}
.toast.toast-error {
  background: rgba(220, 38, 38, 0.94);
}

/* ── WIZARD ───────────────────────────────────────── */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.wizard-step {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.wizard-step .step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--muted);
  flex-shrink: 0;
}
.wizard-step.active .step-num {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.wizard-step.done .step-num {
  border-color: #22c55e;
  background: #22c55e;
  color: #fff;
}
.wizard-step.active {
  color: var(--text);
  font-weight: 600;
}
.wizard-step.done {
  color: #16a34a;
}
.wizard-connector {
  width: 20px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 4px;
}
.wizard-connector.done {
  background: #22c55e;
}

.wizard-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}
.wizard-footer {
  display: flex;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── PROBE ENTRY ──────────────────────────────────── */
.probe-valid {
  color: #16a34a;
}
.probe-invalid {
  color: #dc2626;
}

/* ── TRACKING-SPECIFIC ────────────────────────────── */
tr.tr-archived td {
  color: #94a3b8;
}
tr.tr-exception td {
  background: #fef2f2;
}
tr.tr-stuck td {
  background: #fef2f2;
}
tr.tr-unknown td {
  background: #fffbeb;
}
tr.tr-error td {
  background: #fffbeb;
}

.tracking-status {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.tracking-status.ts-delivered {
  background: #dcfce7;
  color: #16a34a;
}
.tracking-status.ts-in-transit {
  background: #dbeafe;
  color: #2563eb;
}
.tracking-status.ts-exception {
  background: #fee2e2;
  color: #dc2626;
}
.tracking-status.ts-pending {
  background: #fef3c7;
  color: #d97706;
}
.tracking-status.ts-archived {
  background: #f1f5f9;
  color: #94a3b8;
}

.btn-icon-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #94a3b8;
  padding: 4px 8px;
  border-radius: 4px;
  transition:
    color 0.15s,
    background 0.15s;
}
.btn-icon-delete:hover {
  color: #dc2626;
  background: #fee2e2;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.history-table th {
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
}
.history-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
}
.history-table tr.hist-delivered td {
  background: #f0fdf4;
}
.history-table tr.hist-exception td {
  background: #fef2f2;
}

/* ── LOADING / EMPTY STATE ────────────────────────── */
.loading-wrap {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.loading-wrap .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
/* ── STATS ROW ────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 16px 0;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
}
.stat-card .val {
  font-size: 26px;
  font-weight: 700;
}
.stat-card .lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.stat-card.blue .val {
  color: var(--accent);
}
.stat-card.green .val {
  color: #16a34a;
}
.stat-card.amber .val {
  color: #d97706;
}
.stat-card.red .val {
  color: #dc2626;
}
.stat-card.clickable {
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.stat-card.clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.stat-card.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.stat-card.stat-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ── PAGINATION ──────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  font-size: 13px;
  color: var(--muted);
}
.pagination-info {
  font-variant-numeric: tabular-nums;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.page-btn:hover:not(:disabled):not(.active) {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.page-ellipsis {
  min-width: 28px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 1px;
}
.table-loading-overlay {
  position: relative;
}
.table-loading-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.table-loading-overlay.loading::after {
  opacity: 1;
}

/* ── PARSE EMAIL MODAL ────────────────────────────── */
.parse-textarea {
  width: 100%;
  min-height: 200px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: monospace;
  resize: vertical;
}

/* ── CONFIRM DIALOG ───────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.22);
}
.confirm-box h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
.confirm-box p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}
.confirm-box .confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── ESTIMATE REVIEW DIALOG ──────────────────────── */
.estimate-review-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 2600;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.estimate-review-box {
  background: #fff;
  border-radius: 12px;
  max-width: 700px;
  width: 95%;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.28);
  margin: 24px auto;
  animation: modalSlideIn 0.2s ease;
  transition: opacity 0.15s ease;
}
.estimate-review-box .er-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.estimate-review-box .er-header h3 {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
}
.estimate-review-box .er-body {
  padding: 20px 24px;
  max-height: 60vh;
  overflow-y: auto;
}
.estimate-review-box .er-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.er-section {
  margin-bottom: 14px;
}
.er-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.er-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.er-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.er-table th.right,
.er-table td.right {
  text-align: right;
}
.er-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
}
.er-table tr:last-child td {
  border-bottom: none;
}
.er-address {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.er-address-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.er-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
}
.er-summary-row.total {
  font-weight: 700;
  font-size: 14px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
/* ── QBO RESULT SCREEN ───────────────────────────── */
.er-result-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #dcfce7;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.er-result-icon svg {
  width: 28px;
  height: 28px;
  color: #16a34a;
}
.er-result-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}
.er-result-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.er-result-info {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
}
.er-result-info .label {
  font-weight: 600;
  color: var(--muted);
}
.er-result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.er-result-actions .btn {
  width: 100%;
  justify-content: center;
  font-size: 13px;
}
.er-result-actions .btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── ACTIVITY TIMELINE ────────────────────────────── */
.activity-feed {
  padding: 4px 0;
}
.activity-item {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
}
.activity-item:last-child {
  border-bottom: none;
}
.activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 5px;
}
.activity-item .act-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 120px;
  font-variant-numeric: tabular-nums;
}
.activity-item .act-text {
  color: var(--text);
  line-height: 1.4;
}
.activity-item .act-user {
  color: var(--muted);
  font-size: 11px;
}
.activity-empty {
  text-align: center;
  padding: 24px 0;
  font-size: 13px;
  color: var(--muted);
}
.activity-loading {
  text-align: center;
  padding: 16px 0;
  font-size: 12px;
  color: var(--muted);
}

/* ── PRINT ────────────────────────────────────────── */
@media print {
  body > *:not(.modal-backdrop) {
    display: none;
  }
}

/* ── RESPONSIVE BREAKPOINTS ──────────────────────── */
@media (max-width: 1200px) {
  .modal.modal-lg {
    width: 95vw;
  }
}
@media (max-width: 900px) {
  .order-two-col,
  .order-addr-row {
    grid-template-columns: 1fr;
  }
}

/* ── ORDER SIDE PANEL ────────────────────────────── */
.order-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.2);
  z-index: 999;
  display: none;
}
.order-panel-backdrop.open {
  display: block;
}
.order-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 55%;
  max-width: 800px;
  min-width: 500px;
  background: #fff;
  z-index: 1000;
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.15);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.order-panel.open {
  transform: translateX(0);
}
.order-panel .modal-head {
  flex-shrink: 0;
}
.order-panel .modal-tabs {
  flex-shrink: 0;
}
.order-panel .modal-body {
  flex: 1;
  overflow-y: auto;
  max-height: none !important;
}
.order-panel .modal-footer {
  flex-shrink: 0;
}
.data-table tbody tr.row-active {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 var(--accent);
}
/* On narrow screens, fall back to modal behavior */
@media (max-width: 900px) {
  .order-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

/* ── ORDER ACTION BANNER ─────────────────────────── */
.order-action-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  margin-bottom: 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.order-action-banner.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.order-action-banner.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.order-action-banner.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.order-action-banner.done {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #86efac;
}
.order-action-banner .banner-msg {
  flex: 1;
}
.order-action-banner .banner-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  margin-left: 12px;
  transition: filter 0.15s;
}
.order-action-banner .banner-btn:hover {
  filter: brightness(0.92);
}
.order-action-banner.info .banner-btn {
  background: #2563eb;
  color: #fff;
}
.order-action-banner.success .banner-btn {
  background: #16a34a;
  color: #fff;
}
.order-action-banner.warning .banner-btn {
  background: #d97706;
  color: #fff;
}
.order-action-banner .banner-done-icon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}

/* ── TABLE ATTENTION DOTS ────────────────────────── */
.attn-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
  vertical-align: middle;
}
.attn-dot.yellow {
  background: #f59e0b;
}
.attn-dot.green {
  background: #22c55e;
}
.attn-dot.red {
  background: #ef4444;
}

/* ── COLUMN TOGGLE DROPDOWN ──────────────────────── */
.col-toggle-wrap {
  position: relative;
}
.col-toggle-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.col-toggle-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}
.col-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.col-toggle-btn svg {
  width: 14px;
  height: 14px;
}
.col-toggle-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  min-width: 190px;
  z-index: 200;
  display: none;
  padding: 6px 0;
}
.col-toggle-dropdown.open {
  display: block;
}
.col-toggle-dropdown .col-toggle-header {
  padding: 6px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.col-toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.col-toggle-item:hover {
  background: #f1f5f9;
}
.col-toggle-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.col-toggle-item label {
  cursor: pointer;
  flex: 1;
}

/* -- BATCH SELECT CHECKBOX -- */
.data-table .batch-chk-cell {
  width: 36px;
  min-width: 36px;
  text-align: center;
  padding: 6px 8px !important;
}
.data-table .batch-chk-cell input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  vertical-align: middle;
}
.data-table tbody tr.batch-selected {
  background: #eff6ff !important;
}
.data-table tbody tr.batch-selected:hover {
  background: #dbeafe !important;
}

/* -- BATCH ACTION BAR -- */
.batch-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: #1e293b;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.25);
  transform: translateY(100%);
  transition: transform 0.25s ease;
  font-size: 13px;
}
.batch-action-bar.visible {
  transform: translateY(0);
}
.batch-action-bar .batch-count {
  font-weight: 600;
  white-space: nowrap;
  margin-right: 4px;
}
.batch-action-bar .batch-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
}
.batch-action-bar .batch-btn {
  padding: 7px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.batch-action-bar .batch-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.4);
}
.batch-action-bar .batch-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.batch-action-bar .batch-btn.batch-btn-danger {
  background: rgba(239, 83, 80, 0.2);
  border-color: rgba(239, 83, 80, 0.4);
  color: #fca5a5;
}
.batch-action-bar .batch-btn.batch-btn-danger:hover {
  background: rgba(239, 83, 80, 0.35);
}
.batch-action-bar .batch-btn.batch-btn-ghost {
  background: none;
  border-color: transparent;
  color: #94a3b8;
}
.batch-action-bar .batch-btn.batch-btn-ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.batch-action-bar .batch-spacer {
  flex: 1;
}

/* -- BATCH STATUS DROPDOWN -- */
.batch-status-wrap {
  position: relative;
  display: inline-block;
}
.batch-status-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  min-width: 200px;
  z-index: 510;
  display: none;
  padding: 4px 0;
}
.batch-status-dropdown.open {
  display: block;
}
.batch-status-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 14px;
  border: none;
  background: none;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.batch-status-dropdown button:hover {
  background: #f1f5f9;
}

/* ── DATE RANGE FILTER ──────────────────────────── */
.date-range-wrap {
  position: relative;
}
.date-range-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}
.date-range-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}
.date-range-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.date-range-btn.active {
  background: #eff6ff;
  color: var(--accent);
  border-color: var(--accent);
}
.date-range-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.date-range-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  min-width: 200px;
  z-index: 200;
  display: none;
  padding: 6px 0;
}
.date-range-dropdown.open {
  display: block;
}
.date-range-option {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.date-range-option:hover {
  background: #f1f5f9;
}
.date-range-option.selected {
  background: #eff6ff;
  color: var(--accent);
  font-weight: 600;
}
.date-range-custom {
  display: none;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.date-range-custom.show {
  display: block;
}
.date-range-custom label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
  display: block;
}
.date-range-custom input[type="date"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.date-range-custom input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}
.date-range-custom .date-range-apply {
  width: 100%;
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.date-range-custom .date-range-apply:hover {
  background: #1d4ed8;
}

/* ── CUSTOMER HISTORY POPOVER ────────────────────── */
.cust-history-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
}
.cust-history-link:hover {
  border-bottom-color: var(--accent);
}
.cust-history-popover {
  position: fixed;
  z-index: 2100;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 15px 40px rgba(15, 23, 42, 0.18);
  width: 360px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.15s ease;
}
.cust-history-popover .chp-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cust-history-popover .chp-title {
  font-size: 13px;
  font-weight: 700;
}
.cust-history-popover .chp-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1;
}
.cust-history-popover .chp-close:hover {
  background: #f1f5f9;
}
.cust-history-popover .chp-body {
  overflow-y: auto;
  flex: 1;
  padding: 0;
}
.cust-history-popover .chp-loading {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.cust-history-popover .chp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 12px;
}
.cust-history-popover .chp-row:last-child {
  border-bottom: none;
}
.cust-history-popover .chp-row:hover {
  background: #eff6ff;
}
.cust-history-popover .chp-row .chp-date {
  color: var(--muted);
  white-space: nowrap;
  min-width: 72px;
}
.cust-history-popover .chp-row .chp-inv {
  color: var(--muted);
  font-size: 11px;
  min-width: 50px;
}
.cust-history-popover .chp-row .chp-amt {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cust-history-popover .chp-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 0 0 12px 12px;
}
.cust-history-popover .chp-footer .chp-total {
  font-weight: 700;
  color: var(--text);
}

/* ── ORDER AGING INDICATOR ───────────────────────── */
.age-indicator {
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}
.age-indicator.age-normal {
  color: var(--muted);
  background: transparent;
}
.age-indicator.age-warning {
  color: #92400e;
  background: #fef3c7;
}
.age-indicator.age-danger {
  color: #991b1b;
  background: #fee2e2;
}
.age-indicator.age-done {
  color: #166534;
  background: #dcfce7;
}

/* ── REVENUE DASHBOARD ──────────────────────────── */
.revenue-dashboard {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin: 16px 0 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.revenue-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.revenue-header:hover {
  background: #f8fafc;
}
.revenue-header .rev-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.revenue-header .rev-chevron {
  font-size: 12px;
  color: var(--muted);
  transition: transform 0.2s;
}
.revenue-dashboard.collapsed .rev-chevron {
  transform: rotate(-90deg);
}
.revenue-dashboard.collapsed .revenue-body {
  display: none;
}
.revenue-body {
  padding: 0 16px 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.rev-card {
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
}
.rev-card.rev-clickable {
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.rev-card.rev-clickable:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
.rev-card .rev-val {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 2px;
}
.rev-card .rev-lbl {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.rev-card .rev-change {
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
}
.rev-card .rev-change.up {
  color: #166534;
  background: #dcfce7;
}
.rev-card .rev-change.down {
  color: #991b1b;
  background: #fee2e2;
}
.rev-card .rev-change.flat {
  color: var(--muted);
  background: #f1f5f9;
}
.rev-sparkline {
  margin-top: 8px;
}
.rev-sparkline canvas {
  width: 100%;
  height: 80px;
  border-radius: 6px;
  background: #f8fafc;
}

/* ── CUSTOMER HISTORY IN SIDE PANEL ─────────────── */
.panel-cust-history {
  margin-top: 12px;
}
.panel-cust-history .pch-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-cust-history .pch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
  margin: 0 -4px;
  padding-left: 4px;
  padding-right: 4px;
  border-radius: 4px;
}
.panel-cust-history .pch-row:hover {
  background: #eff6ff;
}
.panel-cust-history .pch-row .pch-date {
  color: var(--muted);
  min-width: 68px;
  white-space: nowrap;
}
.panel-cust-history .pch-row .pch-inv {
  color: var(--muted);
  font-size: 11px;
}
.panel-cust-history .pch-row .pch-amt {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.panel-cust-history .pch-summary {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  font-style: italic;
}

/* ── INVENTORY VIEW ──────────────────────────────── */
.inv-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
  flex-wrap: wrap;
}
.inv-header .inv-title {
  font-size: 16px;
  font-weight: 700;
}
.inv-header .inv-updated {
  font-size: 12px;
  color: var(--muted);
}
.inv-header .inv-spacer {
  flex: 1;
}
.inv-table-wrap {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: auto;
  box-shadow: var(--shadow);
}
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.inv-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.inv-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.inv-table th.num {
  text-align: right;
}
.inv-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
  vertical-align: middle;
}
.inv-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.inv-table tbody tr {
  transition: background 0.15s;
}
.inv-table tbody tr:nth-child(even) {
  background: #fafbfd;
}
.inv-table tbody tr:hover {
  background: #eff6ff;
}
.inv-table .inv-item-name {
  font-weight: 500;
}
.inv-table .inv-item-note {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 1px;
}
.inv-sub-tag {
  font-size: 10px;
  color: #7c3aed;
  font-weight: 500;
  margin-left: 3px;
}
.inv-table .inv-category {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.inv-table .inv-stock-input {
  width: 64px;
  padding: 4px 6px;
  text-align: right;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}
.inv-table .inv-stock-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}
.inv-avail-green {
  color: #16a34a;
  font-weight: 600;
}
.inv-avail-yellow {
  color: #d97706;
  font-weight: 600;
}
.inv-avail-red {
  color: #dc2626;
  font-weight: 700;
}
.inv-avail-darkred {
  color: #7f1d1d;
  font-weight: 700;
  background: #fef2f2;
  border-radius: 4px;
  padding: 2px 6px;
}
.inv-section-row td {
  background: #f1f5f9 !important;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 6px 12px !important;
  border-bottom: 1px solid var(--border) !important;
}
/* Shipped Since column — muted to show it's a deduction */
.inv-shipped-col {
  color: var(--muted);
}
/* On Hand column — subtle highlight as the key derived number */
.inv-onhand-col {
  background: rgba(37, 99, 235, 0.03);
}
.inv-onhand {
  font-weight: 600;
}
.inv-onhand-neg {
  font-weight: 700;
  color: #dc2626;
}
/* Visual separator before the planning zone (Committed column) */
.inv-plan-col {
  border-left: 2px solid var(--border) !important;
}
/* Since-date subtitle in Shipped column header */
.inv-since-date {
  font-size: 9px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #94a3b8;
}
/* Last Count cell: input + receive/confirm buttons + age indicator */
.inv-count-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.inv-receive-btn {
  padding: 2px 5px;
  font-size: 11px;
  border: 1px solid #bbf7d0;
  border-radius: 3px;
  background: #f0fdf4;
  cursor: pointer;
  color: #16a34a;
  font-weight: 700;
  line-height: 1;
}
.inv-receive-btn:hover {
  background: #dcfce7;
  border-color: #16a34a;
}
.inv-confirm-btn {
  padding: 2px 5px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f8fafc;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.inv-confirm-btn:hover {
  background: #eff6ff;
  border-color: var(--accent);
  color: var(--accent);
}
.inv-age {
  font-size: 10px;
  font-weight: 500;
  min-width: 20px;
  text-align: right;
}
.inv-age-fresh {
  color: #16a34a;
}
.inv-age-stale {
  color: #d97706;
}
.inv-age-old {
  color: #dc2626;
}
.inv-age-none {
  color: #94a3b8;
}
/* ── Filter bar ──────────────────────────────────── */
.inv-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.inv-filters-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 2px;
}
.inv-filter-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.inv-filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #eff6ff;
}
.inv-filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* ── Stale row highlighting ──────────────────────── */
.inv-stale {
  background: #fefce8 !important;
}
.inv-stale td {
  opacity: 0.7;
}
.inv-stale td:first-child,
.inv-stale td:nth-child(2) {
  opacity: 1;
}
/* ── Needs Attention section ──────────────────────── */
.inv-attention {
  margin-top: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fffbeb;
}
.inv-attention-ok {
  background: #f0fdf4;
  color: #16a34a;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}
.inv-attention-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}
.inv-attention-group {
  margin-bottom: 8px;
}
.inv-attention-group:last-child {
  margin-bottom: 0;
}
.inv-attention-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.inv-attention-out {
  color: #dc2626;
}
.inv-attention-low {
  color: #d97706;
}
.inv-attention-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 3px 0;
  font-size: 12px;
}
.inv-attention-name {
  font-weight: 600;
  color: var(--text);
  min-width: 160px;
}
.inv-attention-detail {
  color: var(--muted);
  font-size: 11px;
}

/* ── ORDERS MAP ──────────────────────────────────── */
.orders-map-panel {
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: none;
}
.orders-map-panel.open {
  display: block;
}
.orders-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.orders-map-header:hover {
  background: #f1f5f9;
}
.orders-map-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.orders-map-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
}
.orders-map-close:hover {
  background: #e2e8f0;
  color: var(--text);
}
#ordersMapContainer {
  height: 480px;
  width: 100%;
}
.orders-map-legend {
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-size: 12px;
  line-height: 1.6;
}
.orders-map-legend-title {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.orders-map-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.orders-map-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* ── CUSTOMS EXPORT LOG MODAL ────────────────────── */
.export-log-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.export-log-form .form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.export-log-form .form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 50px;
}
.export-log-form .form-row input[type="date"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.export-log-form .form-row input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}
.export-log-format-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.export-log-format-toggle button {
  padding: 7px 20px;
  border: none;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.15s;
}
.export-log-format-toggle button:not(:first-child) {
  border-left: 1px solid var(--border);
}
.export-log-format-toggle button.active {
  background: var(--accent);
  color: #fff;
}
.export-log-format-toggle button:hover:not(.active) {
  background: #f1f5f9;
  color: var(--text);
}
.export-log-preview {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── DUPLICATE CUSTOMER WARNING ──────────────────── */
.dup-customer-warn {
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 6px 0 2px;
  font-size: 12px;
  color: #92400e;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.dup-customer-warn:hover {
  background: #fef3c7;
}
.dup-customer-warn .dup-icon {
  flex-shrink: 0;
  font-size: 14px;
  margin-top: 1px;
}
.dup-customer-warn .dup-text {
  flex: 1;
}
.dup-customer-warn strong {
  color: #78350f;
}

/* ── DATA COMPLETENESS SCORE ─────────────────────── */
.completeness-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
  margin-left: 10px;
  vertical-align: middle;
}
.completeness-badge.score-low {
  background: #fef2f2;
  color: #dc2626;
}
.completeness-badge.score-mid {
  background: #fffbeb;
  color: #d97706;
}
.completeness-badge.score-high {
  background: #f0fdf4;
  color: #16a34a;
}
.completeness-badge.score-full {
  background: #eff6ff;
  color: var(--accent);
}
.completeness-bar {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
.completeness-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.score-low .completeness-bar-fill {
  background: #dc2626;
}
.score-mid .completeness-bar-fill {
  background: #d97706;
}
.score-high .completeness-bar-fill {
  background: #16a34a;
}
.score-full .completeness-bar-fill {
  background: var(--accent);
}

/* Table completeness mini-bar */
.completeness-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.completeness-mini-bar {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.completeness-mini-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}
.completeness-mini.c-green .completeness-mini-fill {
  background: #16a34a;
}
.completeness-mini.c-yellow .completeness-mini-fill {
  background: #d97706;
}
.completeness-mini.c-red .completeness-mini-fill {
  background: #dc2626;
}
.completeness-mini .c-pct {
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.completeness-mini.c-green .c-pct {
  color: #16a34a;
}
.completeness-mini.c-yellow .c-pct {
  color: #d97706;
}
.completeness-mini.c-red .c-pct {
  color: #dc2626;
}

/* Missing fields list in order detail */
.completeness-missing {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
  color: #92400e;
  line-height: 1.6;
}
.completeness-missing.all-done {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}
.completeness-missing .missing-label {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Shipping estimate line */
.shipping-estimate-line {
  font-size: 11px;
  color: var(--muted);
  min-height: 16px;
  margin-top: 2px;
  font-style: italic;
  transition: opacity 0.3s;
}
.shipping-estimate-line .est-loading {
  opacity: 0.6;
}
.shipping-estimate-line .est-value {
  color: #16a34a;
  font-weight: 600;
  font-style: normal;
}
.shipping-estimate-line .est-error {
  color: #dc2626;
  font-style: normal;
}

/* ── ZIP CODE AUTO-FILL HIGHLIGHT ────────────────── */
.zip-autofilled {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
  transition:
    background 0.5s,
    border-color 0.5s;
}

/* ── REVENUE TAB ─────────────────────────────────── */
.stats-row.cols-5 {
  grid-template-columns: repeat(5, 1fr);
}
.stat-card.clickable.filter-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.stat-card .filter-hint {
  font-size: 10px;
  color: var(--accent);
  margin-top: 2px;
  font-weight: 500;
}
.section-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}
.section-card-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.section-card-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}
.section-card-body {
  padding: 0;
}
.summary-expand-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  margin-top: -1px;
  overflow: hidden;
  max-height: 400px;
  overflow-y: auto;
}
.summary-expand-panel .expand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.5);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
.summary-expand-panel .expand-row:last-child {
  border-bottom: none;
}
.summary-expand-panel .expand-row:hover {
  background: #f8fafc;
}
.risk-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.risk-badge.medium-risk {
  background: #fef3c7;
  color: #d97706;
}
.risk-badge.high-risk {
  background: #fee2e2;
  color: #dc2626;
}

/* Revenue tab: constrain all content to readable width, centered */
.revenue-content {
  max-width: 960px;
  margin: 0 auto;
}

/* Inventory tab: center and shrink to fit content */
#v-inventory {
  max-width: 960px;
  margin: 0 auto;
}
#v-inventory .inv-table {
  width: auto;
}

@media (max-width: 768px) {
  .stats-row.cols-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── ACCESSIBILITY: Focus indicators ────────────────── */
.data-table tbody tr:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.data-table tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── ACCESSIBILITY: Tracking status text patterns for color-blind ── */
.tracking-status.ts-delivered::before {
  content: "\2713 ";
}
.tracking-status.ts-exception::before {
  content: "\26A0 ";
}
.tracking-status.ts-pending::before {
  content: "\25CB ";
}

/* ── MOBILE: Larger touch targets ───────────────────── */
@media (max-width: 768px) {
  .batch-chk-cell input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }
  .batch-chk-cell {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── PRINT: Orders table and form ───────────────────── */
@media print {
  .toolbar,
  .stats-row,
  .batch-action-bar,
  .modal-footer,
  .modal-close,
  .pipeline-bar,
  .tab-bar,
  #orderPanelBackdrop {
    display: none !important;
  }
  .data-table-wrap {
    overflow: visible !important;
    max-height: none !important;
  }
  .data-table {
    font-size: 10px;
  }
  .data-table th,
  .data-table td {
    padding: 4px 6px;
  }
  #orderPanel {
    position: static !important;
    width: 100% !important;
    box-shadow: none !important;
    transform: none !important;
  }
  #orderPanel .modal-body {
    max-height: none !important;
    overflow: visible !important;
  }
}

/* ── Auto-save indicator ────────────────────────────── */
.autosave-indicator {
  font-size: 11px;
  color: var(--muted);
  transition: opacity 0.3s;
}
.autosave-indicator.saving {
  color: var(--accent);
}
.autosave-indicator.saved {
  color: #16a34a;
}
