:root {
  --green: #07c160;
  --green-dark: #06a552;
  --blue: #1296db;
  --ink: #14201b;
  --ink-2: #4b5a53;
  --ink-3: #8c9a93;
  --line: #e8eeea;
  --bg: #f4f7f5;
  --card: #ffffff;
  --warn: #fff7e6;
  --warn-ink: #9a6b00;
  --danger: #e5484d;
  --radius: 16px;
  --shadow: 0 2px 4px rgba(16, 40, 28, .04), 0 12px 28px rgba(16, 40, 28, .07);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

.page { max-width: 1180px; margin: 0 auto; padding: 20px 18px 80px; }
.footer { text-align: center; color: var(--ink-3); font-size: 12px; padding: 24px 0 8px; }

/* ---------------- 通用控件 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
  white-space: nowrap;
}
.btn:hover { background: #f7faf8; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--green), #14b866); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(7, 193, 96, .28); }
.btn.primary:hover { background: linear-gradient(135deg, var(--green-dark), var(--green)); }
.btn.primary:disabled { background: #cfd8d3; box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.tiny { padding: 5px 12px; font-size: 12px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.lg { padding: 13px 26px; font-size: 16px; border-radius: 14px; }
.btn.block { display: flex; width: 100%; }
.btn.ghost-light { color: #fff; border-color: rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .12); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #e9f8ef; color: var(--green-dark); font-size: 12px; font-weight: 700; }
.tag { font-style: normal; font-size: 11px; color: #b4600b; background: #fff1df; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 1px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.catalog { margin-bottom: 20px; }
.table-scroll { overflow-x: auto; }
.catalog .table { min-width: 520px; }
.login-page { max-width: 420px; padding-top: 12vh; }
.login-page h1 { font-size: 22px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 8px 0; }
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 14px; display: flex; align-items: baseline; gap: 8px; }
.card-title small { color: var(--ink-3); font-weight: 400; font-size: 12px; }

.empty { color: var(--ink-3); font-size: 13px; padding: 14px 0; text-align: center; }
.hint { color: var(--ink-3); font-size: 12px; margin-top: 12px; }
.notice { border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.notice.warn { background: var(--warn); color: var(--warn-ink); }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 16px);
  background: rgba(20, 32, 27, .9); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .22s ease; z-index: 99; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 顶栏 ---------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 40px; height: 40px; display: grid; place-items: center; background: #fff; border-radius: 12px; box-shadow: var(--shadow); font-size: 20px; }
.brand strong { display: block; font-size: 16px; line-height: 1.3; }
.brand small { color: var(--ink-3); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green-dark); background: #e9f8ef; padding: 5px 10px; border-radius: 999px; }
.live i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }

/* ---------------- 分享页 ---------------- */
.share-grid { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 20px; align-items: start; }
.poster { position: relative; overflow: hidden; text-align: center; }
.poster::before {
  content: ""; position: absolute; inset: -40% -30% auto -30%; height: 70%;
  background: radial-gradient(closest-side, rgba(7, 193, 96, .16), transparent); pointer-events: none;
}
.poster-head h1 { font-size: 22px; margin: 10px 0 6px; }
.poster-head p { color: var(--ink-2); font-size: 13px; }
.qr-frame {
  margin: 18px auto 12px; width: min(74vw, 260px); padding: 14px; background: #fff;
  border-radius: 22px; border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(7, 193, 96, .14), inset 0 0 0 6px #f7fcf9;
}
.qr-frame svg { display: block; width: 100%; height: auto; border-radius: 12px; }
.poster-foot .small { color: var(--ink-3); font-size: 12px; }
.poster-foot code { display: inline-block; margin-top: 6px; padding: 3px 8px; background: #f3f6f4; border-radius: 6px; word-break: break-all; color: var(--ink-2); }
.poster-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }

.stack .kpis, .kpis-lg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.kpi { background: #f7faf8; border-radius: 12px; padding: 10px 8px; text-align: center; }
.kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--ink-3); font-size: 11px; }
.kpi.accent { background: linear-gradient(135deg, #e9f8ef, #eef7ff); }
.kpi.accent b { color: var(--green-dark); }

.mini-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .m-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mini-list .bar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--green), #63d99a); min-width: 6px; }
.mini-list .m-right { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-list .trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-more { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--green-dark); font-weight: 600; }
.steps { counter-reset: s; display: grid; gap: 10px; }
.steps li { counter-increment: s; padding-left: 30px; position: relative; font-size: 13px; color: var(--ink-2); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 1px; width: 20px; height: 20px; border-radius: 50%;
  background: #e9f8ef; color: var(--green-dark); font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
.steps b { color: var(--ink); }
.demo-box { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-2); }

/* ---------------- 手机下单页 ---------------- */
body.is-shop { background: #f2f5f3; }
.mobile { max-width: 520px; padding: 0 0 calc(110px + var(--safe-bottom)); }
.shop-hero {
  background: linear-gradient(150deg, #07c160 0%, #17a86a 55%, #1296db 145%);
  color: #fff; padding: 26px 20px 30px; border-radius: 0 0 26px 26px; position: relative; overflow: hidden; text-align: center;
}
.shop-hero::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  background: rgba(255, 255, 255, .12); border-radius: 50%;
}
.shop-hero h1 { font-size: 24px; margin: 8px 0 4px; letter-spacing: .5px; }
.shop-hero p { font-size: 13px; opacity: .9; }
.hero-badge { display: inline-block; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .28); padding: 4px 12px; border-radius: 999px; font-size: 12px; }
.hero-actions { margin-top: 14px; }
.mobile main { padding: 16px 14px 0; }
.mobile .notice { margin: 16px 14px 0; }
.shop-settings { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.shop-settings .card-title { margin-bottom: 4px; }
.section-title { font-weight: 700; font-size: 15px; margin: 18px 4px 10px; display: flex; align-items: baseline; gap: 8px; }
.section-title small { color: var(--ink-3); font-weight: 400; font-size: 12px; }

.name-card { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 16px; }
.name-card label { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.name-card input, .name-card textarea {
  width: 100%; border: 1px solid var(--line); background: #f8faf9; border-radius: 10px;
  padding: 11px 12px; font-size: 15px; outline: none; transition: border-color .2s, background .2s;
}
.name-card input:focus, .name-card textarea:focus { border-color: var(--green); background: #fff; }
.name-card textarea { font: inherit; resize: vertical; }
.product-form { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.product-form label { display: block; margin-bottom: 5px; }
.product-form .wide { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 600px) { .product-form { grid-template-columns: 1fr; } }

.item {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; align-items: center;
  background: #fff; border-radius: 14px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.item.soldout { opacity: .55; }
.thumb { width: 62px; height: 62px; border-radius: 12px; display: grid; place-items: center; font-size: 30px; background: linear-gradient(135deg, #f1faf4, #eef6fd); }
.item-main { min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; }
.item-desc { color: var(--ink-3); font-size: 12px; margin: 2px 0 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.item-meta { display: flex; align-items: baseline; gap: 10px; }
.price { color: #e5453b; font-weight: 700; font-size: 16px; }
.price small { font-weight: 400; font-size: 11px; color: var(--ink-3); }
.stock { font-size: 11px; color: var(--ink-3); }
.stock.low { color: #c2760a; }
.stepper { display: flex; align-items: center; gap: 2px; }
.step {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--green); background: #fff;
  color: var(--green-dark); font-size: 18px; line-height: 1; display: grid; place-items: center; padding: 0;
  transition: transform .1s ease, background .2s;
}
.step:active { transform: scale(.9); }
.step.plus { background: var(--green); color: #fff; border-color: var(--green); }
.step:disabled { opacity: .35; }
.stepper .qty { min-width: 26px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }

.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 520px; margin: 0 auto; padding: 12px 14px calc(12px + var(--safe-bottom));
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px;
  box-shadow: 0 -6px 22px rgba(16, 40, 28, .08);
}
.cart-info { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.cart-count { font-size: 12px; color: var(--ink-3); }
.cart-total { font-size: 13px; color: #e5453b; font-weight: 600; }
.cart-total b { font-size: 20px; }
.cartbar .btn.lg { padding: 12px 26px; }

@media (min-width: 900px) {
  .page.mobile { max-width: 1180px; padding: 28px 18px 110px; }
  .shop-hero { border-radius: 24px; padding: 32px; }
  .shop-hero h1 { font-size: 32px; }
  .mobile main { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px 24px; padding: 24px 0 0; align-items: start; }
  .mobile .buyer-details { grid-column: 1; grid-row: 1 / 3; margin: 0; }
  .mobile .section-title { grid-column: 2; grid-row: 1; margin: 0 4px; }
  #shop-items { grid-column: 2; grid-row: 2; }
  #buyer-orders { grid-column: 1 / -1; }
  .mobile .notice { margin: 24px 0 0; }
  .is-shop .cartbar { max-width: 1144px; width: calc(100% - 36px); border-radius: 16px 16px 0 0; }
}

.sheet-mask { position: fixed; inset: 0; background: rgba(12, 24, 19, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet {
  background: #fff; width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 24px 20px calc(20px + var(--safe-bottom));
  animation: rise .28s cubic-bezier(.2, .8, .3, 1); text-align: center;
}
.check { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px; display: grid; place-items: center; font-size: 28px; color: #fff; background: linear-gradient(135deg, var(--green), #2cc47f); box-shadow: 0 10px 22px rgba(7, 193, 96, .35); }
.sheet h2 { font-size: 19px; }
.sheet-sub { color: var(--ink-3); font-size: 13px; margin: 4px 0 16px; }
.sheet-lines { text-align: left; background: #f7faf8; border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.sheet-lines li { display: flex; justify-content: space-between; padding: 4px 0; }
.sheet-summary { text-align: left; padding: 12px 2px 0; font-size: 13px; color: var(--ink-2); }
.sheet-summary b { color: #e5453b; }
.sheet-actions { display: grid; gap: 8px; margin-top: 18px; }
@keyframes rise { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- 汇总页 ---------------- */
.order-filters { margin-bottom: 16px; }
.date-filters, .status-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-filters { margin-bottom: 12px; }
.date-filters label { font-size: 13px; color: var(--ink-2); }
.date-filters input { padding: 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.status-filters [aria-pressed="true"] { background: var(--green); color: #fff; border-color: var(--green); }
.order-filters .hint { margin-top: 10px; }
.order-day { padding: 10px 2px; font-size: 14px; font-weight: 700; }
.order-day small { color: var(--ink-3); font-weight: 400; margin-left: 8px; }
.order-status { font-size: 12px; white-space: nowrap; color: var(--green-dark); }
.order-status.shipped { color: #1296db; }
.order-status.cancelled { color: var(--danger); }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.kpis-lg { grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpis-lg .kpi { background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 16px; border-radius: 14px; }
.kpis-lg .kpi b { font-size: 26px; }
.kpis-lg .kpi.accent { background: linear-gradient(135deg, #07c160, #1296db); color: #fff; border-color: transparent; }
.kpis-lg .kpi.accent b, .kpis-lg .kpi.accent span { color: #fff; }
.kpis-lg .kpi.accent span { opacity: .85; }

.two-col { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; align-items: start; }
.two-col .card + .card { margin-top: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 6px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--ink-3); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: #fff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .name { display: flex; align-items: center; gap: 8px; }
.table .amt { font-weight: 700; color: #e5453b; }
.table tr.sum-row td { border-bottom: 0; border-top: 2px solid var(--line); padding-top: 12px; }
.muted { color: var(--ink-3); }
.share { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.share .track { flex: 1; height: 6px; background: #eef3f0; border-radius: 3px; overflow: hidden; }
.share .fill { height: 100%; background: linear-gradient(90deg, var(--green), #63d99a); border-radius: 3px; }
.share span { font-size: 11px; color: var(--ink-3); min-width: 34px; text-align: right; }

.order-list { max-height: 520px; overflow: auto; }
.order { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.order.cancelled { opacity: .55; }
.order.cancelled .order-head strong::after { content: "（已取消）"; font-size: 11px; color: var(--danger); font-weight: 400; }
.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.order-head .who { font-size: 14px; }
.order-head .when { color: var(--ink-3); font-size: 11px; }
.order-lines { font-size: 12px; color: var(--ink-2); margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.order-lines span { background: #f5f8f6; border-radius: 6px; padding: 3px 8px; }
.order-lines small { color: var(--ink-3); }
.order-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.order-foot .money { color: #e5453b; font-weight: 700; }
.order-foot .remark { color: var(--ink-3); font-size: 12px; }
.btn-cancel { border: 0; background: none; color: var(--ink-3); font-size: 12px; padding: 2px 6px; text-decoration: underline; }

.picks { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; }
.picks li { background: #f5f8f6; border-radius: 999px; padding: 5px 10px; color: var(--ink-2); }
.picks .who { color: var(--ink); font-weight: 600; }

@media (max-width: 860px) {
  .share-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .kpis-lg { grid-template-columns: repeat(2, 1fr); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .page { padding: 16px 14px 60px; }
  .summary .page { padding: 0; }
}

@media print {
  .topbar-actions, .footer, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ddd; }
}
