:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #65736c;
  --line: #dfe6e2;
  --accent: #ef3f5f;
  --accent-dark: #d72b4e;
  --green: #168454;
  --gold: #a86612;
  --shadow: 0 16px 40px rgba(26, 38, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app {
  width: min(1280px, calc(100% - 40px));
  margin: 28px auto;
}

.topbar,
.summary,
.settings,
.table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.actions,
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.primary {
  color: #fff;
  background: var(--accent);
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  color: #fff;
  background: #17211d;
}

.ghost {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.danger {
  color: #a61f3e;
  background: #fff0f3;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 16px;
  overflow: hidden;
}

.settings {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
  padding: 16px;
}

.settings label {
  margin: 0;
}

.summary div {
  padding: 18px 20px;
  background: #fbfcfb;
}

.summary strong {
  display: block;
  min-height: 34px;
  font-size: 28px;
}

.summary span,
.status {
  color: var(--muted);
  font-size: 13px;
}

.status {
  min-height: 38px;
  margin: 16px 0;
  border-radius: 6px;
  padding: 11px 14px;
  background: #eef4f1;
}

.table-shell {
  overflow: hidden;
}

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.empty {
  margin: 20px;
  border: 1px dashed #cbd8d1;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #33423b;
  background: #f9fbfa;
  font-size: 13px;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

.shop {
  width: 150px;
  color: #33423b;
}

.product {
  width: 260px;
  font-weight: 800;
}

.sold {
  width: 100px;
  font-weight: 900;
}

.delta {
  width: 90px;
  color: var(--green);
  font-weight: 900;
}

.delta.negative {
  color: var(--gold);
}

.created {
  width: 150px;
  color: var(--muted);
}

.url {
  display: inline-block;
  color: var(--accent);
  font-weight: 800;
}

.ops {
  width: 390px;
}

.manual-form {
  display: grid;
  grid-template-columns: 52px 52px 52px minmax(86px, 1fr) 52px;
  gap: 6px;
  margin-bottom: 0;
}

.manual-form button,
.manual-form input {
  min-height: 34px;
}

.manual-form button {
  padding: 6px 8px;
  font-size: 13px;
}

.manual-form input {
  padding: 6px 8px;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}

input {
  min-height: 40px;
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 63, 95, 0.12);
}

.modal {
  width: min(620px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(23, 33, 29, 0.42);
}

.modal form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.history-modal {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.notice-box {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.notice-box p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.notice-modal {
  width: min(420px, calc(100% - 32px));
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--muted);
  background: #f3f5f4;
  font-size: 22px;
  line-height: 1;
}

label {
  display: grid;
  gap: 8px;
  color: #2d3733;
  font-size: 14px;
  font-weight: 800;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 460px;
  overflow: auto;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 100px 90px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfb;
}

.history-item span,
.history-item em,
.history-empty {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.history-item strong {
  font-size: 16px;
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 1280px);
    margin: 10px auto;
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 24px;
  }

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

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

.settings-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.settings-grid label {
  margin: 0;
}
.error-text {
  color: #a61f3e;
}
@media (max-width: 760px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.secret-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  width: 100%;
}

.secret-input-wrap input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.secret-toggle {
  min-height: 40px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
}

.secret-toggle:hover {
  background: #f7f9f8;
}

/* ===== 顶部设置区 + 统计区合并为一行 ===== */
.hero-strip {
  display: grid;
  grid-template-columns: minmax(620px, 1.45fr) minmax(420px, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
}

.hero-settings,
.hero-summary {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-settings {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(220px, 0.9fr) auto;
  gap: 12px;
  align-items: end;
  padding: 12px 16px;
}

.hero-settings label {
  margin: 0;
  gap: 6px;
  font-size: 13px;
}

.hero-settings input {
  min-height: 38px;
  padding: 8px 12px;
}

.hero-settings .primary {
  min-height: 38px;
  padding: 8px 16px;
}

.hero-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
}

.summary-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 86px;
  padding: 12px 18px;
  background: #fbfcfb;
  border-right: 1px solid var(--line);
}

.summary-item:last-child {
  border-right: 0;
}

.summary-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0.2px;
}

.summary-item span {
  color: var(--muted);
  font-size: 13px;
}

.hero-settings .secret-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.hero-settings .secret-toggle {
  min-height: 38px;
  padding: 0 14px;
}

/* 防止旧样式影响合并后的新版顶部 */
.hero-strip + .status {
  margin-top: 14px;
}

@media (max-width: 1120px) {
  .hero-strip {
    grid-template-columns: 1fr;
  }

  .hero-settings {
    grid-template-columns: 1fr;
  }

  .hero-summary {
    min-height: 80px;
  }
}

@media (max-width: 760px) {
  .hero-strip {
    margin-top: 10px;
    gap: 10px;
  }

  .hero-summary {
    grid-template-columns: 1fr;
  }

  .summary-item {
    min-height: 68px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-item:last-child {
    border-bottom: 0;
  }
}
