:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #dbe3ee;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e6f5f3;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #047857;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

textarea {
  min-height: 80px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.12), transparent 42%),
    linear-gradient(300deg, rgba(37, 99, 235, 0.10), transparent 48%),
    var(--bg);
}

.login-panel {
  display: grid;
  width: min(420px, 100%);
  gap: 16px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1,
.login-panel p {
  margin: 0;
}

.login-panel h1 {
  font-size: 24px;
}

.login-panel p {
  color: var(--muted);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand-mark.small {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

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

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #10253f;
  color: #dbeafe;
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 800;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 20px);
  margin: 6px 10px;
  justify-content: flex-start;
  background: transparent;
  color: #cbd5e1;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar h2 {
  margin: 0;
  font-size: 20px;
}

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

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

.ghost-button:hover {
  background: #f1f5f9;
}

.page {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

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

.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

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

.stat {
  display: grid;
  min-height: 98px;
  align-content: center;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat strong {
  font-size: 26px;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px auto auto;
  gap: 10px;
  align-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

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

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

tr:hover td {
  background: #fbfdff;
}

.thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eef2f7;
}

.tag {
  display: inline-grid;
  min-width: 64px;
  min-height: 24px;
  place-items: center;
  border-radius: 6px;
  padding: 2px 8px;
  background: #eef2f7;
  color: #334155;
  font-weight: 700;
}

.tag.active,
.tag.approved,
.tag.redeemed {
  background: #dcfce7;
  color: var(--ok);
}

.tag.pending,
.tag.unused {
  background: #e0f2fe;
  color: #0369a1;
}

.tag.inactive,
.tag.rejected,
.tag.void,
.tag.expired {
  background: #fee2e2;
  color: var(--danger);
}

.mini-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

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

.danger-button:hover {
  background: #991b1b;
}

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

.json-box {
  max-width: 460px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow);
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  #nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .nav-button {
    width: auto;
    white-space: nowrap;
  }

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

  .form-grid .wide,
  .form-grid .full {
    grid-column: auto;
  }
}
