:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1f2823;
  --muted: #68736d;
  --line: #dfe5df;
  --accent: #1f8a70;
  --accent-strong: #146853;
  --warn: #b7791f;
  --danger: #b42318;
  --soft: #e7f3ee;
  --radius: 8px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 14px;
  color: #ffffff;
  background: var(--accent);
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  color: var(--ink);
  background: #edf1ed;
}

button.secondary:hover,
button.ghost:hover {
  background: #dfe7e1;
}

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

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

button.warn {
  background: var(--warn);
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.hidden {
  display: none !important;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(31, 40, 35, 0.08);
}

.login-panel h1 {
  margin-top: 4px;
  font-size: 28px;
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.error {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand h1 {
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.2;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  justify-content: flex-start;
  width: 100%;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.tab.active,
.tab:hover {
  color: #ffffff;
  background: var(--accent);
}

#logoutButton {
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 24px;
}

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

.topbar h2 {
  margin-top: 4px;
  font-size: 26px;
}

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 18px;
}

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

.stat {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

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

.stat strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

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

.panel-head h3 {
  font-size: 17px;
}

.panel-head input,
.panel-head select {
  width: min(240px, 100%);
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 14px;
  padding: 16px;
  align-items: end;
}

.inline-form button {
  width: fit-content;
  min-width: 96px;
}

.inline-form .wide {
  grid-column: span 2;
}

textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.checkbox-line input {
  width: auto;
  min-height: auto;
}

.checkbox-line span {
  margin: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td code,
.api-doc code,
.code-box {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--accent-strong);
  background: var(--soft);
  font-size: 13px;
}

.status.banned,
.status.rejected {
  color: var(--danger);
  background: #fde8e5;
}

.status.pending {
  color: var(--warn);
  background: #fff4d7;
}

.status.redeemed,
.status.approved {
  color: #3553a3;
  background: #e8edff;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.code-box {
  margin: 0 16px 16px;
  max-height: 220px;
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius);
  color: #11241d;
  background: #eef6f1;
}

.api-doc {
  display: grid;
  gap: 14px;
  padding: 16px;
  color: var(--muted);
  line-height: 1.6;
}

.api-doc pre {
  margin: 0;
  overflow-x: auto;
  border-radius: var(--radius);
  padding: 14px;
  color: #eefaf4;
  background: #1d2c26;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #ffffff;
  background: #1d2c26;
  box-shadow: 0 14px 34px rgba(31, 40, 35, 0.18);
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .tab {
    text-align: center;
  }

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

  .inline-form {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }
}
