/* note. admin — monospace-dark 风格
   三层背景 + 1px 边框分层，无投影；等宽字体唯一；青色仅作点状强调。 */
:root {
  --bg-primary: #0b0e11;
  --bg-secondary: #13171c;
  --bg-card: #181e24;
  --border-color: #2a333d;
  --text-primary: #e8edf2;
  --text-secondary: #8899aa;
  --text-muted: #556677;
  --accent-cyan: #00e5a0;
  --status-on: #00e5a0;
  --status-warn: #facc15;
  --status-off: #ef4444;
  --radius: 8px;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

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

.muted { color: var(--text-muted); }

.error {
  color: var(--status-off);
  font-size: 12px;
  margin: 8px 0;
}

/* ── 布局 ─────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.logo-suffix { color: var(--accent-cyan); font-weight: 400; }

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

.nav-link {
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-card); }

.nav-link.active { color: var(--text-primary); background: var(--bg-card); }

.nav-link.active::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-cyan);
  margin-right: 8px;
  vertical-align: middle;
}

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

.main {
  flex: 1;
  padding: 28px 32px;
  max-width: 1080px;
}

/* 概览页左右分栏，宽屏时放开上限让右侧趋势面板自然拉长 */
.main-wide { max-width: none; }

.page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head h1 { font-size: 16px; font-weight: 600; margin: 0; }

.page-head .range-links { margin-left: auto; margin-bottom: 0; }

/* ── 卡片 ─────────────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 24px;
}

.card-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* 标题与右上角说明同一行 */
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-head .card-title { margin-bottom: 0; }

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* 二级指标：三列小卡 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.stat-grid > .card {
  margin-bottom: 0;
}

/* 概览：共享行线的卡片网格。
   行高统一为 180px 的整数倍，每张卡占 1 或 2 行，
   左栏（3 张卡）与右栏（2 张图）的横向分界线因此严格对齐。 */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(180px, auto);
  gap: 24px;
  align-items: stretch;
}

.dash-grid > .card { margin-bottom: 0; min-width: 0; }

.stat-pair {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.stat-pair .stat-tile + .stat-tile {
  border-left: 1px solid var(--border-color);
  padding-left: 24px;
}

.status-card {
  grid-column: 1;
  grid-row: 2;
}

.recent-card {
  grid-column: 1;
  grid-row: 3 / span 2;
}

.chart-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chart-today {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.chart-dau {
  grid-column: 2;
  grid-row: 3 / span 2;
}

.chart-card .chart-box {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

/* 统计 / 账号 / 邀请码：4 列共享行线，卡片占 1 或 2 行 */
.dash-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* 四个指标卡组成 2×2 方块，占左上两列两行 */
.stat-square {
  grid-column: 1 / span 2;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(180px, auto));
  gap: 24px;
  min-width: 0;
}

.stat-square > .card {
  margin-bottom: 0;
  min-width: 0;
}

/* 与方块同高的右上主内容 */
.top-right {
  grid-column: 3 / span 2;
  grid-row: 1 / span 2;
  min-width: 0;
}

.grid-half { grid-column: span 2; }

.grid-full { grid-column: 1 / -1; }

.grid-rows-2 { grid-row: span 2; }

.list-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.list-card .table-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.list-card .error { margin: 0 0 10px; }

.create-card {
  display: flex;
  flex-direction: column;
}

.create-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.hint-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

/* 方形图标 + 数字的核心指标卡 */
.stat-tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.tile-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }

.tile-head .card-title { margin-bottom: 0; }

.tile-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--accent-cyan);
}

.tile-icon svg { width: 20px; height: 20px; }

/* 窄列里的标签/数值行 */
.kv-list { margin: 0; display: flex; flex-direction: column; gap: 10px; }

.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.kv-row + .kv-row {
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.kv-row dt { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }

.kv-row dd { margin: 0; text-align: right; }

.metric { font-size: 24px; font-weight: 600; }

.metric-xl { font-size: 36px; line-height: 1.2; }

.metric-sm { font-size: 16px; }

.metric-sub { font-size: 12px; font-weight: 400; color: var(--text-secondary); }

/* 三级信息：弱化边框与底色，不与指标卡争抢视线 */
.card-secondary { background: var(--bg-primary); }

.empty { margin: 0; padding: 12px 0; }

/* ── 图表容器 ─────────────────────────────────── */
.chart-box { position: relative; height: 280px; }

.chart-box-sm { height: 190px; }

.table-card summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.table-card summary::marker { color: var(--text-muted); }

.table-card[open] summary { margin-bottom: 14px; }

/* ── 列表 ─────────────────────────────────────── */
.row-list { list-style: none; margin: 0; padding: 0; }

/* 列表均匀铺满卡片剩余高度（概览「最近注册」、账号页「最近注册」） */
.fill-list {
  display: flex;
  flex-direction: column;
}

.fill-list .row-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.fill-list .row-item { flex: 1 1 auto; align-items: center; }

.row-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-color);
}

