:root {
  --blue: #2f6df6;
  --blue-dark: #1f4fd0;
  --bg: #f2f3f6;
  --card: #ffffff;
  --line: #e6e8ee;
  --text: #1b1d22;
  --muted: #7b8194;
  --faint: #a8adbd;
  --green: #1f9d63;
  --amber: #c07a17;
  --red: #d64545;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(96px + var(--safe-bottom)); }

/* ===== 顶部 ===== */
.hd {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--card);
  padding: calc(var(--safe-top) + 12px) 16px 0;
  border-bottom: 1px solid var(--line);
}
.hd-row { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 9px; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 500;
}
.ttl { font-size: 17px; font-weight: 500; flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border: 0; background: transparent;
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  border-radius: 50%; padding: 0;
}
.icon-btn:active { background: #eef0f5; }
.icon-btn svg { width: 21px; height: 21px; }

.stats { display: flex; gap: 18px; padding: 12px 0 13px; }
.stat-n { font-size: 19px; font-weight: 500; line-height: 1.15; }
.stat-l { font-size: 11.5px; color: var(--muted); }
.stat.warn .stat-n { color: var(--amber); }

/* ===== 搜索栏 ===== */
.searchbar {
  display: flex; gap: 9px; align-items: center;
  padding: 11px 16px 2px;
}
.sb-box {
  flex: 1; display: flex; align-items: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 0 10px; height: 38px;
}
.sb-box svg { width: 17px; height: 17px; flex: 0 0 17px; color: var(--faint); }
.sb-box input {
  flex: 1; border: 0; background: transparent; font-size: 16px; font-family: inherit;
  color: var(--text); min-width: 0; padding: 0;
}
.sb-box input:focus { outline: none; }
.sb-box input::-webkit-search-cancel-button { display: none; }
.sb-x {
  border: 0; background: #eef0f4; color: var(--muted); width: 20px; height: 20px;
  border-radius: 50%; font-size: 14px; line-height: 1; padding: 0; flex: 0 0 20px;
}
.sb-btn {
  position: relative; flex: 0 0 auto; height: 38px; padding: 0 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 11px; font-size: 13.5px; font-family: inherit;
}
.sb-btn.on { border-color: var(--blue); color: var(--blue); font-weight: 500; }
.sb-btn i {
  position: absolute; top: -5px; right: -5px; background: var(--blue); color: #fff;
  font-style: normal; font-size: 10.5px; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ===== 筛选 ===== */
.chips {
  position: sticky; top: var(--hdh, 108px); z-index: 29;
  display: flex; gap: 8px; overflow-x: auto; padding: 11px 16px;
  background: var(--bg); scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); border-radius: 999px; padding: 6px 14px; font-size: 13.5px;
  font-family: inherit;
}
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 500; }

