:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #5f6b7a;
  --line: rgba(20, 32, 48, .11);
  --accent: #1475f6;
  --accent-strong: #075bd8;
  --accent-soft: #e8f1ff;
  --danger: #dc2626;
  --soft: rgba(255, 255, 255, .64);
  --radius-lg: 28px;
  --radius-md: 20px;
  --shadow-soft: 0 24px 80px rgba(22, 37, 61, .12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(20, 117, 246, .18), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(125, 167, 255, .18), transparent 26%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 48%, #edf3fa 100%);
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

.public-shell { min-height: 100vh; padding: 22px; }
.admin-shell { min-height: 100vh; display: grid; place-items: start center; padding: 28px 18px; }
.public-hero, .public-workspace {
  width: min(1120px, 100%);
  margin: 0 auto;
}
.public-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 34px;
  padding: 18px clamp(18px, 4vw, 46px) clamp(30px, 5vw, 58px);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .86), rgba(255, 255, 255, .48)),
    rgba(255, 255, 255, .62);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
}
.public-hero::before {
  content: "";
  position: absolute;
  inset: auto -10% -42% auto;
  width: min(520px, 70vw);
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, .96), transparent 18%),
    radial-gradient(circle at 50% 50%, rgba(20, 117, 246, .22), rgba(20, 117, 246, 0) 62%);
  pointer-events: none;
}
.public-hero.compact { padding-bottom: clamp(28px, 5vw, 48px); }
.public-nav {
  position: relative;
  z-index: 1;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-lockup, .nav-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-weight: 760;
}
.brand-lockup { gap: 10px; color: #1b2738; }
.brand-orb {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #62a1ff);
  box-shadow: 0 12px 30px rgba(20, 117, 246, .28), inset 0 1px 0 rgba(255,255,255,.38);
  font-size: 13px;
}
.nav-link, .small-link {
  border: 1px solid rgba(20, 32, 48, .08);
  padding: 10px 15px;
  border-radius: 999px;
  color: #1e4f93;
  background: rgba(255, 255, 255, .68);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
  white-space: nowrap;
}
.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: clamp(22px, 6vw, 76px);
  align-items: end;
  padding-top: clamp(28px, 7vw, 74px);
}
.public-hero.compact .hero-grid { grid-template-columns: minmax(0, 760px); }
.hero-kicker {
  margin: 0 0 14px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 700;
}
h1 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(34px, 4.8vw, 52px);
  line-height: 1.08;
  font-weight: 720;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.hero-text {
  max-width: 620px;
  margin: 22px 0 0;
  color: #415064;
  font-size: clamp(16px, 1.8vw, 18px);
  line-height: 1.75;
  text-wrap: pretty;
}
.hero-status {
  border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius-md);
  padding: 18px;
  background: rgba(255,255,255,.58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 18px 50px rgba(28, 53, 82, .1);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.hero-status div { display: flex; align-items: center; gap: 10px; }
.hero-status p { margin: 10px 0 0; font-size: 14px; }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2fd166;
  box-shadow: 0 0 0 6px rgba(47, 209, 102, .16);
}
.public-workspace {
  display: grid;
  grid-template-columns: minmax(0, .98fr) minmax(360px, .82fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}
.public-workspace.single {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}
.instruction-panel, .submit-panel, .admin-card, .admin-login {
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(255, 255, 255, .82);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 60px rgba(28, 53, 82, .09);
  padding: clamp(18px, 3vw, 26px);
  backdrop-filter: blur(22px) saturate(155%);
  -webkit-backdrop-filter: blur(22px) saturate(155%);
}
.admin-card, .admin-login { width: min(100%, 1180px); }
.public-card { width: min(100%, 980px); background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 80px rgba(31,54,78,.12); padding: 24px; }
.public-head, .admin-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
.brand-mark { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: #fff; background: linear-gradient(135deg, var(--accent), #4f46e5); font-weight: 800; margin-bottom: 12px; }
h2 { margin: 0 0 10px; }
p { color: var(--muted); line-height: 1.6; }
.section-title { margin-bottom: 18px; }
.section-title h2 { font-size: clamp(22px, 3vw, 30px); letter-spacing: -.035em; text-wrap: balance; }
.soft-label {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 780;
}

.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 22px; }
.ios-stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.step {
  position: relative;
  border: 1px solid rgba(20, 32, 48, .08);
  border-radius: 18px;
  padding: 14px 10px 14px 44px;
  background: rgba(255,255,255,.56);
  color: #667386;
  font-weight: 720;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
.step::before {
  content: attr(data-step-dot);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
}
.step.active { border-color: rgba(20,117,246,.22); color: var(--accent-strong); background: rgba(232,241,255,.72); }

.guide-panel, .panel-box, .status-panel, .result-panel { border: 1px solid var(--line); border-radius: 18px; background: var(--soft); padding: 18px; margin-bottom: 18px; }
.guide-list { display: grid; gap: 10px; }
.guide-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 15px;
  border: 1px solid rgba(20, 32, 48, .08);
  border-radius: 20px;
  background: rgba(255,255,255,.58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
.guide-row:first-of-type { border-top: 0; }
.guide-row strong { color: #182334; }
.guide-row p { margin: 5px 0 0; font-size: 14px; }
.guide-num { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 800; }

.form-stack { display: grid; gap: 16px; }
label span, .email-grid label { font-weight: 700; color: #263952; }
label { display: grid; gap: 8px; }
input, textarea, select {
  width: 100%;
  border: 1px solid rgba(20, 32, 48, .12);
  border-radius: 18px;
  padding: 14px 15px;
  font: inherit;
  background: rgba(255,255,255,.86);
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease, transform .18s ease;
}
textarea { resize: vertical; font-family: Consolas, "Microsoft YaHei", monospace; }
input::placeholder, textarea::placeholder { color: #748197; }
input:focus, textarea:focus, select:focus { border-color: rgba(20,117,246,.62); box-shadow: 0 0 0 4px rgba(20,117,246,.13), inset 0 1px 0 rgba(255,255,255,.9); background: #fff; }
.btn {
  border: 1px solid rgba(20, 32, 48, .1);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255,255,255,.78);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, opacity .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(28, 53, 82, .12); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .58; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, #2184ff, var(--accent)); border-color: rgba(20,117,246,.2); color: #fff; box-shadow: 0 14px 34px rgba(20,117,246,.24), inset 0 1px 0 rgba(255,255,255,.32); }
.btn.secondary { color: #17324c; }
.btn.danger { color: #b91c1c; border-color: rgba(220,38,38,.18); background: rgba(254,226,226,.7); }
.btn.wide { width: 100%; padding: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }
.query-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; margin-bottom: 18px; align-items: end; }
.query-field { display: grid; gap: 8px; }
.status-top { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.badge { display: inline-flex; padding: 7px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-weight: 800; }
.badge.success { background: #dcfce7; color: #047857; }
.badge.manual { background: #fee2e2; color: #b91c1c; }
.progress-list { display: grid; gap: 10px; list-style: none; padding: 0; margin: 18px 0; }
.progress-list li { border: 1px solid rgba(20, 32, 48, .08); background: rgba(255,255,255,.66); border-radius: 16px; padding: 13px 14px; color: var(--muted); }
.progress-list li.active { border-color: rgba(20,117,246,.34); color: var(--accent-strong); font-weight: 800; background: var(--accent-soft); }
.invoice-box { border-top: 1px solid var(--line); padding-top: 16px; }
.result-panel, .status-panel {
  margin-top: 18px;
  margin-bottom: 0;
  border-color: rgba(20,117,246,.18);
  background: rgba(232,241,255,.64);
}
.result-panel.error {
  border-color: rgba(220,38,38,.2);
  background: rgba(254,226,226,.72);
}
.result-panel.error h2,
.result-panel.error p { color: #991b1b; }
.result-panel.success {
  border-color: rgba(5,150,105,.2);
  background: rgba(236,253,245,.72);
}
.result-panel.success h2 { color: #047857; }

.admin-shell { place-items: start center; }
.admin-actions, .tabs, .toolbar, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tabs { border-bottom: 1px solid var(--line); margin-bottom: 18px; padding-bottom: 12px; }
.tab { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 18px; font-weight: 800; cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stats-grid div { border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 18px; }
.stats-grid span { color: #4a5d77; font-weight: 700; }
.stats-grid strong { display: block; font-size: 34px; margin-top: 10px; }
.toolbar { margin-bottom: 14px; }
.toolbar input { flex: 1 1 360px; }
.toolbar select { width: 160px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #e8eef5; vertical-align: top; }
th { color: #465977; font-size: 13px; background: #fbfdff; }
td { font-size: 14px; }
.status-pill { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-weight: 800; background: #edf5f2; color: #047857; }
.status-pill.pending { background: #fef3c7; color: #a16207; }
.status-pill.processing { background: #dbeafe; color: #1d4ed8; }
.status-pill.failed, .status-pill.session_expired, .status-pill.cancelled, .status-pill.destroyed { background: #fee2e2; color: #b91c1c; }
.cell-actions { display: grid; gap: 8px; }
.mini { padding: 7px 10px; font-size: 13px; }
.email-grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 14px; }
.email-grid label { display: grid; gap: 8px; }
.email-grid label:first-child, .email-grid label:nth-last-child(2), .email-grid .form-actions { grid-column: 1 / -1; }
.login-form { display: flex; gap: 10px; margin-top: 20px; }
.login-form input { max-width: 360px; }
.import-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.generate-form { grid-template-columns: minmax(220px, 1fr) 130px 130px auto; }
.generated-box { margin-top: 14px; display: grid; gap: 10px; }
.generated-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.generated-box textarea { font-family: Consolas, "SFMono-Regular", monospace; }

@media (max-width: 760px) {
  .public-shell { padding: 12px; }
  .public-hero { border-radius: 26px; padding: 14px 16px 28px; }
  .public-nav { min-height: 48px; }
  .hero-grid, .public-workspace { grid-template-columns: 1fr; gap: 12px; }
  .hero-grid { padding-top: 28px; }
  h1 { font-size: clamp(31px, 8.5vw, 40px); letter-spacing: -.04em; }
  .hero-text { font-size: 16px; margin-top: 16px; }
  .instruction-panel, .submit-panel, .admin-card, .admin-login { padding: 16px; border-radius: 24px; }
  .public-card { padding: 18px; border-radius: 18px; }
  .public-head, .admin-head, .guide-row, .query-row, .login-form, .import-form { grid-template-columns: 1fr; display: grid; }
  .ios-stepper, .stepper, .stats-grid, .email-grid { grid-template-columns: 1fr; }
  .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
