* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #eef2f7;
  color: #1f2937;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #1e293b;
  color: #e2e8f0;
  padding: 20px 0;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  padding: 0 20px 20px;
}

.nav-group {
  padding: 0 12px;
}

.nav-title {
  font-size: 12px;
  color: #94a3b8;
  padding: 8px;
}

.nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  margin-bottom: 4px;
}

.nav-item.active {
  background: #2563eb;
  color: #fff;
}

.nav-item.disabled {
  color: #64748b;
}

a.nav-item {
  color: inherit;
  text-decoration: none;
}

.top-note {
  margin: 4px 0 0;
  color: #6b7280;
  font-size: 13px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #2563eb;
  border-radius: 10px;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #dc2626;
  border-radius: 10px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.btn.danger {
  background: #dc2626;
  color: #fff;
}

.btn.danger.ghost {
  background: #fff;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.card {
  position: relative;
}

.card-check {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 6px;
  padding: 4px;
}

.card-actions .danger-link {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 12px;
}

.main {
  flex: 1;
  padding: 20px 24px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.stats-bar {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #059669;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.filters input,
.filters select {
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  background: #e5e7eb;
  color: #111827;
}

.btn.primary {
  background: #2563eb;
  color: #fff;
}

.btn.ghost {
  background: #fff;
  border: 1px solid #d1d5db;
}

.file-btn {
  display: inline-flex;
  align-items: center;
}

.message {
  min-height: 24px;
  color: #059669;
  margin: 0 0 12px;
}

.message.error {
  color: #dc2626;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.product-card {
  position: relative;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.product-card.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.product-card-image {
  height: 150px;
  width: 100%;
  background: #fff;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: zoom-in;
}

.product-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.product-card-id {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 4px;
  font-size: 11px;
  color: #374151;
}

.ml-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #fff159;
  color: #1f2937;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.id-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #2563eb;
  text-decoration: none;
  font-size: 10px;
  word-break: break-all;
}

.id-text:hover {
  text-decoration: underline;
}

.copy-id-btn {
  border: none;
  background: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
}

.product-metrics {
  display: grid;
  gap: 0;
  border-top: 1px solid #f1f5f9;
}

.product-metrics-3 {
  grid-template-columns: repeat(3, 1fr);
}

.product-metrics-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.product-metrics-2 {
  grid-template-columns: repeat(2, 1fr);
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 4px;
  min-height: 46px;
  border-right: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  overflow: hidden;
}

.metric:last-child {
  border-right: none;
}

.metric-label {
  font-size: 9px;
  line-height: 1.15;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-cost .metric-label {
  color: #dc2626;
}

.metric-sale .metric-label {
  color: #2563eb;
}

.metric-commission .metric-label {
  color: #7c3aed;
}

.metric-shipping .metric-label {
  color: #0891b2;
}

.metric-profit .metric-label {
  color: #059669;
}

.metric-input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 2px 1px;
  min-height: 18px;
  line-height: 1.2;
  font-size: 11px;
  font-weight: 600;
  color: #111827;
  background: transparent;
  -moz-appearance: textfield;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-input::-webkit-outer-spin-button,
.metric-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.metric-input:hover,
.metric-input:focus {
  border-color: #93c5fd;
  background: #f8fbff;
  outline: none;
}

.metric-input.saving {
  opacity: 0.6;
}

.metric-input.saved {
  background: #ecfdf5;
}

.metric-input.metric-readonly,
.readonly-field {
  color: #6b7280;
  background: #f8fafc;
  cursor: default;
}

.product-title {
  display: block;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 600;
  color: #111827;
  text-decoration: none;
  word-break: break-word;
  min-height: 40px;
}

.product-title:hover {
  color: #2563eb;
  text-decoration: underline;
}

.product-card-select-zone {
  margin-top: auto;
  cursor: pointer;
  background: #fafafa;
  border-top: 1px dashed #e5e7eb;
}

.product-card-select-zone:hover {
  background: #f3f4f6;
}

.product-card.selected .product-card-select-zone {
  background: #eff6ff;
}

.product-footer {
  padding: 6px 10px 8px;
  font-size: 11px;
  color: #6b7280;
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-select-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.card-select-label input {
  margin: 0;
}

.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  line-height: 1.6;
}

.footer-group,
.footer-user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-date {
  flex-shrink: 0;
  color: #9ca3af;
}

.edit-link {
  border: none;
  background: none;
  color: #2563eb;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}

.card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
}

.card img {
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: #f8fafc;
}

.card-body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-meta {
  font-size: 12px;
  color: #6b7280;
}

.card-title {
  font-size: 14px;
  line-height: 1.4;
  min-height: 40px;
}

.card-price {
  color: #dc2626;
  font-weight: 700;
}

.card-package {
  font-size: 12px;
  color: #047857;
  background: #ecfdf5;
  padding: 6px 8px;
  border-radius: 6px;
}

.card-actions {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-actions a,
.card-actions button {
  font-size: 12px;
}

.card-actions button {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(420px, 92vw);
}

.edit-dialog {
  width: min(760px, 96vw);
  max-height: 92vh;
}

.edit-dialog form {
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

.edit-header,
.edit-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
}

.edit-footer {
  border-bottom: none;
  border-top: 1px solid #e5e7eb;
}

.edit-header h2 {
  margin: 0;
  font-size: 18px;
}

.edit-form-body {
  padding: 12px 18px 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-section {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
}

.edit-section-pricing {
  border-left: 4px solid #2563eb;
  background: #f8fbff;
}

.edit-section-basic {
  border-left: 4px solid #d97706;
}

.edit-section-logistics {
  border-left: 4px solid #0891b2;
}

.edit-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .product-metrics-4,
  .edit-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.edit-section h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.edit-section label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.edit-section input,
.edit-section select,
.edit-section textarea {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
}

.edit-grid-2,
.edit-grid-3 {
  display: grid;
  gap: 8px;
}

.edit-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.edit-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.edit-hint {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

.edit-warn {
  margin: 0;
  font-size: 12px;
  color: #b45309;
}

.edit-tag {
  font-size: 11px;
  color: #2563eb;
  font-weight: normal;
}

.edit-attrs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.edit-pictures {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-picture-btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  cursor: zoom-in;
}

.edit-picture-btn img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
}

.edit-footer-actions {
  display: flex;
  gap: 8px;
}

.dialog-close {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
}

.image-dialog {
  width: min(960px, 96vw);
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #111827;
}

.image-dialog::backdrop {
  background: rgba(17, 24, 39, 0.72);
}

.image-dialog img {
  display: block;
  width: 100%;
  max-height: 88vh;
  object-fit: contain;
  margin: 0 auto;
  image-rendering: auto;
}

.image-close {
  position: absolute;
  top: 8px;
  right: 12px;
  color: #fff;
  z-index: 2;
}

dialog form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

dialog label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

dialog input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.empty {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  color: #6b7280;
}

.auth-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.auth-panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.auth-meta {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
  font-size: 12px;
}

.auth-steps {
  margin: 0;
  padding-left: 20px;
  color: #475569;
  line-height: 1.8;
}

.btn.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.wizard-step {
  position: relative;
}

.wizard-badge {
  display: inline-block;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.wizard-step.wizard-done {
  border-color: #86efac;
  background: #f0fdf4;
}

.wizard-step.wizard-active {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.wizard-hint {
  color: #64748b;
  line-height: 1.6;
  margin: 0 0 14px;
}

.auth-form {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.auth-form input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 16px;
}
