/* 六台阶 CRM 克隆 — 企业后台设计系统 */
:root {
  --navy: #20344f;
  --navy-dark: #1a2c44;
  --navy-hover: #2b426380;
  --sidebar-w: 208px;
  --topbar-h: 50px;
  --primary: #2f7fe0;
  --primary-dark: #2569c0;
  --bg: #eef1f6;
  --card: #ffffff;
  --border: #e6e9f0;
  --border-strong: #d7dce6;
  --text: #2f3540;
  --text-muted: #8b94a7;
  --th-bg: #f5f7fb;
  --row-hover: #f1f7ff;
  --ok: #2bb673;
  --warn: #f0a020;
  --danger: #e25555;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(28, 44, 71, .07), 0 1px 2px rgba(28, 44, 71, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== 顶栏 ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 100;
  background: linear-gradient(90deg, var(--navy-dark), var(--navy));
  display: flex; align-items: center; padding: 0 16px; color: #eaf0fb;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.topbar .brand {
  font-size: 15px; font-weight: 600; color: #fff; letter-spacing: .5px;
  width: calc(var(--sidebar-w) - 16px); display: flex; align-items: center; gap: 8px;
}
.topbar .brand .logo {
  width: 24px; height: 24px; border-radius: 5px; background: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; color: #fff;
}
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #cdd8ea; }
.topbar .user .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #3a567f; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}
.topbar .user a { color: #cdd8ea; }
.topbar .user a:hover { color: #fff; }

/* ===== 侧边栏 ===== */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w); z-index: 90;
  background: var(--navy); overflow-y: auto; padding: 6px 0 30px;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #3a567f; border-radius: 3px; }
.menu-group { border-bottom: 1px solid rgba(255,255,255,.04); }
.menu-group > .group-head {
  display: flex; align-items: center; gap: 9px; padding: 11px 16px;
  color: #c4cfe2; font-size: 13.5px; cursor: pointer; user-select: none;
}
.menu-group > .group-head:hover { background: rgba(255,255,255,.05); color: #fff; }
.menu-group > .group-head .ico { width: 16px; height: 16px; opacity: .85; flex: none; }
.menu-group > .group-head .caret { margin-left: auto; transition: transform .18s; opacity: .6; font-size: 10px; }
.menu-group.collapsed > .group-head .caret { transform: rotate(-90deg); }
.menu-group .group-body { overflow: hidden; }
.menu-group.collapsed .group-body { display: none; }
.menu-item {
  display: block; padding: 9px 16px 9px 41px; color: #9fb0cc; font-size: 13px;
  border-left: 3px solid transparent;
}
.menu-item:hover { background: rgba(255,255,255,.05); color: #eaf1ff; }
.menu-item.active {
  background: rgba(47,127,224,.16); color: #fff; border-left-color: var(--primary);
}

/* ===== 内容区 ===== */
.content { margin-left: var(--sidebar-w); margin-top: var(--topbar-h); padding: 16px 18px 40px; min-height: calc(100vh - var(--topbar-h)); }
.page-head { display: flex; align-items: center; margin: 0 0 14px; }
.page-head h2 { font-size: 17px; font-weight: 600; margin: 0; color: #2a3242; }
.breadcrumb { color: var(--text-muted); font-size: 12.5px; margin-bottom: 12px; }
.breadcrumb a { color: var(--text-muted); }

/* ===== 卡片 ===== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.card > .card-title {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-size: 14px; font-weight: 600;
  color: #303a4d; border-bottom: 1px solid var(--border);
}
.card > .card-title::before { content: ""; width: 3px; height: 14px; background: var(--primary); border-radius: 2px; }
.card > .card-body { padding: 16px; }

/* 分组标题（表单用，六台阶蓝竖条） */
.section-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #303a4d; margin: 4px 0 14px; }
.section-title::before { content: ""; width: 3px; height: 14px; background: var(--primary); border-radius: 2px; }
.subsection-title { font-size: 13px; color: #5a6577; margin: 18px 0 10px; padding-left: 12px; position: relative; }
.subsection-title::before { content: ""; position: absolute; left: 0; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* ===== 工具栏 ===== */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .grow { flex: 1; }
.toolbar form { display: flex; gap: 8px; align-items: center; margin: 0; }

/* ===== 按钮 ===== */
.btn, button[type="submit"], input[type="submit"] {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 13px;
  font-size: 13px; border-radius: 4px; border: 1px solid var(--border-strong); background: #fff; color: #4a5468;
  cursor: pointer; line-height: 1; transition: all .12s; white-space: nowrap;
}
.btn:hover, button[type="submit"]:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary, button[type="submit"], input[type="submit"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, button[type="submit"]:hover, input[type="submit"]:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12.5px; }
.btn-danger { color: var(--danger); border-color: #f0c2c2; background: #fff; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-link { border: none; background: none; color: var(--primary); padding: 0 6px; height: auto; }

/* ===== 表单 ===== */
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="datetime-local"], select, textarea {
  height: 32px; padding: 0 10px; font-size: 13px; border: 1px solid var(--border-strong);
  border-radius: 4px; color: var(--text); background: #fff; outline: none; transition: border .12s; max-width: 100%;
}
textarea { height: auto; padding: 8px 10px; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(47,127,224,.12); }
select { cursor: pointer; }
label { color: #5a6577; }
.form-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.form-row > label { width: 110px; text-align: right; flex: none; color: #5a6577; }
.form-row .field { flex: 1; }
.form-row .field input, .form-row .field select, .form-row .field textarea { width: 320px; max-width: 100%; }
.form-actions { padding-left: 122px; margin-top: 18px; }
.form-help { color: var(--text-muted); font-size: 12px; margin-left: 8px; }

/* 兼容老模板里 <p>label input</p> 的朴素表单 */
form p { margin: 0 0 13px; display: flex; align-items: center; gap: 10px; }
form p label { min-width: 92px; color: #5a6577; }

/* ===== 表格 ===== */
table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.data-table, table.list { border: 1px solid var(--border); }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th { background: var(--th-bg); color: #5a6577; font-weight: 600; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: none; }
table[border] { border: 1px solid var(--border) !important; }
table[border] td, table[border] th { border: none; border-bottom: 1px solid var(--border); }

/* ===== 分页 ===== */
.pager, p:has(+ table) { color: var(--text-muted); }
.muted { color: var(--text-muted); font-size: 12.5px; }

/* ===== 徽章 / 标签 ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; line-height: 1.6; }
.badge-blue { background: #e8f1fd; color: var(--primary); }
.badge-green { background: #e6f7ef; color: var(--ok); }
.badge-gray { background: #eef0f4; color: #7a8499; }
.badge-orange { background: #fdf1e0; color: var(--warn); }
.tag { display: inline-block; padding: 1px 7px; margin: 1px 3px 1px 0; border-radius: 3px; background: #eef1f6; color: #5a6577; font-size: 12px; }

/* ===== 仪表盘 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.stat-card .si { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.stat-card .sv { font-size: 23px; font-weight: 700; color: #2a3242; line-height: 1.1; }
.stat-card .sl { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-grid .full { grid-column: 1 / -1; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
.chart-box { width: 100%; height: 280px; }

/* 排名榜（金银铜） */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px dashed var(--border); }
.rank-list li:last-child { border-bottom: none; }
.rank-no { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; background: #c4ccd8; flex: none; }
.rank-no.g1 { background: #f5b301; } .rank-no.g2 { background: #b9c2cf; } .rank-no.g3 { background: #cd8b52; }
.rank-list .rn { flex: 1; color: #3a4253; }
.rank-list .rv { color: var(--primary); font-weight: 600; }

/* flash 消息 */
.flash { padding: 10px 14px; border-radius: 5px; margin-bottom: 14px; font-size: 13px; }
.flash.success, .flash.message { background: #e6f7ef; color: #1f8a56; border: 1px solid #bfe8d2; }
.flash.error, .flash.danger { background: #fdeaea; color: #c0392b; border: 1px solid #f3c9c9; }

/* 空状态 */
.empty { text-align: center; color: var(--text-muted); padding: 40px 0; }
