:root {
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --primary-light: #e8f2ff;
  --bg: #f2f6ff;
  --ink: #1c2b3a;
  --muted: #7a8bb0;
  --line: #e2ebf4;
  --card: #ffffff;
  --danger: #d4380d;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(115deg, #1677ff 0%, #3f9bff 60%, #6ab4ff 100%);
  color: #fff;
  padding: 18px 16px 22px;
  box-shadow: 0 6px 20px rgba(22, 119, 255, .18);
}
.topbar-inner {
  max-width: 700px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 46px; height: 46px; flex: none; border-radius: 13px;
  background: rgba(255, 255, 255, .2);
  border: 1px solid rgba(255, 255, 255, .45);
  display: grid; place-items: center;
  font-size: 20px; font-weight: 800;
}
.brand h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.brand p { margin: 3px 0 0; font-size: 12px; opacity: .9; }
.logout-btn {
  appearance: none; flex: none; cursor: pointer; font-family: inherit;
  padding: 8px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .16); color: #fff;
}
.logout-btn:hover { background: rgba(255, 255, 255, .3); }

.page { max-width: 700px; margin: 0 auto; padding: 18px 14px 36px; }

/* ---------- 步骤条 ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 18px; }
.step {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 6px; border-radius: 10px;
  background: #fff; color: #9db1d8; font-size: 12.5px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(31, 78, 140, .04);
  transition: .2s;
}
.step b {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: #edf2fa; color: #9db1d8; font-size: 11px; flex: none;
}
.step.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(22, 119, 255, .25); }
.step.active b { background: rgba(255, 255, 255, .28); color: #fff; }
.step.done { background: #eaf7ef; color: #1a9c53; }
.step.done b { background: #1a9c53; color: #fff; }

/* ---------- 登录视图 ---------- */
.login-view { min-height: 340px; }
.login-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 30px 24px 26px;
  box-shadow: 0 8px 28px rgba(35, 78, 125, .07);
  text-align: center;
}
.login-icon {
  width: 56px; height: 56px; margin: 0 auto 12px;
  border-radius: 16px; background: var(--primary-light);
  display: grid; place-items: center; font-size: 26px;
}
.login-card h2 { margin: 0; font-size: 20px; font-weight: 800; }
.login-sub { margin: 6px 0 22px; color: var(--muted); font-size: 13px; }
.login-card .field { text-align: left; margin-bottom: 16px; }
.code-input {
  letter-spacing: 1.5px; font-family: ui-monospace, Consolas, monospace;
  text-transform: uppercase;
}
.login-error {
  margin: 14px 0 0; color: var(--danger); font-size: 13px; font-weight: 600;
  background: #fff2e8; border: 1px solid #ffd8bf; border-radius: 9px; padding: 10px 12px;
}
.login-note { margin: 18px 0 0; color: #9aabc4; font-size: 12px; line-height: 1.7; }
.checking { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 0; }

/* ---------- 通用卡片表单 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px 22px;
  margin-bottom: 16px;
  box-shadow: 0 6px 22px rgba(35, 78, 125, .06);
}
.card h2 {
  margin: 0 0 18px;
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}
.step-no {
  display: inline-grid; place-items: center;
  min-width: 32px; height: 25px; padding: 0 7px;
  border-radius: 8px; background: var(--primary-light); color: var(--primary);
  font-size: 12px; font-weight: 700;
}
.step-no.ok { background: #e3f5e9; color: #1e7a45; }

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

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; color: #566e86; }

input[type="text"], input[type="number"], input[type="date"],
input[readonly], select, .link-row input, .code-input {
  width: 100%; height: 44px;
  padding: 0 12px;
  border: 1px solid #d7e3ef;
  border-radius: 10px;
  background: #fbfdff;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .15);
}
input[readonly] { background: #f3f8fd; color: #3d5c7a; font-family: ui-monospace, Consolas, monospace; letter-spacing: 1px; }

.radio-row { display: flex; gap: 10px; height: 44px; }
.pill { flex: 1; cursor: pointer; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: grid; place-items: center; height: 44px;
  border: 1px solid #d7e3ef; border-radius: 10px;
  background: #fbfdff; color: #566e86; font-size: 14px; font-weight: 600;
  transition: .15s;
}
.pill input:checked + span {
  background: linear-gradient(135deg, #3f9bff, #1677ff);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 12px rgba(22, 119, 255, .25);
}

.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; min-width: 0; }
.with-btn button {
  flex: none; padding: 0 14px; height: 44px;
  border: 1px solid #d7e3ef; border-radius: 10px;
  background: #f3f8fd; color: var(--primary); font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.with-btn button:hover { background: #e7f2ff; }

.tip { margin: 15px 0 0; font-size: 12.5px; color: #8497aa; line-height: 1.7; }
.hidden { display: none !important; }

/* ---------- 上传 ---------- */
.upload-row { display: flex; gap: 22px; align-items: flex-start; }
.drop {
  position: relative; flex: none;
  width: 200px; height: 220px;
  border: 2px dashed #a9cdf5; border-radius: 14px;
  background: #f7fbff;
  display: grid; place-items: center;
  overflow: hidden; cursor: pointer;
  transition: .18s;
}
.drop:hover, .drop.dragover { border-color: var(--primary); background: #eef7ff; }
.drop input[type="file"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; z-index: 3;
}
.drop img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 2; display: none;
}
.drop.has-photo img { display: block; }
.drop.has-photo .drop-hint { display: none; }
.drop-hint { text-align: center; padding: 16px; z-index: 1; }
.drop-hint strong { display: block; font-size: 14px; color: #2c5173; margin-top: 14px; }
.drop-hint span { display: block; font-size: 12px; color: #8ca1b6; margin-top: 8px; line-height: 1.6; }
.camera {
  width: 46px; height: 34px; margin: 0 auto;
  border: 2px solid #7fb2e6; border-radius: 8px; position: relative;
}
.camera::before {
  content: ""; position: absolute; top: -8px; left: 12px;
  width: 18px; height: 7px; border: 2px solid #7fb2e6; border-bottom: none; border-radius: 5px 5px 0 0;
}
.camera::after {
  content: ""; position: absolute; top: 9px; left: 15px;
  width: 12px; height: 12px; border: 2px solid #7fb2e6; border-radius: 50%;
}
.upload-side { flex: 1; min-width: 0; }
.upload-side p { margin: 0; font-size: 13px; line-height: 1.85; color: #60768c; }
.upload-side strong { color: var(--primary); }
.check {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; font-size: 13px; color: #566e86; cursor: pointer;
}
.check input { width: 16px; height: 16px; flex: none; accent-color: var(--primary); cursor: pointer; }
.side-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---------- 按钮 ---------- */
.btn-plain, .link-row button {
  appearance: none; cursor: pointer; font-family: inherit;
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  border: 1px solid #d5e2ef; background: #fff; color: #2c5173;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  transition: .16s;
}
.btn-plain:hover, .link-row button:hover { background: #f2f8ff; border-color: #7fb4ee; }
.btn-primary {
  appearance: none; cursor: pointer; font-family: inherit;
  padding: 11px 20px; border-radius: 10px; font-size: 14px; font-weight: 700;
  border: 1px solid transparent; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3f9bff, #1677ff); color: #fff;
  box-shadow: 0 6px 16px rgba(22, 119, 255, .22);
  transition: .16s;
}
.btn-primary:hover { background: linear-gradient(135deg, #2f8af0, #0958d9); }
.btn-block { width: 100%; height: 46px; font-size: 15px; }
.btn-generate { padding: 14px 40px; font-size: 16px; border-radius: 12px; }
.btn-primary:disabled { opacity: .6; cursor: wait; }

.advanced {
  background: #f8fbff; border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 20px 16px; margin-bottom: 20px;
}
.advanced summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: #2c5173; }
.advanced .field { margin-top: 16px; }

.actions { text-align: center; }
.form-error {
  margin: 14px 0 0; color: var(--danger); font-size: 13.5px; font-weight: 600;
  background: #fff2e8; border: 1px solid #ffd8bf; border-radius: 9px; padding: 10px 14px;
}

/* ---------- 结果 ---------- */
.result-frame {
  width: 100%; height: 640px;
  background: #fff; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line);
}
.result-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.link-row { display: flex; gap: 10px; margin-top: 18px; }
.link-row input { flex: 1; min-width: 0; font-size: 13px; font-family: ui-monospace, Consolas, monospace; }
.result .btn-plain { margin-top: 16px; }
.download-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.download-row span { font-size: 12.5px; color: #7b8ea3; }
.btn-download {
  appearance: none; cursor: pointer; font-family: inherit;
  padding: 12px 22px; border-radius: 11px; font-size: 14px; font-weight: 700;
  color: #fff; border: none; white-space: nowrap;
  background: linear-gradient(135deg, #3f9bff, #1677ff);
  box-shadow: 0 6px 16px rgba(22, 119, 255, .22); transition: .16s;
}
.btn-download:hover { background: linear-gradient(135deg, #2f8af0, #0958d9); transform: translateY(-1px); }
.btn-download:disabled { opacity: .6; cursor: wait; transform: none; }

.site-footer { text-align: center; color: #93a4b6; font-size: 12px; padding: 14px 0 0; }
.site-footer a { color: var(--primary); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.admin-link { display: inline-block; }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .topbar { padding: 14px 14px 18px; }
  .brand h1 { font-size: 18px; }
  .page { padding: 14px 12px 30px; }
  .grid.two { grid-template-columns: 1fr; }
  .upload-row { flex-direction: column; }
  .drop { width: 100%; }
  .link-row { flex-wrap: wrap; }
  .link-row input { flex-basis: 100%; }
  .step span { display: none; }
  .step { padding: 10px 4px; }
  .step b { width: 24px; height: 24px; }
  .result-frame { height: 520px; }
  .card { padding: 18px 16px 20px; }
  .login-card { padding: 26px 18px 22px; }
}

@media (max-width: 380px) {
  .brand p { font-size: 11px; }
  .btn-generate { width: 100%; }
}
