:root {
  --bg: #f5f7fb;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1f2937;
  --muted: #7a8595;
  --border: #e1e7ef;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 13px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.btn:hover {
  background: #f8fafc;
}

.btn.primary,
button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover,
button.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

button.danger,
.danger {
  color: var(--danger);
  border-color: #fecaca;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
  font-size: 13px;
}

input:focus,
textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.11);
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  padding: 0;
  accent-color: var(--primary);
  box-shadow: none;
}

textarea {
  resize: vertical;
}

.app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
  padding: 16px 12px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 6px 6px 12px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  background: #f8fafc;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.sidebar-add {
  width: 100%;
  margin-bottom: 12px;
  border-style: dashed;
  color: var(--primary);
}

.brand-list {
  display: grid;
  gap: 8px;
}

.brand-item {
  display: block;
  width: 100%;
  min-height: auto;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.brand-item:hover {
  border-color: var(--border);
  background: #f8fafc;
}

.brand-item.active {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.brand-name,
.brand-meta {
  display: block;
}

.brand-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.side-empty {
  padding: 16px 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.main {
  min-width: 0;
  padding: 22px 24px 32px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  background: #fff;
}

.table-toolbar h2 {
  margin: 0;
  font-size: 16px;
}

.table-title-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
}

#itemCount {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.sku-search {
  display: inline-flex;
  height: 36px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 10px;
  background: #f8fafc;
}

.sku-search {
  width: 280px;
  min-width: 180px;
}

.tone-picker {
  position: relative;
}

.sku-search svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: #64748b;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.sku-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font: inherit;
  font-size: 13px;
}

.sku-search input::placeholder {
  color: #94a3b8;
}

.tone-trigger {
  display: inline-flex;
  min-width: 132px;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #dbe4ef;
  border-radius: 999px;
  padding: 0 12px;
  color: #334155;
  background: linear-gradient(180deg, #fff, #f8fafc);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  font-size: 13px;
  font-weight: 800;
}

.tone-trigger:hover,
.tone-trigger[aria-expanded="true"] {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #eff6ff;
}

.tone-trigger svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.tone-trigger .tone-caret {
  width: 14px;
  height: 14px;
}

.tone-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  display: grid;
  width: 188px;
  gap: 4px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(14px);
}

