/* ===== 外业验收采集系统 · 公共样式（采集端 + 管理后台） ===== */
:root {
  --primary: #0b63c8;
  --primary-dark: #084c9e;
  --bg: #eef2f7;
  --card: #ffffff;
  --border: #dde3ea;
  --text: #1b2430;
  --muted: #697586;
  --ok: #148a52;
  --ok-bg: #e3f5eb;
  --warn: #b26a00;
  --warn-bg: #fdf1dd;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 4px 14px rgba(16, 32, 56, .05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-text-size-adjust: 100%;
}
#app { min-height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; color: var(--text); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255,255,255,.96); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: .5px; white-space: nowrap; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:active { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #eccac5; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .5; }
.select {
  height: 40px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23697586' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.save-state { font-size: 12px; color: var(--muted); padding: 4px 16px 0; min-height: 20px; }

/* ---------- 登录门 ---------- */
.gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0d2b52 0%, #0b63c8 100%); padding: 24px; }
.gate-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 26px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.gate-card h1 { font-size: 20px; margin: 0 0 6px; }
.gate-card p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.gate-card input { width: 100%; height: 46px; border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; margin-bottom: 12px; }
.gate-card .btn { width: 100%; height: 46px; justify-content: center; }
.gate-err { color: var(--danger); font-size: 13px; min-height: 20px; }
.gate-foot { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- 列表页 ---------- */
main { flex: 1; width: 100%; }
.view { width: 100%; max-width: 980px; margin: 0 auto; padding: 12px 14px 28px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.searchbox { position: relative; flex: 1; }
.searchbox input { width: 100%; height: 44px; border-radius: 10px; border: 1px solid var(--border); background: #fff; padding: 0 12px 0 38px; }
.searchbox .icon { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.filters { display: flex; gap: 8px; margin-bottom: 10px; overflow-x: auto; }
.chip { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; white-space: nowrap; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tasklist { display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.task:active { background: #f7fafd; }
.task .seq { width: 30px; height: 30px; border-radius: 8px; background: #eef3f9; color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.task .t-main { flex: 1; min-width: 0; }
.task .t-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.task .t-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; color: var(--muted); }
.task .t-state { flex: none; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #eef3f9; color: var(--muted); }
.task .t-state.done { background: var(--ok-bg); color: var(--ok); }
.task .t-state.part { background: var(--warn-bg); color: var(--warn); }
.task .t-photos { font-size: 12px; color: var(--muted); flex: none; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* ---------- 表单页 ---------- */
.formhead { position: sticky; top: 57px; z-index: 15; display: flex; align-items: center; gap: 10px;
  padding: 8px 2px 10px; background: var(--bg); }
.iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px; }
.taskmeta { flex: 1; min-width: 0; }
.taskmeta .tname { font-weight: 700; font-size: 17px; }
.taskmeta .tsub { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.formnav { display: flex; gap: 8px; }
.formnav .btn { height: 36px; padding: 0 10px; font-size: 13px; }
.formbody { display: flex; flex-direction: column; gap: 12px; padding-bottom: 96px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; display: flex; align-items: baseline; gap: 8px; }
.card-title .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.field { padding: 9px 0; border-bottom: 1px dashed #eef1f5; }
.field:last-child { border-bottom: 0; }
.field .label { font-size: 14px; color: #344154; margin-bottom: 8px; }
.field .label em { color: var(--danger); font-style: normal; margin-left: 2px; }
.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented button { min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--text); }
.segmented button.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.segmented.vertical button { flex: 1 1 calc(50% - 8px); text-align: left; }
.segmented.vertical button.wide { flex-basis: 100%; }
.photogrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-slot { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; border: 1.5px dashed #b9c6d6;
  background: #f7fafc; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.photo-slot.has { border-style: solid; border-color: var(--border); background: #000; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-slot .ph-hint { color: var(--muted); font-size: 13px; text-align: center; line-height: 1.7; }
.photo-slot .ph-hint b { display: block; font-size: 26px; color: #9db0c4; font-weight: 400; }
.photo-slot .ph-no { position: absolute; left: 8px; top: 6px; font-size: 11px; color: #fff; background: rgba(0,0,0,.45); border-radius: 6px; padding: 1px 6px; }
.photo-slot .ph-meta { position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: #fff; background: rgba(0,0,0,.45); border-radius: 6px; padding: 1px 6px; }
.photo-slot .ph-del { position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; border-radius: 999px;
  border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 18px; line-height: 1; }
.photo-slot.add { border: 1.5px dashed #b9c6d6; background: #fbfdff; }
.photo-note { margin-top: 10px; font-size: 12px; color: var(--muted); }
.photo-count { display: block; margin-top: 6px; color: var(--primary); font-weight: 600; }
textarea#fOpinion { width: 100%; min-height: 108px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); resize: vertical; line-height: 1.6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.grid2 label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.grid2 input { height: 44px; border-radius: 10px; border: 1px solid var(--border); padding: 0 10px; background: #fff; }
.grid2 .full { grid-column: 1 / -1; }
.formfoot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 18; display: flex; gap: 10px; justify-content: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97);
  border-top: 1px solid var(--border); backdrop-filter: blur(10px); }
.formfoot .btn { height: 46px; flex: 1; max-width: 260px; justify-content: center; }

/* ---------- 弹层/提示 ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(15, 26, 42, .42);
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.progressbox { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.progressbox .p-title { font-weight: 700; margin-bottom: 10px; }
.progressbox .p-text { font-size: 13px; color: var(--muted); margin-bottom: 10px; min-height: 20px; }
.bar { height: 8px; border-radius: 99px; background: #eef1f5; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .18s; border-radius: 99px; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: rgba(20, 30, 44, .92); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 80vw; text-align: center; }

/* ---------- 管理后台 ---------- */
.admin-wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 14px 16px 40px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.tabs button { height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.tabs button.active { background: #fff; border-color: var(--border); color: var(--primary); font-weight: 600; }
.admin-section { display: grid; gap: 14px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel h2 .tag { font-size: 12px; font-weight: 400; color: var(--muted); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.form-row label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.form-row input[type=file] { font-size: 13px; }
.form-row select, .form-row input[type=number] { height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; background: #fff; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { border-bottom: 1px solid #eef1f5; padding: 7px 8px; text-align: left; vertical-align: middle; }
table.grid th { color: var(--muted); font-weight: 600; background: #f8fafc; }
table.grid tr:hover td { background: #f9fbfd; }
.state-pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef3f9; color: var(--muted); }
.state-pill.done { background: var(--ok-bg); color: var(--ok); }
.state-pill.part { background: var(--warn-bg); color: var(--warn); }
.muted { color: var(--muted); font-size: 12px; }
.notice { background: var(--warn-bg); color: #8a5300; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kv-item { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.kv-item b { display: block; font-size: 20px; }
.kv-item span { font-size: 12px; color: var(--muted); }
.preview-table { overflow: auto; max-height: 300px; border: 1px solid var(--border); border-radius: 8px; }
.upload-area { border: 1.5px dashed #b9c6d6; border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); font-size: 13px; background: #fbfdff; }

/* ---------- 宽屏/窄屏 ---------- */
@media (min-width: 760px) {
  .photogrid { grid-template-columns: 1fr 1fr; }
  .formbody { max-width: 860px; margin: 0 auto; }
}
@media (min-width: 900px) {
  .photogrid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 560px) {
  .brand small { display: none; }
  .tab-labels { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
