:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #17202d;
  --muted: #627084;
  --line: #dbe3ee;
  --teal: #0f8f83;
  --teal-dark: #09665e;
  --blue: #2868d8;
  --amber: #c77b16;
  --rose: #c84d67;
  --green: #178554;
  --shadow: 0 18px 44px rgba(25, 34, 48, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    linear-gradient(90deg, rgba(23, 32, 45, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(23, 32, 45, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
select {
  cursor: pointer;
}

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

code {
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--teal-dark);
  background: #e7f5f3;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(15, 143, 131, 0.22);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 18px;
  line-height: 1.1;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.nav a:hover {
  color: var(--ink);
  background: #e9eef5;
}

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

.redeem-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.56fr);
  gap: 22px;
  align-items: start;
}

.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.redeem-panel,
.side-panel,
.login-panel,
.panel {
  padding: clamp(18px, 3vw, 30px);
}

.panel-head {
  margin-bottom: 24px;
}

.service-points {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.service-points li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-soft);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.service-points svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  color: var(--teal);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.35;
}

p {
  color: var(--muted);
  line-height: 1.75;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 143, 131, 0.13);
}

form {
  display: grid;
  gap: 18px;
}

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

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 900;
}

.primary-button svg,
.secondary-button svg,
.ghost-button svg,
.search-field svg {
  width: 18px;
  height: 18px;
}

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

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  color: var(--teal-dark);
  background: #e8f5f4;
  border-color: #c8e5e1;
}

.ghost-button {
  color: var(--muted);
  background: #fff;
  border-color: var(--line);
}

.full {
  width: 100%;
}

.notice {
  min-height: 22px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.55;
}

.notice:empty {
  display: none;
}

.notice[data-type="success"] {
  color: var(--green);
}

.notice[data-type="error"] {
  color: var(--rose);
}

.side-panel {
  display: grid;
  gap: 18px;
}

.delivery-card {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 16px;
  border-radius: 8px;
  background: #eef8f6;
  border: 1px solid #cae8e3;
}

.delivery-card strong {
  display: block;
  margin-bottom: 4px;
}

.delivery-card p {
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.6;
}

.status-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(23, 133, 84, 0.14);
}

.mini-preview {
  min-height: 240px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(40, 104, 216, 0.08), transparent 44%),
    #fff;
}

.mail-top {
  display: flex;
  gap: 6px;
  margin-bottom: 34px;
}

.mail-top span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--line);
}

.mail-top span:nth-child(1) {
  background: var(--rose);
}

.mail-top span:nth-child(2) {
  background: var(--amber);
}

.mail-top span:nth-child(3) {
  background: var(--green);
}

.mini-preview h2 {
  margin-bottom: 10px;
}

.mini-preview p {
  margin-bottom: 22px;
}

.fake-lines {
  display: grid;
  gap: 9px;
}

.fake-lines span {
  height: 10px;
  border-radius: 999px;
  background: #dce6f1;
}

.fake-lines span:nth-child(2) {
  width: 76%;
}

.fake-lines span:nth-child(3) {
  width: 54%;
}

.flow-list {
  display: grid;
  gap: 10px;
}

