:root {
  --bg: #f5f6f8;
  --card: #fff;
  --line: #e8eaef;
  --line-2: #f1f3f6;
  --ink: #15181f;
  --ink-2: #4a5261;
  --muted: #8b93a2;
  --primary: #2f6fed;
  --primary-weak: #edf3ff;
  --green: #0e9f6e;
  --green-weak: #e7f8f1;
  --amber: #c47f0a;
  --amber-weak: #fdf4e3;
  --red: #d64545;
  --red-weak: #fdeeee;
  --gray-weak: #f1f2f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 28, 45, 0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: 216px; flex: none; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px;
  font-size: 15px; font-weight: 700; letter-spacing: .2px;
}
.logo {
  width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.nav { padding: 6px 10px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 2px 0;
  border-radius: 9px; color: var(--ink-2); font-size: 13.5px;
}
.nav a:hover { background: var(--line-2); text-decoration: none; }
.nav a.on { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .45; }
.nav a.on .dot { opacity: 1; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 12px; }
.side-user { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.side-user .u-name { font-weight: 600; }
.side-user .u-role { color: var(--muted); font-size: 12px; }

.main { flex: 1; margin-left: 216px; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: rgba(255, 255, 255, .86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.page { padding: 22px 26px 60px; max-width: 1320px; width: 100%; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line-2);
}
.card-hd h2 { font-size: 14px; }
.card-bd { padding: 16px 18px; }
.card-bd.tight { padding: 0; overflow-x: auto; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat.accent { background: linear-gradient(135deg, #2f6fed, #4f8bff); border: 0; color: #fff; }
.stat.accent .k { color: rgba(255, 255, 255, .8); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
  font-size: 13.5px; line-height: 1.2; white-space: nowrap; transition: .12s;
}
.btn:hover { border-color: #d5d9e2; background: #fbfcfe; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #2560d4; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { background: #0b8b60; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.block { width: 100%; justify-content: center; }
.btn.danger { color: var(--red); border-color: #f3d2d2; background: #fff; }
.btn.danger:hover { background: var(--red-weak); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.field .req { color: var(--red); margin-left: 2px; }
.input, .select, textarea.input {
  width: 100%; padding: 9px 11px; border: 1px solid #dfe2e9; border-radius: 9px;
  background: #fff; outline: none; transition: .12s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 237, .12); }
textarea.input { resize: vertical; min-height: 72px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.err-text { color: var(--red); font-size: 12.5px; min-height: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px;
  padding: 10px 14px; background: #fafbfc; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfe; }
.table .num { font-variant-numeric: tabular-nums; }
.table .right { text-align: right; }
.table .ops { white-space: nowrap; }
.table .ops a { margin-right: 10px; font-size: 13px; }

/* ---------- 快捷标记状态 ---------- */
.btn.tiny { padding: 3px 9px; font-size: 12px; border-radius: 6px; line-height: 1.6; }
.btn.amber { color: var(--amber); border-color: #f0dcb8; background: #fffdf8; }
.btn.amber:hover { background: var(--amber-weak); }
.btn.red { color: var(--red); border-color: #f3d2d2; background: #fff; }
.btn.red:hover { background: var(--red-weak); }
.btn.green-line { color: var(--green); border-color: #bfe8d8; background: #f8fdfb; }
.btn.green-line:hover { background: var(--green-weak); }
.btn.tiny:disabled, .btn.big-mark:disabled { opacity: 0.55; cursor: default; }
.quick { display: inline-flex; gap: 6px; flex-wrap: nowrap; vertical-align: middle; }
.quick .btn { white-space: nowrap; }
.mark-block { background: var(--gray-weak); border-radius: 10px; padding: 14px 16px; }
.btn.big-mark { padding: 8px 20px; font-size: 13.5px; border-radius: 8px; }
tr.flash { animation: rowFlash 0.9s ease; }
@keyframes rowFlash {
  0% { background: var(--primary-weak); }
  100% { background: transparent; }
}
.todo-name { display: flex; align-items: center; gap: 8px; }
.strong { font-weight: 600; }
.sub { color: var(--muted); font-size: 12.5px; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; line-height: 1.7; background: var(--gray-weak); color: var(--ink-2); white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.pending { background: #eef1f6; color: #5b6474; }
.badge.passed { background: var(--green-weak); color: var(--green); }
.badge.failed { background: var(--amber-weak); color: var(--amber); }
.badge.skipped { background: #f0f1f4; color: #777f8d; }
.badge.revisit_failed { background: var(--red-weak); color: var(--red); }
.badge.role { background: var(--primary-weak); color: var(--primary); }
.badge.role::before, .badge.plain::before { display: none; }
.badge.off { background: #f0f1f4; color: #9aa1ad; }

/* ---------- 工具栏 / 分页 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.toolbar.sub { padding-top: 0; gap: 8px; }
#f-leads .toolbar:first-child { border-bottom: none; padding-bottom: 8px; }
#f-leads .toolbar.sub { border-bottom: 1px solid var(--line-2); padding-bottom: 14px; }
.toolbar .input[type="date"],
.toolbar .input[type="month"] { width: auto; padding: 7px 30px 7px 10px; }
/* 日期 / 月份选择器：整块可点、右边给日历图标留位置、宽度够看清 */
input.input[type="date"],
input.input[type="month"] {
  min-width: min(156px, 100%);
  padding-right: 30px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}
input.input[type="month"] { min-width: min(138px, 100%); }
input.input[type="date"]::-webkit-calendar-picker-indicator,
input.input[type="month"]::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: .85; padding: 3px; margin-right: -5px; border-radius: 6px;
}
input.input[type="date"]::-webkit-calendar-picker-indicator:hover,
input.input[type="month"]::-webkit-calendar-picker-indicator:hover {
  background: rgba(47, 111, 237, .14); opacity: 1;
}
.chip { border: 1px solid var(--line); background: #fff; color: var(--ink-2); border-radius: 999px; padding: 4px 12px; font-size: 12px; cursor: pointer; line-height: 1.5; }
.chip:hover { border-color: #cfe0ff; color: var(--primary); }
.chip.on { background: var(--primary-weak); border-color: #cfe0ff; color: var(--primary); font-weight: 600; }
.search { position: relative; }
.search .input { padding-left: 32px; width: 240px; }
.search::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }
.pager .btns { display: flex; gap: 8px; }

/* ---------- 空状态 ---------- */
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 28px; opacity: .35; margin-bottom: 8px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1000px 500px at 50% -10%, #e8f0ff, transparent), var(--bg); padding: 20px; }
.login-card { width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 10px 40px rgba(30, 50, 90, .08); }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .muted { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.foot-note { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 20, 30, .38); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; overflow: auto;
  animation: fade .12s ease;
}
.modal { width: 460px; max-width: 100%; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(10, 20, 40, .2); }
.modal.wide { width: 620px; }
.modal-hd { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line-2); }
.modal-hd h3 { font-size: 15px; }
.modal-bd { padding: 18px; max-height: 62vh; overflow: auto; }
.modal-ft { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line-2); }
.x { border: 0; background: transparent; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.x:hover { background: var(--line-2); }
@keyframes fade { from { opacity: 0; } }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1c2333; color: #fff; padding: 9px 16px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); animation: pop .15s ease; }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } }

/* ---------- 时间线 ---------- */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px 4px; font-size: 13px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -17px; top: 5px; width: 7px; height: 7px; border-radius: 50%; background: #fff; border: 1.5px solid #c9cfda; }
.tl-item.hi::before { border-color: var(--primary); background: var(--primary); }
.tl-time { color: var(--muted); font-size: 12px; }

/* ---------- 上传 ---------- */
.drop {
  border: 1.5px dashed #d8dde6; border-radius: 12px; padding: 26px; text-align: center; cursor: pointer;
  color: var(--muted); transition: .15s; background: #fbfcfe;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-weak); color: var(--primary); }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumb { position: relative; width: 96px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f3f4f6; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb .rm { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; border: 0; cursor: pointer; font-size: 11px; line-height: 18px; padding: 0; }

/* ---------- 杂项 ---------- */
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .side { display: none; }
  .main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}
