:root {
  --primary: #00a651;
  --primary-dark: #008a43;
  --primary-deep: #06331e;
  --accent: #f39800;
  --bg: #f4f9f6;
  --card: #ffffff;
  --border: #dcebe2;
  --text: #17301f;
  --muted: #6b8577;
  --danger: #d93025;
  --green: #00a651;
  --orange: #f39800;
  --sidebar: #07301c;
  --sidebar-text: #b9d6c6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, #04240f 0%, #065c2e 55%, #0a7a3f 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px 44px; width: 560px; max-width: 92vw; box-shadow: 0 25px 60px rgba(0, 40, 18, .45); }
.login-brand { margin-bottom: 26px; }
.login-logo { font-size: 22px; font-weight: 700; color: #14231a; }
.login-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.login-form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.login-form input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-form input:focus { outline: none; border-color: var(--primary); }
.otp-row { display: flex; gap: 8px; margin-bottom: 12px; }
.otp-row input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; margin-top: 0; }
.login-tip { font-size: 11px; color: var(--muted); text-align: center; margin-top: 8px; }
.login-divider { text-align: center; font-size: 12px; color: var(--muted); margin: 14px 0 6px; position: relative; }
.login-hint { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); font-size: 12px; color: var(--muted); line-height: 1.9; }
.btn.wecom { background: #12b76a; border-color: #12b76a; color: #fff; font-weight: 600; margin-top: 8px; }
.btn.wecom:hover { background: #0e9d5b; color: #fff; }
.login-msg { margin-top: 12px; padding: 8px 10px; border-radius: 8px; font-size: 13px; background: #fef2f2; color: var(--danger); }
.login-msg.ok { background: #eafaf0; color: var(--primary-dark); }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; }
.side-brand { font-weight: 700; font-size: 14px; color: #fff; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 8px; }
#side-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
#side-nav a { display: block; padding: 11px 18px; color: var(--sidebar-text); text-decoration: none; font-size: 14px; border-left: 3px solid transparent; }
#side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
#side-nav a.active { background: rgba(46, 204, 113, .16); color: #fff; border-left-color: #2ecc71; }
.side-user { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side-user > div:first-child { color: #fff; font-weight: 600; margin-bottom: 4px; }
.role-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #1b4d31; margin-bottom: 10px; }
.role-badge.admin { background: #f39800; color: #3d2800; font-weight: 600; }
.role-badge.engineer { background: #0e5c33; color: #d3f5e2; }
.role-badge.clerk { background: #2e86de; color: #eaf4ff; }
.role-badge.tester { background: #7c5cbf; color: #f0eaff; }
/* 侧边栏底部按钮：深色背景上必须用浅色文字，否则不可见 */
.side-user .btn { display: block; width: 100%; margin-top: 6px; background: transparent; border-color: rgba(255,255,255,.28); color: #e8f5ee; text-align: center; }
.side-user .btn:hover { border-color: #2ecc71; color: #fff; background: rgba(46,204,113,.12); }
.main { flex: 1; margin-left: 200px; padding: 24px 28px; }

/* ---------- 通用组件 ---------- */
.page-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar select, .toolbar input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }
.btn { border: 1px solid var(--border); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.link { border: none; background: none; color: var(--primary); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table.tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: #f3faf6; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid #eef6f1; font-size: 13px; vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #f7fcf9; }

.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tag.blue { background: #e2f4ea; color: #00713a; }
.tag.green { background: #d8f5e4; color: #00713a; }
.tag.gray { background: #eef4f0; color: #52705f; }
.tag.orange { background: #fdeedd; color: #b26a00; }
.tag.red { background: #fde8e6; color: #b3261e; }
.tag.purple { background: #eaf5ee; color: #065c2e; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat-card .num { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-card .lbl { font-size: 12px; color: var(--muted); }
.progress { height: 8px; background: #dcebe2; border-radius: 999px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 弹窗 ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 100; }
.modal { background: #fff; border-radius: 14px; width: 640px; max-width: 100%; padding: 22px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal.wide { width: 860px; }
.modal h3 { margin-bottom: 14px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.modal label { display: block; font-size: 13px; color: var(--muted); }
.modal label input, .modal label select, .modal label textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit;
}
.modal label textarea { min-height: 72px; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.detail-list { font-size: 13px; line-height: 2; }
.detail-list b { color: var(--muted); font-weight: 500; display: inline-block; width: 84px; }

/* Toast */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #06331e; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: fadein .2s; }
.toast.err { background: #b3261e; }
.toast.ok { background: #008a43; }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { border: none; background: none; padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.comment-item { border-bottom: 1px solid #eef6f1; padding: 8px 0; font-size: 13px; }
.kb-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
