:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e6e8ec;
  --border-subtle: #f0f2f5;
  --text: #101828;
  --text-secondary: #475467;
  --text-muted: #667085;
  --primary: #1b56db;
  --primary-hover: #1746b3;
  --primary-soft: #eef4ff;
  --emerald: #067647;
  --emerald-soft: #ecfdf3;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --rose: #b42318;
  --rose-soft: #fef3f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 44px -8px rgba(16, 24, 40, 0.16), 0 8px 16px -4px rgba(16, 24, 40, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Inter", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  min-block-size: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  position: sticky;
  inset-block-start: 0;
  block-size: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-mark {
  inline-size: 30px;
  block-size: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1b56db, #3b82f6);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-title { font-size: 14.5px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }

.nav-list { display: flex; flex-direction: column; gap: 3px; }

.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background 0.14s, color 0.14s;
  inline-size: 100%;
  text-align: left;
}
.nav-item:hover { background: #f2f4f7; color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.nav-icon { inline-size: 16px; block-size: 16px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-label { flex: 1; min-inline-size: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 999px;
  background: #f2f4f7;
  color: var(--text-secondary);
}
.nav-badge:empty { display: none; }
.nav-item.active .nav-badge { background: rgba(27, 86, 219, 0.12); color: var(--primary); }
.nav-badge-warn { background: var(--amber-soft); color: var(--amber); }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--border-subtle);
}
.sync-row { display: flex; align-items: center; gap: 7px; }
.status-dot {
  inline-size: 6px;
  block-size: 6px;
  border-radius: 50%;
  background: #12b76a;
}
.sync-time { font-size: 11.5px; color: var(--text-muted); }

