:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --border: #e6e8f0;
  --border-strong: #d8dcea;
  --danger: #dc2626;
  --success: #047857;
  --shadow: 0 10px 34px rgba(17, 24, 39, 0.06);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 12% -8%, #e8eaff 0%, rgba(232, 234, 255, 0) 62%),
    radial-gradient(900px 480px at 100% 0%, #edf6ff 0%, rgba(237, 246, 255, 0) 58%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.84);
  border-bottom: 1px solid rgba(230, 232, 240, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo,
.login-logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #4f46e5 55%, #4338ca);
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.32);
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-text p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.shop-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shop-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

#shopSelect {
  height: 36px;
  padding: 0 32px 0 12px;
  border: 1.5px solid #c7c9f5;
  border-radius: 9px;
  background: #fff;
  color: #312e81;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

#shopSelect:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 404px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 28px 8px;
}

.left-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}

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

.card-head h2 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.hint {
  color: var(--muted-2);
  font-size: 11.5px;
}

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-wide { grid-column: 1 / -1; }

.field span {
  color: #374151;
  font-size: 12.5px;
  font-weight: 600;
}

.field input,
.field textarea,
.search-input,
.login-card input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fbfbfe;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.field input { height: 40px; }

.field textarea {
  resize: vertical;
  min-height: 58px;
  line-height: 1.55;
}

.field input:focus,
.field textarea:focus,
.search-input:focus,
.login-card input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.13);
}

.field input::placeholder,
.field textarea::placeholder,
.search-input::placeholder {
  color: #aab0c0;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  flex: 1;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5 55%, #4338ca);
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.28);
}

.btn.primary:hover { box-shadow: 0 10px 22px rgba(79, 70, 229, 0.36); }

.btn.ghost {
  color: #374151;
  background: #fff;
  border-color: var(--border-strong);
}

.btn.ghost:hover {
  border-color: #b9bdf0;
  background: #f8f8ff;
  color: var(--primary-dark);
}

.btn.danger {
  color: var(--danger);
  background: #fff;
  border-color: #fecaca;
}

.btn.danger:hover { background: #fff5f5; }

.btn.small {
  height: 34px;
  padding: 0 13px;
  font-size: 12.5px;
  border-radius: 9px;
}

.btn.block { width: 100%; }

/* ---------- 结果 ---------- */
.result-card {
  background: linear-gradient(180deg, #ffffff 0%, #fbfbff 100%);
}

.empty-state {
  padding: 26px 14px;
  border: 1px dashed #d9dcec;
  border-radius: 12px;
  color: var(--muted-2);
  font-size: 12.5px;
  text-align: center;
  line-height: 1.8;
}

.result-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid #e0e3ff;
  border-radius: 13px;
  background: linear-gradient(135deg, #f6f5ff, #eef2ff);
}

.result-label {
  color: #4b5563;
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.result-price {
  margin-top: 4px;
  color: var(--danger);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.badge {
  flex: none;
  max-width: 46%;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #d6d9ff;
  color: var(--primary-dark);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.badge.warn {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fff7f7;
}

.alert {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.75;
}

.alert.danger {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.alert.success {
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: var(--success);
}

.steps {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #e8ebf5;
  border-radius: 12px;
  background: #fafbff;
  color: #475569;
  font-size: 12.5px;
  line-height: 2;
  overflow-wrap: anywhere;
}

.steps-title {
  margin-bottom: 4px;
  color: #334155;
  font-weight: 700;
}

.steps b {
  color: #111827;
  font-weight: 700;
}

/* ---------- 历史记录 ---------- */
.history-card {
  padding-bottom: 12px;
  min-width: 0;
}

.history-head {
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11.5px;
  font-weight: 700;
}

.search-input {
  width: 220px;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.import-report {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12.5px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.import-report .report-title { font-weight: 700; }

.import-report details { margin-top: 6px; }

.import-report summary {
  cursor: pointer;
  color: #4338ca;
  font-weight: 600;
}

.import-report ul {
  margin: 6px 0 0;
  padding-left: 18px;
  color: #475569;
}

.table-wrap {
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.records-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.records-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 10px;
  background: #f7f8ff;
  border-bottom: 1px solid var(--border);
  color: #4b5563;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.records-table tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid #f0f1f7;
  text-align: center;
  white-space: nowrap;
  color: #374151;
}

.records-table tbody tr:last-child td { border-bottom: none; }

.records-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.records-table tbody tr:hover { background: #f8f9ff; }

.records-table tbody tr.selected { background: #eef2ff; }

.check-col,
.records-table td.check-col {
  width: 36px;
  padding-left: 12px;
  padding-right: 0;
}

.records-table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.name-cell {
  min-width: 240px;
  max-width: 360px;
  text-align: left !important;
  white-space: normal !important;
  line-height: 1.55;
}

.name-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price-cell {
  color: #b91c1c;
  font-weight: 700;
}

.muted-cell { color: #9ca3af; }

.raise-cell {
  color: #b91c1c;
  font-weight: 600;
}

.empty-row td {
  padding: 36px 12px !important;
  color: var(--muted-2);
  white-space: normal !important;
}

.table-status {
  padding: 10px 4px 2px;
  color: var(--muted);
  font-size: 11.5px;
}

/* ---------- 页脚 ---------- */
.footnote {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 10px 28px 28px;
  color: var(--muted-2);
  font-size: 11.5px;
  line-height: 1.8;
}

/* ---------- 登录 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 30px 28px 24px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(17, 24, 39, 0.28);
  text-align: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 15px;
  font-size: 25px;
}

.login-card h2 {
  font-size: 18px;
  font-weight: 800;
}

.login-sub {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 12.5px;
}

.login-card input {
  height: 42px;
  margin-bottom: 12px;
  text-align: center;
  letter-spacing: 2px;
}

.login-error {
  min-height: 18px;
  margin-top: 8px;
  color: var(--danger);
  font-size: 12px;
}

.login-hint {
  margin-top: 8px;
  color: var(--muted-2);
  font-size: 11px;
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.14);
  font-size: 12.5px;
  line-height: 1.7;
  animation: toast-in 0.18s ease-out;
  overflow-wrap: anywhere;
}

.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .left-col { order: 1; }
  .history-card { order: 2; }
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
  }

  .brand-text p { display: none; }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .layout {
    padding: 16px 14px 4px;
    gap: 14px;
  }

  .card { padding: 16px; border-radius: 14px; }

  .form-grid { grid-template-columns: minmax(0, 1fr); }

  .form-actions { flex-wrap: wrap; }

  .form-actions .btn.primary { flex: 1 1 100%; }

  .search-input { width: 100%; }

  .history-head { align-items: stretch; }

  .table-wrap { max-height: 520px; }

  .footnote { padding: 10px 16px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
