:root {
  --ink: #2a2420;
  --ink-2: #5a524c;
  --mute: #8f877f;
  --faint: #b5aea6;
  --line: #e6e1db;
  --bg: #f1efec;
  --surface: #fffcf9;
  --accent: #a8483a;
  --accent-soft: #f6ebe8;
  --ok: #2f6b52;
  --ok-soft: #e8f2ec;
  --warn: #8a5a1a;
  --warn-soft: #f6efdf;
  --sidebar: #2a2420;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
button, input { font: inherit; }
.view { min-height: 100vh; }

.login-card {
  width: min(400px, calc(100% - 32px));
  margin: 12vh auto 0;
  padding: 32px 28px 28px;
  border-radius: 16px;
  background: linear-gradient(155deg, #fff8f5 0%, #fffcf9 48%, #f7f3ef 100%);
  box-shadow: 0 12px 40px rgba(42, 36, 32, 0.06);
}
.login-brand {
  width: 52px; height: 52px; line-height: 52px; text-align: center;
  border-radius: 14px; color: #fff; font-weight: 700; font-size: 22px;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(168, 72, 58, 0.22);
}
.login-card h1 { margin: 16px 0 0; font-size: 24px; }
.login-sub { margin: 6px 0 22px; color: var(--mute); font-size: 13px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 6px; color: var(--mute); font-size: 12px; letter-spacing: 2px; }
.field input, .field textarea, .admin-form input, .pwd-form input, .user-search input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.field textarea {
  height: auto;
  min-height: 140px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.55;
}
.field input:focus, .field textarea:focus, .admin-form input:focus, .pwd-form input:focus, .user-search input:focus {
  outline: none;
  border-color: #d2b3ab;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  height: 40px;
  cursor: pointer;
  background: transparent;
  color: var(--ink-2);
}
.btn-primary {
  width: 100%;
  height: 44px;
  color: #fff;
  background: var(--ink);
  font-weight: 600;
}
.btn-primary:hover { opacity: 0.92; }
.btn-ghost {
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #fff; }
.btn-block { width: 100%; }
.btn-danger {
  color: var(--accent);
  background: var(--accent-soft);
}
.error { margin-top: 12px; color: var(--accent); font-size: 13px; }
.hint { margin-top: 12px; color: var(--ok); font-size: 13px; }

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #f5f0ea;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-mark {
  width: 40px; height: 40px; line-height: 40px; text-align: center;
  border-radius: 12px; color: #fff; font-weight: 700; background: var(--accent);
  flex-shrink: 0;
}
.sidebar-title { font-weight: 700; font-size: 15px; }
.sidebar-sub { margin-top: 2px; font-size: 12px; color: rgba(245,240,234,0.55); }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
  flex: 1;
}
.nav-item {
  border: none;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  background: transparent;
  color: rgba(245,240,234,0.72);
  cursor: pointer;
  font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.nav-on {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.sidebar-foot {
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  margin-bottom: 10px;
  padding: 0 4px;
  font-size: 12px;
  color: rgba(245,240,234,0.55);
  word-break: break-all;
}
.sidebar-foot .btn-ghost {
  color: #f5f0ea;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}
.sidebar-foot .btn-ghost:hover { background: rgba(255,255,255,0.12); }

.content {
  min-width: 0;
  padding: 24px 24px 40px;
}
.main { width: min(1100px, 100%); margin: 0 auto; }
.panel-head h2 { margin: 0 0 8px; font-size: 22px; }
.panel-desc { margin: 0 0 16px; color: var(--mute); font-size: 13px; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 16px; }
.tab {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--mute);
  cursor: pointer;
}
.tab-on { background: var(--accent); color: #fff; font-weight: 600; }
.tab-count { opacity: 0.85; margin-left: 4px; font-size: 12px; }

.store-list { display: grid; gap: 12px; }
.store-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  padding: 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.store-logo, .store-mark {
  width: 64px; height: 64px; border-radius: 14px; object-fit: cover; background: #f3efe9;
}
.store-mark {
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 22px; background: var(--accent);
}
.store-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.badge {
  display: inline-block;
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.badge-hot { color: #fff; background: var(--accent); }
.badge-active { color: var(--ok); background: var(--ok-soft); }
.badge-normal { color: var(--warn); background: var(--warn-soft); }
.badge-idle { color: var(--mute); background: #f0ece7; }
.badge-new { color: #fff; background: var(--ok); }
.badge-role-owner { color: #fff; background: #2a2420; }
.badge-role-manager { color: #3d5a80; background: #e8eef5; }
.badge-role-staff { color: #5a524c; background: #efeae4; }
.badge-role-none { color: var(--mute); background: #f0ece7; }
.store-meta { margin-top: 4px; color: var(--mute); font-size: 13px; }
.store-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.store-tags-empty {
  font-size: 12px;
  color: var(--mute);
}
.store-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #8a5a2b;
  background: linear-gradient(135deg, #f8eedf, #f3e4d0);
  border: 1px solid rgba(184, 134, 80, 0.28);
  border-radius: 999px;
}
.store-tags .btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}
.tag-modal-body {
  padding: 16px 18px 20px;
}
.tag-modal-body .panel-desc {
  margin-bottom: 12px;
}
.tag-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}
.tag-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid #e4ddd5;
  border-radius: 10px;
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}
.tag-option:hover:not(:disabled) {
  border-color: #c9a48c;
  background: #fbf8f5;
}
.tag-option-on {
  color: #7a4e24;
  background: #f6ead8;
  border-color: #c4925a;
  box-shadow: inset 0 0 0 1px rgba(196, 146, 90, 0.35);
}
.tag-option-on::before {
  content: '✓';
  font-size: 12px;
  font-weight: 700;
  color: #a0672e;
}
.tag-option:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  background: #f5f2ee;
}
.tag-modal-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.tag-modal-actions .btn-primary {
  width: 100%;
}
@media (max-width: 520px) {
  .tag-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.store-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.stat {
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  background: #f7f3ef;
}
.stat-click {
  border: none;
  width: 100%;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.stat-click:hover { background: #efe8e1; }
.stat-click:disabled {
  cursor: default;
  opacity: 0.7;
}
.stat-click:disabled:hover { background: #f7f3ef; }
.stat-num { display: block; font-weight: 700; }
.stat-label { display: block; margin-top: 2px; font-size: 11px; color: var(--mute); }

.user-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 12px;
}
.user-search .btn-primary { width: auto; padding: 0 18px; height: 42px; }
.user-summary { margin-bottom: 12px; color: var(--mute); font-size: 13px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}
.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}
.data-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--mute);
  letter-spacing: 1px;
  background: #f7f3ef;
  position: sticky;
  top: 0;
}
.data-table tbody tr:hover { background: #faf7f3; }
.data-table tbody tr.row-click { cursor: pointer; }
.data-table tbody tr.row-click:hover { background: #f3ebe4; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .muted { color: var(--mute); }
.data-table .col-actions { white-space: nowrap; }
.user-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  object-fit: cover;
  flex: 0 0 auto;
  background: #f0ece7;
}
.user-avatar-mark {
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
}
.detail-avatar-img {
  padding: 0;
  object-fit: cover;
}
.btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}
.detail-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}
.detail-actions .btn-primary { width: auto; padding: 0 16px; height: 40px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal[hidden] { display: none !important; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 36, 32, 0.45);
}
.modal-card {
  position: relative;
  width: min(480px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(42, 36, 32, 0.18);
}
.modal-card-wide {
  width: min(860px, 100%);
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 820px);
}
.store-data-body {
  padding: 0 18px 8px;
  overflow: auto;
  flex: 1;
  min-height: 120px;
}
.store-data-body .table-wrap {
  margin-top: 4px;
}
.store-data-body .data-table { min-width: 640px; }
.store-data-pager {
  margin: 0;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
  justify-content: center;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { height: 34px; padding: 0 12px; }
.user-detail { padding: 18px; }
.detail-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.detail-avatar {
  width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #fff;
  background: var(--accent);
  flex: 0 0 auto;
}
.detail-name { font-size: 18px; font-weight: 700; }
.detail-sub { margin-top: 4px; color: var(--mute); font-size: 13px; }
.detail-grid {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.detail-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--mute); font-size: 13px; }
.detail-value { word-break: break-all; }
.detail-qr {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
.detail-qr img {
  width: min(200px, 100%);
  border-radius: 8px;
  background: #fff;
}
.detail-qr-cap { margin-top: 8px; color: var(--mute); font-size: 12px; }
.detail-loading, .detail-error {
  padding: 28px 8px;
  text-align: center;
  color: var(--mute);
}
.detail-error { color: var(--accent); }
.user-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}
.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--mute);
  font-size: 13px;
}
.pager-size select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.pager-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pager-nums {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.pager-num {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
}
.pager-num:hover { background: #f7f3ef; }
.pager-num-on {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
  font-weight: 600;
}
.pager-num-on:hover { background: var(--ink); }
.pager-ellipsis {
  width: 24px;
  text-align: center;
  color: var(--mute);
}

.admin-form {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr auto;
  gap: 10px;
  margin-bottom: 16px;
}
.admin-form .btn-primary { width: auto; padding: 0 18px; height: 42px; }
.panel-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.panel-head-row .panel-desc { margin-bottom: 0; }
.field-check span { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.link-num {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  cursor: pointer;
}
.link-num:hover { text-decoration: underline; }
#promo-table code {
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #f3efe9;
}
.promo-form {
  max-width: none;
  padding: 18px 20px 22px;
  box-sizing: border-box;
}
.audit-form { max-width: 560px; }
.audit-switch {
  padding: 14px 16px;
  border-radius: 12px;
  background: #f5f1ec;
  margin-bottom: 8px;
}
.audit-hint {
  margin: 0 0 16px;
  line-height: 1.65;
}
.promo-form .about-grid {
  margin-bottom: 4px;
}
.promo-form .btn-primary {
  width: 100%;
  margin-top: 8px;
}
.admin-list { display: grid; gap: 10px; }
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.admin-phone { font-weight: 700; }
.admin-note { color: var(--mute); font-size: 13px; margin-top: 4px; }

.pwd-form { max-width: 360px; }
.pwd-form .btn-primary { margin-top: 8px; }

.stats-block {
  margin-bottom: 22px;
}
.stats-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.stats-cards-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stats-card {
  padding: 16px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.stats-card-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}
.stats-card-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--mute);
}
.stats-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 24px;
  margin-bottom: 8px;
  align-items: start;
}
.stats-section { margin-top: 4px; min-width: 0; }
.stats-h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}
.stats-table-wrap {
  overflow: visible;
}
.stats-table {
  min-width: 0 !important;
  table-layout: fixed;
  width: 100%;
}
.stats-table th,
.stats-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 10px 10px;
}
.stats-table .col-rank {
  width: 44px;
  text-align: center;
}
.stats-table th.col-num,
.stats-table td.col-num {
  width: 72px;
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  overflow: visible;
}
.stats-table .col-store {
  width: auto;
}
.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--mute);
  background: #f0ece7;
}
.rank-1 { color: #fff; background: #c4925a; }
.rank-2 { color: #fff; background: #8a8078; }
.rank-3 { color: #fff; background: #a67c52; }
.top-name {
  font-weight: 600;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-bar {
  height: 6px;
  border-radius: 999px;
  background: #f0ece7;
  overflow: hidden;
}
.top-bar span {
  display: block;
  height: 100%;
  max-width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d4a574, #a8483a);
}
.data-table td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.empty-cell { text-align: center; color: var(--mute); padding: 24px 12px !important; }

.stats-trends {
  padding: 14px 12px 10px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  min-height: 160px;
}
.trend-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--mute);
}
.trend-legend span { display: inline-flex; align-items: center; gap: 6px; }
.trend-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.trend-dot-b { background: #a8483a; }
.trend-dot-s { background: #d4a574; }
.trend-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
}
.trend-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.trend-stack {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
}
.trend-bar {
  width: 8px;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
}
.trend-bar-b { background: #a8483a; }
.trend-bar-s { background: #d4a574; }
.trend-day {
  margin-top: 6px;
  font-size: 11px;
  color: var(--mute);
}

@media (max-width: 1100px) {
  .stats-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .stats-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .stats-cards, .stats-cards-3 { grid-template-columns: 1fr 1fr; }
}

.about-form { max-width: 720px; }
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}
.about-sec-title {
  margin: 8px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 2px;
}
.about-form .btn-primary { margin-top: 4px; }

@media (max-width: 720px) {
  .about-grid { grid-template-columns: 1fr; }
}

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--mute);
  background: var(--surface);
  border-radius: 14px;
}
.empty-cell {
  padding: 40px 16px !important;
  text-align: center;
  color: var(--mute);
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  .sidebar-brand { border: none; padding: 0; }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    margin: 0;
    flex: 1 1 100%;
  }
  .sidebar-foot {
    border: none;
    padding: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .sidebar-user { margin: 0; }
  .sidebar-foot .btn-ghost { width: auto; }
  .content { padding: 16px; }
  .admin-form, .user-search { grid-template-columns: 1fr; }
  .store-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
