:root {
  --ink: #15233a;
  --ink-soft: #4a5a73;
  --muted: #6f7d94;
  --line: #e4e9f2;
  --line-soft: #edf1f7;
  --surface: #f4f6fb;
  --panel: #ffffff;
  --aside: #fbfcfe;
  --accent: #2f55e0;
  --accent-soft: #eaf0ff;
  --accent-deep: #1f3db8;
  --ok: #1f7a54;
  --ok-soft: #e7f6ef;
  --warn: #9a5b1f;
  --warn-soft: #fff3e8;
  --danger: #b53d2e;
  --danger-soft: #fdeeee;
  --shadow: 0 18px 48px rgba(21, 43, 87, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --aside-w: 228px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-family: var(--font);
  font-synthesis: none;
  font-feature-settings: "tnum" 1;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: #c9d7ff; color: var(--ink); }
button, input, textarea { font: inherit; caret-color: var(--accent); }
button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  padding: 11px 16px;
  font-weight: 600;
  transition: background 160ms var(--ease), transform 160ms var(--ease), opacity 160ms var(--ease);
}
button:hover { background: var(--accent-deep); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: wait; transform: none; }
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #a9bfff;
  outline-offset: 2px;
}
input, textarea {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  width: 100%;
  color: var(--ink);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
input:hover, textarea:hover { border-color: #c7d0e0; }
input:focus, textarea:focus {
  border-color: #8aa4f0;
  box-shadow: 0 0 0 3px rgba(47, 85, 224, 0.12);
  outline: none;
}
textarea { resize: vertical; min-height: 92px; }
label { display: block; margin: 18px 0 7px; font-weight: 550; color: var(--ink-soft); }
.secondary {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.secondary:hover { background: var(--line-soft); color: var(--ink); }
small, .hint { color: var(--muted); }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 760;
  color: var(--accent);
  letter-spacing: -0.03em;
}
.brand span { font-size: 17px; color: var(--ink); letter-spacing: -0.02em; }
.brand small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  margin-top: 4px;
  font-weight: 600;
  color: var(--muted);
}

aside {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--aside-w);
  background: var(--aside);
  border-right: 1px solid var(--line);
  padding: var(--space-6) var(--space-4);
  display: flex;
  flex-direction: column;
}
nav {
  display: grid;
  gap: 4px;
  margin-top: var(--space-6);
  flex: 1;
}
nav button {
  text-align: left;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 10px;
  position: relative;
  min-height: 42px;
}
nav button:hover { background: var(--line-soft); color: var(--ink-soft); }
nav button.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 650;
}
nav button.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}
.aside-bottom {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line-soft);
}
.aside-bottom #operator {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-weight: 600;
}
.aside-bottom button {
  display: block;
  background: transparent;
  color: var(--muted);
  padding: 10px 0;
  min-height: 40px;
}
.aside-bottom button:hover { color: var(--danger); background: transparent; }

