:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e4e8ef;
  --text: #1a2230;
  --dim: #7b869a;
  --brand: #1565d8;
  --brand-soft: #eaf1fd;
  --danger: #d92d20;
  --ok: #0f9d58;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.top {
  background: linear-gradient(135deg, #1565d8, #0d47a1);
  color: #fff;
  padding: 18px 0 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 12px rgba(13, 71, 161, .18);
}
.top .wrap { display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(255, 255, 255, .18);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: .5px;
}
.brand h1 { margin: 0; font-size: 17px; font-weight: 600; }
.brand p { margin: 2px 0 0; font-size: 12.5px; opacity: .85; }

.tabs { display: flex; gap: 6px; }
.tab {
  flex: 1;
  border: 0;
  background: rgba(255, 255, 255, .14);
  color: rgba(255, 255, 255, .88);
  padding: 11px 8px;
  font-size: 14px;
  font-family: inherit;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  transition: .15s;
}
.tab:hover { background: rgba(255, 255, 255, .22); }
.tab.on {
  background: var(--card);
  color: var(--brand);
  font-weight: 600;
}

/* ---------- form ---------- */
main { padding: 22px 16px 60px; }

.formhead { margin-bottom: 18px; }
.formhead h2 { margin: 0 0 6px; font-size: 21px; }
.formhead p { margin: 0; color: var(--dim); font-size: 13.5px; }

.group {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.group:not(.show) { display: none; }
.group h3 {
  margin: 0 0 4px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.gno {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 12.5px; font-weight: 700;
  display: inline-grid; place-items: center;
  flex: none;
}
.ghint { color: var(--dim); font-size: 12.5px; margin: 0 0 12px 33px; }
.gfields { display: flex; flex-direction: column; gap: 16px; margin-top: 14px; }

.field .label { font-size: 14.5px; font-weight: 500; margin-bottom: 6px; }
.req { color: var(--danger); }
.hint { color: var(--dim); font-size: 12.5px; margin: -2px 0 6px; }
.err { color: var(--danger); font-size: 12.5px; margin-top: 5px; min-height: 0; }
.field.bad input, .field.bad textarea, .field.bad select { border-color: var(--danger); }
.field.bad .opts { border: 1px solid var(--danger); border-radius: 10px; padding: 8px; }

input[type=text], input[type=tel], input[type=number], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; }
.unit { color: var(--dim); font-size: 13px; margin-left: 6px; }

.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13.5px;
  cursor: pointer;
  background: #fff;
  transition: .12s;
  user-select: none;
}
.opt:hover { border-color: var(--brand); color: var(--brand); }
.opt input { accent-color: var(--brand); margin: 0; }
.opt:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 500;
}

