:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #66727a;
  --line: #dde4e8;
  --accent: #157f68;
  --accent-strong: #0e5d4d;
  --warn: #a85e00;
  --danger: #b83232;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

header div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

header strong {
  font-size: 17px;
}

header span,
label,
.stat span,
td,
dd {
  color: var(--muted);
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

nav a,
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

button,
.button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 56px;
}

section {
  margin: 0 0 20px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

h1 {
  margin: 0 0 16px;
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  margin: 18px 0 10px;
  font-size: 16px;
}

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

.section-head h1 {
  margin: 0;
}

.actions,
.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.checkline input {
  width: auto;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  min-height: 128px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.stat.warn {
  border-color: #e7b15d;
  background: #fff9ee;
}

.stat h2,
.stat p {
  margin: 0 0 10px;
}

.stat strong {
  font-size: 34px;
  color: var(--accent-strong);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

th {
  color: var(--text);
  font-weight: 650;
  background: #f8fafb;
}

code {
  color: #243238;
  background: #eef3f4;
  padding: 2px 5px;
  border-radius: 4px;
}

form {
  margin: 0;
}

.grid-form,
.manual-form {
  display: grid;
  gap: 12px;
}

.grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.manual-form {
  grid-template-columns: 1.2fr 1fr 1fr .8fr 1fr auto;
  align-items: end;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid #ccd6db;
  border-radius: 6px;
  font: inherit;
}

textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.55;
}

.login {
  width: min(420px, 100%);
  margin: 72px auto;
}

.login form {
  display: grid;
  gap: 14px;
}

.alert,
.notice {
  padding: 10px 12px;
  border-radius: 6px;
}

.alert {
  color: #7a1f1f;
  background: #fff0f0;
  border: 1px solid #f0b8b8;
}

.notice {
  color: #174d3f;
  background: #eefaf6;
  border: 1px solid #b9e2d7;
}

.badge {
  display: inline-flex;
  min-width: 74px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf2f4;
  color: #39464c;
}

.badge.delivered {
  background: #e7f5ee;
  color: #14614e;
}

.badge.available {
  background: #e8f7fb;
  color: #0f6073;
}

.badge.used {
  background: #ece8fb;
  color: #4c3f94;
}

.badge.revoked {
  background: #eee;
  color: #60666a;
}

.badge.manual_hold,
.badge.failed {
  background: #fff2df;
  color: var(--warn);
}

.badge.refunded {
  background: #fae9e9;
  color: var(--danger);
}

.badge.expired {
  background: #f1f3f5;
  color: #555f66;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.filters a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.filters a.active {
  border-color: var(--accent);
  background: #e8f4f1;
  color: var(--accent-strong);
  font-weight: 650;
}

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

.hint {
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

pre {
  overflow-x: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  line-height: 1.5;
}

dt {
  color: var(--text);
  font-weight: 650;
}

dd {
  margin: 0;
}

@media (max-width: 820px) {
  header {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  main {
    width: calc(100% - 20px);
    margin-top: 12px;
  }

  .stats,
  .grid-form,
  .manual-form {
    grid-template-columns: 1fr;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
