:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #185fa5;
  --primary-dark: #0c447c;
  --primary-soft: #e6f1fb;
  --danger: #b42318;
  --danger-soft: #fcebeb;
  --success: #0f6e56;
  --success-soft: #e1f5ee;
  --sidebar-bg: #1b2b3d;
  --sidebar-text: #c3cfdd;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; background: #eef1f5; padding: 1px 5px; border-radius: 4px; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 15px; border-radius: 8px; font-size: 14px; font-family: inherit;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: #f1f4f8; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: #edc9c6; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; padding: 11px 16px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.card + .card { margin-top: 18px; }
.card-title { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--text); }
.card-hint { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }

.notice { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; line-height: 1.7; }
.notice-info { background: var(--primary-soft); color: var(--primary-dark); }
.notice-success { background: var(--success-soft); color: var(--success); }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-warning { background: #faeeda; color: #854f0b; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #374151; }
.field > span { font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit;
  color: var(--text); background: #fff; border: 1px solid #d5dde7;
  border-radius: 8px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(24, 95, 165, .12);
}
.field-full { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-section-title { font-size: 13px; font-weight: 600; color: var(--primary-dark); margin: 20px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-section-title:first-of-type { margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-error-list { margin: 0 0 16px; padding-left: 20px; color: var(--danger); font-size: 13px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; line-height: 1.7; white-space: nowrap; }
.badge-on { background: var(--success-soft); color: var(--success); }
.badge-off { background: #f1f2f4; color: var(--muted); }
.badge-blue { background: var(--primary-soft); color: var(--primary-dark); }
.badge-purple { background: #eeedfe; color: #3c3489; }

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; background: #fafbfc; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table .muted { color: var(--muted); }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; font-size: 13px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.toolbar input { flex: 1; min-width: 140px; padding: 8px 11px; border: 1px solid #d5dde7; border-radius: 8px; font-size: 14px; font-family: inherit; outline: none; }
.toolbar input:focus { border-color: var(--primary); }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager a { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.pager a:hover { background: #f1f4f8; text-decoration: none; }
.pager .current { padding: 4px 10px; border: 1px solid var(--primary); border-radius: 6px; color: var(--primary); background: var(--primary-soft); }

/* ---------- 登录 / 安装 ---------- */
.auth-page { background: #eef2f7; min-height: 100vh; }
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 7vh 18px 40px; }
.auth-card-wide { max-width: 520px; }
.auth-wrap-wide { max-width: 520px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 11px; font-size: 18px; font-weight: 600; color: #21374f; margin-bottom: 22px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; background: var(--primary);
  color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .5px;
}
.auth-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 8px 28px rgba(27, 43, 61, .06); }
.auth-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 600; }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.auth-card .field { margin-bottom: 15px; }
.auth-foot { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.auth-meta { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- 主框架 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--sidebar-bg);
  color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand .brand-mark { width: 34px; height: 34px; font-size: 11px; border-radius: 8px; }
.sidebar-brand strong { color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
/* 隐藏滚动条但保留滚动能力：Firefox / 旧版 Edge / WebKit 三套写法 */
.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 14px 10px 20px;
  scrollbar-width: none; -ms-overflow-style: none; overscroll-behavior: contain;
}
.sidebar-nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
.nav-group-title { padding: 14px 10px 6px; font-size: 11px; color: #7e8fa3; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 7px; color: var(--sidebar-text); font-size: 13.5px; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(83, 158, 235, .18); color: #fff; }
.nav-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .55; flex: 0 0 5px; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11.5px; color: #7e8fa3; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex: 0 0 60px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; gap: 14px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 10px; border-radius: 8px; background: #f5f7fa; font-size: 13px; }
.user-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.user-dept { color: var(--muted); font-size: 12px; }
.menu-toggle { display: none; border: 1px solid var(--border); background: #fff; border-radius: 7px; width: 34px; height: 34px; cursor: pointer; font-size: 17px; line-height: 1; color: var(--text); }
.sidebar-overlay { display: none; }

.content { padding: 22px; max-width: 1400px; width: 100%; }
.page-head { margin-bottom: 18px; }
.page-head h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- 工作台 ---------- */
.welcome {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.welcome h2 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.welcome p { margin: 0; color: var(--muted); font-size: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 27px; font-weight: 600; line-height: 1.4; margin: 2px 0; letter-spacing: -.5px; }
.stat-note { color: #9aa4b2; font-size: 11.5px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; }
.module-card { display: block; border: 1px solid var(--border); border-radius: 9px; padding: 14px 16px; background: #fff; color: var(--text); }
.module-card:hover { border-color: var(--primary); background: #fbfdff; text-decoration: none; }
.module-card strong { display: block; font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.module-card span { color: var(--muted); font-size: 12.5px; }
.module-card .arrow { color: var(--primary); float: right; font-size: 16px; line-height: 1; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: 12px; white-space: nowrap; width: 120px; flex: 0 0 120px; }
.timeline .act { font-weight: 500; }
.timeline .detail { color: var(--muted); }

/* ---------- 其它 ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.detail-row:last-child { border-bottom: 0; }
.detail-row span:first-child { color: var(--muted); }
.error-box { max-width: 520px; margin: 60px auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 32px; text-align: center; }
.error-code { font-size: 42px; font-weight: 600; color: var(--primary); line-height: 1.2; }
.error-box h1 { font-size: 18px; margin: 8px 0; }
.error-box p { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.placeholder-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 22px; margin: 0 auto 16px; }
.text-center { text-align: center; }

/* ---------- 业务模块 ---------- */
.badge-warn { background: #faeeda; color: #854f0b; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-gray { background: #f1f2f4; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.stat-grid-sm { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat-grid-sm .stat-card { padding: 13px 16px; }
.stat-grid-sm .stat-value { font-size: 22px; }
.stat-value-sm { font-size: 23px; }

.toolbar select {
  padding: 8px 28px 8px 10px; border: 1px solid #d5dde7; border-radius: 8px;
  font-size: 13.5px; font-family: inherit; color: var(--text);
  background: #fff; outline: none; cursor: pointer; max-width: 160px;
}
.toolbar select:focus { border-color: var(--primary); }
.filter-form { flex-wrap: wrap; }
.field-hint { color: #9aa4b2; font-size: 11.5px; font-weight: 400; line-height: 1.4; }
.req { color: var(--danger); font-style: normal; }

.chart-block { padding: 9px 0 12px; border-bottom: 1px dashed var(--border); }
.chart-block:last-of-type { border-bottom: 0; }
.chart-month { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.chart-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.chart-key { width: 52px; flex: 0 0 52px; font-size: 12.5px; color: var(--muted); }
.bar-track { flex: 1; height: 12px; background: #f0f3f7; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; min-width: 2px; }
.bar-blue { background: #3b82c4; }
.bar-green { background: #2f9e79; }
.chart-num { width: 110px; flex: 0 0 110px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin-top: 18px; }

@media (max-width: 1100px) {
  .content { padding: 18px; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 35; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 14px; }
  .topbar-title { font-size: 14px; }
  .user-dept { display: none; }
}
@media (max-width: 560px) {
  .auth-wrap { padding-top: 4vh; }
  .auth-card { padding: 22px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .topbar-title { max-width: 130px; }
  .user-chip { padding: 4px 6px; }
  .user-chip .user-name { display: none; }
  .timeline time { width: auto; flex: 0 0 auto; }
  .timeline li { flex-wrap: wrap; gap: 4px 10px; }
  .stat-value { font-size: 23px; }
}