.row-item:last-child { border-bottom: none; }

.row-main { color: var(--text-primary); font-weight: 450; }

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

th, td {
  text-align: left;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

th {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  background: var(--bg-card);
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--bg-card); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.mono-id { font-size: 11px; }

/* 访问统计条形（宽度由模板按占比给百分比） */
.bar-cell { width: 40%; }
.bar { height: 8px; background: var(--accent-cyan); border-radius: 2px; min-width: 2px; }
.range-links { display: flex; gap: 12px; margin-bottom: 8px; }
.range-links .text-btn.active { color: var(--accent-cyan); }

/* ── 状态点 ───────────────────────────────────── */
.status { display: inline-flex; align-items: center; gap: 8px; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-active { background: var(--status-on); }
.dot-used { background: var(--text-muted); }
.dot-revoked { background: var(--status-off); }
.dot-expired { background: var(--status-warn); }

/* ── 表单与按钮 ───────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 14px; }

.inline-form { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 4px; }

.field-label { font-size: 11px; color: var(--text-secondary); }

input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 7px 10px;
  min-width: 220px;
  transition: border-color 0.15s ease;
}

input:focus { outline: none; border-color: var(--accent-cyan); }

.search-bar { margin-bottom: 16px; }

.search-bar input { width: 320px; max-width: 100%; }

.page-head .search-bar { margin: 0 0 0 auto; }

.page-head .search-bar input { width: 280px; }

.submit-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 7px 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.submit-btn:hover { border-color: var(--accent-cyan); color: var(--accent-cyan); }

.text-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.text-btn:hover { color: var(--accent-cyan); }

.text-btn.danger:hover { color: var(--status-off); }

.action-cell { text-align: right; }

/* ── 邀请码一次性展示 ─────────────────────────── */
.flash {
  background: var(--bg-card);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.invite-code {
  color: var(--accent-cyan);
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}

/* ── 登录页（独立居中） ───────────────────────── */
body.standalone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 340px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 28px 26px;
}

.login-hint { margin: 4px 0 18px; font-size: 12px; }

.login-card .submit-btn { width: 100%; margin-top: 4px; }

/* ── 响应式 ───────────────────────────────────── */
@media (max-width: 1120px) {
  .dash-grid { grid-auto-rows: auto; }
  .dash-grid:not(.dash-grid--4) {
    grid-template-columns: minmax(0, 1fr);
  }
  .dash-grid:not(.dash-grid--4) > .card {
    grid-column: 1;
    grid-row: auto;
  }
  .dash-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid--4 .grid-rows-2 { grid-row: auto; }
  .stat-square,
  .top-right {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  .chart-card .chart-box { flex: none; height: 230px; }
}

@media (max-width: 800px) {
  .card-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .dash-grid--4 { grid-template-columns: minmax(0, 1fr); }
  .dash-grid--4 .grid-half { grid-column: 1 / -1; }
  .create-body { grid-template-columns: 1fr; }
  .stat-square { grid-template-rows: repeat(2, minmax(180px, auto)); }
  .stat-pair { grid-template-columns: 1fr; gap: 16px; }
  .stat-pair .stat-tile + .stat-tile {
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding-left: 0;
    padding-top: 16px;
  }
  .metric-xl { font-size: 30px; }
  .chart-box { height: 220px; }
  .chart-box-sm { height: 170px; }
  .chart-card .chart-box { height: 230px; }
  .page-head .range-links { margin-left: 0; }
  .page-head .search-bar { margin-left: 0; width: 100%; }
  .page-head .search-bar input { width: 100%; }
  .main { padding: 16px 20px; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
  }
  .sidebar nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; min-width: 0; }
  .nav-link { white-space: nowrap; }
  .sidebar-foot { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; gap: 12px; white-space: nowrap; }
  .app { flex-direction: column; }
}

/* 窄屏优先保证四个导航项完整可见：隐藏管理员名（登录页已确认身份） */
@media (max-width: 560px) {
  .stat-square { grid-template-columns: 1fr; }
  .sidebar { gap: 10px; }
  .sidebar nav { gap: 2px; }
  .sidebar-foot .muted { display: none; }
}
