:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e8eaee;
  --line-2: #f0f1f4;
  --text: #16181d;
  --muted: #8b929e;
  --primary: #2f6bff;
  --primary-d: #1f57dd;
  --danger: #e5484d;
  --ok: #17a673;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 统一修正：[hidden] 必须压过任何 display 规则 */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: none;
}

button, input { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--muted); }

/* ---------------- 访问码 ---------------- */
.gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 60%);
}
.gate-card {
  width: 100%; max-width: 340px; background: var(--card); border-radius: 20px;
  padding: 32px 24px; box-shadow: var(--shadow); text-align: center;
}
.gate-logo { font-size: 40px; }
.gate-card h1 { font-size: 19px; margin: 10px 0 4px; }
.gate-card p { margin: 0 0 18px; font-size: 13px; }
.gate-card input {
  width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 12px;
  padding: 0 14px; background: #fafbfc; outline: none; text-align: center; letter-spacing: 2px;
}
.gate-card input:focus { border-color: var(--primary); background: #fff; }
.gate-err { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ---------------- 布局 ---------------- */
.app { min-height: 100vh; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand-t { font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.brand-sub {
  font-size: 11px; color: var(--muted); margin-top: 1px;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sync {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  padding: 6px 10px; border-radius: 20px; background: #f2f4f7;
}
.sync .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(23, 166, 115, .14);
}
.sync.busy .dot { background: #f5a524; box-shadow: 0 0 0 3px rgba(245, 165, 36, .16); animation: pulse 1s infinite; }
.sync.err .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(229, 72, 77, .16); }
@keyframes pulse { 50% { opacity: .35; } }

.toolbar { padding: 12px 16px 0; }
.search {
  display: flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; color: var(--muted);
}
.search input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font-size: 15px; }
.search input::-webkit-search-cancel-button { display: none; }
.qclear { color: var(--muted); font-size: 20px; line-height: 1; padding: 0 2px; }

.filter { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.filter button {
  padding: 6px 14px; border-radius: 20px; font-size: 13px; color: #5b616d;
  background: #eceef2; white-space: nowrap;
}
.filter button.on { background: var(--text); color: #fff; }

.summary { padding: 10px 18px 4px; font-size: 12px; color: var(--muted); }

/* ---------------- 列表 ---------------- */
.list { padding: 4px 12px 12px; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; margin-bottom: 8px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
  transition: transform .12s ease, box-shadow .12s;
}
.item:active { transform: scale(.985); }
.thumb {
  position: relative;
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 10px;
  background: #f2f4f7; display: flex; align-items: center; justify-content: center;
  overflow: hidden; color: #c3c8d1; font-size: 18px;
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.meta { flex: 1; min-width: 0; }
.name {
  font-size: 15px; font-weight: 550; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sub { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; align-items: center; }
.tag {
  font-size: 11px; padding: 1px 6px; border-radius: 5px; background: #eef1f6; color: #6b7280;
}
.tag.ok { background: #e7f7f0; color: var(--ok); }
.tag.warn { background: #fff4e5; color: #b76e00; }
.chev { color: #c8ccd4; font-size: 20px; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px; }
.empty-ico { font-size: 34px; margin-bottom: 8px; }
.loadmore { text-align: center; color: var(--muted); font-size: 13px; padding: 14px; }

/* ---------------- 详情面板 ---------------- */
.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: slideIn .22s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slideIn { from { transform: translateX(16px); opacity: .6; } }
.sheet[hidden] { display: none; }

.sheet-head {
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; font-size: 19px;
  color: #444b57; display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: #f1f3f6; }
.sheet-title { flex: 1; min-width: 0; text-align: center; }
.pname {
  font-size: 16px; font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.psub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sheet-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(28px + env(safe-area-inset-bottom));
}

.imgwrap { background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.imgbox {
  position: relative; width: 100%; aspect-ratio: 4 / 3;
  background: #f2f4f7; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.imgbox img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.imgbox .imgph { text-align: center; padding: 0 16px; line-height: 1.6; }
.imgph { color: #a9b0bb; font-size: 13px; }
.imglink-badge {
  position: absolute; top: 8px; right: 8px; font-size: 11px;
  background: rgba(23, 166, 115, .92); color: #fff; padding: 3px 8px; border-radius: 20px;
}

.img-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn {
  flex: 1; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 550; background: #f0f2f5; color: #2b3038;
  border: 1px solid transparent;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(47, 107, 255, .24); }
.btn.primary:active { background: var(--primary-d); }
.btn.block { width: 100%; display: block; line-height: 46px; margin-top: 16px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.uploadbar {
  margin-top: 10px; height: 30px; border-radius: 9px; background: #eef1f6;
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #3b4250;
}
.upbar-inner {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, #dbe6ff, #c9daff); transition: width .18s;
}
.uploadbar span { position: relative; z-index: 1; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-top: 12px; box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #6b7280; margin-bottom: 10px; }
.card-actions { display: flex; gap: 8px; }
.mini { font-size: 12px; padding: 4px 10px; border-radius: 8px; background: #f0f2f5; color: #374151; }
.mini.danger { background: #fdecec; color: var(--danger); }
.link { font-size: 13px; word-break: break-all; line-height: 1.5; display: block; }
.link-empty { font-size: 13px; color: var(--muted); }

.fields { display: flex; flex-direction: column; gap: 10px; }
.field .req { color: #e5484d; font-style: normal; font-weight: 700; }
.field.miss input, .field.miss textarea { border-color: #e5484d; background: #fff8f8; }
.field.miss label { color: #b42318; }
.reqtip {
  margin-bottom: 10px; padding: 9px 12px; border-radius: 9px;
  background: #fff4e5; color: #925b00; font-size: 12.5px; line-height: 1.5;
}

/* ---------- 必填进度条 ---------- */
.reqbar {
  width: 100%; display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 11px 14px; border-radius: 12px;
  background: #fff4e5; color: #925b00; text-align: left;
  border: 1px solid #f7e3bd; font-size: 13px;
}
.reqbar.done { background: #eaf8f2; color: #0d7f55; border-color: #cdeee0; }
.reqbar-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #e08900; flex: 0 0 8px;
}
.reqbar.done .reqbar-dot { background: var(--ok); }
.reqbar-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reqbar-n { font-weight: 600; flex: 0 0 auto; opacity: .85; }

/* ---------- 右侧抽屉 ---------- */
.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer[hidden] { display: none !important; }
.drawer-mask { position: absolute; inset: 0; background: rgba(16, 20, 28, .34); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(320px, 84vw);
  background: var(--card); display: flex; flex-direction: column;
  box-shadow: -12px 0 32px rgba(16, 24, 40, .16);
  animation: drawerIn .2s cubic-bezier(.2, .8, .3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes drawerIn { from { transform: translateX(24px); opacity: .5; } }
.drawer-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 18px 12px;
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.drawer-list { flex: 1; overflow-y: auto; padding: 8px 12px; }
.req-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 12px 10px; border-radius: 10px; text-align: left;
  font-size: 14px; color: var(--text); background: transparent;
}
.req-item + .req-item { margin-top: 2px; }
.req-item:active { background: #f4f6f9; }
.ri-dot {
  width: 16px; height: 16px; border-radius: 50%; flex: 0 0 16px;
  background: #e6f7ef; position: relative;
}
.ri-dot::after {
  content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--ok); font-weight: 700;
}
.req-item.miss .ri-dot { background: #fdeeee; }
.req-item.miss .ri-dot::after { content: '!'; color: var(--danger); }
.ri-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-val { font-size: 12.5px; color: var(--muted); flex: 0 0 auto; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-item.miss .ri-val { color: var(--danger); }
.drawer-f {
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); line-height: 1.6;
}
.drawer-empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13px; }
body.drawer-open { overflow: hidden; }
.field label { display: block; font-size: 12px; color: #6b7280; margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc;
  padding: 11px 12px; font-size: 15px; outline: none;
}
.field textarea { min-height: 68px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }
.hint { font-size: 11px; color: #a3a9b4; margin-top: 10px; }
.save-state { font-size: 12px; color: var(--ok); min-height: 16px; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(22, 24, 29, .93); color: #fff; font-size: 13.5px;
  padding: 11px 18px; border-radius: 12px; z-index: 100; max-width: 86vw; text-align: center;
  animation: toastIn .18s ease; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast.err { background: rgba(190, 40, 45, .95); }

@media (min-width: 720px) {
  .app { max-width: 720px; margin: 0 auto; background: var(--bg); }
  .sheet-body { max-width: 720px; margin: 0 auto; width: 100%; }
}
