:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e8eaed;
  --line-strong: #d8dbe0;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --brand: #e22e2e;
  --brand-soft: #fdecec;
  --blue: #2563eb;
  --green: #12a150;
  --orange: #ed7b2f;
  --purple: #7c5cff;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 600; }
body { -webkit-tap-highlight-color: transparent; }
/* 弹窗 / 移动菜单打开时锁定背景滚动（由 app.js 切换） */
body.modal-open { overflow: hidden; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); }
/* 移动端去掉点击延迟与双击缩放干扰 */
.btn, button, a, select, .shop-name { touch-action: manipulation; }

/* ---------- login ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, #fff 0%, #fff4f4 100%);
  display: grid; place-items: center; padding: 20px;
}
.login-screen[hidden] { display: none !important; }
.login-box {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  width: 100%; max-width: 380px; padding: 32px 28px; box-shadow: 0 16px 48px rgba(0,0,0,.08);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .logo {
  width: 56px; height: 56px; border-radius: 14px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 26px;
  margin: 0 auto 14px;
}
.login-brand h1 { font-size: 20px; margin-bottom: 4px; }
.login-brand p { margin: 0; font-size: 13px; color: var(--text-3); }
.login-form .field { margin-bottom: 16px; }
.login-form label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login-form input {
  width: 100%; height: 46px; border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 0 14px; font-size: 15px; outline: none; background: #fff; color: var(--text);
}
.login-form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-tip { text-align: center; font-size: 12px; color: var(--text-3); margin: 14px 0 0; }

/* ---------- topbar ---------- */
.topbar {
  height: 60px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 15px; font-weight: 600; margin: 0; }
.actions { display: flex; gap: 8px; }
.shop-bar { display: flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 14px; }
.shop-bar label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.shop-bar select { height: 34px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; padding: 0 8px; font-size: 13px; min-width: 120px; max-width: 180px; }
.shop-bar .btn { padding: 0 10px; }
.mobile-menu-btn { display: none; }