main {
  margin-left: var(--aside-w);
  padding: var(--space-6) var(--space-7);
  max-width: 1680px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
h1 {
  font-size: 26px;
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.2;
}
h2 {
  font-size: 16px;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
p { line-height: 1.7; margin: 0 0 10px; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
  margin: var(--space-5) 0;
}
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-5);
}
.card .number {
  display: block;
  font-size: 28px;
  font-weight: 720;
  margin: 14px 0 8px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.card .label { color: var(--ink-soft); font-weight: 600; font-size: 13px; }
.panel { margin: var(--space-4) 0; }
.welcome {
  background: linear-gradient(145deg, #152b57 0%, #1d3a78 100%);
  color: white;
  padding: 28px 30px;
  border-radius: 14px;
}
.welcome h1 {
  font-size: 24px;
  margin: 0 0 8px;
  color: white;
}
.welcome p { color: #c5d2ef; margin: 0; max-width: 52ch; }
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar input { max-width: 360px; }
.toolbar select,
.toolbar input[type="date"] {
  width: auto;
  min-width: 120px;
  max-width: 200px;
  padding: 10px 12px;
}
.toolbar input[type="date"] { min-width: 150px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  max-height: min(70vh, 820px);
}
table {
  border-collapse: collapse;
  width: 100%;
  white-space: nowrap;
}
th, td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafd;
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: inset 0 -1px 0 var(--line);
}
tbody tr { transition: background 120ms var(--ease); }
tbody tr:hover { background: #f7f9fd; }
td small {
  display: block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}
td button {
  padding: 7px 12px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  min-height: 34px;
}
td button:hover { background: #dce6ff; }
.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty strong {
  display: block;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-size: 15px;
}
.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 650;
  font-size: 12px;
}
.bad { background: var(--warn-soft); color: var(--warn); }

#notice, #login-error, #recharge-error {
  min-height: 1.2em;
  margin: 0 0 var(--space-3);
}
#login-error, #recharge-error { color: var(--danger); }
#notice.is-error { color: var(--danger); }
#notice.is-ok {
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid #cfe9dc;
  border-radius: 8px;
  padding: 10px 12px;
}
footer {
  font-size: 12px;
  color: var(--muted);
  margin-top: var(--space-6);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 70% 55% at 12% 8%, #d9e4ff 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 90%, #e8eefc 0%, transparent 50%),
    var(--surface);
}
.login-card {
  width: min(420px, 100%);
  padding: 36px 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: rise 320ms var(--ease) both;
}
.login-card .brand { margin-bottom: 28px; }
.login-card h1 { font-size: 24px; margin-bottom: 8px; }
.login-card > p { color: var(--muted); margin-bottom: 8px; }
.login-card button { width: 100%; margin-top: 20px; }
.login-card small { display: block; margin-top: 16px; text-align: center; }

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(500px, 94vw);
  max-height: min(92vh, 820px);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog[open] { animation: rise 220ms var(--ease) both; }
dialog::backdrop {
  background: rgba(10, 24, 57, 0.42);
  animation: fade 180ms var(--ease) both;
}
#recharge-form {
  display: flex;
  flex-direction: column;
  max-height: min(92vh, 820px);
}
.dialog-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.dialog-title h2 { margin: 0; }
.dialog-body {
  padding: 8px 24px 18px;
  overflow: auto;
  flex: 1;
}
.dialog-actions {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
}
#target {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--line-soft);
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 13px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-weight: 500;
}
.check input { width: auto; }
.hint { font-size: 12px; line-height: 1.55; }
#submit-recharge { width: 100%; margin-top: 0; }
th.actions, td.actions {
  position: sticky;
  right: 0;
  background: var(--panel);
  box-shadow: -8px 0 12px rgba(21, 43, 87, 0.04);
}
th.actions { background: #f8fafd; z-index: 2; }
tbody tr:hover td.actions { background: #f7f9fd; }

.skeleton {
  display: grid;
  gap: 14px;
}
.skeleton-line,
.skeleton-card {
  background: linear-gradient(90deg, #eef1f7 0%, #f7f9fc 45%, #eef1f7 90%);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
  border-radius: 8px;
}
.skeleton-line { height: 14px; }
.skeleton-line.lg { height: 22px; width: 42%; }
.skeleton-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.skeleton-card { height: 108px; border-radius: var(--radius); }

.content-enter { animation: rise 220ms var(--ease) both; }

.usage-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.usage-tabs button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 36px;
}
.usage-tabs button.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: transparent;
  font-weight: 650;
}
.group-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  align-items: center;
}
.dim-picks, .chart-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.dim-picks .check { margin-top: 0; }
.chart-picks button.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.usage-chart {
  width: 100%;
  height: 240px;
  margin-bottom: 16px;
  background: #f8fafd;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}
tbody tr[data-group-row] { cursor: pointer; }

[hidden] { display: none !important; }
[aria-busy="true"] { cursor: progress; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 1100px) {
  .cards, .skeleton-cards { grid-template-columns: repeat(2, 1fr); }
  main { padding: 28px; }
}

@media (max-width: 720px) {
  aside {
    position: sticky;
    top: 0;
    z-index: 20;
    width: auto;
    inset: auto;
    padding: 14px 16px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(251, 252, 254, 0.96);
    backdrop-filter: blur(10px);
  }
  nav {
    display: flex;
    overflow: auto;
    margin-top: 14px;
    gap: 4px;
    padding-bottom: 2px;
  }
  nav button {
    white-space: nowrap;
    flex: 0 0 auto;
  }
  nav button.active::before { display: none; }
  .aside-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 0;
    padding-top: 8px;
  }
  .aside-bottom button {
    display: inline;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  main { margin: 0; padding: 18px 16px 28px; }
  .cards, .skeleton-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 16px; }
  .card .number { font-size: 22px; margin: 10px 0 6px; }
  header { flex-wrap: wrap; }
  .toolbar input { max-width: none; }
  .panel { padding: 14px; }
  h1 { font-size: 22px; }
  .welcome { padding: 22px; }
  .welcome h1 { font-size: 20px; }
  .table-wrap { max-height: 60vh; }
}
