/* ============================================================
   设计令牌 —— 全站唯一配色/间距来源。改这里，不要在各模块里写死色值。
   ============================================================ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #fafbfc;

  --border: #e4e7ec;
  --border-strong: #d3d8df;

  --text: #1f2328;
  --text-soft: #5b6472;
  --text-muted: #8a929e;

  --accent: #2f6fed;
  --accent-hover: #2559c9;
  --accent-soft: #eaf0fe;

  --danger: #d93025;
  --danger-soft: #fdecea;
  --success: #127a4b;
  --success-soft: #e7f5ee;
  --warn: #a3630a;
  --warn-soft: #fdf3e2;

  --radius-sm: 8px;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 2px 10px rgba(16, 24, 40, .07);

  --sidebar-w: 236px;
  --gap: 20px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0 0 12px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.nav { padding: 4px 10px 16px; flex: 1; }

.nav-group { margin-bottom: 14px; }

.nav-group-label {
  padding: 6px 8px;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 13.5px;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--surface-soft); color: var(--text); }

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  flex: 0 0 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title { font-weight: 600; font-size: 15px; }

.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}

.user-name { font-size: 13px; color: var(--text-soft); }

.page { padding: 24px; max-width: 1080px; width: 100%; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head-actions { margin-left: auto; display: flex; gap: 8px; }

.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: var(--gap); }

.card-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-head-actions { margin-left: auto; }

.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* ---------- 统计块 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: var(--gap);
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-label { color: var(--text-muted); font-size: 12.5px; }
.stat-value { font-size: 26px; font-weight: 600; line-height: 1.3; margin-top: 2px; }
.stat-hint { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}

.btn:hover { background: var(--surface-soft); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger { color: var(--danger); border-color: #f0c4c0; }
.btn-danger:hover { background: var(--danger-soft); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-soft); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }

.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
}

.field .hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

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

.textarea { resize: vertical; min-height: 84px; line-height: 1.6; }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 200px; }

.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
}

.inline-form { display: inline; }

/* ---------- 提示条 ---------- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-success { background: var(--success-soft); border-color: #c6e9d7; color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: #f6cdc9; color: var(--danger); }
.alert-warning { background: var(--warn-soft); border-color: #f2ddb6; color: var(--warn); }
.alert-info { background: var(--accent-soft); border-color: #cfdffb; color: var(--accent-hover); }

.alert ul { margin: 0; padding-left: 18px; }

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

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

.table th, .table td {
  padding: 11px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--surface-soft);
  white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfcfd; }

.table .col-actions { text-align: right; white-space: nowrap; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text-soft);
}

.badge-accent { background: var(--accent-soft); border-color: #cfdffb; color: var(--accent-hover); }
.badge-success { background: var(--success-soft); border-color: #c6e9d7; color: var(--success); }
.badge-muted { color: var(--text-muted); }

/* ---------- 空状态 ---------- */
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-title { color: var(--text-soft); font-weight: 500; margin-bottom: 4px; }

/* ---------- 登录页 ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-weight: 600;
}

.auth-foot { color: var(--text-muted); font-size: 12px; margin-top: 18px; }

/* ---------- 移动端 ---------- */
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }

  body.nav-open .sidebar { transform: translateX(0); }

  .nav-toggle { display: inline-flex; }

  .topbar { padding: 0 16px; }
  .page { padding: 16px; }
  .user-name, .topbar-user .badge { display: none; }
}