/* Main Content */
.main-content {
  padding: 22px 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-inline-size: 0;
  max-inline-size: 1520px;
  inline-size: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.page-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

.toast-banner {
  display: none;
  padding: 9px 14px;
  border-radius: 9px;
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid #abefc6;
  font-size: 13px;
  font-weight: 500;
}
.toast-banner.show { display: block; }
.toast-banner.error { background: var(--rose-soft); color: var(--rose); border-color: #fecdca; }

.view-section { display: none; flex-direction: column; gap: 16px; }
.view-section.active { display: flex; }

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.kpi-currency {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: #f2f4f7;
  padding: 1px 6px;
  border-radius: 4px;
}
.kpi-value-row { display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.kpi-num { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; color: var(--text); line-height: 1.15; }
.kpi-unit { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.kpi-sub { font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; gap: 8px; }
.kpi-bar { block-size: 3px; border-radius: 999px; background: #f2f4f7; overflow: hidden; margin-top: 2px; }
.kpi-bar-fill { block-size: 100%; border-radius: 999px; background: var(--primary); }
.kpi-card.accent-emerald .kpi-bar-fill { background: #12b76a; }
.kpi-card.accent-amber .kpi-bar-fill { background: #f79009; }

/* Dashboard Two-Col Live Tables */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-inline-size: 0;
}
.card-flush { padding: 0; overflow: hidden; gap: 0; }
.card-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.card-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }

/* Filters & Segmented */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.filter-left { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; flex: 1; }

.input-search, .select-input, textarea, input[type="text"], input[type="number"] {
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.input-search:focus, .select-input:focus, textarea:focus, input[type="text"]:focus, input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 86, 219, 0.1);
}
.input-search { inline-size: 260px; max-inline-size: 100%; }

.toggle-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.count-pill { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.segmented {
  display: inline-flex;
  gap: 2px;
  background: #eaecf0;
  padding: 3px;
  border-radius: 8px;
}
.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.seg-btn.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
.seg-cnt { font-size: 11px; font-variant-numeric: tabular-nums; padding: 0 5px; border-radius: 999px; background: #f2f4f7; color: var(--text-secondary); }
.seg-cnt-warn { background: var(--amber-soft); color: var(--amber); }

.subtab-panel { display: none; flex-direction: column; gap: 14px; }
.subtab-panel.active { display: flex; }

/* Tables */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(620px, 72vh);
  container-type: inline-size;
}
.table-wrapper.compact-table { max-block-size: 380px; }

.data-table {
  inline-size: 100%;
  min-inline-size: 820px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.compact-table .data-table { min-inline-size: 540px; }
.data-table.has-custom-widths { min-inline-size: 100%; }

.data-table thead { position: sticky; inset-block-start: 0; z-index: 3; }
.data-table thead th {
  position: relative;
  background: #f9fafb;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table:not([data-table-id="split"]) thead th:first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 4;
}
.data-table tbody th {
  background: #fff;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table tbody th:first-child {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
}
.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table tbody tr:last-child td,
.data-table tbody tr:last-child th { border-bottom: 0; }
.data-table tbody tr:hover td,
.data-table tbody tr:hover th { background: #f9fafb; }

/* Column Resize Handle */
.col-resizer {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  inline-size: 10px;
  cursor: col-resize;
  touch-action: none;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.col-resizer::after {
  content: "";
  inline-size: 2px;
  block-size: 56%;
  border-radius: 2px;
  background: transparent;
  transition: background 0.14s, block-size 0.14s;
}
.data-table thead:hover .col-resizer::after {
  background: #d0d5dd;
}
.col-resizer:hover::after,
.col-resizer:focus-visible::after,
.col-resizer.is-resizing::after {
  background: var(--primary);
  block-size: 76%;
}
.col-resizer:focus-visible {
  outline: none;
}
body.is-col-resizing,
body.is-col-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.data-table td .select-input {
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
}
.data-table td input.split-amt {
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
}

.cell-truncate { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-stack { display: flex; flex-direction: column; gap: 1px; min-inline-size: 0; }
.cell-primary { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.code-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 5px;
  font-variant-numeric: tabular-nums;
}

.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-strong { font-weight: 600; color: var(--text); }
.num-muted { color: #98a2b3; }
.num-warn { font-weight: 600; color: var(--amber); }
.col-action { text-align: right !important; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-open { background: var(--amber-soft); color: var(--amber); }
.badge-closed { background: var(--emerald-soft); color: var(--emerald); }
.badge-danger { background: var(--rose-soft); color: var(--rose); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.anomaly-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.topbar-sync-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  background: #f4f6f9;
  border: 1px solid #e4e7ec;
  border-radius: 999px;
  padding: 5px 11px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.topbar-sync-time::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald, #12b76a);
  flex-shrink: 0;
}
.rev-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Order link chips */
.brief-order-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.brief-order-chip {
  appearance: none;
  border: 1px solid #d0d5dd;
  background: #f9fafb;
  color: var(--primary);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.brief-order-chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}
/* Dual-Track Close Modal */
.dlg-wide { max-width: 680px; width: calc(100vw - 32px); }
.close-track-banner {
  background: #f5f8ff;
  border: 1px solid #d9e6ff;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.close-tracks-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.close-track-card {
  background: #fff;
  border: 1px solid #eaecf0;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.close-track-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.close-track-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.close-track-flow {
  font-size: 11.5px;
  color: #667085;
}
.close-track-info {
  background: #f9fafb;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.close-track-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 720px) {
  .close-tracks-grid { grid-template-columns: 1fr; }
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.14s, border-color 0.14s;
  white-space: nowrap;
}
.btn-icon { inline-size: 14px; block-size: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: #fff; color: var(--text-secondary); border-color: #d0d5dd; box-shadow: var(--shadow-xs); }
.btn-outline:hover { background: #f9fafb; color: var(--text); border-color: #98a2b3; }
.btn-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-link:hover { background: var(--primary-soft); }
.btn-link-muted { color: var(--text-muted); font-weight: 500; }
.btn-link-muted:hover { background: #f2f4f7; color: var(--text); }
.muted-text { font-size: 12px; color: var(--text-muted); }

/* Native Modal Dialog */
dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  max-inline-size: min(460px, 92vw);
  inline-size: 100%;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
dialog.dialog-wide { max-inline-size: min(800px, 94vw); }
dialog[open] { display: flex; flex-direction: column; gap: 14px; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop {
  background: rgba(16, 24, 40, 0.4);
  backdrop-filter: blur(2px);
  overflow: hidden;
  overscroll-behavior: contain;
}
.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.dialog-title { margin: 0; font-size: 16px; font-weight: 700; }
.dialog-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-muted); }
.icon-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  inline-size: 28px;
  block-size: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-close:hover { background: #f2f4f7; color: var(--text); }
.dialog-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.two-col-fields { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.split-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--primary-soft);
  border-radius: 9px;
}
.split-sum-left { display: flex; align-items: baseline; gap: 8px; }
.split-sum-val { font-size: 18px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* WeChat-style Red Todo Dot (auto-hides when 0) */
.todo-dot {
  min-inline-size: 18px;
  block-size: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.35);
}
.todo-dot:empty { display: none; }

/* AI 3-Color Advice Banners & Action Button */
.btn-ai-green {
  background: #067647;
  color: #fff;
  border-color: #067647;
}
.btn-ai-green:hover { background: #05603a; border-color: #05603a; }
.ai-spark { font-size: 12px; }

.ai-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  border: 1px solid transparent;
}
.ai-box.green { background: #ecfdf3; border-color: #abefc6; color: #067647; }
.ai-box.amber { background: #fffaeb; border-color: #fedf89; color: #b54708; }
.ai-box.red   { background: #fef3f2; border-color: #fecdca; color: #b42318; }

.ai-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  white-space: nowrap;
}
.ai-box.green .ai-pill { background: #d1fadf; color: #05603a; }
.ai-box.amber .ai-pill { background: #fef0c7; color: #93370d; }
.ai-box.red   .ai-pill { background: #fee4e2; color: #912018; }

.tx-card.level-green { border-color: #abefc6; background: #f8fffb; }
.tx-card.level-amber { border-color: #fedf89; background: #fffdf5; }
.tx-card.level-red   { border-color: #fecdca; background: #fffafa; }

.ai-dot {
  display: inline-block;
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.ai-dot.green { background: #12b76a; }
.ai-dot.amber { background: #f79009; }
.ai-dot.red   { background: #f04438; }

.btn-warn-outline {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #fedf89;
}
.btn-warn-outline:hover { background: #fef0c7; }

/* Inline Progress Cell in Order Master Table */
.order-row { cursor: pointer; }
.prog-cell { display: flex; flex-direction: column; gap: 4px; min-inline-size: 0; overflow: hidden; }
.prog-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; min-inline-size: 0; }
.prog-main { font-weight: 600; color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-inline-size: 0; }
.prog-pct { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.prog-track { block-size: 4px; border-radius: 999px; background: #eaecf0; overflow: hidden; }
.prog-fill { block-size: 100%; border-radius: 999px; background: var(--primary); }
.prog-fill.emerald { background: #12b76a; }
.prog-fill.amber { background: #f79009; }
.prog-foot { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Native <progress> bar (semantic role="progressbar" with custom styling) */
progress.prog-native {
  appearance: none;
  border: 0 solid;
  display: block;
  inline-size: 100%;
  block-size: 5px;
  --progress-bar-radius: 1e5px;
  --progress-bar-track: #eaecf0;
  --progress-bar-fill: var(--primary);
  border-radius: var(--progress-bar-radius);
  background: var(--progress-bar-track);
  overflow: clip;
}
progress.prog-native.emerald { --progress-bar-fill: #12b76a; }
progress.prog-native.amber { --progress-bar-fill: #f79009; }
progress.prog-native.violet { --progress-bar-fill: #6366f1; }

/* Vertically stacked dual-progress cell (出运+收款 / 付款+收票) */
.data-table tbody td.cell-dual {
  vertical-align: top;
  padding-top: 12px;
  padding-bottom: 10px;
}
.dual-prog {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-inline-size: 0;
}
.dual-prog-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-inline-size: 0;
}
.dual-prog-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  min-inline-size: 0;
}
.dual-prog-left {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-inline-size: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dual-prog-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.dual-prog-val {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.dual-prog-right {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}
.dual-prog-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ASD-STE100 structured AI approval block */
.ste-box {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 9px 11px;
}
.ste-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  line-height: 1.45;
}
.ste-action {
  font-weight: 600;
}
.ste-facts {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  line-height: 1.5;
}
.ste-notes {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  line-height: 1.45;
  padding-top: 4px;
  border-top: 1px dashed rgba(0, 0, 0, 0.12);
  width: 100%;
}
.fac-dual-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  padding: 6px 0 2px;
}
@media (max-width: 640px) {
  .fac-dual-bars { grid-template-columns: 1fr; }
}
progress.prog-native::-webkit-progress-bar {
  background: transparent;
}
progress.prog-native::-webkit-progress-value {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.3s;
}
progress.prog-native::-moz-progress-bar {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.3s;
}

/* Slide-over Right Drawer (native <dialog>) */
dialog.drawer-right {
  margin: 0 0 0 auto;
  max-inline-size: min(740px, 94vw);
  inline-size: 100%;
  block-size: 100vh;
  max-block-size: 100vh;
  border-radius: 16px 0 0 16px;
  border: 0;
  border-left: 1px solid var(--border);
  padding: 0;
  overflow: hidden;
}
dialog.drawer-right[open] { display: flex; flex-direction: column; gap: 0; }
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.drawer-title-row { display: flex; align-items: center; gap: 8px; }
.drawer-head-actions { display: flex; align-items: center; gap: 8px; }
.drawer-body {
  padding: 18px 22px 28px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--bg);
}

.lifeline-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.life-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.life-label { font-size: 11.5px; color: var(--text-muted); }
.life-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.life-sub { font-size: 11.5px; color: var(--text-muted); }

.drawer-block {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.drawer-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.drawer-block-title { font-size: 14px; font-weight: 700; color: var(--text); margin: 0; }

.tx-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fcfcfd;
}
.tx-card.pending { border-color: #fedf89; background: #fffdf5; }
.tx-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tx-confirm-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr auto;
  gap: 8px;
  align-items: end;
}
.tx-confirm-bar input { padding: 5px 8px; font-size: 12.5px; }

.fac-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fac-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fac-nums { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12.5px; font-variant-numeric: tabular-nums; align-items: baseline; }
.fac-prog-row { display: flex; align-items: center; gap: 8px; }
.fac-prog-row progress.prog-native { flex: 1; }
.fac-prog-pct { font-size: 11.5px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.fac-pay-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fac-pay-card.is-approving {
  border-color: #b2ddff;
  background: #f8fbff;
}
.fac-pay-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.fac-pay-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  min-inline-size: 0;
}
.fac-pay-time {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.fac-pay-route {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  line-height: 1.45;
}
.fac-pay-company {
  font-weight: 600;
  color: var(--text);
}
.fac-pay-arrow {
  color: var(--text-muted);
  font-weight: 600;
}
.fac-pay-note {
  font-size: 12px;
  color: var(--text-secondary);
  background: #f9fafb;
  border-radius: 6px;
  padding: 5px 8px;
  line-height: 1.45;
  word-break: break-word;
}
.erp-jump-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.erp-jump-btn:hover { background: #dbeafe; }

.approval-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}
.approval-check-chip {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-secondary);
}

details.ship-collapse summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
details.ship-collapse summary::-webkit-details-marker { display: none; }
.ship-mini-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.ship-mini-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f9fafb;
  border-radius: 7px;
  font-size: 12.5px;
  gap: 10px;
}
.ship-mini-amt {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ship-mini-cny {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.ship-mini-rate {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Inline Unassigned Bank Flow Linker inside Order Drawer */
.inline-linker {
  border: 1px dashed #93c5fd;
  background: #f8fbff;
  border-radius: 9px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inline-linker-list {
  max-block-size: 190px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inline-linker-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12.5px;
}
.inline-linker-info { display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.inline-linker-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Other Expenses Aggregation inside Order Drawer */
.oe-summary-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.oe-total { font-size: 15px; font-weight: 700; color: var(--text); }
.oe-cat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.oe-cat-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.oe-cat-pill:hover { background: #f2f4f7; color: var(--text); }
.oe-cat-pill.active {
  background: var(--primary-soft);
  border-color: #b2ddff;
  color: var(--primary);
}
.oe-cat-pill strong { font-weight: 700; color: inherit; }
.oe-cat-cnt { font-size: 11px; opacity: 0.72; }

.oe-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.oe-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 11px;
  border: 1px solid var(--border-subtle);
  background: #fcfcfd;
  border-radius: 8px;
  font-size: 12.5px;
}
.oe-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-inline-size: 0;
}
.oe-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-inline-size: 0;
}
.oe-item-provider {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.oe-item-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.oe-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.oe-item-amt-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.oe-item-amt { font-weight: 700; color: var(--text); }
.oe-item-doc-amt { font-size: 11px; color: var(--text-muted); }

.slip-btn {
  appearance: none;
  border: 1px solid #d0d5dd;
  background: #fff;
  color: var(--primary);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.slip-btn:hover { background: var(--primary-soft); border-color: #b2ddff; }

.reconciled-chip {
  font-size: 11px;
  color: var(--emerald);
  font-weight: 600;
  white-space: nowrap;
}

#dlg-slip.is-fullscreen {
  max-inline-size: 96vw;
  max-block-size: 94vh;
  inline-size: 96vw;
  block-size: 94vh;
}
#dlg-slip.is-fullscreen .slip-preview-wrap {
  max-block-size: none;
  flex: 1;
}
.slip-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.slip-zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-xs {
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.2;
}
.slip-preview-wrap {
  background: #f2f4f7;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  max-block-size: 72vh;
  overflow: auto;
  user-select: none;
}
.slip-preview-wrap.is-zoomed {
  display: block;
  text-align: center;
  cursor: grab;
}
.slip-preview-wrap.is-zoomed.is-dragging {
  cursor: grabbing;
}
.slip-preview-wrap img {
  max-inline-size: 100%;
  max-block-size: 68vh;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.12);
  cursor: zoom-in;
  transition: width 0.12s ease;
}
.slip-preview-wrap.is-zoomed img {
  max-inline-size: none;
  max-block-size: none;
  cursor: zoom-out;
}

/* Receipt Slip Claim Upload & Audit */
.claim-upload-grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.slip-dropzone {
  border: 1.5px dashed #93c5fd;
  background: #f8fbff;
  border-radius: 10px;
  min-block-size: 230px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.slip-dropzone:hover,
.slip-dropzone:focus-visible,
.slip-dropzone.drag-over {
  outline: none;
  border-color: var(--primary);
  background: #eef4ff;
  box-shadow: 0 0 0 3px rgba(27, 86, 219, 0.12);
}
.slip-dropzone.has-file {
  border-style: solid;
  border-color: var(--border);
  background: #f9fafb;
  cursor: default;
}
.drop-title { font-weight: 700; color: var(--primary); margin-bottom: 5px; font-size: 13px; }
.slip-dropzone img { max-inline-size: 100%; max-block-size: 190px; border-radius: 6px; cursor: zoom-in; }
.slip-preview-card { display: flex; flex-direction: column; align-items: center; inline-size: 100%; }
.slip-preview-actions { display: flex; gap: 6px; margin-top: 6px; align-items: center; justify-content: center; }
.claim-fields-col { display: flex; flex-direction: column; gap: 10px; }
.two-eq-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three-eq-fields { display: grid; grid-template-columns: 0.9fr 1.15fr 1fr; gap: 10px; }
.claim-thumb {
  inline-size: 38px;
  block-size: 28px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}
.claim-cell-row { display: flex; align-items: center; gap: 8px; }
.audit-top-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.audit-slip-thumb {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px;
  background: #f2f4f7;
  cursor: pointer;
  text-align: center;
}
.audit-slip-thumb img { max-inline-size: 100%; max-block-size: 170px; border-radius: 5px; display: block; margin: 0 auto; }

/* AI OCR Highlight & Multi-Select Salesperson Chips */
.ai-box.info { background: var(--primary-soft); border-color: #b2ddff; color: var(--primary); }
.ai-box.info .ai-pill { background: #dbeafe; color: var(--primary); }
.ai-filled {
  border-color: #60a5fa !important;
  background: #f5f9ff !important;
  transition: background 0.4s, border-color 0.4s;
}
.sales-multi-box {
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.sales-selected-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sales-selected-row:empty { display: none; }
.sales-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 9px 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
.sales-chip button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.sales-chip button:hover { color: #fff; }
.sales-filter-input {
  border: 0 !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  border-radius: 0 !important;
  padding: 3px 2px 5px !important;
  font-size: 12.5px !important;
  box-shadow: none !important;
}
.sales-options-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-block-size: 82px;
  overflow-y: auto;
}
.sales-opt-pill {
  appearance: none;
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.sales-opt-pill:hover { background: #f2f4f7; color: var(--text); }
.sales-opt-pill.recommended { border-color: #93c5fd; background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sales-opt-pill.selected { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lifeline-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; block-size: auto; }
}
