/* 理发店会员管理 · 现代扁平设计系统（统一规范：圆角 16/10/8/6，间距 4px 栅格） */
:root {
  --bg: #f6f7f6;
  --fg: #111827;
  --card: #ffffff;
  --muted: #f3f4f6;
  --muted-fg: #6b7280;
  --border: #e5e7eb;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: #ecfdf5;
  --primary-fg: #ffffff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --orange: #d97706;
  --orange-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --radius-lg: 16px;   /* 卡片 / 弹窗 */
  --radius: 10px;      /* 按钮 / 输入框 / 图块 */
  --radius-sm: 8px;    /* 小按钮 / 徽标 / 次级控件 */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 400 14.5px/1.6 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
.muted { color: var(--muted-fg); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.money { color: var(--green); font-weight: 600; }
.money-orange { color: var(--orange); font-weight: 600; }
.money-red { color: var(--red); font-weight: 600; }
.tabnum { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }

/* ---------- 登录 ---------- */
.login-layer {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 340px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px 26px; text-align: center;
  display: flex; flex-direction: column; gap: 12px;
}
.login-logo {
  width: 52px; height: 52px; margin: 0 auto; border-radius: var(--radius);
  background: var(--primary); color: var(--primary-fg);
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 17px; margin: 6px 0 0; font-weight: 600; }
.login-card .input { text-align: center; }

/* ---------- 布局 ---------- */
#main { max-width: 780px; margin: 0 auto; padding: 20px 16px 96px; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 12px 18px;
}
.topbar-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 9px; color: var(--fg); }
.topbar-title svg { color: var(--primary); }
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; border: 0; background: none; padding: 7px 0 9px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted-fg); font-size: 11.5px;
}
.nav-item.active { color: var(--primary); font-weight: 500; }

@media (min-width: 900px) {
  #main {
    max-width: 1104px;
    margin: 0 auto 0 max(224px, calc((100vw - 1104px) / 2));
    padding: 26px 32px 60px;
  }
  .topbar { margin-left: 224px; }
  .nav {
    top: 0; bottom: 0; right: auto; width: 224px;
    flex-direction: column; border-top: 0; border-right: 1px solid var(--border);
    padding: 16px 12px; gap: 2px;
  }
  .nav-item {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 11px;
    padding: 10px 13px; border-radius: var(--radius-sm); font-size: 14.5px; color: var(--fg);
  }
  .nav-item:hover { background: var(--muted); }
  .nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
}

/* ---------- 组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; margin-bottom: 14px;
}
.card h3, h3.sec {
  margin: 0 0 10px; font-size: 13.5px; font-weight: 600;
  display: flex; align-items: baseline; gap: 8px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.card h3 .muted, h3.sec .muted { font-weight: 400; font-size: 12.5px; }

.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; background: #fff; color: var(--fg); outline: none; font-size: 14.5px;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; color: var(--muted-fg); margin-bottom: 5px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.btn {
  border: 1px solid var(--border); background: var(--card); color: var(--fg);
  border-radius: var(--radius); padding: 9px 14px; font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: none; border-color: transparent; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { border-color: transparent; background: none; color: var(--muted-fg); }
.btn-ghost:hover { background: var(--muted); color: var(--fg); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 5px 14px; font-size: 13px; color: var(--fg);
}
.chip:hover { background: var(--muted); }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); font-weight: 500; }

.badge {
  display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 500;
  background: var(--primary-soft); color: var(--primary);
}
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: var(--muted); color: var(--muted-fg); }

.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item b { font-weight: 500; }

.avatar {
  width: 40px; height: 40px; border-radius: var(--radius); flex: 0 0 auto;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px;
}
.avatar-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; margin-right: 2px;
  background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 600;
}

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stats-10 { grid-template-columns: repeat(5, 1fr); }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { font-size: 12.5px; color: var(--muted-fg); }
.stat .value { font-size: 20px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { color: var(--muted-fg); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }

/* 流水行 */
.lg-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.lg-row:last-child { border-bottom: 0; }

/* 余额通栏（会员操作弹窗） */
.bal-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.bal-cell { border-radius: var(--radius); padding: 9px 12px; }
.bal-cell span { display: block; font-size: 11.5px; color: var(--muted-fg); margin-bottom: 1px; }
.bal-cell b { font-size: 16.5px; font-weight: 600; }

/* 图表 */
.chart-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted-fg); margin-top: 4px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.trend-svg text { font-family: inherit; }

/* 会员操作大按钮（通栏均分） */
.act-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.act-btn {
  border: 1px solid var(--border); background: var(--card); border-radius: var(--radius);
  padding: 13px 8px; font-size: 15px; font-weight: 500; color: var(--fg);
  transition: background .12s, border-color .12s;
}
.act-btn:hover { background: var(--muted); }
.act-btn.act-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.act-btn.act-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* ---------- 营业弹窗 ---------- */
.cat-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.cat-tabs .chip { flex: 0 0 auto; }

