/* ============================================================
   供货记账助手 · H5 移动端样式
   面向摊主：大字号、大按钮、单手可达、弱网也快
   ============================================================ */
:root {
  --brand: #c0392b;
  --brand-2: #e2553f;
  --brand-soft: #fdeeeb;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #eef0f3;
  --line-2: #e4e7eb;
  --t1: #1d2129;
  --t2: #6b7280;
  --t3: #9aa1a9;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 1px 3px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--t1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
input, button, select, textarea { font-family: inherit; font-size: 16px; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--brand); text-decoration: none; }

/* ---------- 骨架 ---------- */
#app { min-height: 100vh; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; }
.wrap { padding: 12px 12px calc(var(--tab-h) + var(--safe-b) + 20px); }
.wrap.has-action { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 84px); }

/* ---------- 顶部标题栏 ---------- */
.hd {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.hd-t { font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.hd-r { font-size: 13px; color: var(--t2); display: flex; align-items: center; gap: 6px; }
.hd-back { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 600; }
.hd-back .arrow { font-size: 22px; line-height: 1; color: var(--t2); margin-top: -2px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.sec-t { font-size: 14px; font-weight: 600; color: var(--t2); margin-bottom: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sec-t .req { color: var(--brand); }
.muted { color: var(--t2); font-size: 13px; font-weight: 400; }
.hint { font-size: 13px; color: var(--t2); margin-top: 8px; }
.hint-warn { color: var(--warn); }

/* ---------- 胶囊选择（客户/商品/日期） ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 15px;
  font-size: 16px; font-weight: 500;
  color: var(--t1); background: #f5f6f8;
  border: 1.5px solid transparent; border-radius: 12px;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:active { transform: scale(.97); }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }
.chip-add { color: var(--brand); background: #fff; border: 1.5px dashed #e3b6ae; }
.chip-prod { flex-direction: column; align-items: flex-start; gap: 0; padding: 7px 14px; line-height: 1.25; }
.chip-prod .note { font-size: 12px; color: var(--t3); font-weight: 500; }
.chip-prod.on .note { color: var(--brand); opacity: .75; }
.chip-date { position: relative; overflow: hidden; }
.chip-date input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; }

/* ---------- 表单 ---------- */
.fld { display: block; margin-bottom: 14px; }
.fld-label { display: block; font-size: 14px; color: var(--t2); margin-bottom: 6px; }
.fld-input {
  display: block; width: 100%; height: 50px; padding: 0 14px;
  background: #f7f8fa; border: 1.5px solid transparent; border-radius: 12px;
  font-size: 16px; outline: none; transition: border-color .15s, background .15s;
}
.fld-input:focus { background: #fff; border-color: var(--brand); }
.fld-input::placeholder { color: #b9bfc7; }
.fld-pwd { display: flex; align-items: center; gap: 6px; }
.pwd-toggle { flex: none; height: 50px; padding: 0 12px; font-size: 14px; color: var(--t2); border-radius: 12px; }

/* 数字输入（记账主输入框，要大） */
.num-grid { display: flex; gap: 10px; }
.num-fld { flex: 1; min-width: 0; }
.num-fld .cap { font-size: 13px; color: var(--t2); margin-bottom: 6px; display: block; }
.num-input {
  width: 100%; height: 56px; padding: 0 14px;
  background: #f7f8fa; border: 1.5px solid transparent; border-radius: 12px;
  font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums;
  outline: none; transition: border-color .15s, background .15s;
}
.num-input:focus { background: #fff; border-color: var(--brand); }
.num-input::placeholder { color: #c8ced6; font-weight: 500; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 48px; padding: 0 16px;
  font-size: 16px; font-weight: 600; border-radius: 12px;
  background: #f2f3f5; color: var(--t1);
  transition: transform .12s, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; }
.btn-primary { background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 4px 14px rgba(192, 57, 43, .22); }
.btn-lg { min-height: 52px; font-size: 17px; }
.btn-sm { width: auto; min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn-danger-text { color: var(--danger); }
.btn-plain { background: #fff; border: 1.5px solid var(--line-2); }

/* ---------- 金额 ---------- */
.amount { font-size: 30px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.amount-sm { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; }

/* ---------- 统计条 ---------- */
.stat3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat3 > div { background: var(--card); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat3 .n { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat3 .n.accent { color: var(--brand); }
.stat3 .l { font-size: 12px; color: var(--t3); margin-top: 2px; }

/* ---------- 台账列表 ---------- */
.day-card { background: var(--card); border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden; }
.day-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); }
.day-head .d { font-weight: 700; font-size: 15px; }
.day-head .w { font-size: 12px; color: var(--t3); margin-left: 6px; font-weight: 400; }
.day-head .t { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.rec { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.rec:last-child { border-bottom: 0; }
.rec:active { background: #fafbfc; }
.rec-main { flex: 1; min-width: 0; }
.rec-name { font-size: 16px; font-weight: 600; }
.rec-sub { font-size: 13px; color: var(--t2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-amt { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }

/* ---------- 记账明细行 ---------- */
.item { border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.item-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.item-head b { font-size: 16px; }
.item-del { font-size: 13px; color: var(--t3); padding: 6px 4px 6px 10px; }
.item-del:active { color: var(--danger); }
.item-grid { display: flex; gap: 8px; align-items: flex-end; }
.mini-fld { flex: 1; min-width: 0; }
.mini-fld .cap { display: block; font-size: 12px; color: var(--t3); margin-bottom: 4px; }
.mini-input {
  width: 100%; height: 46px; padding: 0 10px; text-align: right;
  background: #f7f8fa; border: 1.5px solid transparent; border-radius: 10px;
  font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; outline: none;
}
.mini-input:focus { background: #fff; border-color: var(--brand); }
.mini-amt { flex: none; width: 92px; text-align: right; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; padding-bottom: 12px; }
.empty-line { text-align: center; color: var(--t3); font-size: 14px; padding: 14px 0; }

/* ---------- 底部固定操作条 ---------- */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 15;
  display: flex; align-items: center; gap: 12px;
  max-width: 560px; margin: 0 auto; padding: 10px 14px;
  background: rgba(255, 255, 255, .98);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.action-bar .sum { flex: none; line-height: 1.15; }
.action-bar .sum .l { font-size: 11px; color: var(--t3); }
.action-bar .sum .v { font-size: 22px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.action-bar .btn { width: auto; flex: 1; min-width: 0; }

/* ---------- 底部 Tab ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: stretch;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .98);
  border-top: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(14px);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--t3); font-size: 11px; font-weight: 500; -webkit-user-select: none; user-select: none;
}
.tab svg { width: 23px; height: 23px; }
.tab.on { color: var(--brand); font-weight: 700; }
.tab:active { opacity: .65; }

/* ---------- 底部弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 20, 30, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: mask-in .18s ease-out;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 88vh;
  background: #fff; border-radius: 20px 20px 0 0;
  padding-bottom: calc(var(--safe-b) + 12px);
  display: flex; flex-direction: column;
  animation: sheet-in .24s cubic-bezier(.22, 1, .36, 1);
}
.sheet-head { position: relative; flex: none; padding: 16px 18px 10px; }
.sheet-title { font-size: 17px; font-weight: 700; text-align: center; }
.sheet-close { position: absolute; right: 10px; top: 10px; width: 36px; height: 36px; font-size: 17px; color: var(--t3); border-radius: 50%; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 18px 6px; }
.sheet-foot { flex: none; display: flex; gap: 10px; padding: 12px 18px 0; }
.sheet-foot .btn { flex: 1; }
@keyframes mask-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---------- 提示 ---------- */
#h5-toasts {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 0;
  pointer-events: none;
}
.h5-toast {
  max-width: 92%; padding: 11px 16px; border-radius: 10px;
  font-size: 15px; font-weight: 500; line-height: 1.4;
  color: #fff; background: rgba(29, 33, 41, .92);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  animation: toast-in .2s ease-out;
  transition: opacity .24s, transform .24s;
}
.h5-toast-success { background: rgba(22, 163, 74, .95); }
.h5-toast-error { background: rgba(220, 38, 38, .95); }
.h5-toast-warning { background: rgba(217, 119, 6, .95); }
.h5-toast-info { background: rgba(29, 33, 41, .92); }
.h5-toast.out { opacity: 0; transform: translateY(-6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--t3); }
.empty .big { font-size: 40px; line-height: 1.2; margin-bottom: 8px; }
.empty .t { font-size: 15px; margin-bottom: 14px; }

/* ---------- 登录 / 注册 ---------- */
.auth {
  min-height: 100vh; padding: 34px 22px calc(var(--safe-b) + 24px);
  background:
    radial-gradient(120% 60% at 50% 0%, #fff1ee 0%, rgba(255, 255, 255, 0) 62%),
    var(--bg);
  display: flex; flex-direction: column; justify-content: center; max-width: 560px; margin: 0 auto;
}
.auth-logo { font-size: 46px; text-align: center; line-height: 1; }
.auth-title { font-size: 25px; font-weight: 800; text-align: center; margin: 12px 0 4px; letter-spacing: .5px; }
.auth-sub { text-align: center; color: var(--t2); font-size: 14px; margin-bottom: 26px; }
.auth-card { background: #fff; border-radius: 18px; padding: 20px 18px; box-shadow: 0 8px 30px rgba(16, 24, 40, .07); }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 15px; }
.auth-links a { color: var(--brand); font-weight: 500; }
.auth-foot { text-align: center; font-size: 14px; color: var(--t2); margin-top: 22px; }
.notice { background: #fff8e6; border: 1px solid #ffe6b0; color: #8a5a00; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; line-height: 1.45; }

/* ---------- 月份切换 ---------- */
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav button { width: 40px; height: 40px; font-size: 24px; color: var(--t2); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.month-nav button:active { background: #f2f3f5; }
.month-label { padding: 4px 12px; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- 对账 ---------- */
.pv { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; font-size: 15px; border-bottom: 1px dashed var(--line-2); }
.pv:last-of-type { border-bottom: 0; }
.pv .k { color: var(--t2); }
.pv .v { font-weight: 700; text-align: right; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 我的 ---------- */
.me-head { display: flex; align-items: center; gap: 12px; }
.avatar { width: 52px; height: 52px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--brand)); }
.me-phone { font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.status { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f0f1f3; color: var(--t2); margin-top: 5px; }
.status.ok { background: #e8f8ee; color: #12813d; }
.status.warn { background: #fff4e5; color: #a45b00; }
.status.bad { background: #fdeaea; color: #b91c1c; }

.menu { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 12px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 15px 14px; border-bottom: 1px solid var(--line); font-size: 16px; }
.menu-item:last-child { border-bottom: 0; }
.menu-item:active { background: #fafbfc; }
.menu-item .ic { width: 26px; text-align: center; font-size: 18px; flex: none; }
.menu-item .arrow { margin-left: auto; color: #c8ced6; font-size: 18px; }

/* ---------- 基础数据 ---------- */
.seg { display: flex; background: #eef0f3; border-radius: 11px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; min-height: 38px; font-size: 15px; font-weight: 600; color: var(--t2); border-radius: 9px; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.row-item { display: flex; align-items: center; gap: 10px; padding: 13px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: 0; }
.row-item .n { font-size: 16px; font-weight: 600; }
.row-item .d { font-size: 13px; color: var(--t2); margin-top: 2px; }
.row-item .v { margin-left: auto; font-size: 15px; color: var(--t2); flex: none; }
.list-box { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 12px; }

/* ---------- 支付选项 ---------- */
.pay-opt { display: flex; align-items: center; gap: 10px; padding: 13px 14px; border: 1.5px solid var(--line-2); border-radius: 12px; margin-bottom: 10px; }
.pay-opt.on { border-color: var(--brand); background: var(--brand-soft); }
.pay-opt .nm { font-size: 16px; font-weight: 600; }
.pay-opt .sub { font-size: 12px; color: var(--t3); }
.pay-opt .pr { margin-left: auto; font-size: 18px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.pay-opt .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #d3d8de; flex: none; position: relative; }
.pay-opt.on .radio { border-color: var(--brand); }
.pay-opt.on .radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--brand); }

/* ---------- 月份选择网格 ---------- */
.month-pick { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 6px 0 14px; }
.month-pick button { width: 40px; height: 40px; font-size: 22px; color: var(--t2); }
.month-pick .yr { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.month-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.month-grid button { height: 46px; border-radius: 11px; background: #f5f6f8; font-size: 15px; font-weight: 600; }
.month-grid button.on { background: var(--brand-soft); color: var(--brand); border: 1.5px solid var(--brand); }
.month-grid button.now::after { content: "本月"; display: block; font-size: 10px; color: var(--t3); line-height: 1; }

/* ---------- 加载 ---------- */
.spin { width: 22px; height: 22px; border: 2.5px solid #e6e9ee; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 18px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 桌面适配（居中显示，像 App） ---------- */
@media (min-width: 600px) {
  body { background: #eceef1; }
  .app { box-shadow: 0 0 0 1px rgba(16, 24, 40, .04), 0 12px 40px rgba(16, 24, 40, .08); }
  .hd { border-radius: 0; }
}
