:root {
  --bg: #0b0d15;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.1);
  --text: #e8eaf2;
  --muted: #9aa0b5;
  --accent: #7c8cff;
  --accent-2: #b06cff;
  --ok: #43d29b;
  --bad: #ff6b81;
  --warn: #ffc266;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 背景光斑 */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.orb-a {
  width: 520px; height: 520px;
  left: -160px; top: -180px;
  background: rgba(90, 110, 255, 0.28);
}
.orb-b {
  width: 460px; height: 460px;
  right: -140px; bottom: -180px;
  background: rgba(150, 80, 255, 0.22);
}

/* ---------------------------------------------------------------- 布局 */
.shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 212px;
  flex: 0 0 212px;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(18px);
}

.main {
  flex: 1;
  padding: 26px 30px 48px;
  max-width: 1180px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand.center { justify-content: center; margin-bottom: 18px; }
.brand b { display: block; font-size: 15px; letter-spacing: 0.5px; }
.brand small { color: var(--muted); font-size: 11px; }

.logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(110, 110, 255, 0.35);
  flex: 0 0 34px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active {
  background: linear-gradient(135deg, rgba(124, 140, 255, 0.22), rgba(176, 108, 255, 0.16));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(140, 150, 255, 0.25);
}
.nav .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}
.nav a.active .dot { opacity: 1; background: #b9c3ff; }

.logout { margin-top: auto; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: 0.3px; }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 16px;
  backdrop-filter: blur(14px);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 14.5px;
  font-weight: 600;
  color: #dfe3f5;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.card-head > form { margin: 0 0 0 auto; flex: none; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
/* 两张横向大卡：总 token / 日 token */
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card.stat.big strong { font-size: 34px; }
.card.stat {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-label { color: var(--muted); font-size: 12px; }
.card.stat strong {
  font-size: 26px;
  font-weight: 600;
  background: linear-gradient(135deg, #c7ceff, #e7c9ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------------------------------------------------------------- 文字 */
.muted { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin: 6px 0; }
.hint { color: var(--muted); font-size: 12px; margin: -4px 0 4px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.key-cell { display: flex; align-items: center; gap: 8px; }
.key-mask {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12.5px;
  white-space: nowrap;
  color: var(--text);
}
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: none;
}
.copy-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.28); }
.copy-btn.copied { color: var(--ok); border-color: rgba(67, 210, 155, 0.5); }

.code {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.65;
  color: #cfd6ff;
  margin: 10px 0;
}

/* ---------------------------------------------------------------- 表格 */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table-scroll { overflow-x: auto; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.02);
}
tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
tbody tr:last-child td { border-bottom: none; }
.notes-cell { white-space: pre-wrap; min-width: 260px; line-height: 1.6; }

.actions { display: flex; gap: 6px; }
.actions form { margin: 0; }

/* ---------------------------------------------------------------- 表单 */
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}
input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; line-height: 1.6; }
input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  border-color: rgba(140, 150, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.16);
}
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
select option { background: #141725; }

.inline-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
a.btn { color: var(--text); text-decoration: none; }
a.btn:hover { text-decoration: none; color: var(--text); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.primary {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(110, 100, 255, 0.28);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: rgba(255, 107, 129, 0.35); }
.btn.danger:hover { background: rgba(255, 107, 129, 0.12); }
.btn.ghost { background: transparent; }

/* ---------------------------------------------------------------- 徽标与提示 */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  line-height: 1.5;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: rgba(67, 210, 155, 0.35); background: rgba(67, 210, 155, 0.1); }
.badge.bad { color: var(--bad); border-color: rgba(255, 107, 129, 0.35); background: rgba(255, 107, 129, 0.1); }
.badge.warn { color: var(--warn); border-color: rgba(255, 194, 102, 0.35); background: rgba(255, 194, 102, 0.1); }
a.badge { text-decoration: none; }

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

.count {
  margin-left: auto;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  color: #dfe3f5;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.count.bad { background: rgba(255, 107, 129, 0.22); color: var(--bad); }

.row-actions { display: flex; gap: 6px; }
.row-actions form { margin: 0; }

.notice-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.02);
}
.notice-item.unread { border-color: rgba(124, 140, 255, 0.4); background: rgba(124, 140, 255, 0.07); }
.notice-item .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.notice-item .head > form { margin: 0 -8px 0 auto; }
.notice-item .head > .read-flag { margin-left: auto; margin-right: -8px; }
.notice-item .head b { font-size: 13.5px; }
.notice-item p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.7; }

.flash {
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid var(--line);
}
.flash.ok { color: var(--ok); background: rgba(67, 210, 155, 0.1); border-color: rgba(67, 210, 155, 0.3); }
.flash.bad { color: var(--bad); background: rgba(255, 107, 129, 0.1); border-color: rgba(255, 107, 129, 0.3); }

/* ---------------------------------------------------------------- 登录页 */
.center-body {
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 100vh;
}
.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  padding: 30px 28px 24px;
  border-radius: 20px;
  background: rgba(20, 23, 37, 0.78);
  border: 1px solid var(--line);
  backdrop-filter: blur(22px);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
}
.login-card .hint { text-align: center; margin-top: 4px; }
.login-card code {
  font-family: Consolas, monospace;
  color: #b9c3ff;
}

/* ---------------------------------------------------------------- 窄屏 */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: auto;
    flex: none;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    overflow-x: auto;
  }
  .nav { flex-direction: row; }
  .logout { margin: 0 0 0 auto; }
  .main { padding: 18px 14px 36px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
  .cards.two { grid-template-columns: 1fr; }
  .main { padding: 14px 10px 30px; }
  table { font-size: 12px; }
  th, td { padding: 8px; }
}
