* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f4f6f8;
  color: #111827;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.phone-page {
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: 32px;
  background: #f6f7f9;
}

.topbar {
  height: 56px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  margin: 0 18px;
  padding-top: env(safe-area-inset-top);
  background: #fff;
  border-bottom: 1px solid #eef0f3;
}

.topbar h1 {
  margin: 0;
  text-align: center;
  font-size: 18px;
}

.back {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  position: relative;
  cursor: pointer;
}

.back::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 17px;
  width: 10px;
  height: 10px;
  border-left: 2px solid #243044;
  border-bottom: 2px solid #243044;
  transform: rotate(45deg);
}

.hero-card,
.step-card,
.result-card,
.qr-card {
  margin: 22px 18px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 8px rgba(17, 24, 39, 0.04);
}

.hero-card {
  padding: 112px 24px 108px;
  text-align: center;
  color: #0052d9;
  background: #edf5ff;
  border: 1px solid #cfe2ff;
}

.shield {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border: 4px solid #5d9df6;
  border-radius: 44% 44% 50% 50%;
  display: grid;
  place-items: center;
  color: #5d9df6;
  font-size: 28px;
  font-weight: 800;
}

.step-card {
  padding: 26px 24px 24px;
}

.step-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.3;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-weight: 700;
}

.step-title span {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #dbeafe;
  color: #2563eb;
  font-size: 13px;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 22px;
}

.code-row input,
.admin-form input,
.admin-form select {
  width: 100%;
  border: 1px solid #d9dee8;
  border-radius: 12px;
  padding: 0 22px;
  height: 48px;
  font-size: 15px;
  outline: none;
  background: #fafbfc;
  font-family: inherit;
}

.code-row input:focus,
.admin-form input:focus,
.admin-form select:focus {
  border-color: #70a8ff;
  background: #fff;
}

.code-row button,
.admin-form button {
  border: 0;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  min-height: 50px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.code-row button:disabled {
  opacity: 0.65;
}

.hint {
  margin: 0;
  color: #8a93a3;
  font-size: 13px;
}

.result-card {
  padding: 22px;
  border: 1px solid #c9f2d8;
  background: #f2fff7;
  overflow: hidden;
}

.result-step-card {
  padding: 20px;
}

.submitted-code {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 12px;
  align-items: center;
}

.submitted-code span:first-child {
  height: 58px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid #d9dee8;
  border-radius: 8px;
  background: #fafbfc;
  color: #111827;
  font-size: 14px;
}

.submitted-code span:last-child {
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f0f2f5;
  color: #8a93a3;
  font-size: 14px;
}

.result-card.error {
  border-color: #ffd1d1;
  background: #fff7f7;
}

.result-card.pending {
  border-color: #dbeafe;
  background: #f7fbff;
}

.success-title span {
  background: #bbf7d0;
  color: #16a34a;
}

.assistant {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: #e8faee;
}

.error .assistant {
  background: #fff0f0;
}

.pending .assistant {
  background: #eef6ff;
}

.bot {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
}

.assistant-name {
  font-weight: 700;
}

.assistant-name em {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #d8f8e2;
  color: #16a34a;
  font-style: normal;
  font-size: 11px;
}

.assistant p {
  margin: 6px 0 0;
  color: #16723a;
  line-height: 1.7;
  font-size: 13px;
}

.assistant strong {
  padding: 2px 6px;
  border-radius: 4px;
  background: #d8f8e2;
  color: #16723a;
  font-weight: 700;
}

.error .assistant p {
  color: #b42318;
}

.qr-card {
  padding: 24px;
  text-align: center;
  box-shadow: none;
}

.qr-card h2 {
  margin: 0;
  font-size: 18px;
}

.qr-card p {
  margin: 8px 0 18px;
  color: #6b7280;
}

.qr-card img {
  width: min(220px, 76vw);
  display: block;
  margin: 0 auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: none;
}

.hidden {
  display: none;
}

.admin-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 18px;
}

.admin-note {
  color: #6b7280;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 20px;
  border-radius: 16px;
  background: #fff;
}

.admin-form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: #374151;
}

.admin-form input[readonly] {
  color: #111827;
  font-weight: 600;
  cursor: default;
}

.admin-form button {
  min-height: 48px;
  align-self: end;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.admin-actions button {
  min-height: 42px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.admin-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.admin-actions span {
  color: #6b7280;
  font-size: 14px;
}

#generate-output {
  margin-top: 18px;
  padding: 18px;
  min-height: 160px;
  overflow: auto;
  border-radius: 16px;
  background: #111827;
  color: #e5e7eb;
}

.batch-panel {
  margin-top: 22px;
  padding: 20px;
  border-radius: 16px;
  background: #fff;
}

.batch-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.batch-panel p {
  margin: 6px 0 0;
  color: #6b7280;
}

.batch-panel button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

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

.batch-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

.batch-table th,
.batch-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  font-size: 14px;
}

.batch-table th {
  color: #374151;
  background: #f8fafc;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.exported {
  color: #047857;
  background: #d1fae5;
}

.status-badge.pending-export {
  color: #b45309;
  background: #fef3c7;
}

.status-note {
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
}

.batch-table .table-action {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.batch-table .table-action:disabled {
  cursor: wait;
  opacity: 0.55;
}

@media (max-width: 640px) {
  .admin-form {
    grid-template-columns: 1fr;
  }
}
