:root {
  --adm-side: #0b1a33;
  --adm-side-2: #122544;
  --adm-blue: #1a56e8;
  --adm-bg: #f0f3f8;
  --adm-line: #e4eaf3;
  --adm-text: #1a2740;
  --adm-muted: #6b7a94;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body.adm {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--adm-text);
  background: var(--adm-bg);
}
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; }

.adm-app { display: flex; min-height: 100vh; }
.adm-aside {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--adm-side), #081426);
  color: #fff;
  display: flex;
  flex-direction: column;
}
.adm-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.adm-brand img { width: 36px; height: 36px; border-radius: 8px; }
.adm-brand b { display: block; font-size: 15px; }
.adm-brand small { display: block; font-size: 11px; color: rgba(255,255,255,.5); font-weight: 400; letter-spacing: .08em; }
.adm-menu { padding: 14px 10px; flex: 1; }
.adm-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,.72);
  font-size: 14px;
  margin-bottom: 4px;
}
.adm-menu a:hover, .adm-menu a.is-on { background: rgba(255,255,255,.1); color: #fff; }
.adm-aside-home {
  display: none;
  margin: 0 10px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,.72);
  font-size: 14px;
}
.adm-aside-home:hover { background: rgba(255,255,255,.1); color: #fff; }
.adm-aside-foot { padding: 16px; font-size: 12px; color: rgba(255,255,255,.4); }
.adm-nav-toggle, .adm-nav-mask { display: none; }

.adm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adm-top {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--adm-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  gap: 12px;
}
.adm-top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.adm-crumb { font-size: 14px; color: var(--adm-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-crumb strong { color: var(--adm-text); }
.adm-user { display: flex; align-items: center; gap: 12px; font-size: 13px; flex-shrink: 0; }
.adm-user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-user .tag {
  background: #edf3ff;
  color: var(--adm-blue);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 650;
}
.adm-user .tag.admin { background: #fff4d6; color: #8a6a00; }
.adm-body { padding: 22px; flex: 1; }
.adm-card {
  background: #fff;
  border: 1px solid var(--adm-line);
  border-radius: 12px;
  padding: 20px;
}
.adm-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.adm-toolbar h2 { margin: 0; font-size: 18px; }
.adm-toolbar p { margin: 4px 0 0; color: var(--adm-muted); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 650;
  touch-action: manipulation;
}
.btn-primary { background: var(--adm-blue); color: #fff; }
.btn-ghost { background: #fff; color: var(--adm-text); border: 1px solid var(--adm-line); }
.btn-danger { background: #c62828; color: #fff; }
.btn-sm { padding: 5px 10px; }

.flash { border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.flash.ok { background: #e8f8f0; color: #0b6b45; }
.flash.error { background: #fdecec; color: #b42318; }

.mer-table { width: 100%; border-collapse: collapse; }
.mer-table th, .mer-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--adm-line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}
.mer-table th { background: #f7f9fc; color: var(--adm-muted); font-weight: 650; }
.mer-logo { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #edf3ff; }
.logo-preview { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; margin-top: 8px; background: #edf3ff; }
.empty { text-align: center; color: var(--adm-muted); padding: 48px 16px; }
.status-on, .status-off {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}
.status-on { background: #e8f8f0; color: #0b6b45; }
.status-off { background: #fdecec; color: #b42318; }
.muted { color: var(--adm-muted); font-size: 13px; }
.mer-table td:last-child { white-space: nowrap; }

.adm-modal[hidden] { display: none; }
.adm-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.adm-modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 36, .45);
}
.adm-modal-box {
  position: relative;
  width: min(380px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 22px 22px 20px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(16, 32, 64, .18);
}
.adm-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--adm-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.adm-modal-close:hover { background: #f0f3f8; color: var(--adm-text); }
.adm-modal-box.is-wide {
  width: min(440px, 100%);
  text-align: left;
}
.adm-modal-box.is-form {
  width: min(520px, 100%);
  text-align: left;
}
.adm-modal-box.is-form h3 { margin: 0 28px 16px 0; font-size: 18px; }
.adm-modal-box.is-form .form-row { margin-bottom: 12px; }
.adm-modal-box.is-form .form-actions { margin-top: 4px; }
.adm-modal-box.is-wide h3,
.adm-modal-box.is-wide .adm-modal-sub { text-align: center; }
.adm-modal-box.is-wide .form-row { margin-bottom: 12px; }
.inline-field { display: flex; gap: 8px; align-items: center; }
.inline-field input { flex: 1; min-width: 0; }
.adm-modal-err { color: #b42318; font-size: 13px; margin: 8px 0 0; }
.test-qr { margin-top: 16px; text-align: center; }
.adm-modal-sub { margin: 0 0 16px; color: var(--adm-text); font-weight: 650; }
.adm-modal-box img {
  width: 220px;
  height: auto;
  display: block;
  margin: 0 auto;
  background: #f7f9fc;
  border-radius: 8px;
}
.adm-modal-hint { margin: 14px 0 6px; color: var(--adm-muted); font-size: 13px; }
.adm-modal-link {
  margin: 0 0 16px;
  color: var(--adm-muted);
  font-size: 12px;
  word-break: break-all;
  line-height: 1.5;
}

.row-ops { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-row { margin-bottom: 0; }
.form-row.full { grid-column: 1 / -1; }
.form-row label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 6px; }
.token-cell, .url-cell { word-break: break-all; white-space: normal; max-width: 220px; }
.token-cell { white-space: nowrap; }
.token-cell code { margin-right: 6px; }
.mer-table code { font-size: 12px; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--adm-line);
  border-radius: 6px;
  background: #fff;
  color: var(--adm-muted);
  cursor: pointer;
  vertical-align: middle;
}
.copy-btn:hover { color: var(--adm-blue); border-color: #c5d4f5; background: #f5f8ff; }
.copy-btn.is-copied { color: #0b6b45; border-color: #b7e4c7; background: #e8f8f0; }
.pick-table .weight-input {
  width: 72px;
  height: 34px;
  border: 1px solid var(--adm-line);
  border-radius: 8px;
  padding: 0 8px;
}
.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="url"],
.form-row input[type="number"],
.form-row input[type="file"],
.form-row select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--adm-line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  background: #fff;
}
.date-field { position: relative; }
.date-field input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--adm-line);
  border-radius: 8px;
  padding: 0 36px 0 12px;
  font-size: 14px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7a94' stroke-width='2'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 10h18M8 3v4M16 3v4'/%3E%3C/svg%3E") no-repeat right 10px center;
  cursor: pointer;
}
.date-panel {
  display: none;
  position: absolute;
  top: 44px;
  left: 0;
  z-index: 40;
  width: 280px;
  background: #fff;
  border: 1px solid var(--adm-line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(16, 32, 64, .12);
  padding: 10px;
}
.date-field.is-open .date-panel { display: block; }
.date-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.date-panel-head strong { font-size: 14px; }
.date-nav {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: #f5f8ff;
  cursor: pointer;
  color: var(--adm-text);
}
.date-week, .date-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.date-week span { font-size: 12px; color: var(--adm-muted); padding: 4px 0; }
.date-day {
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}
.date-day:hover { background: #edf3ff; }
.date-day.is-today { color: var(--adm-blue); font-weight: 650; }
.date-day.is-on { background: var(--adm-blue); color: #fff; }
.date-panel-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}
.date-panel-foot button {
  border: 0;
  background: transparent;
  color: var(--adm-blue);
  cursor: pointer;
  font-size: 13px;
}
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 12px 14px;
  align-items: end;
  margin-bottom: 16px;
}
.filter-actions { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; }
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--adm-muted);
  font-size: 13px;
  flex-wrap: wrap;
}
.pager-nums { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-on { background: var(--adm-blue); color: #fff; cursor: default; }
.pager-ellipsis { color: var(--adm-muted); padding: 0 4px; }
.area-select-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; grid-column: 1 / -1; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.detail-item span { display: block; color: var(--adm-muted); font-size: 12px; margin-bottom: 6px; }
.detail-item b { font-size: 14px; font-weight: 650; word-break: break-all; }
.detail-item.full { grid-column: 1 / -1; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff;
  border: 1px solid var(--adm-line);
  border-radius: 12px;
  padding: 18px;
}
.stat b { display: block; font-size: 26px; color: var(--adm-blue); letter-spacing: -0.02em; }
.stat span { color: var(--adm-muted); font-size: 13px; }
.stat em { display: block; margin-top: 8px; font-style: normal; font-size: 12px; color: var(--adm-text); }
.stat-rate-row { grid-template-columns: 1fr 1fr; }
.chart-card { margin-bottom: 18px; }
.heat-card {
  margin-bottom: 18px;
  background: linear-gradient(180deg, #0e1d38, #0b1a33);
  border-color: #1a2e52;
  color: #d6e4f7;
}
.heat-card .adm-toolbar h2 { color: #fff; }
.heat-card .adm-toolbar p { color: rgba(214, 228, 247, .62); }
.heat-layout {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
  min-height: 420px;
}
.heat-map { min-height: 420px; }
.heat-rank {
  margin: 0;
  padding: 8px 0 0;
  list-style: none;
}
.heat-rank li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
}
.heat-rank li:last-child { border-bottom: 0; }
.heat-rank .n {
  color: rgba(255,255,255,.38);
  font-variant-numeric: tabular-nums;
}
.heat-rank .n.is-top { color: #ffd166; font-weight: 700; }
.heat-rank .p { color: #fff; }
.heat-rank .a {
  color: #8ec5ff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.heat-rank small {
  display: block;
  color: rgba(214, 228, 247, .45);
  font-size: 11px;
  margin-top: 2px;
}
.heat-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: rgba(214, 228, 247, .55);
  font-size: 14px;
  pointer-events: none;
}
.heat-empty.is-on { display: flex; z-index: 2; }
.chart-legend { display: flex; gap: 16px; font-size: 13px; color: var(--adm-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend span::before {
  content: "";
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
}
.lg-amt { color: #1a56e8; }
.lg-cnt { color: #0b9f6e; }
.chart-wrap { position: relative; height: 280px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; }
.chart-wrap-sm { height: 200px; }
.user-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.user-pick label { font-size: 13px; color: var(--adm-muted); }
.user-pick select {
  min-width: 180px;
  height: 36px;
  border: 1px solid var(--adm-line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}
.merchant-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.merchant-chart {
  border: 1px solid var(--adm-line);
  border-radius: 10px;
  padding: 14px;
  background: #fbfcfe;
}
.merchant-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.merchant-chart-head strong { display: block; font-size: 14px; }
.merchant-chart-head span { display: block; color: var(--adm-muted); font-size: 12px; margin-top: 2px; }
.merchant-chart-sum { font-size: 12px; color: var(--adm-muted); white-space: nowrap; }
.merchant-chart-sum b { color: var(--adm-blue); font-size: 14px; }
.chart-tip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: #122544;
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(11, 26, 51, .18);
}

.adm-login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.adm-login-brand {
  background:
    linear-gradient(160deg, rgba(11,26,51,.88), rgba(26,86,232,.55)),
    url("/home/static/img/office.jpg") center / cover no-repeat;
  color: #fff;
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.adm-login-brand img { width: 48px; height: 48px; border-radius: 12px; margin-bottom: 18px; }
.adm-login-brand h1 { margin: 0 0 8px; font-size: 32px; }
.adm-login-brand p { margin: 0; color: rgba(255,255,255,.78); max-width: 420px; }
.adm-login-form {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: #fff;
}
.adm-login-form .box { width: min(380px, 100%); }
.adm-login-form h2 { margin: 0 0 6px; }
.adm-login-form .sub { color: var(--adm-muted); margin: 0 0 22px; font-size: 14px; }
.adm-login-form .form-row { margin-bottom: 14px; }

@media (max-width: 1100px) {
  .stat-row, .merchant-chart-grid { grid-template-columns: 1fr 1fr; }
  .heat-layout { grid-template-columns: 1fr; min-height: 0; }
  .heat-map { min-height: 360px; }
}
@media (max-width: 900px) {
  html, body.adm { overflow-x: hidden; }
  body.adm { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  body.adm-nav-open { overflow: hidden; }
  .adm-app { min-height: 100dvh; }
  .adm-nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    margin-left: -6px;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
  }
  .adm-nav-toggle span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: var(--adm-text);
  }
  .adm-nav-mask {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(8, 20, 38, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  body.adm-nav-open .adm-nav-mask { opacity: 1; pointer-events: auto; }
  .adm-aside {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 90;
    width: min(280px, 86vw);
    transform: translateX(-100%);
    transition: transform .2s ease;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.adm-nav-open .adm-aside { transform: translateX(0); }
  .adm-menu a { min-height: 44px; }
  .adm-aside-home { display: block; }
  .adm-home-link { display: none; }
  .adm-top {
    height: auto;
    min-height: 52px;
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
    gap: 8px;
  }
  .adm-crumb {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }
  .adm-user { gap: 8px; }
  .adm-user-name { max-width: 72px; }
  .adm-body { padding: 12px; }
  .adm-card { padding: 14px; }
  .adm-toolbar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
  }
  .adm-toolbar .btn,
  .adm-toolbar > a,
  .adm-toolbar > div:last-child { flex-shrink: 0; }
  .adm-toolbar h2 { font-size: 16px; }
  .stat { padding: 14px; }
  .stat b { font-size: 20px; word-break: break-all; }
  .form-grid, .area-select-row, .detail-grid, .filter-bar, .merchant-chart-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .stat-row.stat-rate-row { grid-template-columns: 1fr 1fr; }
  .filter-actions { width: 100%; }
  .filter-actions .btn { flex: 1; min-height: 40px; }
  .form-row input[type="text"],
  .form-row input[type="password"],
  .form-row input[type="url"],
  .form-row input[type="number"],
  .form-row input[type="file"],
  .form-row select,
  .date-field input {
    font-size: 16px;
    height: 44px;
  }
  .user-pick { width: 100%; }
  .user-pick select { min-width: 0; width: 100%; flex: 1; font-size: 16px; }
  .toolbar-right { width: 100%; justify-content: flex-start; }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 0 14px;
  }
  .mer-table { min-width: 640px; }
  .pick-table { min-width: 0; }
  .mer-table th, .mer-table td { padding: 10px 8px; }
  .mer-table td:last-child { white-space: normal; }
  .mer-table td:last-child .btn,
  .mer-table td:last-child form { margin: 4px 6px 0 0; display: inline-flex; }
  .token-cell { white-space: normal; max-width: none; }
  .url-cell { max-width: none; }
  .chart-wrap { height: 220px; }
  .chart-wrap-sm { height: 168px; }
  .chart-legend { flex-wrap: wrap; gap: 10px; }
  .heat-layout { min-height: 0; }
  .heat-map { min-height: 260px; }
  .heat-card .adm-toolbar p { display: none; }
  .date-panel { width: min(280px, calc(100vw - 48px)); max-width: 100%; left: 0; right: auto; }
  .merchant-chart-head { flex-wrap: wrap; }
  .merchant-chart-sum { white-space: normal; }
  .adm-modal {
    padding: 0;
    align-items: flex-end;
  }
  .adm-modal-box,
  .adm-modal-box.is-wide,
  .adm-modal-box.is-form {
    width: 100%;
    max-height: min(90vh, 100%);
    overflow: auto;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }
  .adm-modal-box img {
    width: min(220px, 72vw);
    height: auto;
  }
  .inline-field { flex-wrap: wrap; }
  .inline-field .btn { width: 100%; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { min-height: 44px; }
  .pager { align-items: flex-start; }
  .pager-nums { width: 100%; }
  .adm-login { grid-template-columns: 1fr; min-height: 100dvh; }
  .adm-login-form { order: -1; padding: 28px 20px calc(28px + env(safe-area-inset-bottom)); }
  .adm-login-brand { min-height: 148px; padding: 24px 20px; }
  .adm-login-brand h1 { font-size: 22px; }
  .adm-login-form .btn { min-height: 44px; width: 100%; }
}
@media (max-width: 480px) {
  .stat-row { gap: 8px; }
  .adm-user .tag { display: none; }
  .mer-table { min-width: 560px; }
}
