:root {
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --primary-soft: #e6f4ff;
  --sidebar: #001529;
  --page: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f5f7fa;
  --border: #e5e6eb;
  --border-strong: #c9cdd4;
  --text: #1d2129;
  --text-secondary: #4e5969;
  --text-tertiary: #86909c;
  --success: #00b42a;
  --success-soft: #e8ffea;
  --warning: #ff7d00;
  --warning-soft: #fff7e8;
  --danger: #f53f3f;
  --danger-soft: #ffece8;
  --radius: 4px;
  --shadow: 0 8px 24px rgba(29, 33, 41, 0.12);
  --font: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button { border: 0; }
a { color: inherit; text-decoration: none; }

.app-container { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 208px;
  overflow-y: auto;
  color: rgba(255, 255, 255, 0.72);
  background: var(--sidebar);
}
.sidebar-logo {
  display: flex;
  height: 64px;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-logo h1 { margin: 0; color: #fff; font-size: 18px; font-weight: 600; }
.sidebar-nav { padding: 18px 12px; }
.nav-section { margin-bottom: 24px; }
.nav-section-title {
  padding: 0 12px 8px;
  color: rgba(255, 255, 255, 0.36);
  font-size: 11px;
  letter-spacing: .4px;
}
.nav-item {
  display: flex;
  width: 100%;
  height: 40px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  margin: 2px 0;
  color: rgba(255, 255, 255, .68);
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: background .2s, color .2s;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.active { color: #fff; background: var(--primary); }
.nav-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  color: currentColor;
  font-size: 15px;
  line-height: 1;
}

.main-content { min-height: 100vh; margin-left: 208px; }
.content-header {
  padding: 18px 28px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: var(--text-tertiary);
  font-size: 12px;
}
.breadcrumb a:hover { color: var(--primary); }
.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-title { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.35; }
.page-subtitle { margin: 6px 0 0; color: var(--text-tertiary); font-size: 12px; }
.title-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 2px; }
.content-body { max-width: 1560px; padding: 24px 28px 48px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.btn {
  display: inline-flex;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: all .2s;
}
.btn:hover { color: var(--primary); border-color: var(--primary); }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { color: #fff; background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-default { background: var(--surface); }
.btn-group { display: flex; gap: 8px; }
.hidden { display: none !important; }

.filter-section {
  padding: 18px 20px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px; }
.filter-item { display: flex; align-items: center; gap: 8px; }
.filter-item label { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
input[type="text"], input[type="number"], select {
  height: 32px;
  min-width: 136px;
  padding: 0 9px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  font-size: 12px;
  transition: border .2s, box-shadow .2s;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, .12);
}

.object-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.product-thumb {
  display: flex;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  background: linear-gradient(145deg, #f1f3f5, #e7e9ec);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}
.large-thumb { width: 64px; height: 64px; flex-basis: 64px; }
.summary-main { min-width: 0; flex: 1; }
.summary-title { margin-bottom: 9px; font-size: 16px; font-weight: 600; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px 24px; }
.summary-grid div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.summary-grid span { color: var(--text-tertiary); font-size: 11px; }
.summary-grid strong { overflow: hidden; color: var(--text-secondary); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.sync-status { display: flex; flex: 0 0 246px; flex-direction: column; gap: 6px; align-items: flex-end; }
.sync-copy { color: var(--text-tertiary); font-size: 11px; line-height: 1.55; text-align: right; }
.tag { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: 3px; font-size: 11px; white-space: nowrap; }
.tag-info { color: var(--primary); background: var(--primary-soft); }
.tag-success { color: var(--success); background: var(--success-soft); }
.tag-warning { color: var(--warning); background: var(--warning-soft); }
.tag-danger { color: var(--danger); background: var(--danger-soft); }

.section-card {
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.section-head h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.section-head p { margin: 0; color: var(--text-tertiary); font-size: 12px; }
.compact-head { padding-bottom: 14px; }
.table-wrapper { overflow-x: auto; }
.data-table, .operation-log-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table { min-width: 960px; }
.data-table th, .data-table td, .operation-log-table th, .operation-log-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.data-table th, .operation-log-table th { color: var(--text-secondary); background: var(--surface-soft); font-weight: 600; white-space: nowrap; }
.data-table td { color: var(--text); }
.data-table tbody tr:hover td { background: #f8fbff; }
.data-table tbody tr:last-child td, .operation-log-table tbody tr:last-child td { border-bottom: 0; }
.color-cell { display: flex; align-items: center; gap: 8px; }
.color-dot { width: 18px; height: 18px; border: 1px solid rgba(0,0,0,.12); border-radius: 50%; }
.cell-main { font-weight: 500; }
.cell-sub { margin-top: 2px; color: var(--text-tertiary); font-size: 11px; }
.size-list { display: flex; flex-wrap: wrap; gap: 4px; }
.size-chip { display: inline-flex; height: 22px; align-items: center; padding: 0 7px; color: var(--text-secondary); background: var(--surface-soft); border: 1px solid var(--border); border-radius: 3px; font-size: 11px; }
.status-cell { white-space: nowrap; }
.action-link { padding: 0; color: var(--primary); background: transparent; cursor: pointer; font-size: 12px; }
.action-link:hover { color: var(--primary-hover); }
.operation-log-table { min-width: 720px; }
.operation-log-table th, .operation-log-table td { padding: 11px 14px; line-height: 1.65; }
.operation-log-table tbody tr:first-child td { background: #fbfcfe; }
.form-tip { padding: 13px 20px 16px; color: var(--text-tertiary); font-size: 11px; line-height: 1.7; }

.source-layout { display: flex; align-items: flex-start; gap: 18px; }
.source-main { min-width: 0; flex: 1; }
.source-summary { align-items: flex-start; }
.source-summary .summary-main { padding-top: 2px; }
.source-table-wrapper { max-height: 620px; overflow: auto; }
.source-table { min-width: 1120px; }
.source-table th:nth-child(1), .source-table td:nth-child(1) { min-width: 120px; }
.source-table th:nth-child(2), .source-table td:nth-child(2) { min-width: 90px; }
.source-table th:nth-child(3), .source-table td:nth-child(3) { min-width: 130px; }
.source-table th:nth-child(4), .source-table td:nth-child(4) { min-width: 125px; }
.source-table th:nth-child(5), .source-table td:nth-child(5) { min-width: 102px; }
.source-table th:nth-child(6), .source-table td:nth-child(6) { min-width: 220px; }
.source-table th:nth-child(7), .source-table td:nth-child(7) { min-width: 90px; }
.source-table .edit-field { width: 100%; min-width: 0; height: 30px; }
.source-table .url-input { min-width: 200px; }
.source-table .row-action { color: var(--text-tertiary); }
.source-table .row-action.editable { color: var(--primary); cursor: pointer; }
.source-table .new-row td { background: #fffaf0; }
.source-table .new-row td:first-child { border-left: 3px solid var(--warning); }
.anchor-aside { width: 226px; flex: 0 0 226px; position: sticky; top: 18px; }
.anchor-nav { padding: 15px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.anchor-nav-title { padding-bottom: 11px; margin-bottom: 3px; border-bottom: 1px solid var(--border); color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.rule-item { display: flex; flex-direction: column; gap: 2px; padding: 11px 0; border-bottom: 1px solid #f0f1f3; }
.rule-item:last-child { border-bottom: 0; padding-bottom: 0; }
.rule-item strong { color: var(--text-secondary); font-size: 11px; }
.rule-item span { color: var(--text-tertiary); font-size: 11px; line-height: 1.55; }

.modal-mask { display: none; position: fixed; inset: 0; z-index: 1000; align-items: flex-start; justify-content: center; padding: 38px 20px; background: rgba(0, 21, 41, .46); }
.modal-mask.open { display: flex; }
.modal { display: flex; width: min(1020px, 100%); max-height: calc(100vh - 76px); flex-direction: column; background: var(--surface); border-radius: 6px; box-shadow: var(--shadow); }
.modal-header { display: flex; height: 58px; align-items: center; justify-content: space-between; flex: 0 0 58px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 17px; font-weight: 600; }
.modal-close { width: 30px; height: 30px; color: var(--text-tertiary); background: transparent; border-radius: 3px; cursor: pointer; font-size: 24px; line-height: 1; }
.modal-close:hover { color: var(--text); background: var(--surface-soft); }
.modal-body { overflow-y: auto; padding: 20px 24px 28px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; flex: 0 0 66px; padding: 16px 24px; border-top: 1px solid var(--border); }
.modal-product { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 20px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius); }
.modal-product-title { margin-bottom: 2px; font-size: 14px; font-weight: 600; }
.modal-product-meta { color: var(--text-tertiary); font-size: 11px; }
.modal-product .tag { margin-left: auto; }
.field-block { padding: 16px 0 18px; border-top: 1px solid var(--border); }
.field-block:first-of-type { border-top: 0; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.field-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.field-actions { display: flex; gap: 12px; }
.link-btn { padding: 0; color: var(--primary); background: transparent; cursor: pointer; font-size: 12px; }
.link-btn:hover { color: var(--primary-hover); }
.size-groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.size-group { padding: 13px 14px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius); }
.size-group-title { margin-bottom: 10px; color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.checkbox-grid { display: grid; grid-template-columns: repeat(4, minmax(50px, 1fr)); gap: 8px 12px; }
.checkbox-label { display: flex; align-items: center; gap: 7px; color: var(--text-secondary); cursor: pointer; font-size: 12px; }
.checkbox-label input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.selected-counter { color: var(--text-tertiary); font-size: 12px; }
.selected-counter strong { color: var(--primary); font-weight: 600; }
.color-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.color-group { padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.color-group-title { margin-bottom: 10px; font-size: 13px; font-weight: 600; }
.color-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.color-option { position: relative; min-width: 0; padding: 8px 6px; color: var(--text-secondary); background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; text-align: left; transition: all .18s; }
.color-option:hover { background: #fbfcfe; border-color: var(--border-strong); }
.color-option.selected { background: var(--primary-soft); border-color: var(--primary); }
.color-option.selected::after { content: "✓"; position: absolute; top: 5px; right: 6px; color: var(--primary); font-size: 12px; font-weight: 700; }
.color-swatch { width: 100%; height: 26px; margin-bottom: 7px; border: 1px solid rgba(0,0,0,.08); border-radius: 2px; }
.color-name { display: block; overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.color-en { display: block; overflow: hidden; margin-top: 1px; color: var(--text-tertiary); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; right: 28px; bottom: 28px; z-index: 1100; display: none; padding: 12px 16px; color: #fff; background: rgba(29,33,41,.88); border-radius: 4px; box-shadow: var(--shadow); font-size: 13px; }
.toast.show { display: block; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .sync-status { flex-basis: 220px; }
  .source-layout { display: block; }
  .anchor-aside { width: auto; position: static; margin-top: 18px; }
  .anchor-nav { display: grid; grid-template-columns: 120px repeat(4, minmax(0, 1fr)); align-items: stretch; gap: 0 16px; }
  .anchor-nav-title { padding: 11px 0; margin: 0; border: 0; }
  .rule-item { padding: 11px 0; border-bottom: 0; border-left: 1px solid var(--border); padding-left: 16px; }
}
@media (max-width: 860px) {
  .sidebar { position: static; width: 100%; height: auto; }
  .sidebar-logo { height: 54px; }
  .sidebar-nav { display: flex; gap: 16px; padding: 10px 16px; overflow-x: auto; }
  .nav-section { display: flex; align-items: center; gap: 4px; margin: 0; }
  .nav-section-title { display: none; }
  .nav-item { width: auto; flex: 0 0 auto; padding: 0 12px; }
  .main-content { margin-left: 0; }
  .content-header { padding: 16px 18px 18px; }
  .content-body { padding: 18px 18px 36px; }
  .title-row, .object-summary { display: block; }
  .title-actions { justify-content: flex-start; padding-top: 16px; }
  .object-summary .product-thumb { float: left; margin: 0 12px 8px 0; }
  .object-summary::after { display: block; clear: both; content: ""; }
  .summary-grid { clear: both; padding-top: 14px; }
  .sync-status { align-items: flex-start; margin-top: 14px; }
  .sync-copy { text-align: left; }
  .size-groups, .color-columns { grid-template-columns: 1fr; }
  .color-options { grid-template-columns: repeat(5, minmax(70px, 1fr)); }
  .anchor-nav { display: block; }
  .anchor-nav-title { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
  .rule-item { padding: 10px 0; border-bottom: 1px solid #f0f1f3; border-left: 0; }
}
@media (max-width: 540px) {
  .filter-row { display: grid; grid-template-columns: 1fr; }
  .filter-item { justify-content: space-between; }
  .filter-item input, .filter-item select { width: 70%; }
  .filter-row .btn-group { justify-content: flex-end; }
  .modal-mask { padding: 0; }
  .modal { max-height: 100vh; border-radius: 0; }
  .modal-header { padding: 0 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 16px; }
  .color-options { grid-template-columns: repeat(3, minmax(70px, 1fr)); }
  .selected-counter { font-size: 11px; }
  .field-head.color-head { align-items: flex-start; flex-direction: column; }
}
