/* ============================================================
   项目 CSS 规范（base rule）
   ------------------------------------------------------------
   1. 全站表格一律使用 Excel 表格样式（display:table;
      border-collapse:collapse; 单元格 1px 实线边框）。
   2. 严禁使用卡片式表格布局（display:grid / display:flex
      应用于 table/tr/td，或 thead{display:none} 全局隐藏表头，
      或 td::before{content:attr(data-label)} 卡片标签）。
   3. 如某页面确需卡片式布局，必须显式标记 .card-table 类，
      且仅在该类作用域内生效，不得污染全局或其它表格。
      新增卡片式布局前必须与项目负责人确认。
   4. 本规则不可通过任何后续提交或 hotfix 绕过。
   ============================================================ */
:root {
  --bg: #f4f4f5;
  --content: #ffffff;
  --content-2: #f7f7f8;
  --content-3: #ededf0;
  --foreground: #11181c;
  --muted: #71717a;
  --faint: #a1a1aa;
  --line: #e4e4e7;
  --primary: #006fee;
  --primary-50: #eef6ff;
  --primary-100: #d8ecff;
  --primary-700: #005bc4;
  --success: #17c964;
  --success-50: #eefcf4;
  --warning: #f5a524;
  --danger: #f31260;
  --danger-50: #fff0f5;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 18px 48px rgba(17, 24, 39, 0.14);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--foreground);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-700);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 252px;
  overflow-y: auto;
  padding: 18px 12px;
  background: var(--content);
  border-right: 1px solid rgba(228, 228, 231, 0.7);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 16px;
  margin-bottom: 8px;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(0, 111, 238, 0.22);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: var(--foreground);
  font-size: 15px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav-group {
  margin: 16px 12px 6px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
}

.sidebar a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  margin-bottom: 3px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: #52525b;
  font-weight: 650;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar a:hover {
  color: var(--foreground);
  background: var(--content-2);
}

.sidebar a.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(0, 111, 238, 0.20);
}

.sidebar a.active::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 999px;
  background: #fff;
}

.ui-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.sidebar .ui-icon {
  width: 17px;
  height: 17px;
  opacity: 0.9;
}