/* ---------- 照片上传 ---------- */
.photobtns { display: flex; gap: 8px; flex-wrap: wrap; }
.pbtn {
  display: inline-flex; align-items: center;
  border: 1px solid var(--brand);
  color: var(--brand);
  background: #fff;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
.pbtn:hover { background: var(--brand-soft); }
.preview {
  margin-top: 10px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  min-height: 34px;
}
.preview img {
  max-width: 220px; max-height: 140px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #f7f9fc;
}
.ph { color: var(--dim); font-size: 13px; }
.phsize { color: var(--dim); font-size: 12px; }
.delphoto {
  border: 1px solid var(--line); background: #fff; color: var(--dim);
  border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.delphoto:hover { color: var(--danger); border-color: var(--danger); }
.warn { color: #b54708; font-size: 14px; }
.idcardimgs { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.idcardimgs figure { margin: 0; }
.idcardimgs img {
  max-width: 300px; width: 100%;
  border: 1px solid var(--line); border-radius: 10px; display: block;
}
.idcardimgs figcaption { color: var(--dim); font-size: 12.5px; margin-top: 6px; text-align: center; }

/* scale */
.scale { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sbtn {
  width: 42px; height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  font: inherit; font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.sbtn.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.scaletxt { color: var(--dim); font-size: 13px; margin-left: 4px; }

/* rows */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) auto;
  gap: 8px;
  align-items: end;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fbfcfe;
}
.cell { display: flex; flex-direction: column; gap: 4px; }
.celllabel { font-size: 11.5px; color: var(--dim); }
.delrow {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  background: #fff; color: var(--dim);
  border-radius: 8px; cursor: pointer; font-size: 17px; line-height: 1;
}
.delrow:hover { color: var(--danger); border-color: var(--danger); }
.addrow {
  align-self: flex-start;
  border: 1px dashed var(--brand);
  color: var(--brand);
  background: #fff;
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.rowcount { color: var(--dim); font-size: 12.5px; }
.rowcount b { color: var(--brand); }

/* ---------- submit ---------- */
.submitbar { text-align: center; padding: 8px 0 30px; }
.subnote { color: var(--dim); font-size: 12.5px; margin-bottom: 12px; }
.submit {
  width: 100%;
  max-width: 320px;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 14px;
  font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(21, 101, 216, .28);
}
.submit:disabled { opacity: .6; cursor: default; }

/* ---------- done ---------- */
.done { text-align: center; padding: 50px 20px; }
.doneicon {
  width: 66px; height: 66px; margin: 0 auto 16px;
  border-radius: 50%;
  background: #e6f6ee; color: var(--ok);
  display: grid; place-items: center; font-size: 32px;
}
.done h2 { margin: 0 0 8px; }
.done .dim { color: var(--dim); font-size: 13.5px; }
.donebtns { margin-top: 22px; }
.ghost {
  border: 1px solid var(--line);
  background: #fff; color: var(--text);
  border-radius: 10px; padding: 10px 22px;
  font: inherit; cursor: pointer;
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%; bottom: 28px;
  transform: translate(-50%, 20px);
  background: #1a2230; color: #fff;
  padding: 11px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none;
  transition: .2s; z-index: 50; max-width: 88vw; text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footer ---------- */
.foot {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 18px 0;
  color: var(--dim);
  font-size: 12.5px;
}
.foot .wrap { display: flex; justify-content: space-between; gap: 10px; }
.foot a { color: var(--dim); }

/* ---------- admin ---------- */
.adminbox { padding: 24px 0 60px; }
.adminbox h2 { margin: 0 0 4px; font-size: 20px; }
.adminbox .sub { color: var(--dim); font-size: 13.5px; margin: 0 0 20px; }
.login {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 12px; max-width: 420px;
}
.login input { width: 100%; }
.btn {
  background: var(--brand); color: #fff; border: 0;
  border-radius: 10px; padding: 11px 18px;
  font: inherit; cursor: pointer;
}
.btn.gray { background: #5b6675; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; align-items: center; }
.toolbar select { width: auto; min-width: 160px; }
.tblwrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; white-space: nowrap; }
th { background: #f7f9fc; font-weight: 600; position: sticky; top: 0; }
tr:hover td { background: #fafbfe; }
.detail { max-width: 780px; }
.detail h3 { margin: 18px 0 8px; font-size: 15px; }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 16px; font-size: 13.5px; align-items: start; }
.kv div:nth-child(odd) { color: var(--dim); }
.kv div:nth-child(even) { min-width: 0; overflow-wrap: anywhere; line-height: 1.7; }
.kv div:nth-child(odd) { line-height: 1.7; }
.detail .kv + h3 { margin-top: 24px; }
.empty { padding: 30px; text-align: center; color: var(--dim); }
.mask { background: #fffbe9; }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

@media (max-width: 640px) {
  .brand h1 { font-size: 15.5px; }
  .tab { font-size: 13px; padding: 10px 4px; }
  .group { padding: 14px; }
  .row { grid-template-columns: 1fr auto; }
  .kv { grid-template-columns: 104px minmax(0, 1fr); gap: 8px 12px; }
}