/* ===== 列表 ===== */
.list { padding: 2px 16px 8px; display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 7px;
}
.card:active { background: #fafbfd; }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-name {
  font-size: 15.5px; font-weight: 500; flex: 1; line-height: 1.35;
  word-break: break-all;
}
.tag {
  flex: 0 0 auto; font-size: 11.5px; padding: 2.5px 9px; border-radius: 999px;
  white-space: nowrap; font-weight: 500;
}
.s-unused { background: #e8f0ff; color: var(--blue-dark); }
.s-used { background: #e3f6ec; color: var(--green); }
.s-expired { background: #eef0f4; color: var(--muted); }
.s-refunded { background: #fbf0dd; color: var(--amber); }

.card-sub { font-size: 12.5px; color: var(--muted); }
.card-money { display: flex; align-items: baseline; gap: 8px; margin-top: 1px; }
.price { font-size: 19px; font-weight: 500; }
.price small { font-size: 13px; font-weight: 400; }
.price-orig { font-size: 12.5px; color: var(--faint); text-decoration: line-through; }
.qty { font-size: 12.5px; color: var(--muted); }

.card-date {
  font-size: 12.5px; color: var(--muted); margin-top: 2px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.pill { font-size: 11.5px; padding: 1.5px 8px; border-radius: 999px; background: #eef0f4; color: var(--muted); }
.pill.soon { background: #fdf1dd; color: var(--amber); }
.pill.done { background: #eef0f4; color: var(--faint); }

/* ===== 空状态 ===== */
.empty { padding: 60px 30px; text-align: center; color: var(--muted); }
.empty-t { font-size: 15px; color: var(--text); margin-bottom: 6px; font-weight: 500; }
.empty-d { font-size: 13px; line-height: 1.7; }

/* ===== 悬浮按钮 ===== */
.fab {
  position: fixed; right: 18px; bottom: calc(22px + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--blue); color: #fff; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(47,109,246,.36);
}
.fab:active { background: var(--blue-dark); }
.fab svg { width: 28px; height: 28px; }

/* ===== 底部弹层 ===== */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(15,18,26,.42); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease;
}
.sheet-mask.center { align-items: center; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 8px 0 calc(10px + var(--safe-bottom));
  max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: up .22s cubic-bezier(.2,.8,.3,1);
}
.sheet-mask.center .sheet { border-radius: 18px; margin: 0 16px; padding: 18px; max-height: 86vh; }
@keyframes up { from { transform: translateY(16px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet-h {
  padding: 12px 20px 10px; font-size: 15px; font-weight: 500;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sheet-h .x { border: 0; background: transparent; color: var(--muted); font-size: 14px; padding: 4px 0; font-family: inherit; }
.sheet-b { padding: 4px 20px 8px; }
.sheet-foot { padding: 10px 20px 6px; display: flex; gap: 10px; }

.menu-item {
  display: flex; align-items: center; gap: 12px; padding: 15px 20px;
  border: 0; background: transparent; width: 100%; text-align: left;
  font-size: 15.5px; font-family: inherit; color: var(--text);
}
.menu-item:active { background: #f4f6fa; }
.menu-item .mi-s { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.menu-item .mi-t { flex: 1; }
.menu-item svg { width: 22px; height: 22px; flex: 0 0 22px; color: var(--blue); }

/* ===== 按钮 ===== */
.btn {
  border-radius: 11px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-size: 15px; padding: 12px 16px; font-family: inherit;
  font-weight: 500; flex: 1;
}
.btn:active { opacity: .82; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0d4d4; }
.btn.block { width: 100%; flex: none; }
.btn:disabled { opacity: .5; }

/* ===== 表单 ===== */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 16px; font-family: inherit;
  background: #fbfbfd; color: var(--text); -webkit-appearance: none; appearance: none;
}
.field select { background-image: none; }
.field textarea { min-height: 64px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blue); background: #fff;
}
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; margin-bottom: 13px; }
.req { color: var(--red); }
.hint { font-size: 12px; color: var(--faint); margin-top: 5px; line-height: 1.6; }

/* ===== 识别进度 ===== */
.progress-card { text-align: center; padding: 22px 4px 12px; }
.spin {
  width: 40px; height: 40px; margin: 0 auto 16px;
  border: 3px solid #e3e8f4; border-top-color: var(--blue); border-radius: 50%;
  animation: rot .8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg) } }
.progress-t { font-size: 15px; font-weight: 500; margin-bottom: 5px; }
.progress-s { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.bar { height: 6px; background: #eaedf4; border-radius: 99px; overflow: hidden; margin: 16px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 99px; transition: width .25s ease; }

/* ===== 识别结果里的缩略图 ===== */
.thumb-row { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; cursor: pointer; }
.thumb-wrap { position: relative; flex: 0 0 82px; display: block; }
.thumb {
  width: 82px; height: 82px; border-radius: 10px; display: block;
  object-fit: cover; background: #eef0f4; border: 1px solid var(--line);
}
.thumb-zoom {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(15,18,26,.62); color: #fff;
  font-size: 11px; line-height: 1.75; text-align: center;
  border-radius: 0 0 9px 9px; letter-spacing: .5px;
}
.thumb-link { color: var(--blue); text-decoration: underline; }
.thumb-info { font-size: 12.5px; color: var(--muted); line-height: 1.6; }

.notice {
  background: #fdf6e6; border: 1px solid #f2e2c0; color: #8a6113;
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.65;
  margin-bottom: 14px;
}
.notice.blue { background: #eaf1ff; border-color: #cfe0ff; color: #21488f; }

/* ===== 吐司 ===== */
.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(96px + var(--safe-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90;
  pointer-events: none; padding: 0 20px;
}
.toast {
  background: rgba(27,29,34,.93); color: #fff; font-size: 13.5px;
  padding: 10px 16px; border-radius: 10px; max-width: 100%;
  animation: fade .18s ease;
}

/* 首次设置页 */
.setup { padding: 26px 22px calc(30px + var(--safe-bottom)); }
.setup h2 { font-size: 19px; font-weight: 500; margin: 0 0 8px; }
.setup p { font-size: 14px; color: var(--muted); line-height: 1.75; margin: 0 0 16px; }
.setup ul { margin: 0 0 20px; padding-left: 20px; font-size: 14px; color: var(--muted); line-height: 1.9; }
.setup li b { color: var(--text); font-weight: 500; }

.row-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.row-line:last-child { border-bottom: 0; }
.row-line .v { color: var(--muted); font-size: 13px; text-align: right; }

/* ===== 卡片上的小相机标记（有截图） ===== */
.card-cam {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; color: var(--blue); background: #eaf1ff;
  padding: 1px 7px; border-radius: 999px;
}
.card-cam svg { width: 11px; height: 11px; }

/* ===== 筛选面板 ===== */
.filter-grid { padding: 2px 20px 6px; }
.filter-grid .fg-t { font-size: 12.5px; color: var(--muted); margin: 12px 0 7px; }
.filter-grid .fg-row { display: flex; flex-wrap: wrap; gap: 8px; }
.fg-chip {
  border: 1px solid var(--line); background: #fbfbfd; color: var(--muted);
  border-radius: 999px; padding: 6px 13px; font-size: 13.5px; font-family: inherit;
}
.fg-chip.on { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 500; }

/* ===== 详情里的截图 ===== */
.detail-shot { position: relative; margin: 0 0 14px; }
.detail-shot img {
  width: 100%; max-height: 240px; object-fit: contain;
  border-radius: 12px; border: 1px solid var(--line); background: #eef0f4;
  display: block;
}
.detail-shot .ds-tip {
  position: absolute; right: 9px; bottom: 9px;
  background: rgba(15,18,26,.66); color: #fff; font-size: 11.5px;
  padding: 4px 10px; border-radius: 999px;
}
.shot-empty {
  border: 1px dashed var(--line); border-radius: 12px; padding: 14px;
  text-align: center; color: var(--faint); font-size: 12.5px; margin-bottom: 14px;
}

/* ===== 看大图 ===== */
.viewer {
  position: fixed; inset: 0; z-index: 95; background: rgba(8,10,14,.96);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none;
}
.viewer img {
  max-width: 100%; max-height: 100%; display: block;
  will-change: transform; user-select: none; -webkit-user-drag: none;
}
.viewer .vw-close {
  position: absolute; top: calc(var(--safe-top) + 12px); right: 14px;
  background: rgba(255,255,255,.16); color: #fff; border: 0;
  border-radius: 999px; padding: 8px 15px; font-size: 14px; font-family: inherit;
}
.viewer .vw-tip {
  position: absolute; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 18px);
  text-align: center; color: rgba(255,255,255,.62); font-size: 12.5px;
  pointer-events: none;
}
.viewer .vw-note {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  text-align: center; color: rgba(255,255,255,.7); font-size: 13.5px; padding: 0 30px;
}

/* ===== 设置里的名单管理 ===== */
.man-list { padding: 2px 20px 10px; display: flex; flex-direction: column; gap: 8px; }
.man-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: #fbfbfd;
}
.man-item .mi-name { flex: 1; font-size: 14.5px; }
.man-item .mi-del {
  border: 0; background: #fdeeee; color: var(--red); border-radius: 8px;
  font-size: 13px; padding: 5px 11px; font-family: inherit;
}
.man-add { display: flex; gap: 8px; padding: 4px 20px 10px; }
.man-add input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 16px; font-family: inherit; background: #fbfbfd; min-width: 0;
}
.man-add input:focus { outline: none; border-color: var(--blue); background: #fff; }
.man-add button { flex: 0 0 auto; }
