:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e8eaef;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .18);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 500px at 85% -10%, #e9ecff 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 4px 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .6);
}

.brand-name { font-size: 17px; }

.topbar-meta,
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.back {
  color: var(--accent);
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  transition: background .15s ease;
}

.back:hover { background: #e3e7ff; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.top-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 18px -10px rgba(37, 99, 235, .8);
  transition: transform .15s ease, filter .15s ease;
}

.top-action:hover { transform: translateY(-1px); filter: brightness(1.05); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .15);
}

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

/* ---------- hero ---------- */
.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 34px 36px;
  background:
    linear-gradient(120deg, rgba(79, 70, 229, .06), transparent 45%),
    var(--card);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -90px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 70, 229, .14), transparent 65%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.total {
  margin: 0;
  font-size: clamp(38px, 6vw, 56px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.sub {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.stat {
  min-width: 122px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stat strong {
  display: block;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

/* ---------- sections ---------- */
.section { margin-top: 34px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 0 4px;
}

.section-head.compact { margin-bottom: 18px; }

.section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .01em;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- channel grid ---------- */
.channels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.channel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  position: relative;
  overflow: hidden;
}

.channel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--ch-color, var(--accent));
  opacity: .85;
}

.channel:hover {
  transform: translateY(-3px);
  border-color: #d8dce8;
  box-shadow: 0 2px 4px rgba(16, 24, 40, .04), 0 18px 40px -18px rgba(16, 24, 40, .28);
}

.channel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.channel-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.channel-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--ch-soft, var(--accent-soft));
  font-size: 18px;
}

.channel-share {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 999px;
  background: #f3f4f7;
}

.channel-amount {
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}

.channel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12.5px;
}

.channel-link { color: var(--accent); font-weight: 600; white-space: nowrap; }

.bar-track {
  height: 6px;
  border-radius: 999px;
  background: #f0f1f5;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--ch-color, var(--accent));
  width: 0;
  transition: width .6s cubic-bezier(.2, .7, .2, 1);
}

.skeleton {
  height: 178px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(100deg, #f3f4f7 20%, #fafbfd 40%, #f3f4f7 60%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite linear;
}

@keyframes shimmer {
  to { background-position: -220% 0; }
}

/* ---------- two column ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 16px;
  margin-top: 34px;
}

.chart-card,
.recent-card { padding: 24px; min-width: 0; }

/* ---------- chart ---------- */
.chart {
  display: flex;
  align-items: stretch;
  gap: 10px;
  height: 230px;
  padding: 6px 2px 0;
}

.chart-empty {
  display: grid;
  place-items: center;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}

.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}

.bar {
  width: 100%;
  max-width: 44px;
  min-height: 3px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  border-radius: 7px 7px 4px 4px;
  overflow: hidden;
  transition: height .55s cubic-bezier(.2, .7, .2, 1);
}

.seg {
  width: 100%;
  min-height: 1px;
}

.bar-label {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.bar-group.single .bar { max-width: 46px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.legend-item { display: inline-flex; align-items: center; gap: 7px; }

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--ch-color, var(--accent));
}

/* ---------- recent list ---------- */
.recent {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.recent li:last-child { border-bottom: 0; }

.recent-icon {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--ch-soft, var(--accent-soft));
  font-size: 15px;
}

.recent-body { min-width: 0; flex: 1; }

.recent-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
}

.recent-note {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 14px;
}

.muted { color: var(--muted); font-weight: 400; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }

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

.table th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tr:last-child td { border-bottom: 0; }

.table .num,
.table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.table td.num { font-weight: 650; }

/* ---------- footer ---------- */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  margin-top: 36px;
  padding: 18px 4px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.footer code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eceef3;
  color: #414651;
  font-size: 11.5px;
}

/* ---------- 404 ---------- */
.notfound {
  max-width: 520px;
  margin: 14vh auto 0;
  text-align: center;
  padding: 48px 32px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.notfound h1 { margin: 0; font-size: 30px; letter-spacing: -.02em; }

.notfound .sub { margin-bottom: 26px; }

.button {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 10px 22px -10px rgba(37, 99, 235, .7);
}

.button:hover { filter: brightness(1.05); }

/* ---------- admin ---------- */
.admin-wrap {
  max-width: 940px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.admin-card { padding: 28px 30px; }

.admin-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -.02em;
}

.login-shell {
  max-width: 460px;
  margin: 8vh auto 0;
  width: 100%;
}

.record-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field.wide { grid-column: span 2; }

.field span {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfbfd;
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.field input:focus {
  border-color: #b9bfff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.record-form .button {
  border: 0;
  height: 44px;
  cursor: pointer;
  font-family: inherit;
  justify-self: start;
  min-width: 120px;
}

.record-form .button:disabled { opacity: .6; cursor: default; }

.form-msg {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.form-msg.ok { color: #047857; }
.form-msg.err { color: #b91c1c; }

.link-btn {
  border: 0;
  background: none;
  padding: 4px 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
}

.link-btn:hover { color: var(--accent); background: var(--accent-soft); }

.link-btn.danger:hover { color: #b91c1c; background: #fee2e2; }

.row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 11.5px;
  font-weight: 600;
}

.login-shell .button {
  width: 100%;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  margin-top: 18px;
  height: 44px;
}

.login-shell .field { margin-top: 18px; }

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 26px 10px;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .hero { padding: 26px 22px; align-items: flex-start; }
  .hero-stats { width: 100%; }
  .stat { flex: 1 1 120px; }
}

@media (max-width: 560px) {
  .wrap { padding: 20px 14px 32px; }
  .hero { gap: 20px; }
  .hero-stats { gap: 8px; }
  .stat { min-width: 0; padding: 11px 12px; }
  .stat strong { font-size: 16px; }
  .channel-amount { font-size: 24px; }
  .chart { height: 190px; gap: 5px; }
  .bar-label { font-size: 9.5px; }
  .chart-card, .recent-card { padding: 18px; }
  .topbar { padding-bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