/* ---------- 布局：侧边栏 + 主区 ---------- */
#app { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
#app[hidden] { display: none !important; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; height: 100dvh;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
}
.sidebar-mask { display: none; }
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.sb-logo {
  width: 34px; height: 34px; border-radius: 8px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 16px; flex: none;
}
.sb-brand-text h1 { font-size: 15px; }
.sb-brand-text .sub { font-size: 12px; color: var(--text-3); }
.sb-greeting { padding: 10px 8px 12px; }
.sb-greeting-hi { font-size: 14px; font-weight: 600; color: var(--text); }
.sb-greeting-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-item {
  display: flex; align-items: center; width: 100%; height: 40px; padding: 0 12px;
  border: 0; border-radius: 8px; background: none; text-align: left;
  font-size: 14px; color: var(--text-2); cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s;
}
.sb-item:hover { background: #f2f3f5; }
.sb-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sb-actions { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.sb-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.sb-foot .sb-item { color: var(--text-3); }

/* ---------- buttons ---------- */
.btn {
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: .15s;
}
.btn:hover { border-color: #b9bec6; background: #fafbfc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #cf2525; }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.btn.ghost:hover { background: #f2f3f5; }
.btn.danger { color: var(--brand); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

main { padding: 18px 20px 40px; max-width: 1280px; margin: 0 auto; width: 100%; }

/* 页面切换入场动画（hidden 移除重新显示时自动重放） */
.page { animation: pageIn .28s ease both; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* headline */
.headline {
  background: linear-gradient(135deg, #fff 0%, #fff4f4 100%);
  border: 1px solid #f3dada; border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px; font-size: 15px; color: var(--text-2);
}
.headline b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.headline .hl-profit { color: var(--brand); font-weight: 700; }
.headline .hl-up { color: var(--green); }

/* kpi */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px;
  transition: box-shadow .2s, transform .2s, border-color .2s;
}
.kpi:hover { box-shadow: 0 4px 16px rgba(0,0,0,.06); transform: translateY(-1px); border-color: var(--line-strong); }
.kpi .k-label { font-size: 12px; color: var(--text-3); margin-bottom: 5px; }
.kpi .k-value { font-size: 20px; font-weight: 600; letter-spacing: -.2px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.kpi.k-main { border-color: #f0c9c9; background: #fffafa; }
.kpi.k-main .k-value { color: var(--brand); }
.kpi .k-value.neg { color: var(--green); }
.kpi .k-value.pos { color: var(--brand); }

/* 资金流向 */
.flow-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.flow-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.flow-head span:first-child { font-size: 13px; color: var(--text-2); font-weight: 500; }
.flow-tip { font-size: 11px; color: var(--text-3); }
.flow-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: #f0f1f3; }
.flow-seg { position: relative; transition: width .4s; }
.flow-seg + .flow-seg { box-shadow: inset 1px 0 0 rgba(255,255,255,.6); }
.flow-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }
.flow-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.flow-dot { width: 9px; height: 9px; border-radius: 3px; }
.flow-item b { color: var(--text); font-variant-numeric: tabular-nums; }

/* chart */
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 8px; margin-bottom: 14px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.chart-head span { font-size: 13px; color: var(--text-2); font-weight: 500; }
.chart-head select { height: 28px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; padding: 0 6px; font-size: 12px; }
.chart { height: 160px; }

/* panel */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.date-range { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.date-range input {
  height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 8px;
  font-size: 12px; outline: none; background: #fff; color: var(--text); font-family: inherit;
}
.toolbar input[type=search] {
  height: 34px; width: 180px; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 0 12px; font-size: 13px; outline: none; background: #fff;
}
.toolbar input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.spacer { flex: 1; }
.total { font-size: 12px; color: var(--text-3); }
.toolbar select { height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; padding: 0 8px; font-size: 13px; }

/* table */
.table-wrap { overflow: auto; max-height: 60vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 5; background: #fafbfc; text-align: left;
  padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text-2);
  font-weight: 500; white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:hover { background: #f2f3f5; }
thead th .arw { color: var(--text-3); font-size: 10px; margin-left: 2px; }
thead th.act .arw { color: var(--brand); }
thead th.no-sort { cursor: default; }
thead th.no-sort:hover { background: #fafbfc; }
td { padding: 9px 12px; border-bottom: 1px solid #f0f1f3; white-space: nowrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.col-date { font-variant-numeric: tabular-nums; color: var(--text-2); }
td.calc { color: var(--text-2); background: #fcfcfd; }
td.pos { color: var(--brand); }
td.neg { color: var(--green); }
td.col-id { color: var(--text-3); }
/* 店铺徽标：仅手机卡片使用，桌面表格里隐藏 */
.card-shop { display: none; }
tbody tr:hover { background: #fafbfc; }
tbody tr.sel { background: var(--brand-soft); }
tbody tr.empty-row td { color: var(--text-3); }
.ops a { color: var(--blue); cursor: pointer; margin-right: 10px; font-size: 13px; }
.ops a.del { color: var(--brand); }
.empty { padding: 60px 0; text-align: center; color: var(--text-3); }
.empty b { display: block; color: var(--text-2); font-weight: 500; margin-bottom: 6px; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 10px 14px; }
.pager button {
  min-width: 30px; height: 30px; border: 1px solid var(--line-strong); background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-2);
}
.pager button:hover:not(:disabled) { border-color: #b9bec6; }
.pager button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

.foot-note { font-size: 11px; color: var(--text-3); text-align: center; margin-top: 14px; }

/* ---------- 店铺数据页 ---------- */
.shops-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 14px; }
.shop-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  animation: pageIn .3s ease both; transition: box-shadow .2s, border-color .2s;
}
.shop-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.06); border-color: var(--line-strong); }
.shop-card:nth-child(2) { animation-delay: .05s; }
.shop-card:nth-child(3) { animation-delay: .1s; }
.shop-card:nth-child(4) { animation-delay: .15s; }
.shop-card-name { font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.shop-card-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.shop-kpi label { display: block; font-size: 11px; color: var(--text-3); margin-bottom: 1px; }
.shop-kpi b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.shop-kpi b.pos { color: var(--brand); }
.shop-kpi b.neg { color: var(--green); }
.shops-grid .tip { grid-column: 1 / -1; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(20,22,26,.4); display: grid; place-items: center; z-index: 120; padding: 20px; animation: maskIn .2s ease both; }
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
.modal[hidden] { display: none !important; }
.modal-box {
  background: #fff; border-radius: 12px; width: 560px; max-width: 100%; max-height: 86vh;
  display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.18);
  animation: modalIn .24s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 15px; }
.modal-head .x { border: 0; background: none; font-size: 22px; color: var(--text-3); cursor: pointer; line-height: 1; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-tip { font-size: 12px; color: var(--text-3); margin: 0 0 12px; }
/* 记一笔：分组表单 */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group-title {
  font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: .5px;
  display: flex; align-items: center; gap: 8px;
}
.form-group-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form .field { display: flex; flex-direction: column; gap: 5px; }
.form .field.wide { grid-column: 1 / -1; }
.form label { font-size: 12px; color: var(--text-2); }
.form input {
  height: 40px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 12px;
  font-size: 14px; outline: none; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.calc-preview {
  margin-top: 14px; background: #fafbfc; border: 1px dashed var(--line-strong);
  border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--text-2);
  display: flex; gap: 24px; flex-wrap: wrap;
}
.calc-preview b { font-variant-numeric: tabular-nums; }
.calc-preview .cp-loss b { color: var(--orange); }
.calc-preview .cp-net b { color: var(--blue); }
.calc-preview .cp-profit b { color: var(--brand); }

.drop {
  border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 30px; text-align: center;
  color: var(--text-2); cursor: pointer; background: #fafbfc;
}
.drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.drop p { margin: 0; font-size: 13px; }
.tip { font-size: 12px; color: var(--text-3); margin: 10px 0 0; }

.modal-box .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.modal-box .field label { font-size: 12px; color: var(--text-2); }
.modal-box .field input, .modal-box .field select { height: 34px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; font-size: 13px; outline: none; background: #fff; }
.modal-box .field input:focus, .modal-box .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* settings tabs */
.settings-tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.tab-btn {
  height: 32px; padding: 0 14px; border-radius: 6px; border: 0; background: transparent;
  color: var(--text-2); font-size: 13px; cursor: pointer;
}
.tab-btn.on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

.shop-list { display: flex; flex-direction: column; gap: 8px; }
.shop-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc;
}
.shop-name { font-weight: 500; color: var(--text); cursor: pointer; }
.shop-name:hover { color: var(--brand); }
.shop-count { font-size: 12px; color: var(--text-3); }

.user-form { display: grid; grid-template-columns: 1.2fr 1fr .8fr auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.user-form .field { margin-bottom: 0; }
.user-form .btn { height: 34px; }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc;
}
.user-name { font-weight: 500; margin-right: 8px; }
.user-role { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--line); color: var(--text-2); }
.user-role.admin { background: var(--brand-soft); color: var(--brand); }
.user-actions { display: flex; gap: 6px; }
.user-actions .btn { padding: 0 10px; height: 28px; font-size: 12px; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 130;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.err { background: var(--brand); }

svg.spark { width: 100%; height: 100%; display: block; overflow: visible; }
.svg-label { font-size: 10px; fill: var(--text-3); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .user-form { grid-template-columns: 1fr 1fr; }
  .user-form .btn { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  /* 侧边栏 → 左侧滑出抽屉 */
  #app { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; align-self: auto;
    width: 264px; height: auto;
    transform: translateX(-100%); transition: transform .25s ease;
    z-index: 90; border-right: 0; box-shadow: 0 0 24px rgba(0,0,0,.12);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    display: block; position: fixed; inset: 0; z-index: 85;
    background: rgba(20,22,26,.42); opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  .sidebar-mask.show { opacity: 1; pointer-events: auto; }
  .sb-item { height: 44px; }

  /* 顶栏：单行紧凑布局 + 刘海屏安全区 */
  .topbar {
    height: auto; flex-wrap: nowrap; gap: 8px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  }
  .page-title { font-size: 14px; }
  /* 主操作「记一笔」带文字常驻顶栏 */
  .actions { display: flex; flex: none; gap: 8px; }
  .actions .btn { display: none; }
  .actions #btnAdd { display: inline-flex; height: 38px; padding: 0 16px; font-weight: 500; }
  .actions #btnAdd .btn-label { display: inline; }
  .btn-label { display: none; }
  .mobile-menu-btn {
    display: inline-flex; width: 40px; height: 38px; flex: none;
    align-items: center; justify-content: center;
    border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
    font-size: 18px; cursor: pointer;
  }
  .shop-bar { flex: 1; min-width: 0; margin: 0; }
  .shop-bar label { display: none; }
  .shop-bar select { flex: 1; min-width: 0; max-width: none; height: 36px; font-size: 14px; }
  /* 「添加店铺」放回顶栏右侧，避免菜单过长 */
  .shop-bar #btnAddShop { display: inline-flex; }

  main { padding: 12px 12px calc(30px + env(safe-area-inset-bottom, 0px)); }
  .headline { font-size: 14px; padding: 14px; }

  /* KPI 保持两列，避免单列长滚动 */
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi .k-value { font-size: 17px; }
  .kpi .k-sub { font-size: 10px; }

  /* 工具栏：输入 16px 防止 iOS 聚焦自动放大页面 */
  .toolbar { padding: 10px 12px; gap: 8px; }
  .toolbar input, .toolbar select { font-size: 16px; height: 38px; }
  /* 覆盖基础样式的更高优先级选择器，确保搜索框也是 16px（防 iOS 聚焦放大） */
  .toolbar input[type=search] { width: 100%; order: 3; height: 38px; font-size: 16px; }
  .date-range { width: 100%; order: 2; }
  .date-range input { flex: 1; min-width: 0; }
  .toolbar select { order: 4; }
  #btnBatchDel { order: 5; }
  .total { order: 1; width: 100%; margin-bottom: 4px; }
  .toolbar .spacer { display: none; }

  /* 表格 → 详情卡片：日期做标题、字段两列铺开，卡片高度减半 */
  .table-wrap { max-height: none; overflow: visible; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px;
    margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px;
    background: #fff; padding: 10px 10px 2px; position: relative;
  }
  tbody tr.sel { background: var(--brand-soft); border-color: #f0c9c9; }
  tbody td {
    display: flex; flex-direction: column; min-width: 0;
    padding: 2px 0 3px; border: 0; white-space: normal; line-height: 1.4;
  }
  tbody td::before { content: attr(data-label); font-size: 11px; color: var(--text-3); }
  tbody td.num { text-align: left; }
  tbody td.calc { background: transparent; }
  /* 隐藏 ID 与店铺列（店铺已在卡片标题上显示徽标） */
  tbody td.col-id, tbody td.col-shop { display: none; }
  /* 日期 = 卡片标题（带店铺徽标） */
  tbody td.col-date {
    grid-column: 1 / -1; flex-direction: row; align-items: center;
    font-weight: 600; font-size: 15px; color: var(--text);
    padding: 0 44px 7px 0; border-bottom: 1px solid var(--line); margin-bottom: 2px;
  }
  tbody td.col-date::before { display: none; }
  tbody td.col-date .card-shop {
    display: inline-flex; margin-left: auto; font-size: 11px; font-weight: 400;
    color: var(--text-2); background: var(--line); padding: 1px 9px; border-radius: 10px;
    max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  /* 勾选框固定在卡片右上角，44px 触控区 */
  tbody tr:not(.no-data) td:first-child {
    position: absolute; top: 4px; right: 2px; z-index: 2;
    width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0;
  }
  tbody tr:not(.no-data) td:first-child::before { display: none; }
  /* 覆盖基础样式 input[type=checkbox] 的 16px，勾选框本体 20px */
  input.ck { width: 20px; height: 20px; }
  /* 底部操作行：大触控目标 */
  tbody td.ops {
    grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; gap: 8px;
    padding: 6px 0 6px; border-top: 1px dashed #eceef1; margin-top: 3px;
  }
  tbody td.ops::before { display: none; }
  tbody td.ops a { font-size: 15px; padding: 9px 14px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
  tbody td.ops a:active { background: var(--brand-soft); }
  /* 无数据占位（注意与 .empty-row 区分：后者是成交额为空的正常记录卡片） */
  tbody tr.no-data { display: block; padding: 0; }
  tbody tr.no-data td { display: block; padding: 16px 0; }
  tbody tr.no-data .empty { padding: 40px 0; }
  /* 成交额为空的记录：保持卡片布局，整体淡显 */
  tbody tr.empty-row td { color: var(--text-3); }

  .pager { justify-content: center; flex-wrap: wrap; padding: 10px; }
  .pager button { min-width: 40px; height: 40px; font-size: 14px; }

  /* 弹窗 → 底部抽屉（dvh 规避移动端地址栏问题） */
  .modal { padding: 0; align-items: flex-end; }
  .modal-box {
    width: 100%; max-height: 92vh; max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overscroll-behavior: contain;
  }
  .modal-box[style*="640px"] { width: 100% !important; }
  /* 底部按钮栏吸底，键盘弹出或内容较长时保存/取消始终可见 */
  .modal-foot { position: sticky; bottom: 0; background: #fff; z-index: 3; }
  .form-grid { grid-template-columns: 1fr; }
  .form input { height: 44px; font-size: 16px; }
  .modal-box .field input, .modal-box .field select { height: 42px; font-size: 16px; }
  .modal-foot .btn { height: 40px; padding: 0 18px; }
  .calc-preview { gap: 6px 18px; }

  /* 登录页：小屏 + 键盘弹出时顶部不被裁切（margin:auto 居中且可滚动） */
  .login-screen {
    display: flex; flex-direction: column; overflow-y: auto;
    padding: calc(48px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .login-box { margin: auto; padding: 28px 22px; }
  .login-form input { font-size: 16px; height: 48px; }

  .toast {
    left: 14px; right: 14px; bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: none; text-align: center;
  }

  .mobile-menu-body { display: none; }

  /* 店铺数据页：单列卡片 */
  .shops-grid { grid-template-columns: 1fr; }

  .chart { height: 180px; }
}

@media (max-width: 480px) {
  .kpi .k-value { font-size: 16px; }
  .flow-legend { gap: 6px 12px; }
  .user-form { grid-template-columns: 1fr; }
}