.tone-menu button {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 11px;
  padding: 0 10px;
  color: #334155;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.tone-menu button:hover,
.tone-menu button.active {
  color: #0f172a;
  background: #f1f5f9;
}

.tone-dot {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.tone-dot-cool { background: linear-gradient(135deg, #0a84ff, #10b3a8); }
.tone-dot-warm { background: linear-gradient(135deg, #f97316, #ef4444); }
.tone-dot-sunset { background: linear-gradient(135deg, #f2b8a2, #d77b61); }
.tone-dot-forest { background: linear-gradient(135deg, #c7d8be, #6f8f6d); }
.tone-dot-berry { background: linear-gradient(135deg, #ead2dc, #b97d91); }
.tone-dot-cream { background: linear-gradient(135deg, #efe3cc, #b9996a); }
.tone-dot-mono { background: linear-gradient(135deg, #d8d8d6, #777b82); }
.tone-dot-ocean { background: linear-gradient(135deg, #d2e5ee, #6d98aa); }

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

#selectedCount {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1618px;
  border-collapse: collapse;
  table-layout: fixed;
}

.col-select {
  width: 34px;
}

.col-index {
  width: 38px;
}

.col-sku {
  width: 132px;
}

.col-itemid {
  width: 75px;
}

.col-image {
  width: 88px;
}

.col-title {
  width: 220px;
}

.col-name {
  width: 150px;
}

.col-shop {
  width: 190px;
}

.col-benefit {
  width: 150px;
}

.col-gifts {
  width: 180px;
}

.col-cash {
  width: 135px;
}

.col-link {
  width: 145px;
}

.col-status {
  width: 132px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 9px;
  text-align: center;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.th-with-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.bulk-chip {
  min-height: 26px;
  border-color: #93c5fd;
  border-radius: 8px;
  padding: 0 8px;
  background: #dbeafe;
  color: #315a8d;
  font-size: 12px;
  font-weight: 800;
}

.bulk-chip:hover {
  border-color: #60a5fa;
  background: #bfdbfe;
}

.bulk-chip:disabled {
  opacity: 0.45;
}

.bulk-plus {
  margin-right: 2px;
  font-size: 16px;
  line-height: 1;
}

td {
  color: #334155;
  font-size: 13px;
}

tbody tr:hover {
  background: #fbfdff;
}

tbody tr.selected {
  background: #eff6ff;
}

tbody tr.duplicate-sku {
  --duplicate-bg: #fffbeb;
  --duplicate-hover: #fef3c7;
  --duplicate-border: #f59e0b;
  --duplicate-text: #92400e;
  background: var(--duplicate-bg);
}

tbody tr.duplicate-sku:hover {
  background: var(--duplicate-hover);
}

tbody tr.duplicate-sku.selected {
  background: #dbeafe;
}

tbody tr.duplicate-sku td:nth-child(3) .cell-input {
  border-color: var(--duplicate-border);
  background: color-mix(in srgb, var(--duplicate-bg) 72%, #fff);
  color: var(--duplicate-text);
  font-weight: 700;
}

tbody tr.duplicate-sku-1 {
  --duplicate-bg: #fffbeb;
  --duplicate-hover: #fef3c7;
  --duplicate-border: #f59e0b;
  --duplicate-text: #92400e;
}

tbody tr.duplicate-sku-2 {
  --duplicate-bg: #eff6ff;
  --duplicate-hover: #dbeafe;
  --duplicate-border: #3b82f6;
  --duplicate-text: #1d4ed8;
}

tbody tr.duplicate-sku-3 {
  --duplicate-bg: #f0fdf4;
  --duplicate-hover: #dcfce7;
  --duplicate-border: #22c55e;
  --duplicate-text: #15803d;
}

tbody tr.duplicate-sku-4 {
  --duplicate-bg: #fdf2f8;
  --duplicate-hover: #fce7f3;
  --duplicate-border: #ec4899;
  --duplicate-text: #be185d;
}

tbody tr.duplicate-sku-5 {
  --duplicate-bg: #f5f3ff;
  --duplicate-hover: #ede9fe;
  --duplicate-border: #8b5cf6;
  --duplicate-text: #6d28d9;
}

tbody tr.duplicate-sku-6 {
  --duplicate-bg: #ecfeff;
  --duplicate-hover: #cffafe;
  --duplicate-border: #06b6d4;
  --duplicate-text: #0e7490;
}

.select-cell {
  padding-left: 6px;
  padding-right: 4px;
  text-align: center;
}

th:nth-child(2),
td:nth-child(2) {
  padding-left: 4px;
  padding-right: 6px;
}

.item-check {
  cursor: pointer;
}

.cell-input {
  height: 32px;
  padding: 6px 8px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-row {
  height: 72px;
  color: var(--muted);
  font-size: 14px;
}

.gift-cell {
  position: relative;
  display: block;
}

.gift-cell .gift-input {
  width: 100%;
  padding-right: 34px;
}

.gift-upload {
  position: absolute;
  top: 50%;
  right: 4px;
  display: inline-flex;
  width: 26px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  padding: 0;
  color: #1d4ed8;
  background: transparent;
  transform: translateY(-50%);
}

.gift-upload:hover {
  background: #dbeafe;
}

.gift-upload svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.index-cell {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.image-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: #eef2f7;
}

.image-cell img {
  display: block;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  background: #eef2f7;
}

.image-thumb:hover {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.ellipsis {
  display: block;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-full {
  display: inline-block;
  color: var(--primary);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-full:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  white-space: nowrap;
  border-radius: 999px;
  padding: 3px 8px;
  background: #ecfdf3;
  color: #027a48;
  font-size: 12px;
  font-weight: 700;
}

.status.failed {
  background: #fef2f2;
  color: var(--danger);
}

.icon-action {
  width: 30px;
  min-height: 30px;
  border-radius: 9px;
  padding: 0;
  color: #64748b;
}

.toolbar-action {
  width: 42px;
  min-height: 38px;
  border-radius: 12px;
  background: #fff;
}

.icon-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-action.toolbar-action svg {
  width: 18px;
  height: 18px;
}

.icon-action:hover {
  color: var(--primary);
  background: #eff6ff;
}

.icon-action.danger:hover {
  color: var(--danger);
  background: #fef2f2;
}

.empty {
  display: grid;
  min-height: 360px;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 18%, rgba(59, 130, 246, 0.14), transparent 34%),
    rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(760px, 96vw);
  max-height: min(760px, 92vh);
  overflow: auto;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 22px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
}

.import-card {
  width: min(760px, 94vw);
  overflow: hidden;
}

.modal-card.square {
  width: 420px;
  min-height: 420px;
}

.modal-card.compact {
  width: 420px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}

.import-head {
  padding: 18px 20px 16px;
  background:
    linear-gradient(135deg, rgba(239, 246, 255, 0.92), rgba(255, 255, 255, 0.98)),
    #fff;
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
}

.import-head h2 {
  color: #0f172a;
  font-size: 18px;
}

.import-head p {
  margin: 5px 0 0;
  color: #64748b;
  font-size: 13px;
}

.icon-btn {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.import-head .icon-btn {
  border-color: #dbe4ef;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.import-body {
  gap: 14px;
  padding: 18px 20px 20px;
}

.import-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  padding: 11px 13px;
  background: linear-gradient(135deg, #eff6ff, #f8fbff);
  color: #1e40af;
  font-size: 13px;
}

.import-help span {
  font-weight: 900;
}

.import-help strong {
  color: #475569;
  font-weight: 700;
}

.sku-bulk-card,
.import-default-card {
  display: grid;
  gap: 9px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.sku-bulk-card > span,
.default-card-title {
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
}

.sku-bulk-input {
  border: 1px solid #dbe4ef;
  border-radius: 14px;
  padding: 10px;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, 0.12) 1px, transparent 1px) 0 0 / 100% 24px,
    #fbfdff;
}

.sku-bulk-input textarea {
  min-height: 214px;
  border: 0;
  border-radius: 10px;
  padding: 0;
  color: #334155;
  background: transparent;
  box-shadow: none;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 24px;
}

.sku-bulk-input textarea:focus {
  box-shadow: none;
}

.import-defaults {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.import-defaults input {
  height: 38px;
  border-radius: 12px;
  background: #fbfdff;
}

.import-actions {
  padding-top: 2px;
}

.import-actions .btn {
  min-height: 44px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.24);
}

.full {
  width: 100%;
}

.toast {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 200;
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  background: rgba(15, 23, 42, 0.92);
  font-size: 13px;
  opacity: 0;
  transform: translateY(-8px);
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.image-preview {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.68);
}

.image-preview img {
  max-width: min(760px, 92vw);
  max-height: 86vh;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.35);
  object-fit: contain;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .main {
    padding: 16px 12px 24px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .import-table,
  .import-defaults {
    grid-template-columns: 1fr;
  }
}
