* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root { --fs: 17px; --btn-h: 52px; --field-pad: 13px; --card-pad: 14px; }
body.big { --fs: 21px; --btn-h: 60px; --field-pad: 15px; --card-pad: 18px; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f2f5f9; color: #16202c; font-size: var(--fs); line-height: 1.55;
}
.hidden { display: none !important; }
.muted { color: #596678; }
.small { font-size: calc(var(--fs) - 4px); font-weight: 400; }
.err { color: #c0392b; font-size: calc(var(--fs) - 2px); min-height: 22px; }

.screen { height: 100dvh; display: flex; flex-direction: column; }
.login-screen { justify-content: center; align-items: center; padding: 24px; background: linear-gradient(160deg, #185fa5, #0c447c); }
.login-box { width: 100%; max-width: 360px; background: #fff; border-radius: 18px; padding: 32px 24px; text-align: center; }
.brand-mark { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px; background: #185fa5; color: #fff; font-size: 28px; display: flex; align-items: center; justify-content: center; }
.login-box h1 { font-size: 21px; margin: 0 0 4px; }
.login-box p { margin: 0 0 22px; }
.login-box input { margin-bottom: 12px; text-align: center; }
.pwd-wrap { position: relative; }
.pwd-eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: #185fa5; font-size: 15px; cursor: pointer; padding: 8px; }

.topbar {
  height: 54px; flex: none; background: #fff; border-bottom: 1px solid #e4e8ee;
  display: flex; align-items: center; padding: 0 12px; gap: 8px;
  padding-top: env(safe-area-inset-top); height: calc(54px + env(safe-area-inset-top));
}
.topbar strong { font-size: calc(var(--fs) + 1px); flex: 1; }
.topbar-right { color: #596678; font-size: calc(var(--fs) - 3px); }
.icon-btn { border: 0; background: none; font-size: 30px; color: #185fa5; width: 36px; height: 40px; line-height: 1; cursor: pointer; }
main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view { padding: 12px 12px 24px; max-width: 720px; margin: 0 auto; }

input, textarea, select {
  width: 100%; border: 2px solid #cbd4e0; border-radius: 12px; padding: var(--field-pad);
  font-size: var(--fs); font-family: inherit; background: #fff; color: #16202c; outline: none;
}
input:focus, textarea:focus { border-color: #185fa5; }
textarea { resize: vertical; }
label { display: block; font-size: calc(var(--fs) - 1px); font-weight: 500; color: #39465a; margin-bottom: 7px; }
label i { color: #c0392b; font-style: normal; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.group-title { font-size: var(--fs); font-weight: 600; margin: 22px 0 12px; padding-left: 10px; border-left: 4px solid #185fa5; display: flex; align-items: baseline; gap: 8px; }

.btn {
  border: 1px solid #cbd4e0; background: #fff; color: #16202c; border-radius: 12px;
  padding: 12px 18px; font-size: calc(var(--fs) - 1px); font-family: inherit; cursor: pointer; min-height: var(--btn-h); font-weight: 500;
}
.btn.primary { background: #185fa5; border-color: #185fa5; color: #fff; }
.btn.danger { background: #fff; border-color: #e6b3b3; color: #b52d2d; }
.btn.block { width: 100%; }
.btn.big { min-height: calc(var(--btn-h) + 6px); font-size: var(--fs); margin-top: 20px; }
.btn:active { opacity: .75; }
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }
.search-row .btn { flex: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.chip { border: 1px solid #d7dde6; background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.chip.active { background: #185fa5; border-color: #185fa5; color: #fff; }

.card-list { display: grid; gap: 10px; }
.card {
  background: #fff; border: 1px solid #e0e6ee; border-radius: 14px; padding: var(--card-pad);
  display: flex; gap: 14px; cursor: pointer; align-items: center;
  box-shadow: 0 1px 3px rgba(22, 40, 70, .05);
}
.card:active { background: #f4f8fd; }
.thumb { width: 84px; height: 84px; flex: none; border-radius: 10px; background: #eef1f5; object-fit: cover; display: flex; align-items: center; justify-content: center; color: #8d99a9; font-size: 13px; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: calc(var(--fs) + 1px); font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { font-size: calc(var(--fs) - 3px); color: #596678; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; gap: 14px; margin-top: 6px; font-size: calc(var(--fs) - 2px); align-items: center; }
.price { color: #b52d2d; font-weight: 600; font-size: calc(var(--fs) + 1px); }
.stock-tag { color: #217a4c; font-weight: 600; }
.stock-tag.low { color: #c0392b; }
.empty { text-align: center; color: #8793a3; padding: 60px 20px; font-size: calc(var(--fs) - 1px); }
.guide-card { background: #fff8e9; border: 1px solid #f0d9a8; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; font-size: calc(var(--fs) - 1px); line-height: 1.9; }
.guide-card b { color: #8a5a12; font-size: var(--fs); }
.guide-card button { margin-top: 8px; border: 0; background: #b5812f; color: #fff; border-radius: 8px; padding: 8px 18px; font-size: calc(var(--fs) - 2px); cursor: pointer; min-height: 40px; }
.recent-section { margin-bottom: 14px; }
.recent-title { font-size: calc(var(--fs) - 1px); font-weight: 600; color: #39465a; margin: 0 0 8px; }
.recent-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.recent-card { flex: none; width: 126px; background: #fff; border: 1px solid #e0e6ee; border-radius: 12px; padding: 8px; cursor: pointer; box-shadow: 0 1px 3px rgba(22,40,70,.05); }
.recent-card img, .recent-card .no-img { width: 100%; height: 82px; object-fit: cover; border-radius: 8px; background: #eef1f5; display: flex; align-items: center; justify-content: center; color: #8d99a9; font-size: 13px; }
.recent-card .rn { font-size: calc(var(--fs) - 3px); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-card .rp { color: #b52d2d; font-weight: 600; font-size: calc(var(--fs) - 3px); }
.qr-box { text-align: center; padding: 4px 0 10px; }
.qr-box img { width: 190px; height: 190px; image-rendering: pixelated; border: 1px solid #e0e6ee; border-radius: 8px; }
.qr-box p { margin: 8px 0; }

.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.media-item { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #eef1f5; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-item .rm { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 26px; text-align: center; cursor: pointer; }
.upload-btn { display: block; border: 2px dashed #7fa8d0; border-radius: 12px; padding: 18px; text-align: center; color: #185fa5; cursor: pointer; margin-bottom: 10px; background: #f7fbff; font-size: var(--fs); font-weight: 500; min-height: 58px; }
.progress { height: 6px; background: #e4e8ee; border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress div { height: 100%; background: #185fa5; width: 0; transition: width .2s; }

.tabbar { flex: none; display: flex; background: #fff; border-top: 1px solid #e4e8ee; padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; border: 0; background: none; padding: 10px 0 12px; font-size: calc(var(--fs) - 3px); color: #596678; cursor: pointer; }
.tab span { display: block; font-size: 26px; line-height: 1.2; }
.tab.active { color: #185fa5; font-weight: 600; }

.detail-hero { background: #fff; border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.hero-media { width: 100%; aspect-ratio: 4/3; background: #eef1f5; object-fit: contain; }
.hero-thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 8px; }
.hero-thumbs img, .hero-thumbs video { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; cursor: pointer; flex: none; }
.info-card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.info-card h2 { margin: 0 0 10px; font-size: 19px; }
.kv { display: flex; padding: 9px 0; border-bottom: 1px solid #f0f2f5; font-size: calc(var(--fs) - 1px); }
.kv:last-child { border-bottom: 0; }
.kv .k { width: 96px; flex: none; color: #596678; }
.kv .v { flex: 1; word-break: break-all; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stock-summary { display: flex; gap: 10px; margin-bottom: 12px; }
.summary-box { flex: 1; background: #fff; border: 1px solid #e4e8ee; border-radius: 12px; padding: 12px; text-align: center; }
.summary-box b { display: block; font-size: 24px; color: #185fa5; }
.summary-box span { font-size: calc(var(--fs) - 3px); color: #596678; }
.move { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f0f2f5; font-size: calc(var(--fs) - 2px); }
.move .plus { color: #2f7a4f; font-weight: 600; }
.move .minus { color: #c0392b; font-weight: 600; }

.setting-card { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.setting-card h3 { margin: 0 0 6px; font-size: 16px; }
.setting-card p { margin: 0 0 12px; font-size: calc(var(--fs) - 2px); }
.setting-card input { margin-bottom: 8px; font-size: calc(var(--fs) - 2px); }
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: calc(var(--fs) - 2px); }
.switch-row input { width: 22px; height: 22px; flex: none; margin: 0; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(28,36,48,.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 99; max-width: 86%; text-align: center; }
.toast.show { opacity: 1; }
.modal { position: fixed; inset: 0; background: rgba(20,28,40,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-box { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 380px; max-height: 92dvh; overflow-y: auto; }
.modal-box h3 { margin: 0 0 12px; }
.modal-box .btn { margin-top: 10px; }

@media (min-width: 720px) {
  .view { padding: 20px; }
  .media-grid { grid-template-columns: repeat(4, 1fr); }
}
