:root {
  --bg: #f5f1ea;
  --surface: #fffdf8;
  --surface-muted: #fbf7f0;
  --ink: #25211d;
  --muted: #6f675e;
  --soft: #8b8177;
  --line: #ddd4c8;
  --line-strong: #cfc3b5;
  --accent: #c15f3c;
  --accent-hover: #a94e32;
  --accent-soft: #f5ded3;
  --success: #2f7d58;
  --success-soft: #e4f2ea;
  --danger: #b7432f;
  --danger-soft: #fae5de;
  --blue: #3e647e;
  --blue-soft: #e5eef3;
  --shadow: 0 18px 52px rgba(54, 45, 35, 0.08);
  --radius: 8px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(37, 33, 29, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 33, 29, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

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

button {
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--mono);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 64px;
}

.topbar {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-fallback,
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-fallback {
  display: inline-grid;
  place-items: center;
  background: var(--ink);
  color: var(--surface);
  font-weight: 800;
}

.brand-logo {
  display: none;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--surface);
}

.brand-logo.loaded {
  display: block;
}

.brand.has-logo .brand-fallback {
  display: none;
}

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

.plain-action {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.72);
  color: var(--muted);
  font-size: 14px;
}

.plain-action:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.hero-section {
  min-height: 150px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 30px 0 22px;
}

.hero-section,
.workspace,
.panel {
  min-width: 0;
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 520px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.stock-pill {
  min-width: 210px;
  min-height: 76px;
  padding: 14px 18px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid #c6d8df;
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.stock-pill span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.stock-pill strong {
  color: #244b63;
  font-size: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow);
}

.redeem-panel {
  padding: clamp(22px, 3.5vw, 38px);
}

.service-panel {
  padding: 24px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.14;
  letter-spacing: 0;
}

.panel-head.compact h2 {
  font-size: 28px;
}

.redeem-form {
  display: grid;
  gap: 20px;
}

.field-group,
.warranty-search {
  display: grid;
  gap: 9px;
}

label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 56px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input::placeholder {
  color: #a59b90;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(193, 95, 60, 0.14);
}

input.input-error {
  border-color: var(--danger);
  background: #fff8f5;
}

.form-actions,
.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-actions {
  margin-top: 4px;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-weight: 800;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.primary-button {
  min-width: 180px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.secondary-button {
  min-width: 96px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.secondary-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.primary-button:active,
.secondary-button:active,
.plain-action:active {
  transform: translateY(1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.alert {
  margin-bottom: 18px;
  padding: 13px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
}

.alert-error {
  border: 1px solid #efc5b9;
  background: var(--danger-soft);
  color: var(--danger);
}

.result-zone {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

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

.status-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 13px;
  font-weight: 800;
}

.result-time {
  color: var(--soft);
  font-size: 13px;
}

.result-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.detail-grid,
.warranty-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.detail-item,
.summary-item {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.detail-item span,
.summary-item span,
.record-row span {
  display: block;
  margin-bottom: 5px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

.detail-item strong,
.summary-item strong,
.record-row strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.warranty-search {
  margin-bottom: 18px;
}

.search-row input {
  min-width: 0;
}

.warranty-result {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.empty-state,
.warranty-message {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  color: var(--muted);
  line-height: 1.55;
}

.empty-state strong,
.warranty-message strong {
  color: var(--ink);
}

.warranty-message.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.warranty-message.success {
  background: var(--success-soft);
  color: var(--success);
}

.record-list {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.record-row {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.record-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.record-title code {
  overflow-wrap: anywhere;
}

.record-badge {
  flex: 0 0 auto;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

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

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.small-button {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.small-button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.ok-text {
  color: var(--success) !important;
}

.bad-text {
  color: var(--danger) !important;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
  color: var(--ink);
  line-height: 1.55;
}

@media (max-width: 920px) {
  .hero-section,
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-section {
    align-items: start;
    padding-top: 34px;
  }

  .stock-pill {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 24px, 1180px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .plain-action {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 0 10px;
  }

  #copyQqButton {
    grid-column: 1 / -1;
  }

  .hero-copy h1 {
    font-size: 40px;
  }

  .hero-copy p:last-child {
    font-size: 16px;
    line-height: 1.55;
  }

  .redeem-panel,
  .service-panel {
    padding: 18px;
  }

  .hero-section {
    min-height: auto;
    gap: 12px;
    padding: 22px 0 16px;
  }

  .stock-pill {
    min-height: 64px;
  }

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

  .redeem-form {
    gap: 16px;
  }

  input {
    min-height: 52px;
  }

  .form-actions,
  .search-row {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .detail-grid,
  .warranty-summary,
  .record-grid {
    grid-template-columns: 1fr;
  }

  .result-head,
  .record-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
