:root {
  --ink: #17201d;
  --muted: #5f6f69;
  --paper: #f7f5ef;
  --panel: #fffdf8;
  --line: #d8d1c3;
  --green: #126b54;
  --green-soft: #d8efe7;
  --amber: #ba7a15;
  --red: #a33b35;
  --black: #111613;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 32, 29, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(23, 32, 29, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 22px 22px;
  font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
}

.shell-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 28px 34px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.92);
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(14px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-nav a,
.button,
button {
  border: 1px solid var(--black);
  background: var(--black);
  color: white;
  min-height: 36px;
  padding: 8px 13px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
}

.top-nav a.active {
  background: var(--green);
  border-color: var(--green);
}

.ghost,
.ghost-link {
  background: transparent;
  color: var(--ink);
}

.token-badge {
  border: 1px solid var(--green);
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.token-badge.muted {
  border-color: var(--line);
  color: var(--muted);
  background: transparent;
}

.page-shell {
  padding: 28px 34px 52px;
}

.status-strip,
.notice,
.empty,
.panel,
.login-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 18px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 18px;
}

.notice.error {
  border-color: rgba(163, 59, 53, 0.45);
  background: #fff0ed;
  color: var(--red);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metrics-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  min-height: 128px;
  border: 1px solid var(--black);
  background: var(--panel);
  border-radius: 6px;
  padding: 15px;
  box-shadow: 5px 5px 0 rgba(18, 107, 84, 0.18);
}

.metric-card span,
.metric-card small,
td small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 10px 0;
  font-size: 28px;
  line-height: 1.05;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(96px, 0.7fr) auto auto auto;
  gap: 10px;
  align-items: end;
  margin: 18px 0;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.78);
  padding: 14px;
  border-radius: 6px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  min-height: 36px;
  border-radius: 4px;
  padding: 7px 9px;
  color: var(--ink);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
}

.checkline input {
  width: auto;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
}

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

th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  background: #f1eee5;
  padding: 11px;
}

td {
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  padding: 12px 11px;
}

tr:last-child td {
  border-bottom: 0;
}

.strong-link {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.strong-link:hover {
  color: var(--green);
}

.num {
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ece7db;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.pending {
  background: #fff2cf;
  color: var(--amber);
}

.status-pill.paid {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.skipped {
  background: #ece7db;
  color: var(--muted);
}

.event-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-right: 8px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ece7db;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.event-badge.balance {
  border-color: #b9c8e5;
  background: #e8f0ff;
  color: #2e558d;
}

.event-badge.subscription {
  border-color: rgba(18, 107, 84, 0.25);
  background: var(--green-soft);
  color: var(--green);
}

.subscription-state {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.subscription-state .mini-label {
  margin-right: 0;
}

.event-subscription-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.event-subscription-state .mini-label {
  margin-right: 0;
}

.mini-label {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-right: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ece7db;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mini-label.active {
  background: var(--green-soft);
  color: var(--green);
}

.mini-label.balance {
  background: #e8f0ff;
  color: #2e558d;
}

.mini-label.expired {
  background: #fff2cf;
  color: var(--amber);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 92px auto;
  gap: 6px;
  margin-top: 8px;
  min-width: 260px;
}

.inline-form button {
  padding-inline: 10px;
}

.inline-form .inline-note {
  grid-column: 1 / -1;
  min-height: 34px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--green);
  font-weight: 800;
  text-decoration: none;
}

.detail-hero {
  display: grid;
  grid-template-columns: 1fr 1fr minmax(180px, 260px);
  gap: 14px;
  margin-bottom: 16px;
}

.detail-hero > div {
  border: 1px solid var(--black);
  background: var(--panel);
  border-radius: 6px;
  padding: 18px;
}

.hero-number {
  background: var(--green) !important;
  color: white;
}

.hero-number span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
}

.hero-number strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
}

.detail-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.detail-form .wide {
  grid-column: 1 / -1;
}

.panel {
  margin: 16px 0;
}

.panel h3 {
  margin-bottom: 14px;
}

.subtle {
  color: var(--muted);
}

.login-panel {
  max-width: 460px;
  margin: 10vh auto;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

code {
  background: #eee8da;
  padding: 2px 5px;
  border-radius: 4px;
}

@media (max-width: 1100px) {
  .metrics-grid,
  .metrics-grid.compact,
  .detail-hero {
    grid-template-columns: 1fr 1fr;
  }

  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .shell-header,
  .page-shell {
    padding-inline: 16px;
  }

  .shell-header,
  .top-nav,
  .detail-form,
  .metrics-grid,
  .metrics-grid.compact,
  .detail-hero,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .shell-header {
    display: grid;
  }

  .header-side {
    align-items: flex-start;
  }
}
