:root {
  --bg: #f5f1e8;
  --paper: #fffdf8;
  --ink: #1d2a28;
  --muted: #7d8781;
  --line: #e5ddcf;
  --green: #1f6f5c;
  --green-2: #2c8a70;
  --green-soft: #e9f2ed;
  --clay: #b76242;
  --clay-soft: #f7e8df;
  --gold: #b48a4b;
  --shadow: 0 18px 50px rgba(46, 38, 27, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
[hidden] { display: none !important; }

/* ---------- login ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
  background:
    radial-gradient(circle at 18% 16%, rgba(181, 207, 190, 0.55), transparent 36%),
    radial-gradient(circle at 76% 84%, rgba(219, 200, 174, 0.55), transparent 40%),
    var(--bg);
}
.login-brand {
  padding: 64px 8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.brand-mark {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  color: var(--paper);
  font-family: "Songti SC", "STSong", serif;
  font-size: 27px;
  letter-spacing: 1px;
  box-shadow: 0 14px 30px rgba(31, 111, 92, 0.22);
}
.brand-en {
  margin: 26px 0 10px;
  color: var(--green);
  font-size: 11px;
  letter-spacing: 3px;
  font-weight: 700;
}
.login-brand h1 {
  margin: 0;
  max-width: 580px;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(36px, 4.6vw, 62px);
  line-height: 1.18;
  letter-spacing: -1px;
  font-weight: 600;
}
.brand-desc {
  max-width: 470px;
  margin: 24px 0 0;
  color: #68746e;
  font-size: 15px;
  line-height: 1.8;
}
.brand-points {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 30px;
}
.brand-points span {
  padding: 8px 14px;
  border: 1px solid rgba(31, 111, 92, 0.22);
  border-radius: 999px;
  color: var(--green);
  background: rgba(255, 253, 248, 0.5);
  font-size: 12px;
}
.login-note {
  margin-top: 48px;
  color: #9aa09b;
  font-size: 11px;
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-card {
  width: min(420px, 100%);
  padding: 42px;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid rgba(229, 221, 207, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 2.6px;
  font-weight: 700;
  color: var(--gold);
}
.login-card h2 {
  margin: 8px 0 4px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 32px;
  font-weight: 600;
}
.login-sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.field-label {
  display: block;
  margin: 16px 0 7px;
  color: #56625d;
  font-size: 12px;
  font-weight: 600;
}
input, select, textarea {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  color: var(--ink);
  outline: none;
}
textarea { height: auto; min-height: 82px; padding: 10px 13px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.10);
}
.form-error {
  margin: 12px 0 0;
  color: var(--clay);
  font-size: 12px;
  line-height: 1.5;
}
.login-btn {
  width: 100%;
  height: 48px;
  margin-top: 22px;
}
.demo-accounts {
  margin-top: 26px;
  padding: 16px;
  border-radius: 12px;
  background: #f4efe5;
  font-size: 11px;
  color: #7e7161;
  line-height: 1.7;
}
.demo-accounts p { margin: 0 0 4px; font-weight: 600; }
.demo-accounts code { display: block; color: var(--green); font-weight: 700; }
.demo-accounts span { display: block; margin-top: 6px; color: #9b8f80; }

/* ---------- app shell ---------- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 18px 20px;
  background: #173c34;
  color: #e8f1ec;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.side-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f4e9d7;
  color: #173c34;
  font-family: "Songti SC", "STSong", serif;
  font-size: 14px;
}
.side-brand strong { display: block; font-size: 14px; letter-spacing: 1px; }
.side-brand span { display: block; margin-top: 3px; font-size: 10px; color: #9fbdb3; }
.side-nav { flex: 1; padding: 20px 0; }
.side-nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b8cec6;
  text-align: left;
  font-size: 13px;
}
.side-nav button:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-nav button.active { background: #f4e9d7; color: #173c34; font-weight: 700; }
.side-nav .nav-dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.6;
}
.side-foot {
  padding: 16px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  color: #9fbdb3;
}
.side-foot p { margin: 0 0 8px; }
.link-btn {
  border: 0; padding: 0; background: transparent; color: #f4e9d7; font-size: 11px;
}
.link-btn:hover { text-decoration: underline; }

.main {
  min-width: 0;
  padding: 32px clamp(22px, 4vw, 56px) 60px;
}
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}
.topbar h1 {
  margin: 5px 0 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 600;
  letter-spacing: -0.5px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.role-badge {
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}
.global-notice {
  margin-bottom: 20px;
  padding: 13px 16px;
  border: 1px solid #ead6c7;
  border-radius: 12px;
  background: #fbf1e9;
  color: #8a4e33;
  font-size: 12px;
  line-height: 1.6;
}
.view { animation: fade-in 0.2s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- buttons / cards ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-primary { background: var(--green); color: #fffdf8; }
.btn-primary:hover { background: #185d4e; }
.btn-ghost { background: transparent; border-color: var(--line); color: #4f5a55; }
.btn-ghost:hover { border-color: #bcb2a2; background: #fffdf8; }
.btn-soft { background: #efe8db; color: #65584a; }
.btn-soft:hover { background: #e7ddcc; }
.btn-danger { background: #fff1ec; color: #a64d31; border-color: #efd3c7; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: #f2ece1; color: #5e6a64; font-size: 20px; line-height: 1;
}
.icon-btn:hover { background: #e9e0d2; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 6px 20px rgba(50, 42, 30, 0.035);
}
.stat-label { color: var(--muted); font-size: 11px; }
.stat-value {
  margin-top: 9px;
  font-family: "Songti SC", "STSong", serif;
  font-size: clamp(24px, 2.8vw, 34px);
  font-weight: 600;
  letter-spacing: -0.5px;
}
.stat-hint { margin-top: 5px; color: #9aa09b; font-size: 10px; }
.stat.accent { background: #173c34; border-color: #173c34; color: #fffdf8; }
.stat.accent .stat-label, .stat.accent .stat-hint { color: #a9c6bc; }

.panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-title { margin: 0; font-size: 14px; font-weight: 700; }
.panel-sub { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.panel-body { padding: 18px 20px; }
.split-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.split-summary div { padding: 14px; border-radius: 12px; background: #f8f4eb; }
.split-summary span { display: block; color: var(--muted); font-size: 10px; }
.split-summary strong { display: block; margin-top: 5px; font-size: 18px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #eee7db; vertical-align: middle; }
th { color: #8a8f89; font-size: 10px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; background: #fbf8f1; }
td { font-size: 12px; color: #3d4944; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fdfaf4; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; color: #5f6a64; }
.subtext { display: block; margin-top: 2px; color: #9aa09b; font-size: 10px; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f1ece2;
  color: #6e6253;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.green { background: #e9f2ed; color: #1f6f5c; }
.badge.clay { background: #f9e9e2; color: #a95135; }
.badge.gold { background: #f7efdc; color: #8f6c2f; }
.badge.gray { background: #eff1ef; color: #7d8781; }
.empty {
  padding: 50px 20px;
  text-align: center;
  color: #9aa09b;
  font-size: 12px;
}
.empty strong { display: block; margin-bottom: 5px; color: #56625d; font-size: 14px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.toolbar input { width: 220px; height: 36px; }
.toolbar select { width: 150px; height: 36px; }
.toolbar .spacer { flex: 1; }

/* ---------- merchant cards ---------- */
.merchant-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 18px 20px 22px; }
.merchant-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffefb;
}
.merchant-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.merchant-name { margin: 0; font-size: 15px; font-weight: 700; }
.merchant-meta { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.merchant-stats { display: flex; gap: 18px; margin: 14px 0; padding: 12px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); }
.merchant-stats div span { display: block; color: var(--muted); font-size: 10px; }
.merchant-stats div strong { display: block; margin-top: 3px; font-size: 16px; }
.merchant-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.perm-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.perm-row .badge { font-weight: 500; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #eee7db; }
.switch-row:last-child { border-bottom: 0; }
.switch-copy strong { display: block; font-size: 12px; }
.switch-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.switch {
  position: relative; width: 42px; height: 24px; flex-shrink: 0;
}
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; background: #d9d3c7; transition: 0.18s;
  pointer-events: none;
}
.switch i::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: 0.18s; box-shadow: 0 1px 3px rgba(0,0,0,0.16);
}
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ---------- modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(18, 27, 24, 0.48); backdrop-filter: blur(3px); }
.modal {
  position: relative; width: min(620px, 100%); max-height: min(86vh, 760px);
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 20px; background: var(--paper); box-shadow: 0 30px 80px rgba(16, 25, 21, 0.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: "Songti SC", "STSong", serif; font-size: 22px; font-weight: 600; }
.modal-body { padding: 20px 22px 24px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field-label { margin-top: 0; }
.form-grid input, .form-grid select, .form-grid textarea { margin-bottom: 2px; }
.hint { color: #9aa09b; font-size: 10px; line-height: 1.6; }
.code-box {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px;
  background: #f4efe5; border: 1px dashed #d9cdbb;
}
.code-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: 11px; color: #5f4e3d; }
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 80; transform: translateX(-50%);
  max-width: min(90vw, 520px); padding: 11px 18px; border-radius: 999px;
  background: #173c34; color: #fffdf8; font-size: 12px; box-shadow: 0 12px 30px rgba(23,60,52,0.25);
}
.toast.error { background: #a64d31; }

/* ---------- settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.settings-card h3 { margin: 0 0 4px; font-size: 14px; }
.settings-card p { margin: 0 0 16px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.settings-card .btn { margin-top: 14px; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 88px minmax(0, 1fr); }
  .side-brand div:last-child, .side-nav button span, .side-foot p { display: none; }
  .side-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .side-nav button { justify-content: center; padding: 12px 0; font-size: 10px; }
  .side-nav .nav-dot { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .merchant-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { padding: 44px 24px 16px; text-align: left; }
  .login-panel { padding: 20px 24px 44px; }
  .login-card { padding: 28px; }
  .login-note { display: none; }
  .app-shell { display: block; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 14px; gap: 10px;
  }
  .side-brand { border: 0; padding: 0; }
  .side-mark { width: 34px; height: 34px; font-size: 12px; }
  .side-nav { display: flex; overflow-x: auto; padding: 0; gap: 4px; }
  .side-nav button { width: auto; margin: 0; padding: 8px 10px; white-space: nowrap; }
  .side-foot { border: 0; padding: 0; margin-left: auto; }
  .side-foot .link-btn { white-space: nowrap; }
  .main { padding: 22px 14px 44px; }
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 27px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 15px; }
  .form-grid, .inline-fields { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .toolbar input { width: 100%; }
  .toolbar select { width: 100%; }
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  padding: 0 20px 22px;
}
.catalog-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefb;
  padding: 4px;
  text-align: center;
}
.catalog-item img {
  width: 100%;
  aspect-ratio: 120 / 132;
  object-fit: cover;
  border-radius: 7px;
  background: #2f3030;
  display: block;
}
.catalog-item strong {
  display: block;
  padding: 5px 0 3px;
  font-size: 11px;
  color: #4f5a55;
}
@media (max-width: 1100px) {
  .catalog-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .catalog-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
