:root {
  --paper: #f3efe6;
  --paper-deep: #e8e0d2;
  --surface: #fffdf8;
  --ink: #1c2725;
  --ink-soft: #5f6965;
  --line: #d3c9b8;
  --accent: #b8492f;
  --accent-deep: #8d3523;
  --moss: #3d6a56;
  --serif: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  background:
    radial-gradient(circle at 8% 4%, rgba(184, 73, 47, 0.09), transparent 26rem),
    linear-gradient(90deg, rgba(28, 39, 37, 0.035) 1px, transparent 1px) 0 0 / 72px 72px,
    var(--paper);
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) 0 24px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  color: var(--paper);
  background: var(--ink);
  box-shadow: 6px 6px 0 var(--accent);
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.masthead-note {
  max-width: 290px;
  margin: 0 0 4px;
  padding-left: 16px;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-size: 13px;
}

main {
  padding-top: 38px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.section-index {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 15px;
}

.section-heading h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  white-space: nowrap;
}

.count-badge {
  order: 3;
  padding: 2px 9px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.export-button {
  order: 4;
  padding: 5px 12px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
}

.export-button:hover:not(:disabled) {
  color: var(--paper);
  background: var(--ink);
}

.export-button:disabled {
  border-color: var(--line);
  color: #a5a79f;
  cursor: not-allowed;
}

.query-panel {
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid var(--ink);
  background: rgba(255, 253, 248, 0.76);
  box-shadow: 9px 9px 0 rgba(28, 39, 37, 0.07);
}

form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 28px;
}

.field-key {
  grid-column: 1 / -1;
}

.field label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.required,
.optional {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.required {
  color: var(--accent);
}

.optional {
  color: #9a9c95;
}

.field input {
  width: 100%;
  min-width: 0;
  padding: 9px 2px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  font-variant-numeric: tabular-nums;
}

.field input::placeholder {
  color: #a5a79f;
}

.field input:focus {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 var(--accent);
  outline: none;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inline-button {
  flex: 0 0 auto;
  padding: 6px 0;
  border: 0;
  border-bottom: 1px dotted var(--ink-soft);
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}

.inline-button:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 4px;
}

.field-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.primary-button {
  padding: 11px 20px;
  border: 0;
  color: var(--paper);
  background: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  transition: transform 160ms ease-out, background-color 160ms ease-out;
}

.primary-button span {
  margin-left: 10px;
  color: #e8a08a;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translateY(-2px);
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.alert {
  margin-top: 20px;
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  color: var(--accent-deep);
  background: #fff1ea;
  font-size: 13px;
}

.stats-section,
.table-section {
  margin-top: 38px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--ink);
  background: var(--surface);
}

.stat-card {
  padding: 20px 22px 22px;
  border-right: 1px solid var(--line);
}

.stat-card:last-child {
  border-right: 0;
}

.stat-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.stat-value {
  margin: 9px 0 0;
  font-family: var(--serif);
  font-size: clamp(28px, 3.3vw, 40px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-value.accent {
  color: var(--accent);
}

.stat-value.moss {
  color: var(--moss);
}

.recharge-note {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.recharge-note strong {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--ink);
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  padding: 11px 14px;
  color: var(--paper);
  background: var(--ink);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:not(.empty-row):hover {
  background: var(--paper-deep);
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.model-name {
  font-weight: 600;
}

.amount {
  color: var(--accent);
  font-weight: 600;
}

.empty-row td {
  padding: 34px 14px;
  color: var(--ink-soft);
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 14px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.pagination button {
  padding: 7px 13px;
  border: 1px solid var(--ink);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}

.pagination button:hover:not(:disabled) {
  color: var(--paper);
  background: var(--ink);
}

.pagination button:disabled {
  border-color: var(--line);
  color: #a5a79f;
  cursor: not-allowed;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
}

@media (max-width: 820px) {
  .masthead {
    align-items: flex-start;
    flex-direction: column;
  }

  .masthead-note {
    max-width: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-card:nth-child(2) {
    border-right: 0;
  }

  .stat-card:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 600px) {
  .shell {
    width: min(100% - 24px, 1180px);
    padding-top: 24px;
  }

  form {
    grid-template-columns: 1fr;
  }

  .field-key,
  .form-actions {
    grid-column: 1;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stat-card:last-child {
    border-bottom: 0;
  }

  .pagination {
    justify-content: space-between;
    gap: 8px;
  }

  .footer {
    flex-direction: column;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
