:root {
  --bg: #f5f3ec;
  --panel: #ffffff;
  --ink: #1a2620;
  --muted: #6d7b73;
  --line: #e5e0d4;
  --green: #14532d;
  --green-2: #1f7a45;
  --green-soft: #e8f1ea;
  --amber: #b45309;
  --amber-soft: #fdf0df;
  --red: #b91c1c;
  --red-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(26, 38, 32, 0.06), 0 8px 24px rgba(26, 38, 32, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: #12201a;
  color: #e8efe9;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #e0a458, #b45309);
  color: #1b1305; font-weight: 700; font-size: 17px;
}
.brand-mark.large { width: 54px; height: 54px; font-size: 24px; margin: 0 auto 14px; }
.brand-name { font-weight: 600; letter-spacing: 0.02em; }
.brand-sub { font-size: 12px; color: #8fa79a; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; justify-content: space-between; align-items: baseline;
  background: transparent; border: 0; color: #b9c9c0;
  padding: 11px 12px; border-radius: 10px; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item small { font-size: 11px; color: #6f8579; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: #1d3227; color: #fff; }
.nav-item.active small { color: #a9c9b6; }

.sidebar-foot {
  margin-top: auto; padding: 14px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px; color: #7f9488; display: flex; flex-direction: column; gap: 8px;
}
.link { background: none; border: 0; color: #9fb5a8; padding: 0; text-align: left; font-size: 12px; }
.link:hover { color: #fff; }

.main { padding: 26px 30px 60px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.topbar h1 { font-size: 24px; }
.topbar p { margin-top: 5px; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.pill {
  background: var(--amber-soft); color: var(--amber);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 500;
}
.pill.ok { background: var(--green-soft); color: var(--green-2); }

.primary {
  background: var(--green); color: #fff; border: 0;
  padding: 10px 18px; border-radius: 10px; font-weight: 500;
}
.primary:hover { background: #0f3f23; }
.ghost {
  background: transparent; border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 10px; color: var(--ink);
}
.ghost:hover { background: #faf8f2; }
.danger { background: var(--red-soft); color: var(--red); border: 0; padding: 8px 14px; border-radius: 9px; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card h3 { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin-top: 10px; }
.stat small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.card .foot { margin-top: 8px; font-size: 12px; color: var(--muted); }

.section { margin-top: 22px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-head h2 { font-size: 16px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid #f0ece2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #faf9f4; }
tbody tr.clickable { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; background: #f1efe8; color: var(--muted); }
.tag.green { background: var(--green-soft); color: var(--green-2); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.red { background: var(--red-soft); color: var(--red); }

input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(31, 122, 69, 0.12); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* POS */
.pos { display: grid; grid-template-columns: 280px 1fr 320px; gap: 16px; align-items: start; }
.pos-col { display: flex; flex-direction: column; gap: 14px; }

.member-hit { display: flex; justify-content: space-between; padding: 10px; border-radius: 10px; cursor: pointer; }
.member-hit:hover { background: var(--green-soft); }

.pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 6px; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.pick-row:hover { background: #faf9f4; }
.pick-row.on { border-color: var(--green-2); background: var(--green-soft); }
.pick-row input { width: 16px; height: 16px; flex: none; accent-color: var(--green); }
.member-badge { display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-weight: 600; }

.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.product {
  position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  text-align: left; background: #fff; transition: border-color 0.15s, transform 0.1s;
}
.product:hover { border-color: var(--green-2); }
.product:active { transform: scale(0.985); }
.product b { display: block; font-weight: 600; font-size: 13px; line-height: 1.4; }
.product span { display: block; margin-top: 8px; color: var(--amber); font-weight: 600; }
.product em { font-style: normal; font-size: 11px; color: var(--muted); }
.picked-badge {
  display: none; position: absolute; top: 8px; right: 8px;
  background: var(--green); color: #fff; border-radius: 999px;
  padding: 2px 8px; font-style: normal; font-size: 11px; font-weight: 600;
}
.picked-badge.show { display: block; }

.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--line); background: #fff; line-height: 1; }
.qty-num {
  width: 38px; height: 24px; padding: 0 2px; text-align: center;
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
.qty-num::-webkit-inner-spin-button, .qty-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qty-num { -moz-appearance: textfield; appearance: textfield; }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; }
.cart-total b { font-size: 26px; }

.pay-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pay { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px; }
.pay.active { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 600; }
.pay:disabled { opacity: 0.45; cursor: not-allowed; }

/* member detail */
.cardbox {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: #fff;
}
.cardbox.count { background: linear-gradient(135deg, #143d27, #1e5c39); color: #fff; border: 0; }
.cardbox.stored { background: linear-gradient(135deg, #2c2417, #5a4322); color: #fff; border: 0; }
.cardbox .big { font-size: 26px; font-weight: 650; margin-top: 6px; }
.cardbox .sub { font-size: 12px; opacity: 0.75; margin-top: 6px; }

.modal { position: fixed; inset: 0; background: rgba(20, 28, 24, 0.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal-card { background: #fff; border-radius: 18px; padding: 26px; width: min(560px, 100%); max-height: 88vh; overflow: auto; position: relative; box-shadow: 0 24px 60px rgba(0,0,0,0.25); }
.modal-close { position: absolute; top: 14px; right: 16px; border: 0; background: none; font-size: 22px; color: var(--muted); }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #16241d; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 80; font-size: 13px;
}

.login { position: fixed; inset: 0; background: #12201a; display: grid; place-items: center; z-index: 100; }
.login-card { background: #fff; padding: 34px 30px; border-radius: 18px; width: min(380px, 92vw); text-align: center; display: flex; flex-direction: column; gap: 10px; }
.login-card h2 { font-size: 18px; }
.login-card .hint { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 6px; }

.msg-preview {
  background: #f3f7f4; border: 1px solid #d9e6dd; border-radius: 12px; padding: 14px;
  white-space: pre-wrap; line-height: 1.7; font-size: 13px; margin-top: 8px;
}
.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

.session-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fff; }
.session-card .bar { height: 6px; border-radius: 3px; background: #eee9dd; margin-top: 10px; overflow: hidden; }
.session-card .bar i { display: block; height: 100%; background: var(--green-2); }

@media (max-width: 1180px) {
  .pos { grid-template-columns: 1fr 320px; }
  .pos-col.mid { grid-column: 1 / -1; order: 3; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .brand { padding: 0 8px 0 0; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; }
  .nav-item { flex-direction: column; gap: 2px; white-space: nowrap; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 16px 50px; }
  .pos { grid-template-columns: 1fr; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: 1fr 1fr; }
}
