:root {
  color-scheme: light;
  --red: #df2e2e;
  --red-dark: #a71919;
  --gold: #9b6b1d;
  --ink: #1e252b;
  --muted: #68727b;
  --line: #e6dfd5;
  --paper: #fffaf2;
  --soft: #f5f1eb;
  --white: #ffffff;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { background: #f4f2ee; color: var(--ink); margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.page-view { min-height: 100vh; }
.login-layout { align-items: center; display: grid; min-height: 100vh; padding: 24px; }
.login-panel { background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 20px 48px rgba(45, 35, 24, .1); display: grid; gap: 16px; margin: 0 auto; max-width: 520px; padding: 34px; width: 100%; }
.login-panel h1, .topbar h1, h2, h3 { margin: 0; }
.login-panel h1 { font-size: clamp(28px, 4vw, 40px); }
.eyebrow { color: var(--red-dark); font-size: 13px; font-weight: 900; letter-spacing: 0; margin: 0; }
.muted { color: var(--muted); line-height: 1.6; margin: 0; }
.stack-form { display: grid; gap: 14px; }
label { color: var(--muted); display: grid; font-size: 14px; font-weight: 800; gap: 7px; }
input, textarea, select { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); min-height: 44px; padding: 9px 11px; width: 100%; }
textarea { min-height: 78px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--red); outline: 2px solid rgba(223, 46, 46, .16); }
.primary, .quiet, .danger { border-radius: 999px; font-weight: 900; min-height: 42px; padding: 0 18px; }
.primary { background: var(--red); border: 0; color: var(--white); }
.primary:hover { background: var(--red-dark); }
.quiet { background: var(--paper); border: 1px solid #e0bf85; color: var(--gold); }
.danger { background: #fff3f3; border: 1px solid #efb4b4; color: var(--red-dark); }
.wide { width: 100%; }
.form-message { min-height: 24px; margin: 0; }
.form-message.error { color: var(--red-dark); }
.form-message.success { color: #0a7b5b; }
.endpoint-config { border-top: 1px solid var(--line); color: var(--muted); padding-top: 12px; }
.endpoint-config summary { cursor: pointer; font-weight: 800; margin-bottom: 12px; }
.endpoint-config .quiet { margin-top: 10px; }

.app-view { min-height: 100vh; }
.topbar { align-items: center; background: var(--white); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 22px clamp(18px, 4vw, 52px); }
.topbar h1 { font-size: 26px; margin-top: 5px; }
.topbar-actions, .form-actions, .inline-form, .two-inputs, .panel-heading, .section-heading, .list-heading { align-items: center; display: flex; gap: 12px; }
.two-inputs > label { flex: 1; min-width: 0; }
.role-badge, .section-note, .status-text { background: var(--paper); border: 1px solid #e0bf85; border-radius: 999px; color: var(--gold); font-size: 13px; font-weight: 900; padding: 7px 12px; }
.workspace { margin: 0 auto; max-width: 1380px; padding: clamp(18px, 4vw, 42px); }
.role-view { display: grid; gap: 18px; }
.section-heading { justify-content: space-between; margin-bottom: 6px; }
.section-heading h2 { font-size: clamp(24px, 3vw, 34px); margin-top: 6px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 16px; padding: 20px; }
.panel-heading { justify-content: space-between; }
.panel-heading h3 { font-size: 20px; }
.inline-form input { flex: 1; }
.empty-state { background: var(--soft); border: 1px dashed var(--line); color: var(--muted); padding: 20px; text-align: center; }
.member-card { background: #fffdf9; border: 1px solid #ecd7b3; border-radius: 6px; display: grid; gap: 14px; grid-template-columns: 1.2fr repeat(3, 1fr); padding: 18px; }
.member-card .member-main { display: grid; gap: 4px; }
.member-card .member-main strong { font-size: 24px; }
.member-card .member-stat { border-left: 1px solid var(--line); display: grid; gap: 5px; padding-left: 14px; }
.member-card .member-stat span { color: var(--muted); font-size: 13px; }
.member-card .member-stat strong { font-size: 22px; }
.staff-actions, .config-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.config-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.config-grid > .panel:last-child { grid-column: 1 / -1; }
.detail-panel { margin-top: 0; }
.detail-list { display: grid; gap: 8px; }
.detail-row { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 12px; }
.detail-row span { color: var(--muted); font-size: 13px; }

.tab-nav { border-bottom: 1px solid var(--line); display: flex; gap: 4px; overflow-x: auto; }
.tab-button { background: transparent; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 900; min-height: 46px; padding: 0 14px; white-space: nowrap; }
.tab-button.active { border-bottom-color: var(--red); color: var(--red-dark); }
.owner-section { display: none; }
.owner-section.active { display: grid; gap: 18px; }
.metrics-grid { display: grid; gap: 14px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; min-height: 120px; padding: 16px; }
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { font-size: 30px; }
.editable-list, .product-list, .benefit-list { display: grid; gap: 9px; }
.list-heading { justify-content: space-between; }
.tier-row { align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 8px; grid-template-columns: 1fr 1fr 1fr auto; padding: 9px; }
.tier-row input { min-height: 38px; }
.tier-heading { align-items: center; color: var(--muted); display: grid; gap: 8px; grid-template-columns: 1fr 1fr 1fr auto; font-size: 13px; padding: 0 9px 4px; }
.tier-heading span:last-child { width: 68px; }
.product-row, .benefit-row { align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; display: grid; gap: 10px; grid-template-columns: 56px 1fr auto; padding: 10px; text-align: left; }
.product-row.selected, .benefit-row.selected { box-shadow: inset 0 0 0 2px rgba(223, 46, 46, .38); }
.product-row button, .benefit-row button { background: transparent; border: 0; color: inherit; padding: 0; text-align: left; }
.product-image { background: linear-gradient(135deg, #c92d2d, #f0c36f); border-radius: 5px; height: 48px; object-fit: cover; width: 48px; }
.product-placeholder { align-items: center; background: #e6d8c0; border-radius: 5px; color: var(--gold); display: flex; font-size: 12px; height: 48px; justify-content: center; width: 48px; }
.product-meta, .benefit-meta { display: grid; gap: 4px; }
.product-meta span, .benefit-meta span { color: var(--muted); font-size: 13px; }
.product-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.product-actions .quiet { min-height: 34px; padding: 0 11px; }
.file-picker { align-items: start; background: var(--paper); border: 1px dashed #d2aa67; border-radius: 6px; padding: 12px; }
.file-picker input { background: transparent; border: 0; padding: 4px 0; }
.file-picker span { color: var(--muted); font-size: 13px; font-weight: 600; }
.image-preview { border: 1px solid var(--line); border-radius: 6px; max-height: 180px; max-width: 100%; object-fit: contain; }
.checkbox-line { align-items: center; display: flex; gap: 8px; }
.checkbox-line input { min-height: auto; width: auto; }
.export-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.date-field { max-width: 260px; }

@media (max-width: 980px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .config-grid, .staff-actions { grid-template-columns: 1fr; }
  .config-grid > .panel:last-child { grid-column: auto; }
}
@media (max-width: 680px) {
  .topbar, .section-heading, .panel-heading { align-items: flex-start; flex-direction: column; }
  .topbar-actions { align-items: center; width: 100%; }
  .topbar-actions .quiet { margin-left: auto; }
  .member-card, .detail-row, .metrics-grid, .export-grid { grid-template-columns: 1fr 1fr; }
  .member-card .member-main { grid-column: 1 / -1; }
  .member-card .member-stat { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; padding-top: 10px; }
  .inline-form, .two-inputs, .form-actions { align-items: stretch; flex-direction: column; }
  .inline-form button, .form-actions button { width: 100%; }
  .login-panel { padding: 24px; }
}

/* ===== 2026-11-07 老板端交互重构：可点指标卡 / 抽屉 / 配置列表 / 报表反馈 ===== */
.panel-heading-actions { align-items: center; display: flex; gap: 10px; }
.hint-chip { background: #fff4e0; border: 1px dashed #e0bf85; border-radius: 999px; color: var(--gold); font-size: 12px; font-weight: 800; padding: 5px 10px; }

.metric-card { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 6px; min-height: 132px; padding: 16px; text-align: left; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease; }
.metric-card:hover { background: #fffdf9; border-color: #e0bf85; box-shadow: 0 12px 28px rgba(45, 35, 24, .1); transform: translateY(-2px); }
.metric-card:active { transform: translateY(0); }
.metric-card:focus-visible { outline: 2px solid rgba(223, 46, 46, .35); outline-offset: 2px; }
.metric-label { color: var(--muted); font-size: 14px; font-weight: 800; }
.metric-value { font-size: 32px; line-height: 1.1; }
.metric-value i { color: var(--muted); font-size: 13px; font-style: normal; font-weight: 800; margin-left: 4px; }
.metric-hint { color: var(--red-dark); font-size: 12px; font-weight: 800; opacity: .55; }
.metric-card:hover .metric-hint { opacity: 1; }

body.drawer-open { overflow: hidden; }
.drawer-overlay { background: rgba(30, 37, 43, .36); inset: 0; position: fixed; z-index: 40; }
.drawer { animation: drawer-in .22s ease-out; background: var(--white); box-shadow: -24px 0 60px rgba(30, 37, 43, .18); display: flex; flex-direction: column; height: 100vh; max-width: min(780px, 96vw); position: fixed; right: 0; top: 0; width: 780px; z-index: 50; }
@keyframes drawer-in { from { opacity: .5; transform: translateX(28px); } to { opacity: 1; transform: none; } }
.drawer-head { align-items: flex-start; border-bottom: 1px solid var(--line); display: flex; gap: 12px; justify-content: space-between; padding: 20px 22px; }
.drawer-head h3 { font-size: 20px; margin-top: 4px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px; }
.drawer-body.loading { opacity: .5; }
.drawer-body .stack-form { gap: 14px; }
.drawer-foot { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 12px; justify-content: space-between; padding: 14px 22px; }

.detail-head, .detail-row { align-items: start; display: grid; gap: 10px; }
.detail-head { background: var(--white); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 900; padding: 8px 10px; position: sticky; top: 0; z-index: 1; }
.detail-row { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; margin-top: 8px; padding: 10px; }
.detail-row strong { font-size: 14px; }
.detail-row em { color: var(--muted); font-size: 12px; font-style: normal; }
.delta-plus { color: #0a7b5b; font-weight: 900; }
.delta-minus { color: var(--red-dark); font-weight: 900; }

.badge { border-radius: 999px; font-size: 12px; font-weight: 900; padding: 3px 9px; white-space: nowrap; }
.badge-draft { background: #fff4e0; border: 1px solid #e8cf9e; color: #9b6b1d; }
.badge-active { background: #eaf7f0; border: 1px solid #b9e0cd; color: #0f7a52; }
.badge-disabled { background: #f1f2f4; border: 1px solid #dde1e6; color: #68727b; }
.badge-muted { background: #f5f1eb; border: 1px solid var(--line); color: #68727b; }

.config-list { display: grid; gap: 10px; }
.config-item { align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 12px; grid-template-columns: auto minmax(0, 1fr) auto; padding: 12px 14px; }
.config-item:hover { background: #fffdf9; border-color: #e0bf85; }
.config-item-main { display: grid; gap: 4px; grid-column: 2; min-width: 0; }
.config-item-title { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.config-item-sub { color: var(--muted); font-size: 13px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.config-item-actions { display: flex; gap: 8px; }
.btn-sm { font-size: 13px; min-height: 34px; padding: 0 12px; }

.status-chip { background: var(--paper); border: 1px solid #e0bf85; border-radius: 999px; color: var(--gold); display: inline-block; font-size: 13px; font-weight: 900; padding: 7px 12px; }
.status-chip-active { background: #eaf7f0; border-color: #b9e0cd; color: #0f7a52; }
.date-inline { align-items: center; color: var(--muted); display: inline-flex; font-size: 13px; font-weight: 800; gap: 8px; }
.date-inline input { background: var(--white); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-size: 13px; min-height: 34px; padding: 0 10px; }
.export-log-wrap { display: grid; gap: 10px; }
.export-log { display: grid; gap: 8px; }
.export-log-row { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; display: grid; font-size: 13px; gap: 10px; grid-template-columns: .9fr .9fr .9fr 1.6fr; padding: 10px 12px; }
.export-file { color: var(--red-dark); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast { background: #1e252b; border-radius: 999px; bottom: 28px; box-shadow: 0 12px 32px rgba(30, 37, 43, .28); color: #fff; font-weight: 800; left: 50%; max-width: min(720px, 92vw); padding: 12px 22px; position: fixed; transform: translateX(-50%); z-index: 60; }
.toast.error { background: #a71919; }

@media (max-width: 980px) {
  .drawer { max-width: 100vw; width: 100%; }
}
@media (max-width: 680px) {
  .config-item { grid-template-columns: auto minmax(0, 1fr); }
  .config-item-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .export-log-row { grid-template-columns: 1fr 1fr; }
  .panel-heading-actions { width: 100%; }
}

/* ===== 2026-11-07 时间段选择：快捷段 + 自定义起止 ===== */
.range-bar { align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 12px 18px; justify-content: space-between; padding: 10px 12px; }
.range-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.range-chip { background: var(--white); border: 1px solid var(--line); border-radius: 999px; color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 800; min-height: 34px; padding: 0 16px; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.range-chip:hover { border-color: #e0bf85; }
.range-chip.active { background: var(--red); border-color: var(--red); color: #fff; }
.range-chip:focus-visible { outline: 2px solid rgba(223, 46, 46, .35); outline-offset: 2px; }
.range-custom { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.range-sep { color: var(--muted); font-size: 13px; font-weight: 800; }

@media (max-width: 680px) {
  .range-bar { align-items: flex-start; flex-direction: column; }
}

/* ===== 2026-11-08 看板分层：累计总览 + 趋势对比 ===== */
.cumulative-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.cumulative-card { align-content: start; background: #fffdf9; border: 1px solid #ecd7b3; border-radius: 8px; display: grid; gap: 8px; min-height: 136px; padding: 16px; }
.cumulative-card .metric-value { font-size: 30px; }
.delta-badge { background: #f5f1eb; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 800; justify-self: start; margin-top: auto; padding: 3px 10px; }
.delta-badge.delta-up { background: #eaf7f0; border-color: #b9e0cd; color: #0f7a52; }

.trend-metric-chips { margin-top: -4px; }
.trend-chart { min-height: 210px; }
.trend-bars { align-items: stretch; display: flex; gap: 6px; height: 230px; }
.trend-col { align-items: center; display: flex; flex: 1; flex-direction: column; gap: 6px; min-width: 0; }
.trend-value { color: var(--muted); font-size: 11px; font-weight: 800; line-height: 1.2; min-height: 14px; }
.trend-bar-wrap { align-items: flex-end; display: flex; flex: 1; justify-content: center; width: 100%; }
.trend-bar { background: var(--red); border-radius: 4px 4px 0 0; max-width: 72px; min-height: 2px; transition: background .15s ease, height .25s ease; width: 62%; }
.trend-bar-empty { background: #e9e1d5; height: 2px !important; }
.trend-col:hover .trend-bar { background: var(--red-dark); }
.trend-label { color: var(--muted); font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trend-col:hover .trend-label { color: var(--red-dark); font-weight: 800; }

@media (max-width: 680px) {
  .trend-bars { gap: 3px; height: 190px; }
  .trend-label { font-size: 10px; }
}

/* ---- P1-⑥ 小票归档 ---- */
.receipt-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.receipt-card { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
.receipt-photo { background: #f4efe7; display: block; min-height: 120px; object-fit: cover; width: 100%; }
.receipt-photo-missing { align-items: center; color: var(--muted); display: flex; font-size: 12px; justify-content: center; min-height: 120px; }
.receipt-card-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; }
.receipt-amount { font-size: 15px; font-weight: 800; }
.receipt-meta { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.receipt-tag.dine_in { background: #efe7db; color: #6b5133; }
.receipt-tag.group_buy { background: #fbe9e0; color: #a5432a; }
.receipt-tag.abnormal { background: #fdeaea; color: #b03030; }

/* ---- P1-① 等级配置行：4 列（等级/倍率/门槛/月度送分），无删除按钮 ---- */
.tier-heading.levels-tier, #levelList .tier-row { grid-template-columns: 1fr 1fr 1fr 1fr; }
.tier-heading.levels-tier span:last-child { width: auto; }

/* ---- P1-④ 平台对账 ---- */
.settlement-upload-grid { align-items: center; display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.settlement-upload-grid select, .settlement-upload-grid input { min-height: 38px; }
.settlement-file { flex: 1; }
#settlementCsvText { border: 1px solid var(--line); border-radius: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 10px; width: 100%; }
.settlement-lists { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settlement-list { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.settlement-list .config-list { gap: 6px; margin-top: 8px; max-height: 320px; overflow-y: auto; }
.settlement-row { background: #fff; border: 1px solid var(--line); border-radius: 6px; display: flex; font-size: 12px; gap: 8px; justify-content: space-between; padding: 8px 10px; }
.settlement-row.warn { background: #fdeaea; border-color: #e8bcbc; }
@media (max-width: 900px) { .settlement-lists { grid-template-columns: 1fr; } }

/* ---- P1-⑤ 风控预警 ---- */
.risk-badge { background: var(--red); border-radius: 10px; color: #fff; font-size: 11px; margin-left: 6px; min-width: 18px; padding: 1px 6px; }
.risk-alert-row { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; display: grid; font-size: 13px; gap: 12px; grid-template-columns: 1.2fr 1.4fr 2fr 1fr 1fr auto; padding: 12px 14px; }
.risk-alert-row.pending { background: #fff7f5; border-color: #ecc5b8; }
.risk-type-chip { border-radius: 10px; display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 10px; }
.risk-type-chip.late_night { background: #efe6fb; color: #6b4fa5; }
.risk-type-chip.same_amount_repeat { background: #fbe9e0; color: #a5432a; }
.risk-type-chip.same_member_repeat { background: #e4f2ea; color: #3d7a52; }
.risk-detail { color: var(--muted); font-size: 12px; }
.risk-actions { display: flex; gap: 8px; }
.risk-actions button { padding: 5px 12px; }

/* ---- P2-③ 复购留存 cohort ---- */
.cohort-table-wrap { overflow-x: auto; }
.cohort-table { border-collapse: collapse; font-size: 13px; min-width: 680px; width: 100%; }
.cohort-table th, .cohort-table td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: right; white-space: nowrap; }
.cohort-table th:first-child, .cohort-table td:first-child { text-align: left; }
.cohort-table thead th { background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 800; }
.cohort-table tbody tr:hover { background: #fffdf9; }
.cohort-cell { border-radius: 6px; display: inline-block; font-weight: 800; min-width: 84px; padding: 4px 9px; text-align: right; }
.cohort-cell.rate-high { background: #fbe9e0; color: #a5432a; }
.cohort-cell.rate-mid { background: #fdf1dc; color: #8a6015; }
.cohort-cell.rate-low { background: var(--soft); color: var(--muted); }
.cohort-cell.rate-pending { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-weight: 400; }
.cohort-cell-sub { display: block; font-size: 11px; font-weight: 400; opacity: .8; }
.cohort-scene-tag { border-radius: 10px; display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 9px; }
.cohort-scene-tag.group_buy { background: #fbe9e0; color: #a5432a; }
.cohort-scene-tag.dine_in { background: #efe7db; color: #6b5133; }
.cohort-empty { color: var(--muted); padding: 18px 4px; }