.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.item-tile {
  position: relative;
  border: 1px solid var(--border); background: var(--card); border-radius: var(--radius);
  padding: 10px 6px; text-align: center; transition: border-color .12s, background .12s;
}
.item-tile:hover { border-color: var(--primary); background: var(--primary-soft); }
.item-tile.selected { border-color: var(--primary); background: var(--primary-soft); }
.item-tile b { display: block; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-tile span { font-size: 12.5px; color: var(--muted-fg); }
.item-tile.item-custom {
  border: 1.5px dashed var(--primary); background: var(--primary-soft); color: var(--primary);
}
.item-tile.item-custom b { font-size: 13.5px; font-weight: 600; white-space: normal; color: var(--primary); }
.item-tile.item-custom span { color: var(--primary); opacity: .75; }
.item-tile.item-custom:hover { background: color-mix(in srgb, var(--primary) 18%, var(--primary-soft)); }

.cart-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.cart-row:last-child { border-bottom: 0; }
.cart-row .qty { display: flex; align-items: center; gap: 10px; }
.cart-row .qty button {
  width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--card); font-size: 19px; line-height: 1; color: var(--fg);
}
.cart-row .qty button:hover { background: var(--muted); }
.cart-row .qty span { font-size: 16px; font-weight: 500; min-width: 24px; text-align: center; }
.cart-row .price-input { width: 92px; text-align: right; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 16px; }
.cart-del {
  border: 0; background: none; color: var(--red);
  width: 36px; height: 36px; border-radius: var(--radius-sm); font-size: 16px;
}
.cart-del:hover { background: var(--red-soft); }

.pay-total { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 14px; }
.pay-total .amount { font-size: 25px; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; line-height: 1.2; }
.pay-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.pay-btn {
  border: 1px solid var(--border); background: var(--card); border-radius: 999px;
  padding: 10px 6px; font-size: 14px; font-weight: 500;
  transition: border-color .12s, background .12s;
}
.pay-btn:hover { border-color: var(--primary); }
.pay-btn.selected {
  border-color: var(--primary); background: var(--primary-soft);
  color: var(--primary); font-weight: 600;
}
.pay-confirm { margin-top: 10px; padding: 12px; font-size: 15.5px; }

/* ---------- 弹窗 / toast ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(17, 24, 39, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { .modal-mask { align-items: center; } }
.modal {
  width: 100%; max-width: 480px; max-height: 90vh; overflow: auto;
  background: var(--card); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}
.modal-lg { max-width: 600px; }
@media (min-width: 700px) { .modal { border-radius: var(--radius-lg); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.modal-close { border: 0; background: var(--muted); color: var(--muted-fg); width: 28px; height: 28px; border-radius: var(--radius-sm); font-size: 14px; }
.modal-foot { display: flex; gap: 10px; margin-top: 18px; }
.modal-foot .btn { flex: 1; }
.note-box { padding: 9px 12px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); }

#toast-box { position: fixed; top: 14px; left: 0; right: 0; z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: #1f2937; color: #fff; border-radius: var(--radius-sm);
  padding: 9px 18px; font-size: 13.5px; max-width: 86vw;
  animation: toast-in .18s ease-out;
}
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* 流水类型 */
.tx-type { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--muted); color: var(--muted-fg); }
.tx-type.recharge { background: var(--green-soft); color: var(--green); }
.tx-type.consume { background: var(--blue-soft); color: var(--blue); }
.tx-type.debt, .tx-type.refund_card { background: var(--red-soft); color: var(--red); }
.tx-type.repay { background: var(--orange-soft); color: var(--orange); }

/* ---------- 平板 ---------- */
@media (min-width: 641px) and (max-width: 899px) {
  #main { max-width: 720px; padding-bottom: 96px; }
}

/* ---------- 手机 ---------- */
@media (max-width: 640px) {
  #main { padding: 14px 12px 86px; }
  .topbar { padding: 10px 14px; }
  .input, select.input, textarea.input { font-size: 16px; padding: 10px 12px; }
  .card { padding: 14px; }
  .btn { padding: 10px 14px; }
  .btn-sm { padding: 8px 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .stats-10 { grid-template-columns: repeat(2, 1fr); }
  .stat .value { font-size: 18px; }
  .items-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .item-tile { padding: 11px 6px; }
  .pay-grid { gap: 7px; }
  .pay-btn { padding: 12px 4px; }
  .cart-row .qty button { width: 42px; height: 42px; }
  .cart-del { width: 40px; height: 40px; }
  .row { flex-wrap: wrap; }
  .row > .field { flex: 1 1 44%; min-width: 138px; }
  .pay-total .amount { font-size: 22px; }
}