.flow-list div {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.flow-list b {
  color: var(--blue);
  font-size: 13px;
}

.flow-list span {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.45;
}

.query-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.query-card h2 {
  margin-bottom: 8px;
}

.query-card p {
  margin-bottom: 0;
}

.query-result {
  display: grid;
  gap: 12px;
}

.query-result:empty {
  display: none;
}

.query-summary,
.query-result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.query-summary {
  padding: 10px 12px;
  color: var(--teal-dark);
  font-weight: 900;
}

.query-result-card {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.query-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.query-status strong,
.query-status span {
  font-weight: 900;
}

.query-status.ok {
  color: var(--green);
  border-color: #c6e8d5;
  background: #eaf7f0;
}

.query-status.used {
  color: var(--amber);
  border-color: #f1d5a6;
  background: #fff7e8;
}

.query-status.bad {
  color: var(--rose);
  border-color: #f1c9d1;
  background: #fff0f3;
}

.query-result dl {
  display: grid;
  gap: 9px;
  margin: 0;
}

.query-result dl div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.query-result dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.query-result dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.query-loading,
.query-error,
.query-message {
  padding: 12px;
  border-radius: 8px;
  font-weight: 900;
  line-height: 1.55;
}

.query-loading {
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
}

.query-error {
  color: var(--rose);
  background: #fff0f3;
  border: 1px solid #f1c9d1;
}

.query-message {
  color: #8a5a12;
  background: #fff8e8;
  border: 1px solid #f1d5a6;
}

.admin-shell {
  width: min(1360px, calc(100% - 32px));
}

.login-panel {
  max-width: 520px;
  margin: 42px auto;
}

.admin-head,
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-head {
  margin-bottom: 24px;
}

.admin-head h1 {
  margin-bottom: 8px;
}

.admin-head p {
  margin-bottom: 0;
}

.head-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.admin-metrics {
  margin-bottom: 18px;
}

.metric-card {
  padding: 18px;
}

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

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  line-height: 1;
}

.metric-card.pending strong {
  color: var(--amber);
}

.metric-card.delivered strong {
  color: var(--green);
}

.metric-card.cancelled strong {
  color: var(--rose);
}

.metric-card.invalid-account strong {
  color: var(--blue);
}

.search-field {
  position: relative;
  display: block;
  min-width: min(280px, 100%);
}

.search-field svg {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-field input {
  padding-left: 40px;
}

.record-list {
  display: grid;
  gap: 14px;
}

.record-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.record-card[data-status="delivered"] {
  border-color: rgba(23, 133, 84, 0.35);
}

.record-card[data-status="cancelled"] {
  opacity: 0.78;
}

.record-card[data-status="invalid_account"] {
  border-color: rgba(40, 104, 216, 0.32);
  background: #f4f8ff;
}

.record-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--amber);
  background: #fff7e8;
  border: 1px solid #f1d5a6;
  font-size: 12px;
  font-weight: 900;
}

.record-card[data-status="delivered"] .status-pill {
  color: var(--green);
  background: #eaf7f0;
  border-color: #c6e8d5;
}

.record-card[data-status="cancelled"] .status-pill {
  color: var(--rose);
  background: #fff0f3;
  border-color: #f1c9d1;
}

.record-card[data-status="invalid_account"] .status-pill {
  color: var(--blue);
  background: #edf4ff;
  border-color: #bfd5fb;
}

.record-meta {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.record-meta div {
  min-width: 0;
}

.record-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.record-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1.45;
}

.record-remark {
  margin-bottom: 12px;
  color: var(--muted);
}

.session-box {
  margin-bottom: 12px;
}

.session-box textarea {
  min-height: 110px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.55;
  background: #fff;
}

.delivery-note {
  min-height: 84px;
}

.record-actions {
  display: grid;
  align-content: start;
  gap: 10px;
}

.record-actions .primary-button,
.record-actions .secondary-button,
.record-actions .ghost-button {
  width: 100%;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
  background: var(--panel-soft);
}

.cdk-form {
  margin-bottom: 18px;
}

.section-subhead {
  display: grid;
  gap: 6px;
  padding-bottom: 2px;
}

.section-subhead h3 {
  font-size: 18px;
}

.section-subhead p {
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.55;
}

.generator-form {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.generated-codes {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

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

.generated-head strong {
  font-weight: 900;
}

.generated-codes textarea {
  min-height: 150px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.cdk-list {
  display: grid;
  gap: 8px;
}

.cdk-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 140px 80px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.cdk-row span,
.cdk-row strong {
  overflow-wrap: anywhere;
}

@media (max-width: 960px) {
  .redeem-layout,
  .record-card {
    grid-template-columns: 1fr;
  }

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

  .admin-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .head-actions,
  .toolbar {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
  }

  .shell,
  .admin-shell {
    width: min(100% - 24px, 1360px);
    padding-top: 18px;
  }

  h1 {
    font-size: 32px;
  }

  .field-grid,
  .service-points,
  .metric-grid,
  .record-meta,
  .cdk-row {
    grid-template-columns: 1fr;
  }

  .search-field,
  .toolbar select,
  .toolbar button,
  .toolbar a,
  .head-actions a,
  .head-actions button {
    width: 100%;
  }
}
