* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  font-size: 14px;
}

/* ===== Header ===== */
.app-header {
  display: flex;
  align-items: center;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 18px;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.logo-toggle {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  transition: transform 0.1s;
}
.logo-toggle:hover { transform: scale(1.04); }
.logo-toggle img,
.logo-toggle video { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-title { font-size: 18px; font-weight: 600; color: #111827; }
.app-nav { display: flex; gap: 4px; margin-left: 24px; flex: 1; }
.nav-link {
  padding: 8px 14px;
  border-radius: 6px;
  color: #4b5563;
  text-decoration: none;
  font-size: 14px;
}
.nav-link:hover { background: #f3f4f6; color: #111827; }
.nav-link.active { background: #1f2937; color: #fff; }
.user-info { display: flex; align-items: center; gap: 12px; color: #4b5563; }
.user-info .role-badge {
  background: #eef2ff; color: #4338ca;
  padding: 2px 8px; border-radius: 12px; font-size: 12px;
}

/* ===== Main + cards ===== */
.main { padding: 22px; }
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { font-size: 16px; margin-bottom: 14px; color: #111827; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ===== Buttons ===== */
.btn {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  transition: all 0.1s;
}
.btn:hover { background: #f9fafb; border-color: #9ca3af; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 3px 10px; font-size: 12px; }

/* ===== Toolbar strip (batch select + stats) ===== */
.toolbar-strip {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  align-items: stretch;
}
.toolbar-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 16px;
}
.toolbar-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.toolbar-section textarea.input { min-width: 320px; }
.stats-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.selection-summary {
  padding: 10px 16px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #93c5fd;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 700;
  color: #1e40af;
  letter-spacing: 0.3px;
  flex: 1;
  display: flex;
  align-items: center;
}

/* ===== Forms ===== */
.input, select.input, textarea.input {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}
.input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15); }
.input:disabled, .input[readonly] { background: #f3f4f6; color: #6b7280; }
textarea.input { resize: vertical; }
label { font-size: 13px; color: #4b5563; }
label.field { display: flex; flex-direction: column; gap: 4px; }

/* ===== Login ===== */
.login-wrap {
  min-height: calc(100vh - 100px);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; border: 1px solid #e5e7eb;
  border-radius: 10px; padding: 32px;
  width: 360px; box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; text-align: center; }
.login-card .sub { color: #6b7280; text-align: center; margin-bottom: 22px; }
.login-card label.field { margin-bottom: 14px; }
.login-card .input { padding: 8px 12px; }
.error-msg { color: #dc2626; font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
table.data thead th {
  background: #f9fafb;
  color: #4b5563;
  font-weight: 600;
  position: sticky; top: 0;
  border-bottom: 1px solid #e5e7eb;
}
table.data tbody tr:hover { background: #fafbff; }
table.data tbody tr.dirty { background: #fef9c3; }
table.data tbody tr.dirty:hover { background: #fef08a; }
table.data input.cell, table.data select.cell {
  width: 100%;
  min-width: 100px;
  padding: 4px 6px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  border-radius: 4px;
}
table.data input.cell:focus, table.data select.cell:focus {
  outline: none;
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
table.data input.cell:hover, table.data select.cell:hover { border-color: #d1d5db; }
table.data input.cell[readonly], table.data input.cell:disabled,
table.data select.cell:disabled {
  color: #6b7280; background: #f9fafb;
}
table.data .col-narrow { max-width: 90px; }
table.data .col-mid { max-width: 130px; }
table.data .col-wide { min-width: 160px; }
table.data .col-checkbox { width: 32px; padding: 8px 6px; }
table.data .col-toggle { width: 28px; padding: 4px 0; text-align: center; }
table.data .col-actions { white-space: nowrap; }
table.data .col-audit { color: #2563eb; cursor: pointer; text-decoration: underline; }
table.data .col-audit-h { width: 50px; }

/* ----- Tree rows (USSH parent + IP children) ----- */
table.data.tree tbody tr.ussh-row {
  background: #f8fafc;
  border-top: 2px solid #e5e7eb;
}
table.data.tree tbody tr.ussh-row:hover { background: #eef2ff; }
table.data.tree tbody tr.ip-row td { background: #fff; }
table.data.tree tbody tr.ip-row { border-bottom: 1px dashed #f1f5f9; }
table.data.tree tbody tr.ip-row.dirty td { background: #fef9c3; }

table.data .tree-toggle {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0 4px;
  font-size: 13px;
  color: #4b5563;
  border-radius: 4px;
  line-height: 1.4;
}
table.data .tree-toggle:hover { background: #e5e7eb; color: #111827; }

table.data .u-cell { display: table-cell; }
table.data .u-cell .ip-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
}

table.data .u-tree-cell .ip-tree-line {
  color: #cbd5e1;
  margin-right: 4px;
  font-family: monospace;
}
table.data .u-tree-cell {
  padding-left: 18px;
  color: #cbd5e1;
}
table.data .ip-summary-cell {
  text-align: center;
  color: #6b7280;
}

/* ----- Section header (mode toggle) ----- */
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 { margin: 0; }
.section-head .spacer { flex: 1; }

/* ----- Sheet mode ----- */
table.data.sheet tbody tr { background: #fff; }
table.data.sheet tbody tr.dirty { background: #fef9c3; }
table.data.sheet tbody tr.new   { background: #ecfdf5; }
table.data.sheet tbody tr.dirty.new { background: #fef9c3; }
table.data.sheet input.cell[readonly] { background: #f9fafb; color: #6b7280; }

/* ----- Tree mode (read-only display) ----- */
table.data.tree.readonly td.ro-cell {
  color: #1f2937;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
table.data.tree.readonly tr.ip-row td.ro-cell { background: #fff; }
table.data.tree.readonly tr.ussh-row strong { color: #111827; font-size: 14px; }
table.data.tree.readonly tr.ussh-row { background: #f8fafc; }

table.data .sum-cell {
  color: #6b7280;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  padding-right: 12px;
}

/* ===== Click popover (replaces hover popovers) ===== */
.audit-pop {
  position: absolute;
  background: #1f2937; color: #f9fafb;
  padding: 10px 12px; border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  font-size: 12px; line-height: 1.5;
  max-width: 380px; z-index: 200;
  white-space: normal;
}
.audit-pop .pop-close {
  float: right;
  cursor: pointer;
  color: #9ca3af;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  margin-left: 8px;
}
.audit-pop .pop-close:hover { color: #fff; }
.audit-pop .entry { padding: 4px 0; border-bottom: 1px solid #374151; }
.audit-pop .entry:last-child { border-bottom: none; }
.audit-pop .meta { color: #9ca3af; font-size: 11px; }

/* IP nos popup */
.ip-nos-pop { max-height: 300px; overflow-y: auto; min-width: 200px; }
.ip-count-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  background: #dbeafe;
  color: #1e40af;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.ip-count-badge:hover { background: #bfdbfe; }

/* Column visibility dropdown */
.col-vis-pop { min-width: 200px; max-height: 400px; overflow-y: auto; }
.col-vis-item {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0; font-size: 12px; color: #f9fafb;
  cursor: pointer;
}
.col-vis-item input[type="checkbox"] { margin: 0; }

/* Sort headers */
.sort-header {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sort-header:hover { color: #2563eb; }

/* Status timestamp link */
.status-ts-link {
  color: #2563eb;
  cursor: pointer;
  text-decoration: underline;
  font-size: 12px;
  white-space: nowrap;
}
.status-ts-link:hover { color: #1d4ed8; }

/* Status columns */
table.data .status-col { min-width: 100px; max-width: 140px; }

/* Archive section */
.archive-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 8px;
}
.archive-toggle {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  user-select: none;
}
.archive-toggle:hover { color: #374151; }
.archive-table tbody tr { background: #fafafa; }
.archive-table tbody tr:hover { background: #f3f4f6; }
.archived-row td { color: #6b7280; }

/* ===== Modal ===== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff; border-radius: 10px; padding: 22px;
  width: 420px; max-width: 90vw;
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
}
.modal h3 { font-size: 16px; margin: 0; }
.modal .modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.modal-close-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 20px; line-height: 1; color: #555;
  cursor: pointer; user-select: none;
}
.modal-close-x:hover { background: #f0f0f0; color: #000; }
.modal .body { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== Logo lightbox ===== */
.logo-lightbox {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
  flex-direction: column;
  gap: 16px;
}
.logo-lightbox-stage {
  display: flex; align-items: center; justify-content: center;
}
.logo-lightbox-media {
  max-width: 80vw;
  max-height: 80vh;
  cursor: pointer;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  background: #fff;
  display: block;
}
.logo-lightbox-counter {
  color: #f9fafb;
  font-size: 14px;
  background: rgba(0,0,0,0.5);
  padding: 4px 12px;
  border-radius: 12px;
}

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 26px; left: 50%;
  transform: translateX(-50%);
  background: #1f2937; color: #fff;
  padding: 10px 22px; border-radius: 8px;
  opacity: 0; transition: opacity 0.25s;
  z-index: 300; font-size: 13px;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.error { background: #dc2626; }

/* ===== Misc ===== */
.muted { color: #6b7280; font-size: 13px; }
.empty { padding: 40px; text-align: center; color: #9ca3af; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 12px; background: #f3f4f6; color: #374151; font-size: 12px; }
.config-list { display: flex; flex-direction: column; gap: 6px; max-width: 700px; }
.config-list .item { display: flex; gap: 6px; align-items: center; }
.config-list .item .input { flex: 1; }

/* Status editor (wider for role checkboxes) */
.config-list .status-item {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 6px 0; border-bottom: 1px solid #f3f4f6;
  transition: background 0.15s;
}
.config-list .status-item .input { width: 160px; flex: none; }
.config-list .status-item .drag-handle {
  cursor: grab; font-size: 16px; color: #9ca3af; user-select: none;
}
.config-list .status-item .drag-handle:active { cursor: grabbing; }
.config-list .status-item.dragging { opacity: 0.4; }
.config-list .status-item.drag-over { background: #dbeafe; border-radius: 4px; }
.role-group { display: flex; gap: 8px; flex-wrap: wrap; }
.role-cb { display: flex; align-items: center; gap: 2px; font-size: 12px; color: #4b5563; cursor: pointer; white-space: nowrap; }
.role-cb input[type="checkbox"] { margin: 0; }

/* Batch status confirm */
.batch-confirm-text {
  margin: 8px 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: #1e40af;
}

/* IP / warehouse history link */
.hist-link {
  cursor: pointer;
  color: #6366f1;
  font-size: 11px;
  margin-left: 2px;
  user-select: none;
}
.hist-link:hover { color: #4338ca; }

/* IP history popover */
.ip-hist-pop { min-width: 220px; }
.ip-hist-pop .hist-title {
  font-weight: 600;
  font-size: 12px;
  color: #374151;
  margin-bottom: 4px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 4px;
}
.ip-hist-pop .hist-current { color: #059669; font-weight: 600; }
.ip-hist-pop .hist-old { color: #6b7280; }

/* ===== Truck badges ===== */
.truck-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  font-size: 12px;
  color: #6b7280;
}
.truck-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #fef3c7;
  color: #92400e;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.truck-badge-x {
  cursor: pointer;
  margin-left: 2px;
  color: #b45309;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}
.truck-badge-x:hover { color: #dc2626; }
.truck-badge-link {
  color: inherit;
  text-decoration: none;
}
.truck-badge-link:hover {
  text-decoration: underline;
}
.truck-add-btn {
  margin-left: 6px;
  font-size: 11px !important;
  padding: 1px 6px !important;
}
.truck-tags-inline {
  display: block;
  font-size: 10px;
  color: #92400e;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Distribution page ===== */
.dist-mismatch { background: #fef3c7 !important; }
.dist-mismatch:hover { background: #fde68a !important; }
.dist-highlight { color: #dc2626 !important; font-weight: 700; }
.dist-ok { color: #059669; font-weight: 600; }
.dist-warn { color: #d97706; font-weight: 600; }
.dist-conf-row { background: #f8fafc; }
.dist-conf-row:hover { background: #f1f5f9 !important; }
.dist-conf-detail { font-size: 12px; color: #6b7280; }
.dist-conf-boxes { font-weight: 600; color: #374151; }
.dist-conf-meta { font-size: 11px; color: #9ca3af; }
.dist-fraction { color: #d97706; font-weight: 600; white-space: nowrap; font-size: 12px; }

/* ===== Pallet plan modal ===== */
.plan-badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.plan-badge.planned { background: #fff7ed; border: 1px solid #fed7aa; color: #d97706; }
.plan-badge.shipped { background: #f0fdf4; border: 1px solid #bbf7d0; color: #16a34a; }
.warn-text { color: #d97706; font-weight: 600; }
.plan-meta > div { margin-bottom: 4px; }
.plan-meta details summary { cursor: pointer; color: #6b7280; padding: 4px 0; }
.plan-meta details > div { padding-left: 12px; }
.pallet-list { margin: 8px 0; max-height: 250px; overflow-y: auto; }
.pallet-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px dashed #e5e7eb;
}
.pallet-row:last-child { border-bottom: none; }
.pallet-row .input {
  flex: 1 1 0; min-width: 60px; width: auto;
  padding: 4px 6px; font-size: 12px;
}
.pallet-row .btn { flex-shrink: 0; }
.pallet-row .pallet-vol {
  flex: 1 1 0; min-width: 70px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  text-align: right;
  padding: 4px 6px;
}
.pallet-row.pallet-head {
  border-bottom: 1px solid #d1d5db;
  background: #f9fafb;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  padding: 6px 0;
}
.pallet-row.pallet-head > span { flex: 1 1 0; padding: 0 6px; min-width: 60px; }
.modal.plan-modal {
  width: 1100px;
  max-width: 98vw;
}
.modal.plan-modal .pallet-row > span:first-child { flex-shrink: 0; }
.pallet-totals { display: flex; gap: 16px; padding: 8px; background: #f9fafb; border-radius: 4px;
  font-size: 13px; margin-top: 4px; flex-wrap: wrap; }

/* ===== IP links ===== */
.ip-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}
.ip-link:hover {
  text-decoration: underline;
  color: #1d4ed8;
}
.ip-detail-icon {
  display: inline-block;
  margin-left: 4px;
  color: #9ca3af;
  text-decoration: none;
  font-size: 12px;
  cursor: pointer;
}
.ip-detail-icon:hover {
  color: #2563eb;
}

/* ===== IP Summary page ===== */
.cost-cell {
  font-weight: 600;
  color: #059669;
  white-space: nowrap;
}
.cost-breakdown-cell {
  font-size: 12px;
  line-height: 1.4;
}
.cost-item {
  white-space: nowrap;
}
.cost-item .muted {
  font-size: 11px;
}

/* ===== IP Detail page ===== */
.ip-detail-card {
  max-width: 900px;
  margin: 0 auto;
}
.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: #6b7280;
  text-decoration: none;
  font-size: 14px;
}
.back-link:hover {
  color: #2563eb;
}
.ip-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.ip-detail-header h2 {
  margin: 0;
}
.ip-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 24px;
  margin-bottom: 24px;
  padding: 16px;
  background: #f8fafc;
  border-radius: 8px;
}
.ip-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ip-info-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}
.ip-info-value {
  font-size: 14px;
  color: #111827;
  font-weight: 500;
}
.ip-detail-section {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}
.ip-detail-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #374151;
}
.data-table.compact {
  font-size: 13px;
}
.data-table.compact th,
.data-table.compact td {
  padding: 6px 10px;
}
.detail-truck {
  margin-right: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  padding: 3px 10px;
}

/* Timeline */
.timeline {
  padding-left: 16px;
  border-left: 2px solid #e5e7eb;
}
.timeline-item {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  position: relative;
}
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2563eb;
  margin-top: 4px;
  margin-left: -21px;
  flex-shrink: 0;
}
.timeline-content {
  flex: 1;
}
.timeline-time {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 2px;
}

/* Audit list */
.audit-list {
  font-size: 13px;
}
.audit-item {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}
.audit-time {
  color: #6b7280;
  white-space: nowrap;
  font-size: 12px;
  min-width: 140px;
}
.audit-user {
  color: #2563eb;
  font-weight: 500;
  min-width: 60px;
}
.audit-desc {
  color: #374151;
}
tr.highlight {
  background: #dbeafe !important;
}

/* ===== Truck page ===== */
.truck-link {
  font-weight: 600;
}
.cost-badge {
  background: #d1fae5;
  color: #065f46;
}
.truck-ussh-block {
  margin-bottom: 20px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.truck-ussh-header {
  background: #f8fafc;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
}
.truck-ussh-block .data-table {
  margin: 0;
  border: none;
  border-radius: 0;
}
.truck-ussh-block .data-table th {
  background: #f1f5f9;
}

/* Distribution toolbar & selection */
.dist-toolbar {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 10px 0;
}
.batch-select-section {
  flex-shrink: 0;
}
.dist-sel-info {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.stats-badge {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}
.stats-badge.warn {
  background: #fef3c7;
  color: #92400e;
}
.dist-badge {
  background: #d1fae5 !important;
  color: #065f46 !important;
}
.dist-truck-badges {
  margin-left: 6px;
}
tr.selected {
  background: #eff6ff !important;
}
.wh-pending-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===== U单管理 / IP单管理 / 分发计划 ===== */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.page-head h2 { margin: 0; }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ussh-link, .ip-link {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.ussh-link:hover, .ip-link:hover { text-decoration: underline; }

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ussh-mgmt-table .timeline-cell { min-width: 320px; }
.ussh-mgmt-table tr td { vertical-align: middle; }

.inline-timeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.inline-timeline .tl-node {
  display: inline-block;
  padding: 3px 9px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 12px;
  color: #374151;
  cursor: help;
  white-space: nowrap;
}
.inline-timeline .tl-node.current {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 600;
}
.inline-timeline .tl-arrow {
  color: #9ca3af;
  font-weight: 700;
  cursor: help;
}

.vertical-timeline {
  position: relative;
  padding-left: 24px;
  margin-top: 8px;
}
.vertical-timeline::before {
  content: "";
  position: absolute;
  left: 8px; top: 4px; bottom: 4px;
  width: 2px;
  background: #e5e7eb;
}
.vt-item {
  position: relative;
  margin-bottom: 14px;
}
.vt-marker {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 2px white;
}
.vt-create .vt-marker { background: #16a34a; }
.vt-status .vt-marker { background: #2563eb; }
.vt-truck .vt-marker  { background: #f59e0b; }
.vt-arrival .vt-marker { background: #14b8a6; }
.vt-confirm .vt-marker { background: #8b5cf6; }
.vt-archive .vt-marker { background: #6b7280; }
.vt-delete .vt-marker  { background: #ef4444; }
.vt-update .vt-marker  { background: #94a3b8; }

.vt-body { font-size: 13px; }
.vt-line1 { color: #111827; }
.vt-label { font-weight: 600; }
.vt-meta {
  color: #6b7280;
  font-size: 12px;
}
.vt-since {
  font-size: 11px;
  margin-top: 2px;
}

.ip-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ip-chip {
  display: inline-block;
  padding: 4px 10px;
  background: #f3f4f6;
  border-radius: 12px;
  font-size: 13px;
}
.ip-chip.current {
  background: #fde68a;
  font-weight: 600;
}

.ip-mgmt-table td, .ussh-mgmt-table td { font-size: 13px; }

/* ============================================================ */
/* Professional list pages (卡车单 / IP单管理 / 分发计划 / U单管理)  */
/* ============================================================ */

/* --- Page header & breadcrumb --- */
.page-shell { max-width: 1400px; margin: 0 auto; }
.page-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 14px;
}
.page-title-bar h1 {
  font-size: 22px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}
.page-title-bar .page-subtitle {
  color: #6b7280;
  font-size: 13px;
  margin-top: 2px;
}
.page-title-bar .page-actions { display: flex; gap: 8px; align-items: center; }

/* --- Stat cards (summary panel at top of list pages) --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.stat-card .stat-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  line-height: 1.1;
}
.stat-card .stat-sub {
  font-size: 12px;
  color: #6b7280;
}
.stat-card.accent-blue   .stat-value { color: #1d4ed8; }
.stat-card.accent-green  .stat-value { color: #047857; }
.stat-card.accent-orange .stat-value { color: #b45309; }
.stat-card.accent-purple .stat-value { color: #6d28d9; }

/* --- Section / panel cards --- */
.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafbfc;
}
.panel-head h3 {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin: 0;
}
.panel-head .panel-count {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  padding: 2px 8px;
  background: #f3f4f6;
  border-radius: 10px;
}
.panel-toolbar {
  padding: 12px 18px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.panel-body { padding: 0; }
.panel-body.padded { padding: 16px 18px; }

/* --- Tabs / segmented control --- */
.tab-bar {
  display: inline-flex;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 14px;
}
.tab-bar .tab {
  padding: 6px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #4b5563;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-bar .tab:hover { color: #111827; }
.tab-bar .tab.active {
  background: #fff;
  color: #111827;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.tab-bar .tab .tab-count {
  background: #e5e7eb;
  padding: 0 7px;
  border-radius: 10px;
  font-size: 11px;
  color: #4b5563;
  font-weight: 600;
}
.tab-bar .tab.active .tab-count { background: #dbeafe; color: #1d4ed8; }

/* --- Pro data table --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafb;
  color: #4b5563;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table.compact thead th { padding: 8px 12px; font-size: 11px; }
.data-table.compact tbody td { padding: 8px 12px; font-size: 13px; }

.data-table .num    { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .center { text-align: center; }
.data-table .nowrap { white-space: nowrap; }

.data-table .empty {
  padding: 40px;
  text-align: center;
  color: #9ca3af;
  font-style: italic;
}

/* Override .panel containing a table (no rounded corners/border conflict) */
.panel .table-wrap {
  border: none;
  border-radius: 0;
  background: transparent;
}

/* --- Search input --- */
.search-input {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-input::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0.55;
}
.search-input input {
  padding: 7px 12px 7px 30px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  width: 280px;
  background: #fff;
}
.search-input input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

/* --- Plan-no monospace badge --- */
.code-badge {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
  background: #f3f4f6;
  padding: 3px 8px;
  border-radius: 4px;
}

/* --- Status pills --- */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill.planned { background: #fef3c7; color: #92400e; }
.pill.shipped { background: #d1fae5; color: #065f46; }
.pill.pickup  { background: #dbeafe; color: #1e40af; }
.pill.dist    { background: #ede9fe; color: #5b21b6; }
.pill.muted   { background: #f3f4f6; color: #4b5563; }

/* --- Truck link tweaks --- */
.truck-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  white-space: nowrap;
}
.truck-link:hover { text-decoration: underline; }

/* --- Inline timeline polish --- */
.ussh-mgmt-table .inline-timeline { padding: 2px 0; }

/* --- Responsive --- */
@media (max-width: 760px) {
  .page-title-bar { flex-direction: column; align-items: flex-start; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
