* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: #1d2430;
  background: #f6f7f9;
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.login {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f6f7f9;
}

.login[hidden] {
  display: none;
}

.login-box {
  width: min(360px, calc(100vw - 32px));
  padding: 22px;
  background: #fff;
  border: 1px solid #dde1e7;
  border-radius: 8px;
}

.login-box label {
  display: block;
  margin-bottom: 12px;
}

.captcha-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.captcha-row input {
  flex: 1;
}

.captcha-image {
  height: 40px;
  width: 112px;
  border: 1px solid #c8ced8;
  border-radius: 6px;
  background: #f1f3f6;
  cursor: pointer;
  object-fit: contain;
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

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

h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

p {
  margin: 0;
  color: #5d6675;
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(220px, 300px) minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #dde1e7;
  border-radius: 8px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: #465162;
  font-size: 13px;
}

select,
input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #c8ced8;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
}

button {
  min-height: 38px;
  border: 1px solid #b8c0cc;
  border-radius: 6px;
  padding: 0 14px;
  background: #ffffff;
  color: #1d2430;
  cursor: pointer;
}

button.primary {
  border-color: #1769e0;
  background: #1769e0;
  color: #ffffff;
}

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

.status-line {
  min-height: 22px;
  margin: 14px 0;
  color: #465162;
}

.table-wrap {
  overflow: auto;
  background: #ffffff;
  border: 1px solid #dde1e7;
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #edf0f4;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  background: #f9fafb;
  color: #465162;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  background: #e9f7ef;
  color: #137333;
}

.badge.warn {
  background: #fff4df;
  color: #a05a00;
}

.store-photo {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  background: #edf0f4;
}

.photo-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: #edf0f4;
  color: #8a94a3;
  font-size: 12px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

/* ── Export History ─────────────────────────────────────────────────────────── */
.export-history {
  margin-bottom: 16px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #dde1e7;
  border-radius: 8px;
}

.export-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.export-history-header h2 {
  margin: 0;
  font-size: 16px;
  color: #1d2430;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.history-empty {
  text-align: center;
  color: #8a94a3;
  padding: 20px 0;
  font-size: 14px;
}

.history-record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #edf0f4;
  border-radius: 6px;
  background: #fafbfc;
  flex-wrap: wrap;
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.history-store {
  font-size: 14px;
  font-weight: 600;
  color: #1d2430;
}

.history-operator {
  font-size: 12px;
  color: #8a94a3;
}

.history-time {
  font-size: 12px;
  color: #8a94a3;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.history-dl {
  font-size: 12px;
  padding: 4px 10px;
  min-height: auto;
  text-decoration: none;
}

.history-error {
  font-size: 12px;
  color: #c5221f;
  max-width: 220px;
  word-break: break-all;
}

/* Status badges */
.badge-done {
  background: #e9f7ef;
  color: #137333;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
}

.badge-failed {
  background: #fce8e8;
  color: #c5221f;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
}

.badge-processing {
  background: #e8f0fe;
  color: #1769e0;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
}

/* ── Operator Dialog ─────────────────────────────────────────────────────────── */
.operator-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(20, 30, 50, 0.28);
}

.operator-dialog::backdrop {
  background: rgba(20, 30, 50, 0.45);
}

.operator-dialog-inner {
  padding: 22px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

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

.operator-dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.operator-add-form {
  padding-top: 16px;
  border-top: 1px solid #edf0f4;
}

.operator-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.operator-form-grid label span {
  display: block;
  margin-bottom: 6px;
  color: #465162;
  font-size: 13px;
}

/* Legacy downloads section kept hidden via HTML (removed from HTML) */

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

button.ghost {
  background: #ffffff;
  border-color: #c8ced8;
  color: #465162;
}

button.ghost:hover {
  background: #f2f4f7;
}

tbody tr:hover td {
  background: #f7f9fc;
}

tr.selected td {
  background: #eef4ff;
}

.empty-row td {
  text-align: center;
  color: #8a94a3;
  padding: 28px 12px;
}

.skeleton {
  display: block;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #eef0f3 25%, #e2e6eb 37%, #eef0f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.download-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.download-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid #1769e0;
  border-radius: 8px;
  color: #1769e0;
  text-decoration: none;
  font-size: 14px;
  background: #f3f8ff;
}

.download-card:hover {
  background: #e7f0ff;
}

.form-message {
  min-height: 20px;
  margin-top: 10px;
  color: #c5221f;
  font-size: 13px;
}

.toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(20, 30, 50, 0.18);
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  background: #334155;
}

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

.toast.success {
  background: #137333;
}

.toast.error {
  background: #c5221f;
}

.confirm-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(20, 30, 50, 0.28);
}

.confirm-dialog::backdrop {
  background: rgba(20, 30, 50, 0.45);
}

.confirm-dialog form {
  margin: 0;
  padding: 22px;
}

.confirm-dialog h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.confirm-dialog p {
  margin: 0 0 18px;
  color: #465162;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 760px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .toasts {
    left: 16px;
    right: 16px;
  }

  .toast {
    max-width: none;
  }

  .history-record {
    flex-direction: column;
    align-items: flex-start;
  }

  .operator-form-grid {
    grid-template-columns: 1fr;
  }
}
