/* 青年美发 · 收银前台视觉系统
   契约：docs/salon/ui-and-interaction.md
   设计语言：实体收银机 —— 深色机面（计算器区）+ 纸感台面（工作区），
   当前结算轨道的资产是最大信息，绿色用于结算动作。 */

:root {
  --desk: #F5F2EA;        /* 台面纸感底 */
  --desk-line: #E4DFD2;   /* 台面分隔线 */
  --panel: #FDFBF6;       /* 卡片纸面 */
  --shell: #191C22;       /* 机面深色 */
  --shell-hi: #262B33;    /* 机面按键 */
  --shell-line: #323845;
  --ink: #201D19;         /* 台面正文 */
  --ink-dim: #8B857A;     /* 台面静默 */
  --lcd: #D8F3C8;         /* 计算器液晶字 */
  --green: #0F9D6A;       /* 收款绿（唯一动作色） */
  --green-deep: #0B7E55;
  --red: #C7402F;         /* 撤销/警示 */
  --amber: #B97A1F;       /* 待补全/待同步 */
  --radius: 16px;
  --shadow-card: 0 1px 2px rgba(32,29,25,.06), 0 8px 24px rgba(32,29,25,.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
  background: var(--desk); color: var(--ink);
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
button:disabled { cursor: default; }
input, textarea, select { font-family: inherit; font-size: 16px; color: var(--ink); }
.num { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

/* ============ 顶栏与 Tab ============ */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px 0; flex: none;
}
.brand { font-size: 19px; font-weight: 800; letter-spacing: .5px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; background: #EBE7DB; padding: 4px; border-radius: 12px; }
.tab {
  min-height: 42px; padding: 0 26px; border-radius: 9px;
  font-size: 16px; font-weight: 700; color: var(--ink-dim);
}
.tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(32,29,25,.12); }
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.sync-badge {
  min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center;
  background: #E3EFE7; color: var(--green-deep);
}
.sync-badge.warn { background: #F6ECD9; color: var(--amber); }
.icon-btn, .nav-btn {
  height: 40px; border-radius: 10px; background: var(--panel);
  box-shadow: var(--shadow-card); font-size: 15px; font-weight: 700; color: var(--ink-dim);
  display: inline-flex; align-items: center; justify-content: center; padding: 0 16px;
}
.nav-btn.active { color: var(--ink); background: #EBE7DB; box-shadow: none; }

/* ============ 主体 ============ */
.main { flex: 1; min-height: 0; padding: 16px 22px 20px; overflow: hidden; display: flex; flex-direction: column; }

/* ============ 收银 Tab（顾客消费信息为主 ≈60%，机面为辅 ≈40%） ============ */
.pos { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; flex: 1; min-height: 0; }
.pos.pos-times { grid-template-columns: minmax(0, 1fr); }

/* 左：顾客消费信息列 */
.cust-col { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; padding-bottom: 4px; }
.cust-card { flex: none; }
.machine {
  background: var(--shell); border-radius: 22px; padding: 18px;
  display: flex; flex-direction: column; gap: 12px; min-width: 0; align-self: start;
  box-shadow: 0 18px 40px rgba(22,24,29,.28);
}
.machine-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex: none; }
.lcd-amt { color: var(--lcd); font-size: 38px; font-weight: 700; letter-spacing: 1px; line-height: 1.15; }
.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.key {
  background: var(--shell-hi); border: 1px solid var(--shell-line); border-radius: 13px;
  color: #EDF0F4; font-size: 20px; font-weight: 700; min-height: 48px;
}
.key:active { background: #39414f; }
.key.op { color: #86EFAC; }
.key.fn { color: #AEB6C2; font-size: 16px; }
.key.wide { grid-column: span 2; }
.lcd { background: #10130F; border-radius: 14px; padding: 12px 16px; flex: none; border: 1px solid #2A3324; }
.lcd-expr { color: #7E9B6C; font-size: 15px; min-height: 20px; word-break: break-all; font-family: ui-monospace, monospace; }
.lcd-sub { color: #7E9B6C; font-size: 13px; }
.discounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; flex: none; }
.disc {
  min-height: 44px; border-radius: 12px; background: #20242C; border: 1px solid var(--shell-line);
  color: #F5D9A8; font-weight: 800; font-size: 17px;
}
.disc.on { background: #F5D9A8; color: #3A2C0A; border-color: #F5D9A8; }
.disc.ghost { color: #AEB6C2; }
.disc.mini { font-size: 12px; font-weight: 600; color: #7B8494; min-height: 40px; align-self: end; }

/* 计次操作只是紧凑快捷键，不拉伸成机面。 */
.times-checkout { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--desk-line); }
.checkout-label { font-size: 14px; font-weight: 700; }
.times-keys { display: flex; flex-wrap: wrap; gap: 8px; }
.tkey {
  min-height: 44px; padding: 0 18px; border-radius: 10px; background: var(--green);
  color: #fff; font-size: 15px; font-weight: 700;
}
.tkey:active { background: var(--green-deep); }
.tkey:disabled { opacity: .5; }
.times-checkout > small { font-size: 12px; color: var(--ink-dim); }

/* 右：机面列（见 .pos 定义）——小票卡片样式 */
.card {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-card);
  padding: 18px;
}
.card h3 { font-size: 14px; color: var(--ink-dim); font-weight: 600; margin-bottom: 12px; }

.cust-row { display: flex; gap: 8px; margin: 12px 0; }
.cust-chip {
  flex: 1; min-height: 46px; border-radius: 11px; border: 1.5px solid var(--desk-line);
  background: #fff; font-weight: 700; font-size: 15px; color: var(--ink-dim);
}
.cust-chip.on { border-color: var(--ink); color: var(--ink); background: var(--desk); }
.cust-info { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 4px; }
.cust-info b { font-size: 22px; }
.cust-info .btn { margin-left: auto; min-height: 44px; padding: 0 12px; }
.account-overview { margin-top: 12px; }
.account-times { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 2fr); gap: 24px; align-items: start; }
.asset-label { font-size: 14px; color: #655F55; }
.asset-value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; font-size: 56px; font-weight: 750; line-height: 1.15; margin-top: 4px; overflow-wrap: anywhere; }
.account-times .asset-value { font-size: 72px; }
.asset-unit { font-size: 22px; font-weight: 600; }
.overdrawn, .asset-warning { color: var(--red); }
.asset-warning { font-size: 13px; }
.batch-details { border-left: 1px solid var(--desk-line); padding-left: 24px; min-width: 0; }
.batch-details h3 { font-size: 14px; color: var(--ink); margin-bottom: 8px; }
.batch-details h3 small { font-size: 12px; font-weight: 400; color: var(--ink-dim); margin-left: 8px; }
.batch-list { list-style: none; max-height: 156px; overflow: auto; }
.batch-row { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; padding: 10px 0; border-bottom: 1px solid var(--desk-line); }
.batch-row:first-child { padding-top: 0; }
.batch-row:last-child { border-bottom: none; }
.batch-row > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.batch-label, .batch-remaining > span { font-size: 13px; color: #655F55; }
.batch-paid { font-size: 22px; }
.batch-origin { font-size: 15px; }
.batch-remaining b { font-size: 26px; }
.batch-history { font-size: 15px; color: #655F55; }

.phone-fix {
  background: #F6ECD9; border-radius: 12px; padding: 10px 12px; margin: 12px 0;
  display: grid; gap: 6px; font-size: 14px;
}
.phone-fix label { font-weight: 700; }
.phone-fix p { font-size: 13px; color: #705327; overflow-wrap: anywhere; }
.phone-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.phone-controls input { flex: 1 1 160px; min-width: 0; width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid #D6BC91; border-radius: 9px; background: #fff; }
.phone-controls .btn { flex: 0 0 auto; min-height: 44px; padding: 0 14px; background: #fff; border-color: #D6BC91; }
.phone-controls input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.phone-fix .field-error { color: var(--red); }
.phone-fix input[aria-invalid="true"] { border-color: var(--red); }
.pos-note .note-input { margin: 0; min-height: 44px; }

.note-input {
  width: 100%; min-height: 44px; border: 1.5px solid var(--desk-line); border-radius: 11px;
  padding: 10px 12px; resize: none; background: #fff; margin: 4px 0 14px;
}

/* 收款大按钮 */
.pay-btn {
  width: 100%; min-height: 92px; border-radius: 20px;
  background: var(--green); color: #fff;
  font-size: 24px; font-weight: 800; letter-spacing: 1px;
  box-shadow: 0 12px 26px rgba(15,157,106,.36);
}
.pay-btn:active { background: var(--green-deep); }
.pay-btn small { display: block; font-size: 13px; font-weight: 600; opacity: .85; margin-top: 2px; }
.pay-btn:disabled { background: #C9C3B6; box-shadow: none; }
.checkout-card { flex: none; }
.aux-row { display: flex; gap: 8px; }
.member-actions { margin: 12px 0; align-items: center; }
.member-actions .aux-btn { flex: 0 0 auto; min-height: 44px; padding: 0 18px; }
.quiet-action { margin-left: auto; padding: 0 8px; min-height: 44px; color: #655F55; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.aux-btn {
  flex: 1; min-height: 46px; border-radius: 11px; background: #fff;
  border: 1.5px solid var(--desk-line); font-weight: 700; font-size: 14px;
}

.cash-diff {
  background: #F6ECD9; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.cash-diff b { color: var(--amber); }

/* 刚完成交易（票据） */
.last-ticket { flex: none; border-left: 3px solid var(--green); padding: 12px 16px; animation: ticket .3s ease; }
.last-ticket.revoked { border-left-color: #C9C3B6; opacity: .6; }
@keyframes ticket { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }
.ticket-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ticket-tag { font-size: 13px; font-weight: 800; color: var(--green-deep); }
.ticket-time { font-size: 12px; color: var(--ink-dim); }
.ticket-amt { font-size: 24px; font-weight: 700; margin: 2px 0 4px; }
.ticket-meta { font-size: 12px; color: var(--ink-dim); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 4px; }
.ticket-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket-actions button { min-height: 44px; padding: 0 12px; font-size: 13px; background: transparent; }
.undo-btn {
  min-height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 700; font-size: 14px;
  background: #F9E9E6; color: var(--red);
}
.again-btn {
  min-height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 700; font-size: 14px;
  background: var(--desk);
}

/* ============ 会员 Tab ============ */
.members { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }
.members-toolbar { display: flex; gap: 10px; flex: none; }
.search {
  flex: 1; min-width: 0; height: 50px; border: 1.5px solid var(--desk-line); border-radius: 13px;
  background: #fff; padding: 0 16px;
}
.search:focus { outline: 2px solid var(--green); outline-offset: -1px; }
.member-grid {
  flex: 1; min-height: 0; overflow: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; align-content: start; padding-bottom: 8px;
}
.m-card {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-card);
  padding: 14px 16px; text-align: left; display: flex; flex-direction: column; gap: 6px;
}
.m-card:active { background: #fff; }
.m-name { font-size: 18px; font-weight: 800; }
.m-phone { font-size: 13px; color: var(--ink-dim); }
.m-asset-label { color: #655F55; font-size: 12px; margin-top: 10px; }
.m-asset { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-size: 34px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.m-unit { font-size: 16px; font-weight: 500; }
.empty-hint { text-align: center; color: var(--ink-dim); padding: 60px 0; }
.empty-hint b { display: block; font-size: 17px; color: var(--ink); margin-bottom: 6px; }

/* ============ 统计 Tab ============ */
.stats { display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0; overflow: auto; }
.stat-head { display: flex; gap: 10px; flex: none; }
.seg { display: flex; background: #EBE7DB; border-radius: 11px; padding: 3px; }
.seg button { min-height: 40px; padding: 0 18px; border-radius: 9px; font-weight: 700; color: var(--ink-dim); font-size: 14px; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(32,29,25,.12); }
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 16px 18px; }
.stat-card span { display: block; font-size: 13px; color: var(--ink-dim); margin-bottom: 4px; }
.stat-card b { font-size: 30px; }
.stat-card small { display: block; font-size: 12px; color: var(--ink-dim); margin-top: 4px; }
.stat-card.in b { color: var(--green-deep); }
.stat-card.out b { color: var(--red); }

.flow-list { display: flex; flex-direction: column; gap: 8px; }
.flow {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--panel); border-radius: 12px; padding: 12px 16px;
}
.flow.revoked { opacity: .45; }
.flow-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flow-type { font-size: 12px; background: var(--desk); border-radius: 6px; padding: 2px 8px; color: var(--ink-dim); }
.flow-amt { font-weight: 800; font-size: 16px; }
.flow-amt.in { color: var(--green-deep); }
.flow-amt.out { color: var(--ink); }

/* ============ 登录 ============ */
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.login-card { text-align: center; }
.brand-lg { font-size: 34px; font-weight: 800; margin-bottom: 4px; }
.login-tip { color: var(--ink-dim); margin-bottom: 26px; }
.pwd-dots { display: flex; justify-content: center; align-items: center; gap: 18px; min-height: 44px; }
.pwd-dot { width: 18px; height: 18px; flex: none; border: 2px solid var(--ink-dim); border-radius: 50%; }
.pwd-dot.filled { border-color: var(--green-deep); background: var(--green-deep); }
.pwd-progress { color: var(--ink); font-variant-numeric: tabular-nums; margin: 4px 0 20px; }
.numpad { display: grid; grid-template-columns: repeat(3, 92px); gap: 12px; justify-content: center; }
.numpad button {
  height: 70px; border-radius: 18px; background: var(--panel);
  box-shadow: var(--shadow-card); font-size: 24px; font-weight: 700;
}
.numpad button:active { background: var(--desk-line); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(32,29,25,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: var(--panel); border-radius: 22px; padding: 26px 28px; width: min(600px, 94vw);
  max-height: 88vh; overflow: auto; box-shadow: 0 24px 60px rgba(32,29,25,.3);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 20px; margin-bottom: 4px; }
.modal .sub { color: var(--ink-dim); font-size: 14px; margin-bottom: 16px; }
.field { margin-bottom: 16px; }
.field-label { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.field-help { font-size: 13px; color: var(--ink-dim); margin-bottom: 8px; line-height: 1.5; }
.field input, .field select { width: 100%; min-height: 48px; border: 1.5px solid var(--desk-line); border-radius: 11px; padding: 10px 12px; background: #fff; }
.field input:focus { outline: 2px solid var(--green); outline-offset: -1px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.btn {
  min-height: 48px; padding: 0 22px; border-radius: 12px; font-weight: 700; font-size: 15px;
  background: var(--desk); border: 1.5px solid transparent;
}
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:active { background: var(--green-deep); }
.btn.quiet { background: transparent; color: var(--ink-dim); }
.disc-edit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.disc-edit-grid input { text-align: center; font-size: 18px; font-weight: 700; min-height: 52px; border: 1.5px solid var(--desk-line); border-radius: 11px; background: #fff; }

.import-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; }
.import-table th, .import-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--desk-line); }
.import-table tr.boundary td { background: #F6ECD9; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--desk); color: var(--ink-dim); }
.pill.warn { background: #F6ECD9; color: var(--amber); }
.pill.danger { background: #F9E9E6; color: var(--red); }
.muted { color: var(--ink-dim); font-size: 13px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(16px);
  background: var(--shell); color: #F2F4F7; padding: 13px 24px; border-radius: 999px;
  font-size: 15px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: all .22s ease; z-index: 200; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.warn { background: var(--red); }

/* 设置/统计通用页面容器 */
.page { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; overflow: auto; }
.page .card { flex: none; }
.set-h4 { font-size: 15px; margin: 20px 0 8px; padding-top: 14px; border-top: 1px dashed var(--desk-line); }
.card > .set-h4:first-of-type { border-top: none; }

/* 收起式说明块 */
details.guide {
  background: var(--desk); border-radius: 12px; padding: 0; margin: 0 0 10px;
  font-size: 14px; overflow: hidden;
}
details.guide summary {
  cursor: pointer; padding: 11px 14px; font-weight: 700; color: var(--ink);
  list-style: none; user-select: none;
}
details.guide summary::-webkit-details-marker { display: none; }
details.guide summary::before { content: '▸ '; color: var(--ink-dim); }
details.guide[open] summary::before { content: '▾ '; }
details.guide[open] summary { border-bottom: 1px dashed var(--desk-line); }
details.guide .guide-body { padding: 12px 14px; line-height: 1.7; }
details.guide ol { padding-left: 20px; margin: 6px 0; }
details.guide li { margin: 2px 0; }

/* ============ 竖屏 / 窄屏 ============ */
@media (max-width: 900px), (orientation: portrait) {
  #app { height: auto; min-height: 100dvh; }
  .topbar { flex-wrap: wrap; padding: 12px 14px 0; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; padding: 0 8px; }
  .top-right { margin-left: auto; }
  .main { padding: 12px 14px 18px; height: auto; overflow: visible; }
  .pos { grid-template-columns: 1fr; }
  .cust-col { order: 1; }
  .machine { order: 2; }
  .account-times { grid-template-columns: 1fr; gap: 16px; }
  .batch-details { padding: 12px 0 0; border-left: none; border-top: 1px solid var(--desk-line); }
  .asset-value { font-size: 46px; }
  .account-times .asset-value { font-size: 60px; }
  .times-checkout > small { flex-basis: 100%; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .member-grid { overflow: visible; }
  .page { overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
