:root {
  --bg-1: #ddf3fc;
  --bg-2: #d4f0fc;
  --bg-3: #ffeaf1;
  --card: #ffffff;
  --ink: #2f5570;
  --ink-soft: #3c5f77;
  --muted: #7e96a8;
  --line: #dceef7;
  --line-strong: #cbe7f4;
  --accent: #63b3e6;
  --accent-deep: #2f6d8e;
  --accent-soft: #e5f6fe;
  --green: #57c08a;
  --red: #d05a72;
  --red-soft: #fdeef2;
  --amber: #b07a2a;
  --pink: #ffcbd6;
  --lavender: #a98bf0;
  --shadow: 0 16px 36px rgba(47, 109, 142, 0.10);
  --shadow-soft: 0 8px 20px rgba(47, 109, 142, 0.07);
  --radius: 20px;
  --radius-sm: 13px;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background-color: var(--bg-1);
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
}

body::before {
  width: 560px;
  height: 560px;
  left: -190px;
  top: -210px;
  background: #cdeffc;
}

body::after {
  width: 460px;
  height: 460px;
  right: -160px;
  bottom: -200px;
  background: #ffe3ec;
  opacity: 0.75;
}

#login-view,
#app-view { position: relative; z-index: 1; }

body.modal-open { overflow: hidden; }

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: rgba(59, 159, 214, 0.09);
  border: 1px solid rgba(59, 159, 214, 0.14);
  color: var(--accent-deep);
  border-radius: 7px;
  padding: 1px 6px;
}

h1, h2, h3, p { margin: 0; }

h1 { font-size: 21px; letter-spacing: 0.2px; }
h2 { font-size: 17px; letter-spacing: 0.2px; }
h3 { font-size: 18px; }

button, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid rgba(59, 159, 214, 0.35);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- 品牌 */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  color: var(--ink);
  font-size: 25px;
  font-weight: 800;
  background: #cdeffc;
  border: 2px solid #cdeffc;
  box-shadow: 0 6px 14px rgba(47, 109, 142, 0.16);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.brand.small .brand-mark { width: 48px; height: 48px; border-radius: 15px; font-size: 19px; }
.brand h1 { color: var(--ink); }
.brand p { color: var(--muted); font-size: 12.5px; letter-spacing: 0.4px; }
.brand.small h1 { font-size: 17px; }
.brand.small p { font-size: 11.5px; }

/* ---------------------------------------------------------------- 登录 */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
}

.login-card {
  width: min(430px, 100%);
  background: #ffffff;
  border: 1px solid #e6f4fb;
  border-radius: 30px;
  box-shadow: 0 26px 64px rgba(47, 109, 142, 0.14);
  padding: 34px 32px 28px;
}

.login-card .brand { margin-bottom: 28px; }
.login-card h1 { font-size: 24px; }
.login-card .brand-mark { width: 56px; height: 56px; font-size: 24px; }

.stack { display: flex; flex-direction: column; gap: 15px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }

.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fbfdff;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.input::placeholder { color: #9fb6c6; }
.input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(59, 159, 214, 0.14);
}

.login-hint {
  margin-top: 20px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;
  text-align: center;
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 16px;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.btn.primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 7px 16px rgba(99, 179, 230, 0.24);
}

