* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f1f5f9; color: #1e293b; font-size: 15px; }
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; background: #f1f5f9; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: #fff; position: sticky; top: 0; z-index: 10; border-bottom: 1px solid #eef2f7; }
.logo { font-size: 18px; font-weight: 700; }
.env { font-size: 11px; color: #94a3b8; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view { padding: 14px; }

.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { flex: 1 1 45%; background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.stat .lbl { font-size: 12px; color: #64748b; }
.stat .val { font-size: 18px; font-weight: 700; margin-top: 4px; }
.stat .val.profit { color: #10b981; }

.entry { display: flex; gap: 12px; margin: 16px 0 10px; }
.entry-btn { flex: 1; text-align: center; padding: 26px 0; border-radius: 14px; color: #fff; font-size: 16px; font-weight: 600; text-decoration: none; }
.entry-btn.in { background: linear-gradient(135deg,#4f46e5,#6366f1); }
.entry-btn.out { background: linear-gradient(135deg,#f97316,#fb923c); }

.sub-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.sub { flex: 1 1 30%; text-align: center; padding: 12px; background: #fff; border-radius: 10px; color: #475569; font-size: 13px; text-decoration: none; }

.search { margin: 12px 0; }
.search input { width: 100%; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; font-size: 14px; outline: none; }
.search input:focus { border-color: #6366f1; }

.list { margin-top: 6px; }
.item { background: #fff; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; cursor: pointer; }
.item .name { font-size: 15px; font-weight: 600; }
.prices { display: flex; gap: 8px; margin-top: 6px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 12px; }
.tag.in { background: #eef2ff; color: #4f46e5; }
.tag.out { background: #fff7ed; color: #f97316; }
.stock { font-size: 12px; color: #64748b; margin-top: 6px; }
.empty { text-align: center; color: #94a3b8; padding: 40px 0; font-size: 13px; }

.head { text-align: center; padding: 18px; border-radius: 12px; color: #fff; font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.head.in { background: linear-gradient(135deg,#4f46e5,#6366f1); }
.head.out { background: linear-gradient(135deg,#f97316,#fb923c); }

.photo { background: #fff; border-radius: 12px; padding: 10px; margin-bottom: 12px; cursor: pointer; }
.photo-img { width: 100%; height: 200px; object-fit: cover; border-radius: 8px; display: block; }
.photo-ph { text-align: center; color: #94a3b8; padding: 70px 0; font-size: 13px; }

.sel { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.sel-label, .qty-label { font-size: 13px; color: #64748b; margin-bottom: 8px; }
.sel-search { width: 100%; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; margin-bottom: 8px; }
.cand-item { padding: 12px 10px; margin-bottom: 6px; border: 1px solid #eef2f7; border-radius: 8px; cursor: pointer; background: #fff; }
.cand-item.on { border-color: #4f46e5; background: #eef2ff; }
.cand-name { font-size: 14px; font-weight: 600; }
.cand-flag { font-size: 11px; color: #4f46e5; font-weight: 500; margin-left: 6px; }
.cand-price { font-size: 11px; color: #94a3b8; margin-top: 3px; }
.cand-empty { text-align: center; color: #64748b; padding: 14px; font-size: 13px; }
.link { color: #4f46e5; text-decoration: none; }
.seled { padding: 12px; background: #f8fafc; border-radius: 8px; border: 1px dashed #cbd5e1; }
.seled-empty { font-size: 13px; color: #94a3b8; }
.seled-name { font-size: 15px; font-weight: 600; }
.seled-name .link { float: right; font-size: 12px; font-weight: 400; }
.seled-info { font-size: 12px; color: #64748b; margin-top: 4px; }
.sel-label-gap { margin-top: 16px; }
.summary-empty { text-align: center; color: #94a3b8; font-size: 13px; padding: 4px 0; }
.summary .row.warn { color: #dc2626; font-weight: 600; font-size: 13px; }

.qty { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.qty-ctrl { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.minus, .plus { width: 44px; height: 44px; line-height: 44px; text-align: center; background: #eef2ff; color: #4f46e5; border: none; border-radius: 10px; font-size: 22px; cursor: pointer; }
.qty-input { flex: 1; text-align: center; font-size: 20px; font-weight: 700; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px; outline: none; }

.summary { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.summary .row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 14px; color: #475569; }
.summary .row .profit { color: #10b981; font-weight: 700; }

.submit { width: 100%; color: #fff; border: none; border-radius: 12px; font-size: 16px; font-weight: 600; padding: 14px 0; cursor: pointer; background: #4f46e5; box-shadow: 0 4px 12px rgba(79,70,229,.22); }
.submit.in { background: #4f46e5; }
.submit.out { background: #f97316; box-shadow: 0 4px 12px rgba(249,115,22,.22); }
.submit:active { opacity: .88; }
.submit:disabled { background: #cbd5e1; box-shadow: none; cursor: not-allowed; opacity: 1; }

.form { background: #fff; border-radius: 12px; padding: 4px 16px; }
.fld { display: flex; align-items: center; padding: 14px 0; border-bottom: 1px solid #f1f5f9; }
.fld .lbl { width: 90px; font-size: 14px; color: #475569; }
.fld input { flex: 1; font-size: 14px; border: none; outline: none; background: transparent; }
.fld .hint { font-size: 11px; color: #94a3b8; margin-left: 8px; }

.filters { display: flex; gap: 10px; margin: 12px 0; }
.f { flex: 1; text-align: center; padding: 10px; background: #fff; border-radius: 10px; color: #475569; font-size: 13px; text-decoration: none; }
.f.on { background: #4f46e5; color: #fff; }

.tx { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.tx-head { display: flex; justify-content: space-between; align-items: center; }
.tx-name { font-size: 15px; font-weight: 600; }
.tx-type { font-size: 11px; padding: 3px 10px; border-radius: 12px; }
.tx-type.in { background: #eef2ff; color: #4f46e5; }
.tx-type.out { background: #fff7ed; color: #f97316; }
.tx-body { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 12px; color: #64748b; }
.tx-body .profit { color: #10b981; font-weight: 700; }
.tx-time { font-size: 11px; color: #94a3b8; margin-top: 8px; }

.toast { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); background: rgba(0,0,0,.82); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99; max-width: 80%; text-align: center; }
.toast.show { opacity: 1; }

.analyze-btn { width: 100%; margin: 0 0 12px; padding: 13px 0; border: none; border-radius: 12px; background: linear-gradient(135deg,#0ea5e9,#38bdf8); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; }
.analyze-result { margin-bottom: 12px; }
.analyze-tip { font-size: 12px; color: #0ea5e9; margin: 4px 2px 8px; }
.analyze-result .cand-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.analyze-result .cand-name { flex: 1 1 100%; font-size: 14px; font-weight: 600; }
.analyze-result .cand-price { flex: 1; font-size: 11px; color: #94a3b8; }
.analyze-result .use-item { border: none; background: #4f46e5; color: #fff; border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer; }

/* 拍照识别记录（原图 + 结构化结果均来自数据库） */
.rec-block { margin-top: 18px; }
.rec-title { font-size: 14px; font-weight: 600; color: #475569; margin: 0 2px 10px; }
.rec-title .link { float: right; font-size: 12px; font-weight: 400; }
.rec-tip { background: #fff; border-radius: 10px; padding: 12px 14px; font-size: 12px; color: #64748b; line-height: 1.6; margin-bottom: 12px; }
.rec-card { display: flex; gap: 12px; background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.rec-thumb { width: 72px; height: 72px; flex: 0 0 72px; object-fit: cover; border-radius: 8px; background: #f1f5f9; }
.rec-thumb-empty { display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 11px; }
.rec-body { flex: 1; min-width: 0; }
.rec-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 11px; color: #94a3b8; }
.rec-id { font-weight: 700; color: #475569; }
.rec-status { padding: 2px 8px; border-radius: 10px; background: #eef2ff; color: #4f46e5; }
.rec-status.ok { background: #ecfdf5; color: #059669; }
.rec-status.error { background: #fef2f2; color: #dc2626; }
.rec-status.not_configured { background: #fffbeb; color: #b45309; }
.rec-status.empty { background: #f1f5f9; color: #64748b; }
.rec-msg { font-size: 12px; color: #64748b; margin-top: 6px; line-height: 1.5; }
.rec-items { margin-top: 8px; }
.rec-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid #f1f5f9; font-size: 12px; color: #475569; }
.rec-use { flex: 0 0 auto; border: none; background: #4f46e5; color: #fff; border-radius: 6px; padding: 5px 10px; font-size: 11px; cursor: pointer; }
