:root {
  --canvas: #f4f6f7;
  --surface: #fff;
  --surface-soft: #f8faf9;
  --text: #17231f;
  --muted: #61706a;
  --subtle: #98a39e;
  --line: #e1e7e4;
  --primary: #176b5b;
  --primary-dark: #105648;
  --primary-soft: #e8f3ef;
  --orange: #a85b25;
  --orange-soft: #fbf0e8;
  --danger: #b42318;
  --danger-soft: #fef3f2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--canvas); }
body {
  margin: 0;
  color: var(--text);
  background: var(--canvas);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
h1, h2, p { margin-top: 0; }

.topbar {
  display: flex;
  align-items: center;
  height: 58px;
  padding: 0 max(28px, calc((100vw - 1400px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 700; }
.brand i {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  color: white;
  background: var(--primary);
  font-family: Georgia, serif;
  font-style: normal;
}
.topbar-separator { width: 1px; height: 18px; margin: 0 16px; background: var(--line); }
.topbar > strong { font-size: 14px; }

.shell { width: min(1400px, calc(100% - 56px)); margin: auto; padding: 28px 0 24px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
h1 { margin-bottom: 5px; font-size: 27px; line-height: 1.2; letter-spacing: -.025em; }
.page-heading > div > p:last-child { margin: 0; color: var(--muted); font-size: 13px; }

.query-panel {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.query-main {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  padding: 15px 17px;
}
.query-form { display: flex; align-items: flex-end; gap: 9px; }
.query-form label { display: grid; gap: 5px; }
.query-form label span { color: var(--subtle); font-size: 10px; }
.query-panel input, .query-panel select {
  width: 148px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid #d0d7d4;
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  font-size: 12px;
}
.query-panel input[type="date"] {
  width: 162px;
  height: 38px;
  padding: 0 10px 0 12px;
  border-color: #cbd5d0;
  border-radius: 7px;
  color: var(--text);
  background-color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  cursor: pointer;
  color-scheme: light;
}
.query-panel select#promotionCode { width: 190px; height: 38px; }
.query-panel input:focus, .query-panel select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23, 107, 91, .09); }
.to { padding-bottom: 9px; color: var(--subtle); font-size: 11px; }
.query-form button {
  height: 38px;
  min-width: 88px;
  padding: 0 15px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.query-form button:hover { background: var(--primary-dark); }
.query-form button:disabled { cursor: wait; opacity: .65; }
.channel i { width: 7px; height: 7px; flex: none; border-radius: 50%; }

.notice {
  margin: 10px 0 0;
  padding: 8px 11px;
  border-left: 3px solid #d1905d;
  color: var(--orange);
  background: var(--orange-soft);
  font-size: 11px;
}
.notice b { margin-right: 8px; }
.notice--error { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

.overview-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.overview-summary article {
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.overview-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.overview-summary strong {
  margin-left: auto;
  font: 700 26px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -.04em;
}

.ledger {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 14px; }
.section-heading h2 { margin: 0 0 4px; font-size: 15px; }
.section-heading p { margin: 0; color: var(--subtle); font-size: 10px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; min-width: 850px; border-collapse: collapse; }
th {
  position: sticky;
  z-index: 1;
  top: 0;
  height: 38px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 600;
  text-align: left;
}
th:nth-last-child(-n+3) { text-align: center; }
td { height: 42px; padding: 6px 14px; border-bottom: 1px solid #edf0ef; font-size: 11px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfb; }
.date-cell {
  width: 152px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
.date-cell b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.2;
}
.date-cell small {
  display: block;
  color: var(--subtle);
  font: 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.channel { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.code { font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.count {
  display: block;
  min-width: 38px;
  margin: auto;
  padding: 5px 9px;
  border: 0;
  border-radius: 5px;
  color: var(--primary);
  background: transparent;
  cursor: pointer;
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.count:hover, .count:focus-visible { background: var(--primary-soft); outline: none; }
.empty { padding: 40px 20px; color: var(--subtle); text-align: center; font-size: 11px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 44px; padding-top: 11px; }
.pagination-summary { color: var(--subtle); font-size: 10px; }
.pagination-controls { display: flex; gap: 5px; }
.pagination-controls button {
  min-width: 29px;
  height: 29px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
  font-size: 10px;
}
.pagination-controls button:hover:not(:disabled):not(.is-current) { border-color: #b8c0bc; background: var(--surface-soft); }
.pagination-controls button.is-current { border-color: var(--primary); color: #fff; background: var(--primary); }
.pagination-controls button:disabled { cursor: not-allowed; opacity: .45; }
.drawer-layer { position: fixed; z-index: 20; inset: 0; display: flex; justify-content: flex-end; background: rgba(16, 24, 40, .28); }
.drawer {
  display: flex;
  flex-direction: column;
  width: min(560px, 94vw);
  height: 100%;
  padding: 22px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: -10px 0 32px rgba(16, 24, 40, .12);
  animation: slide-in .18s ease-out;
}
.drawer header { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.drawer header p { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.drawer header h2 { margin: 0; font-size: 18px; }
.drawer header button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 20px; }
.drawer header button:hover { background: var(--surface-soft); }
.drawer-total { display: flex; align-items: baseline; gap: 5px; padding: 16px 0; }
.drawer-total span { margin-right: auto; color: var(--muted); font-size: 11px; }
.drawer-total strong { font: 700 28px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.drawer-total small { color: var(--subtle); font-size: 11px; }
.user-list { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); }
.user-list article { padding: 14px 2px; border-bottom: 1px solid var(--line); }
.user-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.user-heading code { font-size: 11px; font-weight: 600; }
.user-heading span { padding: 4px 7px; border-radius: 5px; color: var(--primary); background: var(--primary-soft); font-size: 10px; }
.user-list dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.user-list dl div { display: grid; gap: 4px; }
.user-list dt { color: var(--subtle); font-size: 10px; }
.user-list dd { margin: 0; font: 500 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.pagination--drawer { flex: none; }
@keyframes slide-in { from { transform: translateX(30px); opacity: .7; } }

@media (min-width: 721px) {
  body { height: 100vh; overflow: hidden; }
  .shell {
    display: flex;
    height: calc(100vh - 58px);
    padding: 24px 0 18px;
    flex-direction: column;
    overflow: hidden;
  }
  .page-heading, .query-panel, .notice, .overview-summary { flex: none; }
  .ledger {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
  }
  .section-heading, .pagination { flex: none; }
  .table-wrap {
    min-height: 0;
    flex: 1;
    overflow: auto;
  }
}

@media (max-width: 960px) {
  .query-main { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 720px) {
  .shell { width: min(100% - 28px, 680px); padding-top: 22px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .query-form { display: grid; width: 100%; grid-template-columns: 1fr 18px 1fr; }
  .query-panel input, .query-panel select { width: 100%; }
  .query-form button { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 14px; }
  .topbar-separator { display: none; }
  .shell { width: calc(100% - 20px); }
  .overview-summary { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .pagination { align-items: flex-start; flex-direction: column; gap: 8px; }
  .pagination-controls { width: 100%; overflow-x: auto; }
  .drawer { width: 100%; padding: 18px 14px; }
  .user-list dl { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; scroll-behavior: auto !important; } }
