:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c1f23;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid #1f2937; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
}
.brand-mark { flex: 0 0 auto; }
/* 品牌名可能较长（如「顶流互推·私享档案」），允许换行但不能撑破侧边栏。 */
.brand > div:last-child { min-width: 0; flex: 1; }
.brand-title {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.brand-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.sidebar nav { display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; flex: 1; }
.sidebar nav a {
  color: #d1d5db; padding: 9px 12px; border-radius: 8px; font-size: 13px;
}
.sidebar nav a:hover { background: #1f2937; text-decoration: none; }
.sidebar nav a.active { background: #2563eb; color: #fff; }
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid #1f2937;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: #9ca3af;
}
.sidebar-footer .logout { color: #f87171; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.content { padding: 20px 24px 40px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-grid.compact { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 600; }
.stat-value.warn { color: var(--warn); }
.stat-value.ok { color: var(--ok); }
.stat-value.danger { color: var(--danger); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-header h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card > form, .card.hint, .card-body { padding: 16px; }
.card-body.hint { color: var(--muted); line-height: 1.9; }
.card.hint ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.9; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #fafbfc; font-weight: 600; font-size: 12px; color: var(--muted); }
.table tbody tr:hover { background: #fafbfc; }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
.table td.reason { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input, .select {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; background: #fff; color: var(--text); font-family: inherit;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.card form label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.card form label .input, .card form label .select, .card form label textarea { display: block; width: 100%; margin-top: 6px; color: var(--text); }
.card form label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.tag.ok { background: #ecfdf5; color: var(--ok); }
.tag.danger { background: #fef2f2; color: var(--danger); }
.tag.warn { background: #fffbeb; color: var(--warn); }
.tag.muted { background: #f3f4f6; color: var(--muted); }

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

.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 10px 14px; color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; list-style: none; margin: 0 0 14px; padding: 0; }
.tabs li { padding: 8px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); background: #fff; border: 1px solid var(--line); }
.tabs li.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.modal { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 12px; padding: 22px; width: 460px; max-width: 92vw; max-height: 88vh; overflow: auto; }
.modal-card h3 { margin: 0 0 16px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #eef2ff, #f8fafc); }
.login-card { background: #fff; border-radius: 14px; padding: 30px; width: 360px; max-width: 92vw; box-shadow: 0 18px 45px rgba(15,23,42,.12); border: 1px solid var(--line); }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand .brand-mark { margin: 0 auto 10px; width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
.login-brand h1 { font-size: 17px; margin: 0 0 4px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 12px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.login-card label input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.login-card label input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-card button {
  width: 100%; padding: 10px; border: 0; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 14px; cursor: pointer;
}
.login-card button:hover { background: var(--primary-dark); }
.login-hint { color: var(--muted); font-size: 11px; text-align: center; margin: 14px 0 0; line-height: 1.7; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 200; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; flex: 1; }
  .sidebar-footer { display: none; }
  .brand { border-bottom: 0; }
}

/* 导航待办徽标 */
.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  background: #f59e0b;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.switch input { width: 16px; height: 16px; cursor: pointer; }
