:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --line: #e2e5ea;
  --text: #1f2430;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warn: #f59e0b;
  --ok: #0f766e;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn.ghost { background: var(--surface-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.block { width: 100%; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea, input.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 11px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field-error, .form-error { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: -6px; margin-bottom: 6px; }
.form-error { min-height: 20px; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.login-card { max-width: 360px; margin: 12vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.login-logo { font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 22px; color: var(--primary); }
.btn.wechat { background: #07c160; border-color: #07c160; color: #fff; font-size: 16px; font-weight: 600; padding: 12px 14px; }
.btn.wechat:hover { background: #06ad56; }
.login-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0 14px; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.wechat-hint { text-align: center; color: var(--muted); font-size: 12px; margin: -6px 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.hidden { display: none !important; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.tag.ok { background: #e7f6f2; color: var(--ok); }
.tag.warn { background: #fff4e5; color: #a15c00; }
.tag.info { background: #e8f0fe; color: var(--primary); }

/* client shell */
.client-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--surface); position: relative; padding-bottom: 68px; box-shadow: 0 0 0 1px var(--line); }
.client-header { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 14px; display: flex; align-items: center; gap: 10px; min-height: 52px; }
.client-header .title { font-size: 16px; font-weight: 600; flex: 1; }
.client-body { padding: 14px; }
.client-tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 480px; max-width: 100%; height: 62px; background: var(--surface); border-top: 1px solid var(--line); display: flex; z-index: 20; }
.client-tabs button { flex: 1; border: 0; background: none; color: var(--muted); font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
.client-tabs button.active { color: var(--primary); }
.tab-dot { width: 20px; height: 20px; border: 2px solid currentColor; border-radius: 6px; }
.drag-handle { cursor: grab; text-align: center; color: var(--muted); font-size: 16px; user-select: none; -webkit-user-select: none; }
.prod-row.dragging { opacity: .4; }
.prod-row.drag-over td { border-top: 2px solid var(--primary); }
.prod-row.marked-del td { background: #fff1f2; }
.prod-row.marked-del:hover td { background: #ffe4e6; }
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cat-card { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 15px 12px; cursor: pointer; font-size: 14px; }
.cat-card:hover { border-color: var(--primary); color: var(--primary); }
/* 公司简介入口：细长长方形条，点击弹出完整简介 */
.company-intro-bar { display: flex; align-items: center; gap: 8px; height: 34px; margin-bottom: 12px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer; font-size: 13px; color: var(--text); }
.company-intro-bar:active { background: #e9edf3; }
.company-intro-bar .ci-icon { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-style: normal; flex: none; }
.company-intro-bar .ci-label { flex: 1; }
.company-intro-bar .ci-arrow { color: var(--muted); font-size: 18px; line-height: 1; }
.company-intro-modal .ci-body { font-size: 14px; line-height: 1.75; color: var(--text); white-space: normal; margin-bottom: 16px; }
.company-intro-modal .ci-contact { font-size: 13px; color: var(--muted); line-height: 1.9; padding-top: 12px; border-top: 1px solid var(--line); margin-bottom: 16px; }
/* 公司简介图片卡片：与首页大类同款样式 */
.company-intro-card { position: relative; height: 108px; margin-bottom: 12px; border-radius: 12px; overflow: hidden; cursor: pointer; border: 1px solid var(--line); background: var(--surface-2); }
.company-intro-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.company-intro-card .ci-noimg { width: 100%; height: 100%; background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.company-intro-card .overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 10px 12px; color: #fff; background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.68) 100%); }
.company-intro-card .m-title { font-size: 15px; font-weight: 700; }
.company-intro-card .m-sub { font-size: 11px; opacity: .88; margin-top: 2px; }
.company-intro-card .ci-arrow { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: #fff; font-size: 24px; line-height: 1; text-shadow: 0 1px 4px rgba(0,0,0,.45); }
.company-intro-modal .ci-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.company-intro-modal .ci-gallery img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-2); }
/* 后台公司简介图片编辑区 */
.intro-image-list { display: flex; flex-wrap: wrap; gap: 10px; min-height: 40px; }
.intro-img-item { position: relative; width: 92px; height: 92px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.intro-img-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.intro-img-del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(220,38,38,.92); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; padding: 0; }
.home-modules { margin-bottom: 18px; }
.home-module-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.home-module-card, .home-module-banner { position: relative; border-radius: 12px; overflow: hidden; cursor: pointer; border: 1px solid var(--line); background: var(--surface-2); }
.home-module-card { height: 108px; }
.home-module-banner { height: 132px; margin-bottom: 10px; }
.home-module-card img, .home-module-banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.home-module-card .overlay, .home-module-banner .overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 10px 12px; color: #fff; background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.68) 100%); }
.home-module-card .m-title { font-size: 14px; font-weight: 600; }
.home-module-card .m-sub, .home-module-banner .m-sub { font-size: 11px; opacity: .88; margin-top: 2px; }
.home-module-banner .m-title { font-size: 18px; font-weight: 700; }
.module-preview-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.module-preview-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); }
.module-preview-item.off { opacity: .55; }
.module-preview-label { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.module-preview-card { cursor: default; }
.module-preview-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag.pos-tag { background: var(--primary); color: #fff; font-weight: 600; }
.pos-set { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.pos-set select { width: auto; padding: 4px 6px; margin: 0; }
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.product-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); cursor: pointer; }
.product-card img { width: 100%; height: 130px; object-fit: contain; background: var(--surface-2); display: block; }
.product-card .info { padding: 9px; }
.product-card .name { font-size: 13px; font-weight: 500; min-height: 38px; }
.product-card .price { color: var(--danger); font-weight: 600; margin-top: 6px; }
.product-card .meta { color: var(--muted); font-size: 11px; margin-top: 3px; }
.thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: contain; background: var(--surface-2); }
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input { flex: 1; border: 1px solid var(--line); border-radius: 20px; padding: 9px 13px; background: var(--surface); outline: none; }
.cart-item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.cart-item .grow { flex: 1; min-width: 0; }
.qty-control { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty-control button { width: 30px; height: 30px; border: 0; background: var(--surface-2); cursor: pointer; }
.qty-control span { min-width: 30px; text-align: center; }
.order-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--surface); }
.order-card .head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.detail-img { width: 100%; max-height: 340px; object-fit: contain; border-radius: 10px; background: var(--surface-2); }
.spec-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* admin shell */
.admin-shell { min-height: 100vh; display: flex; }
.admin-side { width: 210px; background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; flex-shrink: 0; }
.admin-side .brand { font-size: 17px; font-weight: 600; color: var(--primary); padding: 0 10px 16px; }
.admin-side nav button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; cursor: pointer; color: var(--text); margin-bottom: 3px; }
.admin-side nav button:hover { background: var(--surface-2); }
.admin-side nav button.active { background: #e8f0fe; color: var(--primary); }
.admin-main { flex: 1; min-width: 0; padding: 20px 24px; }
.admin-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.admin-top h1 { margin: 0; font-size: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .num { font-size: 26px; font-weight: 600; color: var(--primary); }
.stat .label { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; background: var(--surface-2); }
tr:hover td { background: #fafbfc; }
.tree-row { cursor: grab; }
.tree-row.dragging { opacity: .4; }
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; padding: 20px; }
.modal h2 { margin: 0 0 16px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 12px; }
.dropzone { border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 34px; text-align: center; color: var(--muted); cursor: pointer; background: var(--surface); }
.dropzone.over { border-color: var(--primary); background: #f5f8ff; color: var(--primary); }
.error-row td { background: #fff7ed !important; color: #9a3412; }
.banner { padding: 11px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.banner.info { background: #e8f0fe; color: var(--primary); }
.banner.warn { background: #fff4e5; color: #a15c00; }
.banner.error { background: #fef2f2; color: var(--danger); }
.banner.ok { background: #e7f6f2; color: var(--ok); }
.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 200; font-size: 13px; }
/* ===== 数据分析 ===== */
.analytics-toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 16px; }
.analytics-toolbar .fld { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.analytics-toolbar .fld label { font-size: 12px; color: var(--muted); }
.analytics-toolbar select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 11px; outline: none; }
.analytics-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.analytics-kpis .kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.analytics-kpis .kpi .num { font-size: 24px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.analytics-kpis .kpi .num.money { color: var(--danger); }
.analytics-kpis .kpi .num.up { color: #d4380d; }
.analytics-kpis .kpi .num.down { color: #389e0d; }
.analytics-kpis .kpi .label { color: var(--muted); font-size: 12px; margin-top: 6px; }
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.analytics-grid .card { margin-bottom: 16px; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 360px; }
.analytics-note { color: var(--muted); font-size: 12px; margin-top: 8px; }
@media (max-width: 980px) { .analytics-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .admin-side { width: 100%; padding: 10px; }
  .admin-shell { flex-direction: column; }
  .admin-side nav { display: flex; overflow-x: auto; gap: 4px; }
  .admin-side nav button { white-space: nowrap; width: auto; }
  .admin-main { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
}