.btn.primary:hover { background: #4ea6db; box-shadow: 0 9px 20px rgba(99, 179, 230, 0.30); }

.btn.ghost {
  color: var(--ink-soft);
  background: #ffffff;
  border-color: var(--line-strong);
}

.btn.ghost:hover { background: #fff; border-color: var(--accent); color: var(--accent-deep); }

.btn.danger {
  color: #fff;
  background: #e07b8e;
  box-shadow: 0 7px 16px rgba(208, 90, 114, 0.20);
}

.btn.danger:hover { background: #d05a72; }

.btn.small { padding: 6px 12px; font-size: 12.5px; border-radius: 10px; }
.btn.tiny { padding: 5px 10px; font-size: 12px; border-radius: 9px; font-weight: 600; }
.btn.block { width: 100%; padding: 12px 16px; }

.btn.primary-soft {
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-color: #c9ebfa;
}
.btn.primary-soft:hover { background: #d8f2fd; }

.btn.danger-soft {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f8d8e0;
}
.btn.danger-soft:hover { background: #fbe3e9; }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { color: var(--red); border-color: #f3c6d0; background: var(--red-soft); }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 26px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-left: auto;
  background: #eaf8fe;
  border: 1px solid #d7eef9;
  border-radius: 15px;
}

.nav-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 16px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.nav-btn:hover { color: var(--ink); }
.nav-btn.active {
  color: var(--accent-deep);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #d7eef9;
}

/* ---------------------------------------------------------------- 布局 */
.content {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 26px 60px;
}

.tab { animation: fade-in 0.22s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.stat {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid #e6f4fb;
  border-top: 4px solid #cdeffc;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 20px 15px;
}

.stat:nth-child(1) { border-top-color: #cdeffc; }
.stat:nth-child(2) { border-top-color: #daf6e5; }
.stat:nth-child(3) { border-top-color: #daf6e5; }
.stat:nth-child(4) { border-top-color: #ffcbd6; }

.stat span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat strong { display: block; margin: 4px 0 2px; font-size: 30px; letter-spacing: -0.5px; line-height: 1.1; }
.stat small { color: #93aab9; font-size: 11.5px; }

.plus { color: var(--green) !important; }
.minus { color: var(--red) !important; }

.meta-line {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 2px 18px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid #e6f4fb;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px 18px;
  min-width: 0;
}

.panel + .panel { margin-top: 18px; }
.two-col > .panel + .panel { margin-top: 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head h2::before {
  content: "";
  width: 9px;
  height: 18px;
  border-radius: 6px;
  background: var(--accent);
  flex: none;
}

#tab-ledger .panel-head h2::before { background: var(--green); }
#tab-perms .panel-head h2::before { background: #ec7fbc; }
#tab-settings .panel-head h2::before { background: #f0b45e; }

.panel-head.sub {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.toolbar { display: flex; align-items: center; gap: 8px; }
.input.search { width: 200px; padding: 7px 12px; font-size: 13px; border-radius: 10px; }

.muted { color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.panel > .muted { margin-top: 10px; }

.notice {
  border: 1px dashed #f0d9ae;
  background: #fffaef;
  color: #8a6424;
  border-radius: 13px;
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.7;
}

.empty {
  margin-top: 14px;
  padding: 18px;
  text-align: center;
  color: #93aab9;
  font-size: 13px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: #fbfdff;
}

.empty-cell {
  text-align: center !important;
  color: #93aab9;
  padding: 22px 10px !important;
}

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; border-radius: 14px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  color: #8aa3b4;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid #eef7fb;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fcff; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.actions, td.actions, td.actions-cell { text-align: right; white-space: nowrap; }
td.actions-cell .btn { margin-left: 6px; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12px; }
.sub { color: #93aab9; font-size: 11.5px; margin-top: 1px; }
.reason { color: var(--ink-soft); max-width: 220px; }

td.delta { font-weight: 700; font-variant-numeric: tabular-nums; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 700;
}

/* ---------------------------------------------------------------- 排行 */
.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rank-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 12px;
}

.rank-item:hover { background: #f8fcff; }

.rank-no {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: #eef8fd;
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 800;
}

.rank-item:nth-child(1) .rank-no { background: #fff3d6; color: #b07a2a; }
.rank-item:nth-child(2) .rank-no { background: #eef1f5; color: #708090; }
.rank-item:nth-child(3) .rank-no { background: #fdeede; color: #b56a54; }

.rank-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.rank-qq { color: #9fb6c6; font-family: var(--mono); font-size: 11px; margin-left: 6px; }
.rank-balance { color: var(--accent-deep); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 权限 */
.owner-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border-radius: 16px;
  background: #f2fbff;
  border: 1px solid #d8f0fb;
}

.avatar {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  font-weight: 800;
  font-size: 19px;
  background: #63b3e6;
  box-shadow: 0 6px 14px rgba(99, 179, 230, 0.22);
}

.owner-info { display: flex; flex-direction: column; min-width: 0; }
.owner-info strong { font-size: 15px; }
.owner-info span { color: var(--muted); }

.owner-pill {
  margin-left: auto;
  background: #fff;
  border: 1px solid #cdeaf7;
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.inline-form { display: flex; gap: 9px; }
.inline-form .input { flex: 1; }

.target-form { margin: 12px 0 2px; }
.target-form .input { max-width: 320px; }

@media (max-width: 640px) {
  .target-form .input { max-width: none; }
}

/* ---------------------------------------------------------------- 表单 */
.form-error {
  color: #b6445c;
  background: var(--red-soft);
  border: 1px solid #f6d3dc;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- 弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(37, 73, 94, 0.32);
  animation: fade-in 0.18s ease;
}

.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(16, 45, 65, 0.3);
  padding: 24px;
  animation: pop-in 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h3 { margin-bottom: 2px; }
.modal-head .muted { margin-top: 2px; }

.adjust-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  margin-bottom: 16px;
  border-radius: 13px;
  background: #f4fbff;
  border: 1px solid #dcf0fa;
  color: var(--muted);
  font-size: 13px;
}

.adjust-current strong { color: var(--accent-deep); font-size: 16px; font-variant-numeric: tabular-nums; }

.modal-card .stack { gap: 13px; }

.segmented {
  display: flex;
  gap: 5px;
  padding: 4px;
  border-radius: 14px;
  background: #f1f9fd;
  border: 1px solid #e2f2fa;
  margin-bottom: 14px;
}

.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.seg-btn.active {
  background: #fff;
  color: var(--accent-deep);
  box-shadow: 0 3px 10px rgba(47, 109, 142, 0.13);
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: -4px 0 2px; }

.chip {
  border: 1px solid #d8edf8;
  background: #f8fcff;
  color: var(--accent-deep);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.chip:hover { background: var(--accent-soft); border-color: #bfe7f8; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 6px;
}

.confirm p { color: var(--ink-soft); margin: 6px 0 18px; }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  max-width: min(520px, calc(100vw - 36px));
  padding: 10px 18px;
  border-radius: 999px;
  background: #22445c;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 14px 34px rgba(16, 45, 65, 0.28);
  transition: opacity 0.2s, transform 0.2s;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #b03a52; }

/* ---------------------------------------------------------------- 其他 */
.data-panel { margin-top: 18px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfe5f1; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; gap: 10px 14px; padding: 10px 18px; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .nav-btn { flex: 1; padding: 7px 10px; }
  .content { padding: 18px 16px 48px; }
}

@media (max-width: 640px) {
  /* 点券表改为卡片：避免小屏横向截断操作按钮 */
  .points-table thead { display: none; }

  .points-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    padding: 12px 2px;
    border-bottom: 1px solid #eef7fb;
  }

  .points-table tbody td { border: 0; padding: 1px 0; }

  .points-table td:nth-child(1) { grid-column: 1; font-weight: 700; }
  .points-table td:nth-child(2) { grid-column: 1; }

  .points-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    font-size: 18px;
  }

  .points-table td:nth-child(4) { display: none; }

  .points-table td:nth-child(5) {
    grid-column: 1 / -1;
    display: flex;
    gap: 6px;
    margin-top: 8px;
    text-align: left;
  }

  .points-table td.actions-cell .btn { flex: 1; margin-left: 0; }

  .recent-table th:nth-child(5),
  .recent-table td:nth-child(5),
  .ledger-table th:nth-child(5),
  .ledger-table td:nth-child(5),
  .ledger-table th:nth-child(6),
  .ledger-table td:nth-child(6) { display: none; }

  .recent-table th:nth-child(1),
  .recent-table td:nth-child(1),
  .ledger-table th:nth-child(1),
  .ledger-table td:nth-child(1) { font-size: 11px; }
}

@media (max-width: 560px) {
  .stat strong { font-size: 25px; }
  .panel { padding: 16px 15px; }
  .panel-head { flex-wrap: wrap; }
  .input.search { width: 100%; }
  .toolbar { width: 100%; }
  .toolbar .input { flex: 1; }
  .login-card { padding: 26px 22px 22px; border-radius: 24px; }
  .brand.small h1 { font-size: 15px; }
  .brand.small p { display: none; }
}
