:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  --text: #111827;
  --muted: #64748b;
  --line: #d7dee8;
  --soft: #f4f7fb;
  --panel: #ffffff;
  --blue: #0f62b8;
  --blue-dark: #17446f;
  --green: #2f7d32;
  --amber: #9a640d;
  --red: #b83232;
  --shadow: 0 14px 36px rgba(29, 45, 68, 0.1);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.primary {
  color: #fff;
  background: var(--blue);
}

.secondary {
  color: #fff;
  background: var(--green);
}

.danger {
  color: #fff;
  background: var(--red);
}

.ghost {
  color: var(--text);
  background: #e9eef5;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input {
  height: 44px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  min-height: 112px;
  padding: 14px;
  line-height: 1.65;
}

input:focus,
textarea:focus {
  border-color: #4a90e2;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

label {
  display: block;
  margin: 14px 0 8px;
  color: #213044;
  font-size: 14px;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(1120px, calc(100% - 36px));
  margin: 30px auto;
}

.title-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 30px 34px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #eef3f8 100%);
}

.title-panel h1,
.admin-header h1 {
  margin: 0;
  font-size: 42px;
  letter-spacing: 0;
}

.title-panel p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.workbench {
  margin-top: 20px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel,
.login-panel,
.import-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

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

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

.message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--red);
  font-weight: 700;
}

.message.ok {
  color: var(--green);
}

.result,
.code-card {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.result span,
.code-card span {
  color: var(--muted);
  font-size: 13px;
}

.result strong {
  overflow-wrap: anywhere;
}

.code-card strong {
  font-size: 34px;
  letter-spacing: 2px;
}

.mail-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.mail-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mail-item strong,
.mail-item span {
  display: block;
  overflow-wrap: anywhere;
}

.mail-item span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.admin-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 20px;
  color: #fff;
  background: #204f82;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  font-size: 20px;
}

.brand-mark {
  width: 28px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.66);
  border-radius: 4px;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px 4px auto;
  height: 10px;
  border-left: 2px solid rgba(255, 255, 255, 0.66);
  border-bottom: 2px solid rgba(255, 255, 255, 0.66);
  transform: rotate(-45deg);
}

.nav-item {
  display: block;
  padding: 13px 16px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
}

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

.sidebar-stat {
  margin-top: auto;
  padding: 22px;
  border-radius: 8px;
  text-align: center;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-stat span {
  display: block;
  color: rgba(255, 255, 255, 0.74);
}

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

.admin-main {
  min-width: 0;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 34px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.admin-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.login-panel,
#adminContent {
  width: min(1120px, calc(100% - 44px));
  margin: 24px auto;
}

.login-panel {
  max-width: 460px;
  padding: 26px;
}

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

.stat {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stat span {
  display: block;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.import-panel {
  margin-bottom: 16px;
  padding: 18px;
}

.panel-head p {
  margin: 8px 0 0;
  color: var(--muted);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  font-weight: 500;
}

.checkbox-line input,
th input {
  width: 16px;
  height: 16px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #475569;
  background: #f1f5f9;
  font-size: 13px;
}

td {
  font-size: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 70px;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.unused {
  color: var(--amber);
  background: #fff4d8;
}

.status.redeemed {
  color: var(--green);
  background: #e6f4e8;
}

@media (max-width: 900px) {
  .two-column,
  .admin-layout,
  .stats-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .title-panel,
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .title-panel h1,
  .admin-header h1 {
    font-size: 34px;
  }
}
