:root {
  --bg: #f3eee4;
  --bg-2: #ebe4d6;
  --panel: #fffdf8;
  --panel-2: #f7f1e7;
  --line: #e2d8c8;
  --line-soft: #eee6d8;
  --ink: #2c2416;
  --text: #2c2416;
  --dim: #6f6456;
  --faint: #9a8d7c;
  --accent: #b5471d;
  --accent-hot: #c85a2e;
  --accent-soft: rgba(181, 71, 29, 0.1);
  --forest: #1f3d34;
  --pos: #2d7a4f;
  --warn: #a15c12;
  --neg: #b42318;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(44, 36, 22, 0.04), 0 10px 28px -18px rgba(44, 36, 22, 0.18);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC",
    "Noto Serif SC", Georgia, serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei",
    sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 90% 50% at 10% -10%, rgba(181, 71, 29, 0.08), transparent 55%),
    radial-gradient(ellipse 70% 40% at 100% 0%, rgba(31, 61, 52, 0.06), transparent 50%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.28;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.17  0 0 0 0 0.14  0 0 0 0 0.09  0 0 0 0.45 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- app shell ---------- */

.shell { display: flex; min-height: 100vh; width: 100%; position: relative; z-index: 1; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: #fbf6ee;
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.03em;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff8f0;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 14px -8px var(--accent);
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--dim);
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}

.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-split {
  height: 1px;
  background: var(--line);
  margin: 10px 10px 8px;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.who {
  padding: 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--dim);
  word-break: break-all;
}

.main { flex: 1; min-width: 0; width: 100%; padding: 30px 38px 64px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.page-head h1 { font-size: 26px; }
.page-head p { margin: 6px 0 0; color: var(--dim); font-size: 13px; font-family: var(--sans); }

/* ---------- primitives ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 18px 20px; }

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

.stat { padding: 16px 18px; }
.stat-label {
  color: var(--faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.stat-value {
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  margin-top: 7px;
  letter-spacing: -0.03em;
}
.stat-sub { color: var(--faint); font-size: 12px; margin-top: 3px; }

.pos { color: var(--pos); }
.warn { color: var(--warn); }
.neg { color: var(--neg); }
.dim { color: var(--dim); }
.faint { color: var(--faint); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.btn:hover { border-color: #cbbca8; background: var(--panel-2); }

.btn-primary {
  background: var(--accent);
  color: #fff8f0;
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 8px 18px -12px var(--accent);
}
.btn-primary:hover { background: var(--accent-hot); }

.btn-quiet { background: transparent; color: var(--dim); }
.btn-quiet:hover { color: var(--text); }

.btn-danger { background: transparent; color: var(--neg); border-color: transparent; }
.btn-danger:hover { background: rgba(180, 35, 24, 0.08); border-color: rgba(180, 35, 24, 0.2); }

.balance-hero {
  background: var(--accent);
  border-color: transparent;
  padding: 22px 24px;
  box-shadow: 0 10px 28px -16px var(--accent);
}
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.copy-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.copy-row input { flex: 1; }
.copy-row .btn { flex-shrink: 0; white-space: nowrap; }

.who-card {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
}
.who-avatar,
.avatar-lg {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent);
  flex-shrink: 0;
}
.avatar-lg { width: 88px; height: 88px; }

.avatar-edit {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

input[type="file"] {
  padding: 8px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { min-height: 140px; resize: vertical; line-height: 1.5; }

label {
  display: block;
  font-size: 12.5px;
  color: var(--dim);
  margin-bottom: 6px;
  font-weight: 500;
}

.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 6px; }

/* ---------- table ---------- */

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  font-weight: 600;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(181, 71, 29, 0.04); }

.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.empty { padding: 44px 20px; text-align: center; color: var(--faint); font-size: 13px; }

/* ---------- misc ---------- */

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  color: var(--dim);
}
.tag-ok { color: var(--pos); border-color: rgba(45, 122, 79, 0.28); background: rgba(45, 122, 79, 0.08); }
.tag-err { color: var(--neg); border-color: rgba(180, 35, 24, 0.25); background: rgba(180, 35, 24, 0.07); }
.tag-warn { color: var(--warn); border-color: rgba(161, 92, 18, 0.28); background: rgba(161, 92, 18, 0.08); }