body:not(.has-svg-icons) .sidebar a::after,
body:not(.has-svg-icons) button::before,
body:not(.has-svg-icons) .button-link::before {
  display: inline-grid;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  place-items: center;
  color: currentColor;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

body:not(.has-svg-icons) .sidebar a::after {
  order: -1;
  margin-right: 0;
  opacity: 0.9;
  content: "•";
}

body:not(.has-svg-icons) .sidebar a[href$="/dashboard"]::after { content: "⌂"; }
body:not(.has-svg-icons) .sidebar a[href$="/stores"]::after { content: "▥"; }
body:not(.has-svg-icons) .sidebar a[href$="/products"]::after { content: "□"; }
body:not(.has-svg-icons) .sidebar a[href$="/orders"]::after { content: "≡"; }
body:not(.has-svg-icons) .sidebar a[href$="/shipments"]::after { content: "⇥"; }
body:not(.has-svg-icons) .sidebar a[href$="/suppliers"]::after { content: "▤"; }
body:not(.has-svg-icons) .sidebar a[href$="/factory-skus"]::after { content: "▦"; }
body:not(.has-svg-icons) .sidebar a[href$="/purchase-orders"]::after { content: "▣"; }
body:not(.has-svg-icons) .sidebar a[href$="/skus"]::after { content: "▧"; }
body:not(.has-svg-icons) .sidebar a[href$="/finance"]::after { content: "¥"; }
body:not(.has-svg-icons) .sidebar a[href$="/automation"]::after { content: "◇"; }
body:not(.has-svg-icons) .sidebar a[href$="/platforms"]::after { content: "⌁"; }
body:not(.has-svg-icons) .sidebar a[href$="/data-sources"]::after { content: "◫"; }
body:not(.has-svg-icons) .sidebar a[href$="/permissions"]::after { content: "◈"; }
body:not(.has-svg-icons) .sidebar a[href$="/logs"]::after { content: "☰"; }
body:not(.has-svg-icons) .sidebar a[href$="/settings"]::after { content: "⚙"; }
/* 线下供货 */
body:not(.has-svg-icons) .sidebar a[href$="/offline/customers"]::after { content: "◉"; }
body:not(.has-svg-icons) .sidebar a[href$="/offline/orders"]::after { content: "▣"; }
body:not(.has-svg-icons) .sidebar a[href$="/offline/returns"]::after { content: "↩"; }
body:not(.has-svg-icons) .sidebar a[href$="/offline/reconciliation"]::after { content: "☑"; }

body:not(.has-svg-icons) button::before,
body:not(.has-svg-icons) .button-link::before {
  content: "✓";
}

body:not(.has-svg-icons) button.ghost::before,
body:not(.has-svg-icons) .button-link.secondary::before {
  content: "·";
}

body:not(.has-svg-icons) button[data-modal-target*="create"]::before,
body:not(.has-svg-icons) button[data-modal-target*="add"]::before,
body:not(.has-svg-icons) button[data-modal-target*="store-create"]::before,
body:not(.has-svg-icons) button[data-modal-target*="product-create"]::before,
body:not(.has-svg-icons) button[data-modal-target*="finance-create"]::before,
body:not(.has-svg-icons) button[data-modal-target*="purchase-create"]::before,
body:not(.has-svg-icons) button[data-modal-target*="supplier-create"]::before,
body:not(.has-svg-icons) button[data-modal-target*="factory-sku-create"]::before,
body:not(.has-svg-icons) button[data-modal-target*="source-create"]::before,
body:not(.has-svg-icons) button[data-modal-target*="automation-create"]::before {
  content: "+";
}

body:not(.has-svg-icons) button[data-modal-target*="edit"]::before {
  content: "✎";
}

body:not(.has-svg-icons) button[data-modal-target*="delete"]::before,
body:not(.has-svg-icons) .danger-button::before {
  content: "×";
}

body:not(.has-svg-icons) button[data-modal-target*="import"]::before {
  content: "⇧";
}

body:not(.has-svg-icons) button[data-modal-target*="shipment"]::before {
  content: "⇥";
}

body:not(.has-svg-icons) button[data-modal-close]::before {
  content: "×";
}

body:not(.has-svg-icons) button[type="submit"]::before {
  content: "✓";
}

.brand .ui-icon,
.badge .ui-icon,
.db-chip .ui-icon,
.user-chip .ui-icon {
  width: 14px;
  height: 14px;
}

.main {
  margin-left: 252px;
  padding: 22px 28px 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  margin: -22px -28px 24px;
  padding: 12px 28px;
  background: rgba(244, 244, 245, 0.82);
  border-bottom: 1px solid rgba(228, 228, 231, 0.7);
  backdrop-filter: saturate(180%) blur(14px);
}

.topbar > div,
.topbar form {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar form {
  margin: 0;
}

.topbar strong {
  white-space: nowrap;
}

.db-chip,
.user-chip,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 520px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge.warning {
  color: #9a6700;
  background: #fff7e6;
}

.badge.success {
  color: #067647;
  background: var(--success-50);
}

.user-chip {
  background: var(--content);
  color: #52525b;
  box-shadow: var(--shadow-sm);
}

.page-head {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 0;
  color: var(--foreground);
  letter-spacing: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

p {
  margin: 0;
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel,
.toolbar-form,
.finance-summary,
.add-record-panel,
.all-records-panel {
  background: var(--content);
  border: 1px solid rgba(228, 228, 231, 0.65);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric {
  min-height: 108px;
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin-top: 12px;
  color: var(--foreground);
  font-size: 34px;
  line-height: 1;
}

.panel,
.toolbar-form,
.finance-summary,
.add-record-panel,
.all-records-panel {
  padding: 16px;
}

.toolbar-form,
.finance-summary,
.add-record-panel,
.all-records-panel {
  margin-bottom: 16px;
}

.split,
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

table {
  display: table;
  width: 100%;
  overflow: visible;
  border: 0;
  border-spacing: 0;
  border-collapse: collapse;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

th,
td {
  padding: 0;
  border-bottom: 0;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: #52525b;
  background: var(--content-2);
  font-weight: 800;
  white-space: nowrap;
}

td {
  min-width: 0;
  color: #27272a;
}

/* 卡片式表格（仅用于明确标记 .card-table 的表格） */
.card-table thead {
  display: none;
}

.card-table tbody {
  display: grid;
  gap: 12px;
}

.card-table tbody tr {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px 16px;
  padding: 14px;
  border: 1px solid rgba(228, 228, 231, 0.72);
  border-radius: var(--radius);
  background: var(--content);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.card-table td::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.sheet-panel td::before {
  display: none !important;
  content: none !important;
}
  border-color: rgba(0, 111, 238, 0.20);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

td[colspan] {
  grid-column: 1 / -1;
}

td[colspan]::before {
  display: none;
}

form {
  margin: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  outline: none;
  background: var(--content-2);
  color: var(--foreground);
  font: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
select:hover,
textarea:hover {
  background: var(--content-3);
}

input:focus,
select:focus,
textarea:focus {
  background: var(--content);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 111, 238, 0.14);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

input[type="file"] {
  padding: 7px;
  background: var(--content);
  border-color: var(--line);
}

textarea {
  min-width: min(720px, 100%);
  resize: vertical;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #fff;
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(0, 111, 238, 0.18);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

button:hover,
.button-link:hover {
  color: #fff;
  background: var(--primary-700);
  box-shadow: 0 10px 22px rgba(0, 111, 238, 0.22);
}

button:active,
.button-link:active {
  transform: translateY(1px);
}

.button-link.btn-sm,
button.btn-sm {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
}

.page-head .private-toggle {
  position: absolute;
  top: 12px;
  right: 16px;
  width: auto;
}

.page-head {
  position: relative;
  padding-right: 160px;
}

.sync-split {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.sync-left {
  flex: 1 1 50%;
  min-width: 0;
}
.sync-right {
  flex: 1 1 50%;
  min-width: 0;
  border-left: 1px solid var(--line, #e5e7eb);
  padding-left: 16px;
}
.job-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 12px;
}
.job-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed #eee;
}
.job-list li:last-child { border-bottom: 0; }
.job-id { color: #999; }
.job-store { color: #333; font-weight: 500; }
.job-type { color: #666; }
.job-status {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
}
.job-status-pending { background: #f0f0f0; color: #666; }
.job-status-running { background: #e6f4ff; color: #1677ff; }
.job-status-success { background: #e6f7ec; color: #389e0d; }
.job-status-failed { background: #ffe4e6; color: #d9363e; }
.job-progress { color: #888; }

button.ghost,
.button-link.secondary {
  color: #3f3f46;
  background: var(--content-2);
  box-shadow: none;
}

button.ghost:hover,
.button-link.secondary:hover {
  color: var(--primary-700);
  background: var(--primary-50);
  box-shadow: none;
}

.danger-button {
  background: var(--danger);
  box-shadow: 0 8px 18px rgba(243, 18, 96, 0.16);
}

.danger-button:hover {
  background: #d20f55;
  box-shadow: 0 10px 22px rgba(243, 18, 96, 0.20);
}

.table-actions,
.toolbar-form form,
.inline-form,
.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.table-actions form {
  margin: 0;
}

.star-cell {
  width: 72px;
  text-align: center;
}

.supplier-star-form {
  display: inline-flex;
  margin: 0;
}

.supplier-star-button,
.supplier-star-static {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 28px;
  line-height: 1;
}

.supplier-star-button {
  padding: 0;
  border: 0;
  color: #a1a1aa;
  background: transparent;
  box-shadow: none;
}

.supplier-star-button:hover {
  color: #f5a524;
  background: #fff7e6;
  box-shadow: none;
  transform: scale(1.04);
}

.supplier-star-button.active,
.supplier-star-static.active {
  color: #f5a524;
}

body:not(.has-svg-icons) .supplier-star-button::before {
  content: "";
}

.finance-filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--content-2);
}

.finance-filter-form select,
.finance-filter-form input {
  min-height: 36px;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.filter-actions button,
.filter-actions .button-link {
  flex: 1;
}

.finance-records-table,
.all-records-panel > table {
  display: table;
  width: 100%;
  table-layout: fixed;
  overflow: hidden;
  padding-bottom: 2px;
  border: 1px solid rgba(228, 228, 231, 0.65);
  border-radius: var(--radius);
  background: var(--content);
  box-shadow: var(--shadow-sm);
}

.finance-records-table thead,
.all-records-panel > table thead {
  display: table-header-group;
}

.finance-records-table tbody,
.all-records-panel > table tbody {
  display: table-row-group;
  min-width: 0;
}

.finance-records-table tbody tr,
.all-records-panel > table tbody tr {
  display: table-row;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}

.finance-records-table tbody tr:hover,
.all-records-panel > table tbody tr:hover {
  background: #fafafa;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.finance-records-table th,
.finance-records-table td,
.all-records-panel > table th,
.all-records-panel > table td {
  display: table-cell;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
}

.finance-records-table td::before,
.all-records-panel > table td::before {
  display: none;
}

.finance-records-table tr:last-child td,
.all-records-panel > table tr:last-child td {
  border-bottom: 0;
}

.finance-records-table .table-actions,
.all-records-panel > table .table-actions {
  align-items: flex-start;
}

.compact-list-table,
.main > table {
  display: table;
  width: 100%;
  table-layout: fixed;
  overflow: hidden;
  border: 1px solid rgba(228, 228, 231, 0.65);
  border-radius: var(--radius);
  background: var(--content);
  box-shadow: var(--shadow-sm);
}

.compact-list-table thead,
.main > table thead {
  display: table-header-group;
}

.compact-list-table tbody,
.main > table tbody {
  display: table-row-group;
}

.compact-list-table tbody tr,
.main > table tbody tr {
  display: table-row;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}

.compact-list-table tbody tr:hover,
.main > table tbody tr:hover {
  background: #fafafa;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.compact-list-table th,
.compact-list-table td,
.main > table th,
.main > table td {
  display: table-cell;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.compact-list-table td::before,
.main > table td::before {
  display: none;
}

.compact-list-table tr:last-child td,
.main > table tr:last-child td {
  border-bottom: 0;
}

.inline-form input {
  width: 132px;
}

.compact-button {
  min-height: 28px;
  padding: 4px 8px;
  margin-top: 4px;
}

.password-secret {
  display: inline-flex;
  max-width: 180px;
  vertical-align: middle;
  word-break: break-all;
}

.password-toggle {
  min-height: 26px;
  margin: 0 0 0 6px;
  padding: 3px 8px;
  color: var(--primary-700);
  background: var(--primary-50);
}

.sub-account-line {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.sub-account-line:last-child {
  border-bottom: 0;
}

.automation-platform-panel,
.automation-stage-head {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(228, 228, 231, 0.72);
  border-radius: var(--radius);
  background: var(--content);
  box-shadow: var(--shadow-sm);
}

.automation-stage-title {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.automation-stage-title span {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-weight: 850;
}

.automation-platforms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.platform-choice {
  display: grid;
  gap: 3px;
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--content-2);
  color: #3f3f46;
}

.platform-choice:hover,
.platform-choice.active {
  border-color: rgba(0, 111, 238, 0.38);
  background: var(--primary-50);
  color: var(--primary-700);
}

.platform-choice span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.automation-account-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 10px;
}

.automation-account-form label {
  display: grid;
  gap: 6px;
  color: #3f3f46;
  font-size: 13px;
  font-weight: 750;
}

.automation-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.automation-category-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px;
  border-radius: 999px;
  background: var(--content-2);
}

.automation-category-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--content-2);
  color: #3f3f46;
  font-weight: 800;
}

.automation-category-tabs a:hover,
.automation-category-tabs a.active {
  border-color: rgba(0, 111, 238, 0.34);
  background: var(--primary-50);
  color: var(--primary-700);
}

.automation-category-tabs span {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.automation-category-item .compact-button {
  width: 28px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
}

.danger-lite {
  color: var(--danger) !important;
  background: var(--danger-50) !important;
}

.automation-table td:nth-child(4) {
  min-width: 220px;
}

.automation-table {
  display: table;
  width: 100%;
  min-width: 1100px;
  table-layout: fixed;
  overflow: hidden;
  border: 1px solid rgba(228, 228, 231, 0.78);
  border-radius: var(--radius);
  border-collapse: separate;
  border-spacing: 0;
  background: var(--content);
  box-shadow: var(--shadow-sm);
}

.automation-table thead {
  display: table-header-group;
}

.automation-table tbody {
  display: table-row-group;
}

.automation-table tr,
.automation-table tbody tr {
  display: table-row;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.automation-table tbody tr:hover {
  background: #fafafa;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.automation-table tbody tr.automation-row-completed {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.14), rgba(239, 246, 255, 0.92) 24%, rgba(255, 255, 255, 0.98));
}

.automation-table tbody tr.automation-row-completed:hover {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.18), rgba(219, 234, 254, 0.95) 24%, rgba(255, 255, 255, 0.98));
}

.automation-table th,
.automation-table td {
  display: table-cell;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.automation-table tr.automation-row-completed td:first-child {
  box-shadow: inset 4px 0 0 #3b82f6;
}

.automation-table tr.automation-row-completed td:nth-child(2) strong {
  color: #1d4ed8;
}

.automation-table tr.automation-row-completed .badge.success {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.28);
}

.automation-table td::before {
  display: none;
}

.automation-table tr:last-child td {
  border-bottom: 0;
}

.automation-table th:nth-child(1),
.automation-table td:nth-child(1) {
  width: 58px;
}

.automation-table th:nth-child(2),
.automation-table td:nth-child(2) {
  width: 18%;
}

.automation-table th:nth-child(3),
.automation-table td:nth-child(3) {
  width: 140px;
}

.automation-table th:nth-child(4),
.automation-table td:nth-child(4) {
  width: 180px;
  min-width: 0;
}

.automation-table th:nth-child(5),
.automation-table td:nth-child(5) {
  width: 18%;
}

.automation-table th:nth-child(7),
.automation-table td:nth-child(7) {
  width: 260px;
}

.automation-bulk-form {
  display: grid;
  gap: 12px;
  overflow-x: auto;
}

.automation-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  padding: 12px;
  border: 1px solid rgba(228, 228, 231, 0.72);
  border-radius: var(--radius);
  background: var(--content);
  box-shadow: var(--shadow-sm);
}

.automation-interval {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #3f3f46;
  font-size: 13px;
  font-weight: 750;
}

.automation-interval input {
  width: 94px;
  min-height: 34px;
}

.automation-table th:first-child,
.automation-table td:first-child {
  width: 64px;
  text-align: center;
}

.automation-steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.automation-steps li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: #3f3f46;
  line-height: 1.45;
}

.automation-steps span {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.automation-steps-large {
  margin-top: 12px;
}

.automation-execute-summary {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--content-2);
}

.address-field-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.address-field-map div {
  display: grid;
  gap: 4px;
  min-height: 74px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--content-2);
}

.address-field-map span {
  color: var(--muted);
  font-size: 12px;
}

.address-book-form textarea {
  min-width: 100%;
}

.json-textarea {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #18181b;
  background: #fafafa;
}

.takeover-panel ul {
  margin: 12px 0 0;
  padding-left: 20px;
}

.takeover-panel li {
  margin-bottom: 6px;
  color: #3f3f46;
}

.thumb {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--content-2);
}

.thumb.small {
  width: 44px;
  height: 44px;
}

.long-text {
  max-width: 280px;
  color: #9a6700;
  line-height: 1.55;
}

.selling-points-cell {
  min-width: 260px;
}

.selling-points-scroll {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 10px 40px 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--content-2);
  color: #374151;
  line-height: 1.6;
  font-size: 13px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}

.selling-points-scroll:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 8px rgba(59,130,246,.1);
}

.sp-truncated {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-expand-hint {
  position: absolute;
  bottom: 2px;
  right: 8px;
  font-size: 9px;
  color: #c4b5fd;
}

.desensitized-block {
  margin-top: 6px;
  padding: 6px 8px;
  background: #f5f3ff;
  border-left: 3px solid #8b5cf6;
  border-radius: 0 4px 4px 0;
  font-size: 11px;
  color: #6d28d9;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.desensitized-block::before {
  content: "脱敏版";
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  background: #ede9fe;
  color: #7c3aed;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.factory-style-table {
  min-width: 1540px;
}

/* 明细视图覆盖：取消 min-width 限制 */
.factory-style-table.factory-detail-table {
  min-width: 0 !important;
  width: 100% !important;
}

/* 款号视图卡片式布局仅应用于不含 .factory-detail-table 的 .factory-style-table */
.factory-style-table:not(.factory-detail-table) thead { display: none !important; }
.factory-style-table:not(.factory-detail-table) tbody { display: grid !important; width: 100%; min-width: 0; gap: 12px; }
.factory-style-table:not(.factory-detail-table) tr { display: grid !important; width: 100%; min-width: 0; grid-template-columns: 122px minmax(170px, 1fr) minmax(205px, 1.12fr) 128px minmax(180px, 1fr) 126px; grid-template-areas: "image info variants price selling actions" "image info variants price meta actions" "image info variants price status actions"; gap: 10px 12px; padding: 14px; border: 1px solid rgba(228, 228, 231, 0.72); border-radius: var(--radius); background: var(--content); box-shadow: var(--shadow-sm); }
.factory-style-table:not(.factory-detail-table) th,
.factory-style-table:not(.factory-detail-table) td { display: block !important; min-width: 0; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
.factory-style-table:not(.factory-detail-table) td::before { content: attr(data-label); display: block; margin-bottom: 5px; color: #667085; font-size: 12px; font-weight: 780; }
.factory-style-table:not(.factory-detail-table) th:nth-child(1),
.factory-style-table:not(.factory-detail-table) td:nth-child(1) { grid-area: image; width: auto; }
.factory-style-table:not(.factory-detail-table) th:nth-child(2),
.factory-style-table:not(.factory-detail-table) td:nth-child(2) { grid-area: info; width: auto; }
.factory-style-table:not(.factory-detail-table) th:nth-child(3),
.factory-style-table:not(.factory-detail-table) td:nth-child(3) { grid-area: variants; width: auto; }
.factory-style-table:not(.factory-detail-table) th:nth-child(4),
.factory-style-table:not(.factory-detail-table) td:nth-child(4) { grid-area: price; width: auto; }
.factory-style-table:not(.factory-detail-table) th:nth-child(6),
.factory-style-table:not(.factory-detail-table) td:nth-child(6) { grid-area: selling; width: auto; }
.factory-style-table:not(.factory-detail-table) th:nth-child(7),
.factory-style-table:not(.factory-detail-table) td:nth-child(7) { grid-area: meta; width: auto; }
.factory-style-table:not(.factory-detail-table) th:nth-child(8),
.factory-style-table:not(.factory-detail-table) td:nth-child(8) { grid-area: status; width: auto; }
.factory-style-table:not(.factory-detail-table) th:nth-child(9),
.factory-style-table:not(.factory-detail-table) td:nth-child(9) { grid-area: actions; width: auto; }
.factory-style-table:not(.factory-detail-table) td:nth-child(5) { display: none !important; }
.factory-style-table:not(.factory-detail-table) .table-actions { align-items: stretch; justify-content: flex-start; flex-direction: column; flex-wrap: nowrap; gap: 7px; }
.factory-style-table:not(.factory-detail-table) .table-actions button,
.factory-style-table:not(.factory-detail-table) .table-actions .button-link { width: 100%; min-height: 32px; padding: 6px 8px; white-space: nowrap; }
@media (max-width: 1180px) {
  .factory-style-table:not(.factory-detail-table) tr { grid-template-columns: 120px minmax(170px, 1fr) minmax(200px, 1fr) minmax(180px, 1fr) 126px; grid-template-areas: "image info variants selling actions" "image info variants meta actions" "image price status status actions"; }
}
@media (max-width: 760px) {
  .factory-style-table:not(.factory-detail-table) tr { grid-template-columns: 96px 1fr; grid-template-areas: "image info" "variants variants" "price selling" "meta status" "actions actions"; }
  .factory-style-table:not(.factory-detail-table) .table-actions { flex-direction: row; flex-wrap: wrap; }
  .factory-style-table:not(.factory-detail-table) .table-actions button,
  .factory-style-table:not(.factory-detail-table) .table-actions .button-link { width: auto; }
}

/* 明细视图：Excel 表格 */
.factory-detail-table { display: table !important; width: auto !important; min-width: 0 !important; max-width: 100% !important; border-collapse: collapse !important; border: 1px solid #d1d5db !important; background: #fff !important; box-shadow: none !important; table-layout: fixed !important; }
.factory-detail-table thead { display: table-header-group !important; }
.factory-detail-table tbody { display: table-row-group !important; }
.factory-detail-table tr { display: table-row !important; border: none !important; padding: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
.factory-detail-table th { display: table-cell !important; background: #f1f5f9 !important; color: #334155 !important; font-size: .75rem !important; font-weight: 600 !important; padding: 6px 8px !important; border: 1px solid #d1d5db !important; text-align: center !important; white-space: nowrap !important; }
.factory-detail-table td { display: table-cell !important; padding: 4px 8px !important; border: 1px solid #e5e7eb !important; text-align: left !important; vertical-align: middle !important; font-size: .78rem !important; color: #182230 !important; white-space: nowrap !important; width: auto !important; }
.factory-detail-table td::before { display: none !important; content: none !important; }

/* 明细视图操作按钮：垂直堆叠 + 统一宽度 */
.factory-detail-table .table-actions,
.factory-detail-table .detail-row-actions,
.factory-detail-table .style-row-actions {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  gap: 8px !important;
  padding: 8px 0 !important;
  width: 100% !important;
  min-width: 110px !important;
}
.factory-detail-table .table-actions form,
.factory-detail-table .detail-row-actions form,
.factory-detail-table .style-row-actions form {
  margin: 0 !important;
  width: 100% !important;
}
.factory-detail-table .table-actions button,
.factory-detail-table .table-actions .button-link,
.factory-detail-table .table-actions .style-action-button,
.factory-detail-table .detail-row-actions button,
.factory-detail-table .detail-row-actions .button-link,
.factory-detail-table .detail-row-actions .style-action-button,
.factory-detail-table .style-row-actions button,
.factory-detail-table .style-row-actions .button-link,
.factory-detail-table .style-row-actions .style-action-button {
  display: block !important;
  width: 100% !important;
  min-height: 30px !important;
  padding: 6px 10px !important;
  font-size: .75rem !important;
  white-space: nowrap !important;
  text-align: center !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  border-radius: 4px !important;
  line-height: 1.4 !important;
  background: #2563eb !important; color: #fff !important; border: none !important;
}
/* 状态按钮颜色区分 */
.factory-detail-table .style-row-actions .style-action-button.action-cancel { background: #dc2626 !important; }
.factory-detail-table .style-row-actions .style-action-button.action-stop   { background: #ea580c !important; }
.factory-detail-table .style-row-actions .style-action-button.action-resume { background: #059669 !important; }
.factory-detail-table .style-row-actions .style-action-button.action-delete { background: #991b1b !important; }
.factory-detail-table .style-row-actions .style-action-button:disabled { background: #9ca3af !important; cursor: not-allowed !important; }
.factory-style-table .style-thumb { max-width: 122px; object-fit: cover; }
/* Excel 表格中允许换行的单元格（覆盖 nowrap） */
.factory-detail-table td.td-wrap { white-space: normal !important; max-width: 100px; word-wrap: break-word; overflow-wrap: break-word; }
/* 卖点单元格在 Excel 表格中收紧宽度 */
.factory-detail-table .selling-points-cell { min-width: 120px !important; }
.factory-detail-table .selling-points-scroll { max-width: none !important; padding: 4px 6px !important; border: none !important; background: none !important; border-radius: 0 !important; }
.factory-detail-table .desensitized-block { margin-top: 2px !important; padding: 2px 4px !important; font-size: .65rem !important; }

.deleted-record {
  background: var(--danger-50);
  color: #a10e4a;
  text-decoration: line-through;
  opacity: 0.72;
}

.deleted-record td::before,
.deleted-record .badge {
  text-decoration: none;
}

.records-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.add-record-panel {
  position: sticky;
  top: 80px;
}

.add-record-panel form {
  display: grid;
  gap: 12px;
}

.records-header {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.pagination-container {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

.page-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 5px 10px;
  border-radius: var(--radius);
  background: var(--content);
  color: var(--primary);
  font-weight: 750;
  box-shadow: var(--shadow-sm);
}

.page-link.active {
  color: #fff;
  background: var(--primary);
}

.messages {
  margin-bottom: 16px;
}

.message {
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: 750;
}

.message.danger {
  color: #a10e4a;
  background: var(--danger-50);
}

.message.success {
  color: #0b8f49;
  background: var(--success-50);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid rgba(228, 228, 231, 0.75);
  border-radius: var(--radius);
  background: var(--content);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin-bottom: 8px;
}

.login-card label {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  color: #3f3f46;
  font-size: 13px;
  font-weight: 750;
}

.login-card input,
.login-card button {
  width: 100%;
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.form-actions {
  margin-top: 12px;
}

code {
  display: inline-block;
  max-width: 520px;
  color: #3f3f46;
  white-space: pre-wrap;
  word-break: break-word;
}

dl {
  margin: 0;
}

dt {
  color: var(--muted);
  margin-top: 12px;
  font-weight: 750;
}

dd {
  margin: 4px 0 0;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

.page-head-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.field-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid.compact {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.form-grid .wide {
  grid-column: span 2;
}

.settings-form,
.purchase-create-form label {
  display: grid;
  gap: 6px;
  color: #3f3f46;
  font-size: 13px;
  font-weight: 750;
}

.settings-form {
  gap: 12px;
}

.settings-form label {
  display: grid;
  gap: 6px;
}

.purchase-order-list {
  display: grid;
  gap: 12px;
}

.purchase-order-card {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(6, minmax(120px, 1fr)) minmax(260px, auto);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(228, 228, 231, 0.72);
  border-radius: var(--radius);
  background: var(--content);
  box-shadow: var(--shadow-sm);
}

.order-no {
  display: inline-block;
  font-weight: 850;
}

.purchase-create-form {
  display: grid;
  gap: 16px;
}

.purchase-create-section {
  display: grid;
  gap: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-index {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
  font-weight: 850;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px;
  border-radius: 999px;
  background: var(--content-2);
  width: fit-content;
}

.segmented label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 999px;
  color: #52525b;
  font-weight: 800;
  cursor: pointer;
}

.segmented label:has(input:checked) {
  color: var(--primary-700);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.segmented input {
  width: auto;
  min-height: auto;
}

.terms-grid {
  grid-template-columns: 220px 220px 180px 1fr;
}

.batch-fill {
  display: flex !important;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.batch-fill input {
  width: 96px;
}

.purchase-lines {
  display: grid;
  gap: 12px;
}

.purchase-line {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) 70px repeat(6, minmax(110px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--content-2);
}

.line-search {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.line-image {
  display: grid;
  min-height: 54px;
  place-items: center;
}

.submit-bar {
  display: flex;
  justify-content: flex-end;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.contract-body {
  background: #f6f7f9;
}

.contract-page {
  width: min(1080px, calc(100% - 32px));
  margin: 20px auto 40px;
  padding: 28px;
  background: #fff;
  color: #111;
  box-shadow: var(--shadow-md);
}

.contract-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 18px;
}

.contract-header {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 2px solid #111;
}

.contract-header h1 {
  font-size: 28px;
}

.contract-parties,
.contract-sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 22px 0;
}

.contract-section {
  margin-top: 24px;
}

.contract-section h2 {
  padding-left: 8px;
  border-left: 4px solid #111;
  font-size: 18px;
}

.contract-table {
  display: table;
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  border-spacing: 0;
}

.contract-table thead {
  display: table-header-group;
}

.contract-table tbody {
  display: table-row-group;
}

.contract-table tr {
  display: table-row;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}

.contract-table tbody tr:hover {
  border-color: #111;
  box-shadow: none;
  transform: none;
}

.contract-table th,
.contract-table td {
  display: table-cell;
  padding: 9px 8px;
  border: 1px solid #111;
  color: #111;
  font-size: 13px;
  text-align: center;
  vertical-align: middle;
}

.contract-table td::before {
  display: none;
}

.contract-total {
  margin-top: 10px;
  text-align: right;
  font-weight: 850;
}

.contract-terms {
  margin: 12px 0 0;
  padding-left: 22px;
}

.contract-terms li {
  margin-bottom: 8px;
  color: #111;
}

.contract-sign {
  margin-top: 48px;
}

.contract-sign p {
  margin-bottom: 18px;
  color: #111;
}

.purchase-flat-tools {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.purchase-tool-line {
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(360px, 1.6fr);
  gap: 12px;
  align-items: end;
}

.purchase-tool-line label {
  display: grid;
  gap: 6px;
}

.bulk-code-field textarea {
  min-height: 72px;
  resize: vertical;
}

.purchase-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.purchase-tool-actions .batch-fill {
  min-height: 36px;
}

.purchase-tool-actions button {
  min-height: 36px;
  padding: 7px 10px;
}

.purchase-flat-tools .sku-result-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 7px;
  max-height: 154px;
  overflow: auto;
  padding: 2px;
}

.purchase-spreadsheet {
  border: 1px solid rgba(228, 228, 231, 0.9);
  border-radius: var(--radius);
  background: var(--content);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.purchase-sheet-head,
.purchase-spreadsheet .line-compact-main {
  display: grid;
  grid-template-columns: 34px 42px 54px minmax(250px, 2fr) 120px 90px 90px 88px 80px 104px 128px;
  gap: 8px;
  align-items: center;
  min-width: 1110px;
}

.purchase-sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--content-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.purchase-spreadsheet .purchase-lines {
  display: block;
  max-height: 620px;
  overflow: auto;
}

.purchase-spreadsheet .purchase-line {
  position: relative;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 0;
  background: var(--content);
  box-shadow: none;
}

.purchase-spreadsheet .purchase-line:nth-child(odd) {
  background: #ffffff;
  border-left-color: var(--primary);
}

.purchase-spreadsheet .purchase-line:nth-child(even) {
  background: #fafafa;
  border-left-color: var(--warning);
}

.purchase-spreadsheet .purchase-line:hover {
  background: var(--primary-50);
}

.purchase-spreadsheet .line-compact-main {
  padding: 8px 10px 8px 6px;
}

.line-check {
  justify-self: center;
  width: 16px;
  height: 16px;
  min-height: 16px;
}

.line-index {
  display: inline-grid;
  width: 30px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--content-3);
  color: #52525b;
  font-size: 12px;
  font-weight: 850;
}

.purchase-spreadsheet .line-image {
  width: 42px;
  min-height: 42px;
}

.purchase-spreadsheet .line-image .thumb.small {
  width: 42px;
  height: 42px;
}

.purchase-spreadsheet .line-product-cell {
  display: grid;
  gap: 5px;
}

.purchase-spreadsheet input {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.purchase-spreadsheet .line-product-name {
  font-size: 13px;
  font-weight: 800;
}

.purchase-spreadsheet .line-amount {
  color: var(--primary-700);
  font-weight: 850;
}

.purchase-spreadsheet .line-row-actions {
  display: flex;
  gap: 6px;
}

.purchase-spreadsheet .line-row-actions button {
  min-height: 32px;
  padding: 6px 8px;
}

.purchase-spreadsheet .line-more {
  min-width: 1110px;
  border-top: 1px dashed var(--line);
  background: rgba(244, 244, 245, 0.72);
}

.purchase-spreadsheet .line-extra-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(6, minmax(120px, 1fr));
  gap: 8px;
  padding: 10px;
}

.purchase-spreadsheet .line-extra-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.purchase-terms-grid {
  grid-template-columns: 190px 190px 150px 190px 1fr;
}

.purchase-products-section {
  gap: 14px;
}

.purchase-products-head {
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.purchase-products-head .section-title {
  flex-wrap: wrap;
}

.purchase-products-head .badge {
  max-width: none;
}

.purchase-sheet-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.purchase-sheet-actions button {
  min-height: 36px;
  padding: 7px 10px;
}

.sheet-action-message {
  min-width: 150px;
  align-self: center;
}

.purchase-workbench {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.purchase-bulk-panel,
.purchase-list-panel {
  border: 1px solid rgba(228, 228, 231, 0.85);
  border-radius: var(--radius);
  background: var(--content-2);
}

.purchase-bulk-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.purchase-bulk-panel label {
  display: grid;
  gap: 6px;
}

.sku-result-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.sku-result-item {
  display: grid;
  grid-template-columns: minmax(74px, auto) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 7px 8px;
  border-radius: var(--radius);
  background: var(--content);
  color: #27272a;
  box-shadow: none;
}

.sku-result-item span {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sku-result-item em {
  color: var(--primary-700);
  font-style: normal;
  font-weight: 850;
}

.sku-empty {
  padding: 8px;
}

.bulk-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.purchase-list-panel {
  overflow: hidden;
}

.purchase-list-head {
  display: grid;
  grid-template-columns: 54px minmax(260px, 2fr) minmax(120px, 0.8fr) 94px 88px 112px 136px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--content);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.purchase-list-head span:first-child {
  grid-column: 1 / span 2;
}

.purchase-list-panel .purchase-lines {
  display: grid;
  gap: 0;
  max-height: 620px;
  overflow: auto;
}

.purchase-line {
  display: block;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--content);
  box-shadow: none;
  overflow: visible;
}

.purchase-line:last-child {
  border-bottom: 0;
}

.line-compact-main {
  display: grid;
  grid-template-columns: 54px minmax(260px, 2fr) minmax(120px, 0.8fr) 94px 88px 112px 136px;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
}

.line-product-cell {
  display: grid;
  gap: 6px;
  align-items: center;
}

.line-sku-search,
.line-product-name {
  min-width: 0;
}

.line-product-name {
  min-height: 34px;
  font-weight: 750;
}

.line-sku-search {
  min-height: 32px;
  font-size: 12px;
}

.line-style-no,
.line-unit-price,
.line-quantity {
  min-height: 34px;
}

.line-amount {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--primary-700);
}

.line-row-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

.line-row-actions button {
  min-height: 34px;
  padding: 7px 9px;
}

.line-more {
  border-top: 1px dashed var(--line);
  background: var(--content-2);
}

.purchase-list-panel .line-extra-grid {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  padding: 10px 12px 12px;
}

.purchase-list-panel .line-extra-grid label {
  display: grid;
  gap: 5px;
}

.line-card-main {
  display: grid;
  grid-template-columns: 64px minmax(220px, 1.7fr) minmax(150px, 1fr) minmax(210px, 1.25fr) 92px;
  gap: 12px;
  align-items: end;
  padding: 12px;
}

.line-card-main label,
.line-extra-grid label {
  min-width: 0;
}

.line-picker select {
  min-width: 0;
}

.line-card-main .line-image {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.line-picker {
  grid-column: 2 / span 2;
}

.line-product-field {
  grid-column: 4;
}

.line-style-field {
  grid-column: 2;
}

.line-money {
  grid-column: 3 / span 2;
}

.line-total-box {
  grid-column: 5;
}

.line-card-main .remove-line {
  grid-column: 5;
  grid-row: 1;
}

.line-image {
  width: 46px;
  min-height: 46px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--content-2);
  overflow: hidden;
}

.line-image .thumb.small {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 0;
}

.line-money {
  display: grid;
  grid-template-columns: 1fr 0.8fr 0.8fr;
  gap: 8px;
}

.line-total-box {
  display: grid;
  align-content: center;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--primary-50);
  color: var(--primary-700);
}

.line-total-box span {
  font-size: 12px;
  font-weight: 750;
}

.line-total-box strong {
  font-size: 15px;
}

.line-more {
  border-top: 1px solid var(--line);
  background: var(--content-2);
}

.line-more summary {
  padding: 10px 12px;
  color: var(--primary-700);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.line-extra-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
  padding: 0 12px 12px;
}

.line-extra-grid label:first-child {
  grid-column: span 2;
}

.location-cascade {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.location-cascade select {
  min-width: 0;
  width: 100%;
}

/* 表格行内嵌的紧凑级联选择器（用于批量入库每行设置库位） */
.location-cascade--row {
  grid-template-columns: 1fr;
  gap: 4px;
}

.location-cascade--row .location-cascade-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.location-cascade--row .location-cascade-selects select {
  flex: 1 1 56px;
  min-width: 56px;
  max-width: 96px;
  padding: 3px 6px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.location-cascade--row .location-cascade-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.location-cascade--row .location-cascade-preview {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.3;
}

.location-cascade--row .ghost {
  padding: 2px 8px;
  font-size: 11px;
}

.purchase-items-table {
  table-layout: fixed;
}

.purchase-items-table th:nth-child(1),
.purchase-items-table td:nth-child(1) {
  width: 72px;
}

.purchase-items-table th:nth-child(2),
.purchase-items-table td:nth-child(2) {
  width: 64px;
}

.purchase-items-table th:nth-child(3),
.purchase-items-table td:nth-child(3) {
  width: 220px;
}

.purchase-items-table th:nth-child(4),
.purchase-items-table td:nth-child(4) {
  width: 72px;
}

.purchase-items-table th:nth-child(5),
.purchase-items-table td:nth-child(5) {
  width: 60px;
}

.purchase-items-table th:nth-child(6),
.purchase-items-table td:nth-child(6) {
  width: 72px;
}

.purchase-items-table th:nth-child(7),
.purchase-items-table td:nth-child(7) {
  width: 60px;
}

.purchase-items-table th:nth-child(8),
.purchase-items-table td:nth-child(8) {
  width: 210px;
}

.purchase-sheet-head,
.purchase-spreadsheet .line-compact-main {
  grid-template-columns: 34px 42px 54px minmax(250px, 2fr) 120px 90px 90px 88px 80px 104px 128px;
}

.purchase-spreadsheet .line-more {
  border-top: 1px dashed var(--line);
  background: rgba(244, 244, 245, 0.72);
}

.purchase-spreadsheet .line-extra-grid {
  grid-template-columns: minmax(220px, 1.4fr) repeat(6, minmax(120px, 1fr));
  padding: 10px;
}

@media print {
  body,
  .contract-body {
    background: #fff;
  }

  .contract-toolbar {
    display: none;
  }

  .contract-page {
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .split,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .page-head-actions,
  .purchase-order-card,
  .section-row {
    align-items: stretch;
    flex-direction: column;
  }

  .purchase-order-card,
  .form-grid,
  .form-grid.compact,
  .automation-account-form,
  .location-cascade,
  .terms-grid,
  .purchase-terms-grid,
  .purchase-workbench,
  .purchase-list-head,
  .line-compact-main,
  .line-card-main,
  .line-extra-grid {
    grid-template-columns: 1fr;
  }

  .purchase-list-head {
    display: none;
  }

  .purchase-list-panel .purchase-lines {
    max-height: none;
  }

  .line-money {
    grid-template-columns: repeat(3, 1fr);
  }

  .purchase-head,
  .section-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .purchase-head dl {
    grid-template-columns: repeat(2, 72px 1fr);
  }
}

.purchase-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.purchase-head dl {
  display: grid;
  grid-template-columns: repeat(5, 72px 1fr);
  gap: 8px 12px;
  margin: 0;
  width: 100%;
  align-items: center;
}

.purchase-head dt {
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
  padding-right: 6px;
  white-space: nowrap;
}

.purchase-head dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  min-width: 0;
}

.purchase-head .table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px solid rgba(230, 233, 240, 0.7);
}

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .nav-group {
    grid-column: 1 / -1;
    margin-top: 12px;
  }

  .main {
    margin-left: 0;
    padding: 16px;
  }

  .topbar {
    position: static;
    margin: -16px -16px 18px;
    padding: 12px 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar > div,
  .topbar form {
    width: 100%;
    justify-content: space-between;
  }

  .db-chip {
    max-width: 100%;
  }

  .records-layout {
    grid-template-columns: 1fr;
  }

  .add-record-panel {
    position: static;
  }

  .modal-form {
    grid-template-columns: 1fr;
  }

  .store-form-section {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  th {
    position: static;
  }
}

@media (max-width: 560px) {
  .metric-grid,
  .sidebar nav {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 22px;
  }

  .topbar > div,
  .topbar form,
  .table-actions,
  .inline-form,
  .filter-form,
  .filter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form input,
  button,
  .button-link {
    width: 100%;
  }
}

/* Modern dashboard refresh: HeroUI-inspired visual layer. */
:root {
  --bg: #f6f7fb;
  --content: #ffffff;
  --content-2: #f4f6fa;
  --content-3: #edf1f7;
  --foreground: #171923;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e6e9f0;
  --primary: #006fee;
  --primary-50: #edf6ff;
  --primary-100: #d9ecff;
  --primary-700: #0055c8;
  --success: #17c964;
  --success-50: #ecfdf3;
  --warning: #f5a524;
  --danger: #f31260;
  --danger-50: #fff1f6;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: #ffffff;
  --ring: rgba(0, 111, 238, 0.16);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 10px 28px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.16);
  --radius: 8px;
}

html {
  background:
    radial-gradient(circle at 18% -10%, rgba(0, 111, 238, 0.10), transparent 28%),
    radial-gradient(circle at 86% 2%, rgba(23, 201, 100, 0.08), transparent 24%),
    var(--bg);
}

body {
  background: transparent;
  color: var(--foreground);
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  text-rendering: optimizeLegibility;
}

.sidebar {
  width: 264px;
  padding: 16px 12px;
  background: rgba(255, 255, 255, 0.84);
  border-right: 1px solid rgba(230, 233, 240, 0.9);
  box-shadow: 16px 0 40px rgba(16, 24, 40, 0.04);
  backdrop-filter: blur(18px) saturate(160%);
}

.brand {
  min-height: 58px;
  margin: 2px 4px 14px;
  padding: 10px;
  border: 1px solid rgba(230, 233, 240, 0.9);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f7faff 100%);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #006fee 0%, #17c964 100%);
  box-shadow: 0 12px 24px rgba(0, 111, 238, 0.22);
}

.brand strong {
  font-size: 15px;
  letter-spacing: 0;
}

.nav-group {
  margin: 18px 12px 7px;
  color: #8b95a7;
  font-size: 11px;
  letter-spacing: 0;
}

.sidebar a {
  min-height: 38px;
  margin: 2px 0;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #4b5565;
  font-size: 13px;
  font-weight: 700;
}

.sidebar a:hover {
  color: #0f172a;
  border-color: rgba(230, 233, 240, 0.95);
  background: rgba(244, 246, 250, 0.92);
}

.sidebar a.active {
  color: #0b5fcb;
  border-color: rgba(0, 111, 238, 0.18);
  background: linear-gradient(135deg, #edf6ff 0%, #f8fbff 100%);
  box-shadow: inset 3px 0 0 #006fee, 0 8px 18px rgba(0, 111, 238, 0.08);
}

.sidebar a.active::before {
  display: none;
}

.main {
  margin-left: 264px;
  padding: 24px 30px 48px;
}

.topbar {
  min-height: 60px;
  margin: -24px -30px 24px;
  padding: 12px 30px;
  background: rgba(246, 247, 251, 0.78);
  border-bottom: 1px solid rgba(230, 233, 240, 0.86);
  backdrop-filter: blur(18px) saturate(160%);
}

.page-head {
  margin-bottom: 18px;
  padding: 0 2px;
}

.page-head h1 {
  font-size: 26px;
  font-weight: 850;
  letter-spacing: 0;
}

.page-head p {
  max-width: 980px;
  color: #697386;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
}

.metric {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  padding: 17px 18px;
  border: 1px solid rgba(230, 233, 240, 0.95);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-sm);
}

.metric::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, #006fee, #17c964);
}

.metric span {
  color: #667085;
  font-size: 12px;
}

.metric strong {
  margin-top: 10px;
  color: #101828;
  font-size: 32px;
  font-weight: 850;
}

.panel,
.toolbar-form,
.finance-summary,
.add-record-panel,
.all-records-panel,
.automation-platform-panel,
.automation-stage-head,
.split > div,
.settings-grid > .panel,
.records-layout > section {
  border: 1px solid rgba(230, 233, 240, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
}

.split > div {
  padding: 16px;
}

.split h2,
.panel h2,
.finance-summary h2,
.all-records-panel h2 {
  margin-bottom: 12px;
  color: #182230;
  font-size: 16px;
  font-weight: 850;
}

.toolbar-form,
.filter-form,
.finance-filter-form {
  gap: 10px;
}

.toolbar-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.finance-filter-form {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  padding: 10px;
  border: 1px solid rgba(230, 233, 240, 0.8);
  background: #f8fafc;
}

input,
select,
textarea {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f5f7fb;
  color: #182230;
}

input:hover,
select:hover,
textarea:hover {
  background: #f0f3f8;
}

input:focus,
select:focus,
textarea:focus {
  background: #fff;
  border-color: #006fee;
  box-shadow: 0 0 0 3px var(--ring);
}

button,
.button-link {
  min-height: 36px;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(0, 111, 238, 0.16);
  font-weight: 760;
}

button.ghost,
.button-link.secondary {
  color: #344054;
  border-color: rgba(230, 233, 240, 0.9);
  background: #fff;
}

button.ghost:hover,
.button-link.secondary:hover {
  color: #0055c8;
  border-color: rgba(0, 111, 238, 0.18);
  background: #edf6ff;
}

.danger-button {
  box-shadow: 0 8px 18px rgba(243, 18, 96, 0.16);
}

.compact-button {
  min-height: 30px;
  padding: 5px 9px;
}

.db-chip,
.user-chip,
.badge {
  min-height: 24px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 780;
}

.badge {
  background: #edf6ff;
}

.badge.success {
  color: #087443;
  background: #eafbf1;
}

.badge.warning {
  color: #93370d;
  background: #fff4e5;
}

.badge-imported {
  color: #087443;
  background: #eafbf1;
}

table,
.compact-list-table,
.finance-records-table,
.all-records-panel > table,
.automation-table,
.contract-table,
.compact-table,
.main > table {
  border: 1px solid rgba(230, 233, 240, 0.95);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.compact-list-table,
.finance-records-table,
.all-records-panel > table,
.automation-table,
.contract-table,
.compact-table,
.main > table {
  overflow: hidden;
}

thead,
.compact-list-table thead,
.finance-records-table thead,
.automation-table thead,
.contract-table thead,
.main > table thead {
  background: #f8fafc;
}

th,
.compact-list-table th,
.finance-records-table th,
.all-records-panel > table th,
.automation-table th,
.contract-table th,
.compact-table th,
.main > table th {
  padding: 11px 12px;
  color: #475467;
  background: #f8fafc;
  border-bottom: 1px solid #e6e9f0;
  font-size: 12px;
  font-weight: 850;
}

.main > table th.sortable {
  cursor: pointer;
  user-select: none;
}

.main > table th.sortable:hover {
  background: #e8edf5;
}

.main > table th.sortable.sorted {
  background: #dce8f8;
  color: #1a73e8;
}

td,
.compact-list-table td,
.finance-records-table td,
.all-records-panel > table td,
.automation-table td,
.contract-table td,
.compact-table td,
.main > table td {
  padding: 12px;
  border-bottom: 1px solid #eef1f6;
  color: #182230;
}

tbody tr:hover,
.compact-list-table tbody tr:hover,
.finance-records-table tbody tr:hover,
.all-records-panel > table tbody tr:hover,
.automation-table tbody tr:hover,
.main > table tbody tr:hover {
  background: #fbfdff;
}

.table-actions {
  gap: 7px;
}

.table-actions button,
.table-actions .button-link,
.table-actions .ghost,
.table-actions .danger-button {
  min-height: 32px;
  padding: 6px 10px;
}


.deleted-record {
  color: #98a2b3;
  background: #fff6f8 !important;
}

.deleted-record td {
  color: #98a2b3;
  text-decoration: line-through;
}

.modal-backdrop {
  display: none;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 9999 !important;
  padding: 42px 18px;
  background: rgba(0, 0, 0, 0.65) !important;
  align-items: flex-start !important;
  justify-content: center !important;
  overflow-y: auto !important;
}

.modal-backdrop.is-open {
  display: flex !important;
}

.modal-panel {
  width: min(900px, 100%);
  max-height: calc(100vh - 84px);
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  min-height: 58px;
  padding: 14px 18px;
  background: #fbfcff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.modal-head h2,
.modal-head h3,
.modal-head h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}
.modal-head .ghost,
.modal-head [data-modal-close] {
  flex-shrink: 0;
  cursor: pointer;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 13px;
}
.modal-form.single-column {
  grid-template-columns: 1fr;
  max-width: 560px;
}

.modal-form label,
.add-record-panel label,
.settings-form label {
  color: #344054;
  font-size: 13px;
  font-weight: 760;
}

.modal-actions {
  padding: 14px 18px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: #fafbfc;
}
.modal-actions button,
.modal-actions .btn {
  min-width: 90px;
}

.modal-desc {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ===== 右侧抽屉弹窗 ===== */
.drawer-backdrop {
  display: none;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 9999 !important;
  background: rgba(0, 0, 0, 0.45) !important;
  overflow: hidden !important;
}
.drawer-backdrop.is-open {
  display: block !important;
}
.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(96vw, 1600px);
  min-width: 1100px;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -8px 0 40px rgba(15,23,42,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.drawer-backdrop.is-open .drawer-panel {
  transform: translateX(0);
}
.drawer-head {
  min-height: 56px;
  padding: 12px 18px;
  background: #fbfcff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.drawer-head h2 {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
  margin: 0;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}
[data-drawer-close] { cursor: pointer; }
[data-drawer-close]:hover { opacity: 0.75; }

/* 关闭按钮 hover */
[data-modal-close] { cursor: pointer; }
[data-modal-close]:hover { opacity: 0.75; }

/* ===== 手工减库存（批量）弹窗 ===== */
#sku-manual-decrease .modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#sku-manual-decrease .modal-desc {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 12.5px;
  line-height: 1.6;
}

/* 搜索添加条 */
.decrease-add-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.6fr) 110px auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--content-2);
}

.decrease-add-bar__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.decrease-add-bar__field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.decrease-add-bar__field input,
.decrease-add-bar__field select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--foreground);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.decrease-add-bar__field input:focus,
.decrease-add-bar__field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 111, 238, 0.15);
}

.decrease-add-bar__field input[disabled],
.decrease-add-bar__field select[disabled] {
  background: var(--content-2);
  color: var(--faint);
  cursor: not-allowed;
}

.decrease-add-bar__action {
  display: flex;
  align-items: flex-end;
}

.decrease-add-bar__action .button {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0, 111, 238, 0.18);
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.decrease-add-bar__action .button:hover:not(:disabled) {
  background: var(--primary-700);
  box-shadow: 0 6px 14px rgba(0, 111, 238, 0.22);
}

.decrease-add-bar__action .button:active:not(:disabled) {
  transform: translateY(1px);
}

.decrease-add-bar__action .button:disabled {
  background: var(--content-3);
  color: var(--faint);
  cursor: not-allowed;
  box-shadow: none;
}

.decrease-help {
  display: block;
  margin-top: -6px;
  color: var(--muted);
  font-size: 12px;
}

/* 列表容器 */
.decrease-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--content);
  overflow: hidden;
}

.decrease-list__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--content-2);
}

.decrease-list__head h4 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: #27272a;
}

.decrease-list__count {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-700);
  background: var(--primary-50);
  padding: 2px 10px;
  border-radius: 999px;
}

.decrease-list__body {
  position: relative;
  max-height: 320px;
  overflow: auto;
}

/* 空态 */
.decrease-list__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 18px;
  color: var(--faint);
  text-align: center;
  gap: 4px;
}

.decrease-list__empty[hidden] {
  display: none;
}

.decrease-list__empty p {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.decrease-list__empty small {
  font-size: 12px;
  color: var(--faint);
}

.decrease-list__empty-icon {
  width: 44px;
  height: 44px;
  color: var(--content-3);
}

/* 表格 —— 独立class前缀避免被全局 table 响应式卡片规则覆盖 */
.decrease-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  display: table;
  background: var(--content);
}

.decrease-table[hidden] {
  display: none;
}

.decrease-table colgroup,
.decrease-table thead,
.decrease-table tbody,
.decrease-table tfoot,
.decrease-table tr {
  display: table-row-group;
}

.decrease-table thead {
  display: table-header-group;
}

.decrease-table tbody {
  display: table-row-group;
}

.decrease-table tfoot {
  display: table-footer-group;
}

.decrease-table tr {
  display: table-row;
  border-radius: 0;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  transition: background 0.12s ease;
}

.decrease-table tr:hover {
  background: var(--primary-50);
  transform: none;
}

.decrease-table th,
.decrease-table td {
  display: table-cell;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  color: #27272a;
  white-space: normal;
}

.decrease-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--content-2);
  color: #52525b;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: none;
  box-shadow: none;
}

.decrease-table th::before,
.decrease-table td::before {
  content: none;
}

.decrease-table thead tr,
.decrease-table tfoot tr {
  background: var(--content-2);
}

.decrease-table tfoot th,
.decrease-table tfoot td {
  background: var(--content-2);
  font-weight: 700;
  color: #27272a;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.decrease-table__col-stock { width: 90px; }
.decrease-table__col-qty   { width: 160px; }
.decrease-table__col-loc   { width: 360px; }
.decrease-table__col-op    { width: 90px; }

.decrease-table__num {
  text-align: center !important;
  font-variant-numeric: tabular-nums;
}

.decrease-table__sku {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.decrease-table__sku-code {
  font-weight: 700;
  color: var(--primary-700);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.decrease-table__sku-name {
  color: #27272a;
  font-size: 13px;
}

.decrease-table__sku-product {
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.decrease-table__stock-pill {
  display: inline-block;
  min-width: 32px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--content-2);
  color: #3f3f46;
  font-weight: 600;
  font-size: 12px;
}

.decrease-table__total-qty {
  color: var(--danger);
  font-size: 14px;
}

/* 数量步进器 */
.decrease-qty-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  height: 32px;
}

.decrease-qty-stepper__btn {
  width: 30px;
  border: 0;
  background: var(--content-2);
  color: #3f3f46;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.decrease-qty-stepper__btn:hover {
  background: var(--primary-50);
  color: var(--primary-700);
}

.decrease-qty-stepper__btn:active {
  background: var(--primary-100);
}

.decrease-qty-stepper__input {
  width: 60px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #27272a;
  background: #fff;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.decrease-qty-stepper__input::-webkit-outer-spin-button,
.decrease-qty-stepper__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 行内删除按钮 */
.decrease-table__del {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.decrease-table__del:hover {
  background: rgba(243, 18, 96, 0.08);
  color: var(--danger);
  border-color: rgba(243, 18, 96, 0.20);
}

.decrease-table__del span[aria-hidden] {
  font-size: 12px;
  line-height: 1;
}

/* 底部表单（原因 + 摘要） */
.decrease-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}

.decrease-form__reason {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.decrease-form__reason > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.decrease-form__reason > span small {
  font-weight: 500;
  color: var(--faint);
  font-size: 11.5px;
}

.decrease-form__reason textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--foreground);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.decrease-form__reason textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 111, 238, 0.15);
}

.decrease-form__summary {
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--content-2);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.decrease-form__summary b {
  color: var(--danger);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .decrease-add-bar {
    grid-template-columns: 1fr 1fr;
  }
  .decrease-add-bar__action {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .decrease-add-bar__action .button {
    width: 100%;
  }
  .decrease-table__sku-product {
    max-width: 200px;
  }
}


.store-form-section {
  border-radius: 8px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 12%, rgba(0, 111, 238, 0.14), transparent 28%),
    radial-gradient(circle at 82% 80%, rgba(23, 201, 100, 0.12), transparent 24%),
    #f6f7fb;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(230, 233, 240, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin-bottom: 8px;
  font-size: 28px;
  font-weight: 900;
}

.login-card p {
  margin-bottom: 18px;
}

.login-card label {
  display: grid;
  gap: 7px;
  margin-top: 13px;
  color: #344054;
  font-weight: 760;
}

.login-card button {
  width: 100%;
  margin-top: 18px;
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 860px) {
  .sidebar {
    width: auto;
    padding: 12px;
  }

  .brand {
    margin: 0 0 10px;
  }

  .main {
    margin-left: 0;
    padding: 16px;
  }

  .topbar {
    margin: -16px -16px 18px;
    padding: 12px 16px;
  }

  .modal-panel {
    width: min(720px, 100%);
  }
}

@media (max-width: 620px) {
  .metric-grid,
  .split,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .finance-filter-form {
    grid-template-columns: 1fr;
  }
}

.automation-run-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
  padding: 16px;
}

.automation-run-panel .toolbar-form {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding: 12px;
}

.automation-run-panel .toolbar-form form {
  flex: 0 0 auto;
  display: inline-flex;
  margin: 0;
}

.automation-run-panel .continue-run-form {
  align-items: center;
  gap: 8px;
}

.automation-run-panel .continue-run-form select {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  height: 38px;
  min-width: 150px;
  padding: 0 12px;
}

.automation-run-panel .toolbar-form button,
.automation-run-panel .toolbar-form .button-link {
  flex: 0 0 auto;
  white-space: nowrap;
  width: auto;
}

.run-status-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.execution-console {
  background: #101828;
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  color: #e5e7eb;
  overflow: hidden;
}

.execution-console-head {
  align-items: center;
  background: #0b1220;
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
}

.execution-log-list {
  list-style: none;
  margin: 0;
  max-height: 62vh;
  overflow: auto;
  padding: 8px 0;
}

.execution-log {
  border-left: 4px solid transparent;
  display: grid;
  gap: 12px;
  grid-template-columns: 160px minmax(0, 1fr);
  padding: 9px 16px;
}

.execution-log time {
  color: #94a3b8;
  font-size: 12px;
}

.execution-log span {
  white-space: pre-wrap;
  word-break: break-word;
}

.execution-log.info { border-left-color: #38bdf8; }
.execution-log.success { border-left-color: #22c55e; }
.execution-log.warning { border-left-color: #f59e0b; }
.execution-log.error { border-left-color: #ef4444; }
.finance-workbench-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.finance-quick-actions,
.finance-filter-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.finance-pool {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) 1.6fr;
  gap: 12px;
  margin-bottom: 14px;
}

.finance-pool-primary,
.finance-account-strip,
.finance-ledger {
  border: 1px solid rgba(228, 228, 231, 0.9);
  border-radius: 8px;
  background: var(--content);
  padding: 14px;
}

.finance-ledger {
  width: 100%;
  max-width: none;
  overflow-x: auto;
}

.finance-pool-primary span,
.finance-pool-metrics span,
.finance-account-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.finance-pool-primary strong {
  display: block;
  margin: 6px 0;
  font-size: 30px;
  line-height: 1.1;
}

.finance-pool-primary small {
  color: var(--muted);
}

.finance-pool-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.finance-pool-metrics > div,
.finance-account-item {
  border: 1px solid rgba(228, 228, 231, 0.82);
  border-radius: 8px;
  background: color-mix(in srgb, var(--content) 86%, #f8fafc);
  padding: 10px;
}

.finance-pool-metrics strong,
.finance-account-item strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.finance-account-strip {
  margin-bottom: 14px;
}

.finance-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.finance-ledger .records-header {
  align-items: flex-start;
}

.finance-filter-inline {
  justify-content: flex-end;
}

.finance-filter-inline select,
.finance-filter-inline input {
  min-height: 34px;
  max-width: 150px;
}

.finance-ledger-table {
  display: table !important;
  width: 100% !important;
  min-width: 1120px;
  max-width: none;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: fixed;
  margin-top: 10px;
  font-size: 13px;
}

.finance-person-overview { margin: 0 0 18px; min-width: 0; }
.finance-person-overview h2 { font-size: 17px; margin: 0 0 12px; color: #0969da; }
.finance-person-scroll { width: 100%; overflow-x: auto; border: 1px solid #dce3ed; border-radius: 6px; background: #fff; }
.finance-person-table { display: table !important; width: 100%; min-width: 1120px; table-layout: fixed; border-collapse: collapse; font-size: 12px; margin: 0; }
.finance-person-table thead { display: table-header-group !important; }
.finance-person-table tbody { display: table-row-group !important; }
.finance-person-table tfoot { display: table-footer-group !important; }
.finance-person-table tr { display: table-row !important; background: none; }
.finance-person-table th,.finance-person-table td { display: table-cell !important; padding: 12px 8px; border: 1px solid #dce3ed; text-align: right; vertical-align: middle; font-variant-numeric: tabular-nums; }
.finance-person-table td { white-space: nowrap; }
.finance-person-table td::before { content: none !important; display: none !important; }
.finance-person-table th:first-child { text-align: left; width: 100px; }
.finance-person-table thead th { background: #087cf0; color: #fff; font-weight: 600; }
.finance-person-table small { display: block; font-size: 11px; margin-top: 4px; color: inherit; }
.finance-person-table tbody tr:nth-child(even) { background: #f6f8fb; }
.finance-person-table tfoot { background: #eaf0f6; font-weight: 700; }
.finance-person-table tfoot th,.finance-person-table tfoot td { border-top: 2px solid #7c8899; }
.finance-person-table .finance-principal { color: #0969da; }
.finance-person-table .danger-text { color: #dc2626; }
.finance-person-table .success-text { color: #078557; }

.finance-ledger-table thead {
  display: table-header-group !important;
}

.finance-ledger-table tbody {
  display: table-row-group !important;
}

.finance-ledger-table tbody tr,
.finance-ledger-table tr {
  display: table-row !important;
  grid-template-columns: none;
  gap: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.finance-ledger-table th,
.finance-ledger-table td {
  display: table-cell !important;
  border-bottom: 1px solid rgba(228, 228, 231, 0.86);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

.finance-ledger-table td::before {
  display: none !important;
  content: none !important;
}

.finance-ledger-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: color-mix(in srgb, var(--content) 82%, #f4f7fb);
}

.finance-ledger-table th:nth-child(1),
.finance-ledger-table td:nth-child(1) {
  width: 86px;
}

.finance-ledger-table th:nth-child(2),
.finance-ledger-table td:nth-child(2) {
  width: 112px;
}

.finance-ledger-table th:nth-child(3),
.finance-ledger-table td:nth-child(3) {
  width: 104px;
}

.finance-ledger-table th:nth-child(4),
.finance-ledger-table td:nth-child(4) {
  width: 240px;
}

.finance-ledger-table th:nth-child(5),
.finance-ledger-table td:nth-child(5) {
  width: 130px;
}

.finance-ledger-table th:nth-child(6),
.finance-ledger-table td:nth-child(6) {
  width: 110px;
}

.finance-ledger-table th:nth-child(7),
.finance-ledger-table td:nth-child(7) {
  width: 144px;
}

.finance-ledger-table th:nth-child(8),
.finance-ledger-table td:nth-child(8) {
  width: 112px;
}

.finance-ledger-table th:nth-child(9),
.finance-ledger-table td:nth-child(9) {
  width: 128px;
}

.finance-ledger-table th:nth-child(10),
.finance-ledger-table td:nth-child(10) {
  width: 260px;
}

.finance-ledger-table .table-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.finance-ledger-table .table-actions form {
  flex: 0 0 auto;
}

.finance-ledger-table .table-actions button,
.finance-ledger-table .table-actions .button-link {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 4px 8px;
  min-height: 28px;
  font-size: 12px;
}

.finance-ledger-table tbody tr:hover {
  background: color-mix(in srgb, var(--accent-soft) 42%, transparent);
}

.finance-type-help {
  margin: 0 18px;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent-soft) 58%, transparent);
  color: var(--muted);
  font-size: 13px;
}

.finance-create-panel {
  max-width: 760px;
}

@media (max-width: 980px) {
  .finance-workbench-head,
  .finance-pool {
    display: block;
  }

  .finance-quick-actions,
  .finance-pool-primary {
    margin-top: 10px;
  }

  .finance-pool-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 10px;
  }
}


/* Tenant and merchant permission management */
.inline-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-form {
  width: 100%;
}
.wide-modal {
  width: min(1120px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  overflow: auto;
}
.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 12px;
  padding: 12px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 12px;
  background: var(--soft, #f8fafc);
}
.permission-item {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  background: #fff;
}


/* System tenant permission picker */
.permission-panel-form {
  display: block;
}
.permission-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}
.permission-panel-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.tenant-permission-sections {
  display: grid;
  gap: 14px;
}
.permission-section {
  padding: 14px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}
.permission-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #334155;
}
.tenant-permission-item {
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}
.tenant-permission-item:hover {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}
.tenant-permission-item.is-checked {
  border-color: rgba(37, 99, 235, 0.45);
  background: #eff6ff;
}
.tenant-permission-item span {
  display: grid;
  gap: 3px;
  line-height: 1.35;
}
.tenant-permission-item strong {
  font-size: 13px;
  color: #0f172a;
}
.tenant-permission-item small {
  font-size: 11px;
  color: #64748b;
  word-break: break-all;
}
.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: 14px;
  padding: 12px 0 0;
  background: linear-gradient(180deg, rgba(248,250,252,0), #f8fafc 42%);
}
@media (max-width: 760px) {
  .permission-panel-head {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Store editor */
.store-editor-panel {
  width: min(1080px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}
.store-editor-panel .store-editor-head {
  flex: 0 0 auto;
  padding: 14px 20px;
}
.store-editor-head h2 { margin: 0; font-size: 18px; }
.store-editor-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.store-editor-panel .modal-body {
  min-height: 0;
  overflow-y: auto;
  padding: 0;
}
.store-editor-panel .modal-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.store-editor-panel .store-form-section {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: 20px;
}
.store-editor-panel .store-basic-section {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: #fff;
}
.store-editor-panel .store-basic-section .form-section-title {
  padding-bottom: 8px;
  color: #1f2937;
}
.store-editor-panel .store-publish-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  border: 0;
  padding: 20px;
  background: #f8fafc;
  box-shadow: none;
}
.store-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.store-section-heading h3 { margin: 0; color: #1f2937; font-size: 16px; }
.store-section-heading p { margin: 4px 0 0; color: #667085; font-size: 12px; font-weight: 500; }
.store-directory-table .store-registrant-heading th {
  padding: 13px 16px;
  background: #edf6f5;
  border-left: 3px solid #0f766e;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
.store-registrant-label,
.store-registrant-count {
  color: #52636b;
  font-size: 12px;
  font-weight: 400;
}
.store-registrant-label { margin-right: 12px; }
.store-registrant-count { margin-left: 12px; white-space: nowrap; }

.store-settings-group {
  min-width: 0;
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid #dfe4ec;
  border-radius: 6px;
  background: #fff;
}
.store-settings-group legend {
  padding: 0 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}
.store-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.store-field-grid .full { grid-column: 1 / -1; }
.store-field-grid .checkbox-line {
  align-self: end;
  min-height: 40px;
  padding: 0 2px;
}
.platform-publish-fields[hidden] { display: none; }
.store-advanced-group {
  overflow: hidden;
  border: 1px solid #dfe4ec;
  border-radius: 6px;
  background: #fff;
}
.store-advanced-group summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 16px;
  cursor: pointer;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
  list-style-position: inside;
}
.store-advanced-group summary small {
  color: #98a2b3;
  font-size: 12px;
  font-weight: 500;
}
.store-advanced-group[open] summary { border-bottom: 1px solid var(--line); }
.store-advanced-group > .store-field-grid { padding: 16px; }
.store-field-help {
  margin: 0;
  color: #667085;
  font-size: 12px;
  font-weight: 500;
}
.store-editor-panel .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.97);
  box-shadow: 0 -8px 22px rgba(15,23,42,.06);
}
@media (max-width: 900px) {
  .store-editor-panel .store-basic-section,
  .store-field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .store-editor-panel { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .store-editor-panel .store-basic-section,
  .store-field-grid { grid-template-columns: 1fr; }
}
/* Collapsible sidebar navigation */
.sidebar nav {
  display: flex;
  flex-direction: column;
}

.sidebar .nav-home {
  margin: 4px 0 8px;
}

.sidebar-group {
  margin-top: 4px;
}

.sidebar-group .nav-group {
  width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) 10px;
  gap: 9px;
  align-items: center;
  color: #71717a;
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.sidebar-group .nav-group:hover {
  color: var(--foreground);
  background: var(--content-2);
}

.sidebar-group .nav-group::before {
  display: none !important;
  content: none !important;
}

.sidebar-group .nav-group .ui-icon {
  display: block !important;
  width: 17px;
  height: 17px;
  opacity: 0.82;
}

.sidebar-group-chevron {
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.sidebar-group.is-open .sidebar-group-chevron {
  transform: rotate(225deg);
}

.sidebar-group-links {
  display: none;
  padding-top: 2px;
}

.sidebar-group.is-open .sidebar-group-links {
  display: block;
}

.sidebar-group-links a {
  padding-left: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-group-chevron {
    transition: none;
  }
}
/* Sidebar category icon colors */
.sidebar .nav-home:not(.active) > .ui-icon {
  color: #2563eb;
}

.sidebar-group[data-nav-group="operations"] > .nav-group > .ui-icon {
  color: #2563eb;
}

.sidebar-group[data-nav-group="supply-chain"] > .nav-group > .ui-icon {
  color: #d97706;
}

.sidebar-group[data-nav-group="offline"] > .nav-group > .ui-icon {
  color: #0891b2;
}

.sidebar-group[data-nav-group="merchant-tools"] > .nav-group > .ui-icon {
  color: #7c3aed;
}

.sidebar-group[data-nav-group="accounts"] > .nav-group > .ui-icon {
  color: #dc2626;
}

.sidebar-group[data-nav-group="system-operations"] > .nav-group > .ui-icon {
  color: #2563eb;
}

.sidebar-group[data-nav-group="system-governance"] > .nav-group > .ui-icon {
  color: #7c3aed;
}

/* ===== 导入弹窗说明区域 ===== */
.import-supplier {
  margin: 0 0 10px;
  font-size: 14px;
  color: #1e293b;
}
.import-supplier strong {
  color: #006fee;
}

.import-note {
  margin: 0 0 16px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.65;
  color: #475569;
}

.import-note p {
  margin: 0 0 6px;
}
.import-note p:last-child {
  margin-bottom: 0;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px;
}

.tag-list span {
  display: inline-block;
  padding: 2px 10px;
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.6;
}

/* ===== 内联编辑 ===== */
.editable-cell {
  cursor: pointer;
  border-bottom: 1px dashed #94a3b8;
  padding: 1px 4px;
  border-radius: 3px;
  transition: background .15s;
}
.editable-cell:hover {
  background: #f1f5f9;
}
.editable-cell input {
  width: 100%;
  min-width: 80px;
  padding: 2px 6px;
  font-size: inherit;
  font-family: inherit;
  border: 1px solid #3b82f6;
  border-radius: 3px;
  outline: none;
  box-sizing: border-box;
}

/* ===== 已删除 SKU 行 ===== */
tr.sku-deleted {
  opacity: 0.55;
  background: #fef2f2 !important;
}
tr.sku-deleted td {
  color: #9ca3af;
}
.badge-status.deleted {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

/* ===== 显示已删除按钮 ===== */
#toggle-deleted-btn {
  font-size: 12px;
  padding: 4px 10px;
}
/* ===== Dropship command bar ===== */
#dropship-area .dropship-command-bar {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
  margin: 0 0 16px;
  padding: 16px 18px;
  border: 1px solid #dce3eb;
  border-left: 3px solid #2563eb;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}
#dropship-area .dropship-command-primary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 7px;
  padding-right: 20px;
  border-right: 1px solid #e5eaf0;
}
#dropship-area .dropship-generate-btn,
#dropship-area .dropship-sync-btn {
  height: 36px;
  min-height: 36px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
}
#dropship-area .dropship-generate-btn {
  min-width: 126px;
  padding: 0 16px;
  border: 1px solid #2563eb;
  color: #fff;
  background: #2563eb;
}
#dropship-area .dropship-generate-btn:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.18);
}
#dropship-area .dropship-command-note {
  color: #64748b;
  font-size: 12px;
  line-height: 1.45;
}
#dropship-area .dropship-address-tools {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 11px;
  min-width: 0;
}
#dropship-area .dropship-address-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
#dropship-area .dropship-address-title {
  color: #172033;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
}
#dropship-area .dropship-address-help {
  margin-top: 3px;
  color: #718096;
  font-size: 12px;
  line-height: 1.35;
}
#dropship-area .dropship-selection-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
#dropship-area .dropship-selection-actions > span {
  width: 1px;
  height: 12px;
  background: #d9e0e8;
}
#dropship-area .dropship-selection-actions button {
  width: auto;
  min-width: 0;
  min-height: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: #64748b;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
}
#dropship-area .dropship-selection-actions button:hover {
  color: #2563eb;
  background: transparent;
  box-shadow: none;
}
#dropship-area .dropship-address-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
#dropship-area .dropship-address-picker {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}
#dropship-area .dropship-store-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #d5dde7;
  border-radius: 5px;
  color: #334155;
  background: #fff;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
#dropship-area .dropship-store-option:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}
#dropship-area .dropship-store-option:has(input:checked) {
  border-color: #0f766e;
  color: #0f6b64;
  background: #f0fdfa;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.08);
}
#dropship-area .dropship-store-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
#dropship-area .dropship-store-option:focus-within {
  outline: 2px solid rgba(37, 99, 235, .24);
  outline-offset: 2px;
}
#dropship-area .dropship-choice-mark {
  display: inline-grid;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  place-items: center;
  border: 1px solid #c4ced9;
  border-radius: 4px;
  color: transparent;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}
#dropship-area .dropship-store-option:has(input:checked) .dropship-choice-mark {
  border-color: #0f766e;
  color: #fff;
  background: #0f766e;
}
#dropship-area .dropship-store-name {
  overflow-wrap: anywhere;
}
#dropship-area .dropship-store-option small {
  padding-left: 7px;
  border-left: 1px solid #d8e0e8;
  color: #7c8797;
  font-size: 11px;
}
#dropship-area .dropship-sync-btn {
  flex: 0 0 auto;
  min-width: 104px;
  padding: 0 15px;
  border: 1px solid #0f766e;
  color: #fff;
  background: #0f766e;
}
#dropship-area .dropship-sync-btn:hover {
  border-color: #115e59;
  background: #115e59;
  box-shadow: 0 4px 10px rgba(15, 118, 110, .18);
}
#dropship-area .dropship-generate-btn:disabled,
#dropship-area .dropship-sync-btn:disabled {
  cursor: not-allowed;
  opacity: .58;
}
body:not(.has-svg-icons) #dropship-area .dropship-command-bar button::before {
  display: none;
  content: none;
}
@media (max-width: 1080px) {
  #dropship-area .dropship-command-bar {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  #dropship-area .dropship-command-primary {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding-right: 0;
    padding-bottom: 13px;
    border-right: 0;
    border-bottom: 1px solid #e5eaf0;
  }
}
@media (max-width: 680px) {
  #dropship-area .dropship-command-bar {
    padding: 14px;
  }
  #dropship-area .dropship-address-heading,
  #dropship-area .dropship-address-controls {
    align-items: stretch;
    flex-direction: column;
  }
  #dropship-area .dropship-selection-actions {
    align-self: flex-start;
  }
  #dropship-area .dropship-store-option {
    width: 100%;
  }
  #dropship-area .dropship-sync-btn {
    width: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  #dropship-area .dropship-store-option {
    transition: none;
  }
}
/* ===== End dropship command bar ===== */
/* ===== Sidebar hierarchy refinement ===== */
.sidebar nav {
  gap: 2px;
}

.sidebar .nav-home {
  min-height: 40px;
  margin: 3px 0 11px;
  padding: 8px 11px;
  border-radius: 6px;
}

.sidebar-group {
  --group-accent: #64748b;
  --group-soft: #f1f5f9;
  margin-top: 7px;
}

.sidebar-group[data-nav-group="operations"],
.sidebar-group[data-nav-group="system-operations"] {
  --group-accent: #2563eb;
  --group-soft: #eff6ff;
}

.sidebar-group[data-nav-group="supply-chain"] {
  --group-accent: #d97706;
  --group-soft: #fff7ed;
}

.sidebar-group[data-nav-group="offline"] {
  --group-accent: #0891b2;
  --group-soft: #ecfeff;
}

.sidebar-group[data-nav-group="merchant-tools"],
.sidebar-group[data-nav-group="system-governance"] {
  --group-accent: #7c3aed;
  --group-soft: #f5f3ff;
}

.sidebar-group[data-nav-group="accounts"] {
  --group-accent: #dc2626;
  --group-soft: #fff1f2;
}

.sidebar-group .nav-group {
  grid-template-columns: 28px minmax(0, 1fr) 10px;
  gap: 9px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid #e1e7ef;
  border-radius: 6px;
  color: #334155;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 750;
  box-shadow: none;
}

.sidebar-group .nav-group:hover {
  color: #172033;
  border-color: #ccd6e3;
  background: #f3f6fa;
  box-shadow: none;
}

.sidebar-group .nav-group > span:not(.sidebar-group-chevron) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-group .nav-group .ui-icon {
  box-sizing: border-box;
  width: 28px;
  height: 28px;
  padding: 5px;
  border: 1px solid #e1e7ef;
  border-radius: 5px;
  color: var(--group-accent);
  background: #fff;
  opacity: 1;
}

.sidebar-group.is-open > .nav-group {
  border-color: #d5dde8;
  color: #172033;
  background: #eef2f6;
}

.sidebar-group:has(.sidebar-group-links a.active) > .nav-group {
  border-color: #cbd7e6;
  color: #172033;
  background: var(--group-soft);
  box-shadow: inset 3px 0 0 var(--group-accent);
}

.sidebar-group-chevron {
  width: 7px;
  height: 7px;
  margin: 0 2px 0 0;
  color: #7b8797;
}

.sidebar-group-links {
  margin: 3px 0 4px 14px;
  padding: 3px 0 3px 13px;
  border-left: 1px solid #d8e0ea;
}

.sidebar-group.is-open .sidebar-group-links {
  display: block;
}

.sidebar-group-links a {
  min-height: 35px;
  margin: 1px 0;
  padding: 7px 9px !important;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #526071;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  font-weight: 600;
}

.sidebar-group-links a:hover {
  color: #172033;
  border-color: transparent;
  background: #f1f4f8;
  box-shadow: none;
}

.sidebar-group-links a .ui-icon {
  width: 15px;
  height: 15px;
  color: #7b8797;
  opacity: .92;
}

.sidebar-group-links a.active {
  color: #0b5fcb;
  border-color: #d9e8fb;
  background: #edf6ff;
  box-shadow: inset 2px 0 0 #2563eb;
  font-weight: 750;
}

.sidebar-group-links a.active .ui-icon {
  color: #2563eb;
  opacity: 1;
}

.sidebar-group-links a.active::before {
  display: none;
}

.sidebar-group .nav-group:focus-visible,
.sidebar-group-links a:focus-visible,
.sidebar .nav-home:focus-visible {
  outline: 2px solid rgba(37, 99, 235, .28);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .sidebar nav {
    display: flex;
    flex-direction: column;
  }

  .sidebar-group-links {
    margin-left: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-group .nav-group,
  .sidebar-group-links a {
    transition: none;
  }
}
/* ===== End sidebar hierarchy refinement ===== */
