:root {
  --bg: #f4efe4;
  --ink: #18221b;
  --muted: #6c7668;
  --line: rgba(24, 34, 27, 0.12);
  --panel: rgba(255, 252, 245, 0.86);
  --green: #0c8f52;
  --blue: #0f6f9f;
  --orange: #b86900;
  --red: #cf2d20;
  --shadow: 0 24px 70px rgba(49, 42, 28, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(88, 204, 2, 0.22), transparent 30%),
    radial-gradient(circle at 84% 18%, rgba(28, 176, 246, 0.18), transparent 26%),
    linear-gradient(135deg, #f8f1df 0%, #edf6e7 52%, #eaf4f7 100%);
}

body.redeem-admin-wide .admin-shell {
  width: min(1800px, calc(100% - 8px));
}

body.redeem-admin-wide .dashboard-view {
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
}

.login-card,
.link-card,
.record-panel,
.metric-card {
  border: 1px solid rgba(255, 255, 255, 0.74);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-card {
  width: min(460px, 100%);
  padding: 34px;
  border-radius: 34px;
}

.brand-row,
.dashboard-head,
.head-actions,
.link-card,
.record-head,
.link-actions {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 10px;
  color: var(--muted);
  font-weight: 900;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, #58cc02, #1cb0f6);
  box-shadow: 0 12px 28px rgba(88, 204, 2, 0.28);
}

h1,
h2,
p {
  margin: 0;
}

.login-card h1,
.dashboard-head h1 {
  margin-top: 18px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.login-card p,
.dashboard-head p,
.record-head p,
.metric-card small {
  color: var(--muted);
  line-height: 1.7;
}

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

label {
  display: grid;
  gap: 8px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  outline: none;
}

textarea {
  min-height: 180px;
  padding: 16px;
  line-height: 1.6;
  resize: vertical;
}

select {
  cursor: pointer;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--green);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(88, 204, 2, 0.65);
  box-shadow: 0 0 0 4px rgba(88, 204, 2, 0.14);
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-btn {
  color: white;
  background: var(--ink);
  box-shadow: 0 14px 30px rgba(24, 34, 27, 0.2);
}

.secondary-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
}

.ghost-btn {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.56);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.message {
  min-height: 24px;
  margin-top: 14px;
  color: var(--red);
  font-weight: 800;
}

.dashboard-view {
  display: grid;
  gap: 22px;
}

.filter-panel,
.compact-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-panel {
  border: 1px solid rgba(255, 255, 255, 0.74);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: 24px;
  padding: 18px;
}

.dashboard-head {
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0 4px;
}

.eyebrow {
  color: var(--green) !important;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.head-actions {
  gap: 10px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 999px;
  padding: 0 14px;
  color: var(--green);
  font-weight: 900;
  background: rgba(232, 249, 239, 0.9);
}

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

.metric-card {
  display: grid;
  gap: 8px;
  padding: 22px;
  border-radius: 28px;
}

.metric-card span {
  color: var(--muted);
  font-weight: 900;
}

.metric-card strong {
  font-size: 42px;
  line-height: 1;
}

.link-card {
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-radius: 28px;
}

.link-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 900;
}

.link-card strong {
  overflow-wrap: anywhere;
}

.link-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.record-panel {
  overflow: hidden;
  border-radius: 30px;
}

.record-head {
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.record-head h2 {
  font-size: 26px;
}

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

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

th,
td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}

td {
  font-size: 14px;
  line-height: 1.55;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-weight: 900;
  white-space: nowrap;
}

.tag.success {
  color: var(--green);
  background: rgba(232, 249, 239, 0.9);
}

.tag.member {
  color: var(--orange);
  background: rgba(255, 246, 224, 0.95);
}

.tag.failed {
  color: var(--red);
  background: rgba(255, 235, 232, 0.95);
}

.tag.selected {
  color: #5d3f00;
  background: rgba(255, 240, 214, 0.98);
}

.empty-cell {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.danger-btn {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: white;
  background: linear-gradient(135deg, #cf2d20, #b11e13);
  font-weight: 900;
  cursor: pointer;
}

.muted-line {
  color: var(--muted);
  line-height: 1.7;
}

.copy-feedback,
.mini-btn.copied,
.primary-btn.copied,
.secondary-btn.copied {
  color: var(--green);
  border-color: rgba(12, 143, 82, 0.32);
  background: rgba(232, 249, 239, 0.92);
}

.wide-table {
  min-width: 1180px;
}

.wide-table th,
.wide-table td {
  padding: 14px 12px;
}

.check-cell {
  width: 42px;
}

.admin-only-hidden {
  display: none !important;
}

.copy-target {
  display: grid;
  gap: 6px;
}

.copy-target strong,
.copy-target span {
  overflow-wrap: anywhere;
}

#cardsPage .wide-table {
  table-layout: fixed;
}

#cardsPage .wide-table th:nth-child(1) {
  width: 38px;
}

#cardsPage .wide-table th:nth-child(2) {
  width: 138px;
}

#cardsPage .wide-table th:nth-child(3) {
  width: 230px;
}

#cardsPage .wide-table th:nth-child(4) {
  width: 120px;
}

#cardsPage .wide-table th:nth-child(5) {
  width: 90px;
}

#cardsPage .wide-table th:nth-child(6) {
  width: 110px;
}

#cardsPage .wide-table th:nth-child(7) {
  width: 155px;
}

#cardsPage .wide-table th:nth-child(8),
#cardsPage .wide-table th:nth-child(9) {
  width: 78px;
}

#cardsPage .wide-table th:nth-child(10) {
  width: 90px;
}

#cardsPage .code-cell strong {
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100% - 44px));
  border-radius: 18px;
  padding: 14px 16px;
  color: white;
  font-weight: 900;
  background: var(--ink);
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .admin-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 18px;
  }

  .dashboard-head,
  .link-card,
  .record-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .login-card {
    padding: 24px;
    border-radius: 26px;
  }
}

.dashboard-view {
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 22px;
  display: grid;
  gap: 20px;
  min-height: calc(100vh - 64px);
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 30px;
  padding: 22px;
  background: rgba(255, 252, 245, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.menu-list,
.main-panel,
.page-panel {
  display: grid;
  gap: 12px;
}

.main-panel,
.page-panel {
  gap: 22px;
  min-width: 0;
}

.menu-item {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.menu-item.active,
.menu-item:hover {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.76);
}

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

.form-panel {
  display: grid;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 30px;
  padding: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.form-panel h2 {
  font-size: 26px;
}

.form-panel p {
  color: var(--muted);
  line-height: 1.7;
}

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

.code-list-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}

table {
  min-width: 1080px;
}

.code-cell,
.link-cell {
  display: grid;
  gap: 8px;
  max-width: 280px;
}

.code-cell strong,
.link-cell span {
  overflow-wrap: anywhere;
}

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

.mini-btn {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  font-weight: 900;
  cursor: pointer;
}

.mini-btn.danger {
  color: var(--red);
}

.tag.unused {
  color: var(--blue);
  background: rgba(234, 248, 255, 0.95);
}

.tag.disabled {
  color: var(--muted);
  background: rgba(238, 238, 232, 0.95);
}

@media (max-width: 980px) {
  .dashboard-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

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

@media (max-width: 980px) {
  body.redeem-admin-wide .dashboard-view {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  body.redeem-admin-wide .admin-shell {
    width: min(100% - 16px, 1600px);
  }

  .filter-panel,
  .compact-form {
    grid-template-columns: 1fr;
  }

  .wide-table {
    min-width: 1180px;
  }
}