.banner {
  border-radius: var(--radius);
  padding: 13px 16px;
  font-size: 13px;
  margin-bottom: 18px;
  border: 1px solid;
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.banner-warn { border-color: #ead2a8; background: #faf0dc; color: #7a4e10; }
.banner-ok { border-color: #c5e0cf; background: #e8f4ec; color: #215c38; }
.banner-err { border-color: #f0c4bc; background: #fdecea; color: #8f2a22; }

.keybox {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
  margin: 12px 0 4px;
}

.chart { display: flex; align-items: flex-end; gap: 3px; height: 92px; padding: 0 2px; }
.bar {
  flex: 1;
  min-width: 3px;
  background: linear-gradient(180deg, var(--accent-hot), rgba(181, 71, 29, 0.28));
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: opacity 0.12s;
}
.bar:hover { opacity: 0.7; }
.bar-zero { background: #e4d9c8; min-height: 3px; }
.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--faint);
  margin-top: 9px;
  font-family: var(--mono);
}

/* ---------- auth pages ---------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.auth-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(380px, 520px);
  position: relative;
  z-index: 1;
}

.auth-hero {
  background: #b5471d;
  color: #fff8f0;
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-hero::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -120px;
  bottom: -80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 232, 204, 0.22), transparent 68%);
}

.auth-hero .brand { padding: 0; color: #fff8f0; }
.auth-hero .brand-mark { background: #fff8f0; color: #b5471d; box-shadow: none; }
.auth-hero h1 {
  font-size: 40px;
  line-height: 1.15;
  max-width: 12em;
  position: relative;
}
.auth-hero p {
  margin: 16px 0 0;
  color: rgba(255, 248, 240, 0.82);
  font-size: 15px;
  max-width: 28em;
  position: relative;
  font-family: var(--sans);
}
.auth-hero-foot {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 248, 240, 0.55);
  position: relative;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 40px 32px;
}

.auth-card { width: 100%; max-width: 396px; }

.auth-head { text-align: center; margin-bottom: 26px; }
.auth-head .brand { justify-content: center; margin-bottom: 16px; font-size: 18px; }
.auth-head h1 { font-size: 24px; }
.auth-head p { color: var(--dim); margin: 7px 0 0; font-size: 13px; font-family: var(--sans); }

.auth-foot {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--dim);
}
.auth-foot a { color: var(--accent); font-weight: 600; }
.auth-foot a:hover { text-decoration: underline; }

.captcha-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.captcha-refresh {
  flex: 0 0 168px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f0e4;
  cursor: pointer;
  overflow: hidden;
}
.captcha-refresh:hover { border-color: var(--accent); }
.captcha-refresh img {
  display: block;
  width: 168px;
  height: 52px;
}
.captcha-row input { flex: 1; letter-spacing: 0.18em; text-transform: uppercase; font-family: var(--mono); }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.12s, color 0.12s;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }

.row { display: flex; align-items: center; gap: 12px; }
.spread { justify-content: space-between; }
.mt { margin-top: 20px; }
.mb { margin-bottom: 16px; }

.channel-row { display: flex; gap: 10px; }
.channel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  color: var(--dim);
}
.channel:has(input:checked) {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}
.channel input { accent-color: var(--accent); }

.qr {
  width: 220px;
  height: 220px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
}
.qr-fallback {
  width: 220px;
  height: 220px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--dim);
  font-size: 13px;
  padding: 16px;
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; gap: 16px; overflow-x: auto; }
  .nav { flex-direction: row; }
  .sidebar-foot { margin-top: 0; }
  .who { display: none; }
  .main { padding: 22px 18px 48px; }
  .grid-3, .grid-4, .profile-grid { grid-template-columns: 1fr 1fr; }
  .copy-row { flex-direction: column; }
  .auth-split { grid-template-columns: 1fr; }
  .auth-hero { min-height: 220px; padding: 32px 24px; }
  .auth-hero h1 { font-size: 28px; }
  .captcha-row { flex-direction: column; }
  .captcha-refresh { flex-basis: auto; width: 100%; }
  .captcha-refresh img { width: 100%; }
}
