* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb; --primary-dark: #1d4ed8; --bg: #f4f6fb; --card: #fff;
  --text: #1f2937; --muted: #6b7280; --border: #e5e7eb; --danger: #dc2626;
  --warn: #d97706; --ok: #16a34a; --radius: 10px;
}
body { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
button { font-family: inherit; cursor: pointer; font-size: 13px; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2563eb, #7c3aed); }
.login-box { background: #fff; padding: 40px; border-radius: 16px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box p.sub { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.btn { padding: 9px 16px; border: none; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 500; }
.btn:hover { background: var(--primary-dark); }
.btn.block { width: 100%; padding: 11px; font-size: 15px; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f9fafb; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.gray { background: #e5e7eb; color: #374151; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #111827; color: #d1d5db; padding: 18px 0; position: fixed; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 0 20px 18px; font-size: 16px; font-weight: 600; color: #fff; }
.sidebar .brand small { display: block; font-weight: 400; font-size: 11px; color: #9ca3af; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: #d1d5db; text-decoration: none; font-size: 14px; border-left: 3px solid transparent; }
.nav a:hover { background: #1f2937; color: #fff; }
.nav a.active { background: #1f2937; color: #fff; border-left-color: var(--primary); }
.nav .badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.main { margin-left: 220px; flex: 1; padding: 22px 28px; max-width: calc(100vw - 220px); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar h2 { font-size: 20px; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.user-name { display: inline-flex; align-items: center; gap: 6px; color: var(--text,#111827); text-decoration: none; font-size: 14px; font-weight: 600; padding: 5px 10px; border-radius: 8px; }
.user-name:hover { background: #f3f4f6; }
.role-chip { font-size: 11px; font-weight: 400; color: var(--muted); background: #f3f4f6; padding: 1px 6px; border-radius: 8px; }
.bell { position: relative; cursor: pointer; font-size: 18px; }
.bell .dot { position: absolute; top: -4px; right: -6px; background: var(--danger); color: #fff; font-size: 10px; padding: 0 5px; border-radius: 8px; }
tr.row-done { background: #f0fdf4; }
tr.row-done td { color: #6b7280; }
tr.row-done a { color: #6b7280; }
.tag.done { background: #dcfce7; color: #15803d; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat.red .num { color: var(--danger); } .stat.warn .num { color: var(--warn); }
.stat.ok .num { color: var(--ok); } .stat.blue .num { color: var(--primary); }
.stat.green .num { color: #059669; }
.stat.clickable { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.stat.clickable:hover { box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-1px); }
.stat.active { outline: 2px solid var(--primary); outline-offset: -2px; background: #f0f6ff; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.toolbar .spacer { flex: 1; }
.batch-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 10px 14px; margin-bottom: 14px; background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 10px; font-size: 13px; }
.batch-bar .spacer { flex: 1; }
.batch-bar b { color: var(--primary); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 500; background: #fafbfc; position: sticky; top: 0; z-index: 2; }
/* 可筛选表头 */
th.stu-filt { cursor: pointer; user-select: none; white-space: nowrap; }
th.stu-filt:hover { background: #eef2ff; color: var(--primary); }
th.stu-filt .filt-ico { color: #9aa4b2; font-size: 11px; }
th.stu-filt.filt-active { color: var(--primary); font-weight: 600; }
th.stu-filt.filt-active .filt-ico { color: var(--primary); }
th.stu-filt.filt-open { background: #e0e7ff; }
.table-wrap { max-height: 62vh; overflow: auto; border-radius: 8px; }
.table-wrap table { min-width: 900px; }
/* 筛选下拉弹层 */
.filt-pop { background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.14); padding: 6px; min-width: 150px; max-height: 320px; overflow: auto; z-index: 9999; }
.filt-pop-title { font-size: 12px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.filt-item { padding: 7px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.filt-item:hover { background: #f1f5f9; }
.filt-item-on { color: var(--primary); font-weight: 600; background: #eef2ff; }
.filt-pop-dates { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.filt-pop-dates input { border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px; font-size: 12px; }
.filt-pop-quick { display: flex; gap: 10px; padding: 4px 12px 8px; font-size: 12px; }
.filt-pop-quick a { color: var(--primary); }
.filt-pop-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--border); }
/* 顶部筛选块 */
.filter-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; margin-left: 6px; background: #eef2ff; color: var(--primary); border-radius: 12px; font-size: 12px; cursor: pointer; }
.filter-chip:hover { background: #e0e7ff; }
tbody tr:hover { background: #f9fafb; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.tag.new { background: #dbeafe; color: #1e40af; }
.tag.old { background: #e5e7eb; color: #374151; }
.tag.deposit { background: #fef3c7; color: #92400e; }
.tag.full { background: #d1fae5; color: #065f46; }
.tag.pending { background: #fef3c7; color: #92400e; }
.tag.done { background: #d1fae5; color: #065f46; }
.tag.overdue { background: #fee2e2; color: #991b1b; }
.tag.gray { background: #f3f4f6; color: #4b5563; }
.tag.blue { background: #e0edff; color: #1e40af; }
.tag.fresh { background: #10b981; color: #fff; font-weight: 600; padding: 1px 6px; }
.tag.assign-new { background: #f59e0b; color: #fff; font-weight: 600; padding: 1px 6px; }
.tag.refund { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }
.tag.contact-ok { background: #d1fae5; color: #065f46; }

/* 联系状态单选 */
.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-opt { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--border); border-radius: 20px; background: #fff; cursor: pointer; font-size: 13px; user-select: none; transition: all .12s; }
.radio-opt:hover { border-color: var(--primary); }
.radio-opt input[type="radio"] { width: auto; margin: 0; accent-color: var(--primary); cursor: pointer; }
.radio-opt:has(input:checked) { background: #eef2ff; border-color: var(--primary); color: var(--primary); font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 40px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; color: var(--muted); }

/* 时间线 */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; margin-bottom: 18px; }
.tl-item::before { content: ''; position: absolute; left: -21px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary); }
.tl-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tl-time { font-weight: 600; }
.tl-body { color: #374151; margin-top: 4px; white-space: pre-wrap; }
.tl-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 720px; max-width: 100%; padding: 24px; }
.modal.narrow { width: 480px; }
.modal.medium { width: 560px; }
.modal h3 { margin-bottom: 18px; font-size: 17px; }
/* 紧凑表单：标签与控件同行，行间距更小 */
.form-compact .frow { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 10px; margin-bottom: 12px; }
.form-compact .frow > label { margin: 0; text-align: right; font-size: 13px; color: var(--muted); line-height: 1.3; }
.form-compact .frow .ctl { min-width: 0; }
.form-compact .frow.top { align-items: flex-start; }
.form-compact .frow.top > label { padding-top: 9px; }
.form-compact input, .form-compact select, .form-compact textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; box-sizing: border-box; }
.form-compact input:focus, .form-compact select:focus, .form-compact textarea:focus { border-color: var(--primary); }
.form-compact textarea { resize: vertical; }
.form-compact .frow2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-compact .frow2 .field { margin-bottom: 0; }
/* 紧凑表单：多列行（标签在上、控件在下），用于短字段并排 */
.frow-cols { display: grid; gap: 12px 14px; margin-bottom: 12px; }
.frow-cols.c3 { grid-template-columns: 1fr 1fr 1fr; }
.frow-cols .fc { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.frow-cols .fc > label { font-size: 13px; color: var(--muted); line-height: 1.3; }
.frow-cols .fc input, .frow-cols .fc select, .frow-cols .fc textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; box-sizing: border-box; }
.frow-cols .fc input:focus, .frow-cols .fc select:focus, .frow-cols .fc textarea:focus { border-color: var(--primary); }
.form-compact .sect-t { font-size: 13px; font-weight: 600; color: var(--text); margin: 4px 0 10px; padding-left: 8px; border-left: 3px solid var(--primary); }
.form-compact .sect-t:not(:first-child) { margin-top: 6px; }
/* 图片选择器在紧凑表单中：去掉内层自带的外边距与重复标题 */
.form-compact .ctl .field { margin-bottom: 0; }
.form-compact .ctl .field > label { display: none; }
.form-compact .img-picker { padding: 8px 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid2 .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.close-x { float: right; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }

#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 100; }
.toast { background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; margin-bottom: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* 通知列表（消息提醒弹窗） */
.nd { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.nd:last-child { border-bottom: none; }
.nd:hover { background: #f9fafb; }
.nd .t { font-weight: 500; }
.nd .b { color: var(--muted); font-size: 12px; margin-top: 2px; }
.nd.unread { background: #eff6ff; }
.nd-link { margin-top: 6px; }
.nd-link a { color: var(--primary); font-size: 13px; text-decoration: none; }
.nd-link a:hover { text-decoration: underline; }
.notif-list { max-height: 60vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.notif-more { padding: 12px; text-align: center; border-top: 1px solid var(--border); }
.notif-more.muted { color: var(--muted); font-size: 13px; }
.notif-unread-tip { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--primary); }

.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 14px; }
.row-actions { display: flex; gap: 6px; }

/* 参数设置：两列栅格 + 选项列表 */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.settings-grid .card { margin-bottom: 0; }
.settings-card { display: flex; flex-direction: column; }
.settings-card h3 { margin-bottom: 8px; }
.settings-card .muted { font-size: 12px; margin-bottom: 10px; }
.opt-list { margin: 10px 0; max-height: 300px; overflow-y: auto; }
.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.opt-actions { display: flex; gap: 10px; margin-top: auto; padding-top: 6px; }

/* ---------- 自定义日期选择器 ---------- */
input.dp-date { cursor: pointer; background-color: #fff; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa4b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='18' rx='2'/><line x1='16' y1='2' x2='16' y2='6'/><line x1='8' y1='2' x2='8' y2='6'/><line x1='3' y1='10' x2='21' y2='10'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.dp-pop { position: absolute; z-index: 10000; width: 292px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 10px; user-select: none; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dp-title { font-weight: 600; font-size: 15px; }
.dp-nav { width: 34px; height: 34px; border: none; background: #f3f4f6; border-radius: 8px; font-size: 20px; line-height: 1; cursor: pointer; color: #374151; }
.dp-nav:hover { background: #e0e7ff; color: var(--primary); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow span { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.dp-day { display: flex; align-items: center; justify-content: center; height: 36px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.dp-day:hover { background: #eef2ff; }
.dp-out { color: #c3c9d2; }
.dp-today { color: var(--primary); font-weight: 700; box-shadow: inset 0 0 0 1px var(--primary); }
.dp-sel, .dp-sel:hover { background: var(--primary); color: #fff; font-weight: 600; box-shadow: none; }
.dp-quick { display: flex; gap: 12px; justify-content: center; padding: 8px 0 4px; font-size: 13px; }
.dp-quick a { color: var(--primary); }
.dp-actions { display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }
@media (max-width: 640px) { .dp-pop { width: calc(100vw - 24px); max-width: 340px; } .dp-day { height: 42px; font-size: 15px; } }

/* ---------- 图片查看器(放大/滚轮缩放/拖拽) ---------- */
.img-viewer { position: fixed; inset: 0; z-index: 20000; background: rgba(0,0,0,.86); display: flex; flex-direction: column; animation: iv-in .12s ease-out; }
@keyframes iv-in { from { opacity: 0 } to { opacity: 1 } }
.iv-stage { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.iv-img { max-width: none; max-height: none; transform-origin: center center; user-select: none; will-change: transform; box-shadow: 0 8px 40px rgba(0,0,0,.5); border-radius: 4px; }
.iv-bar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; background: rgba(0,0,0,.4); }
.iv-bar button { min-width: 40px; height: 36px; padding: 0 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.1); color: #fff; border-radius: 8px; font-size: 15px; cursor: pointer; line-height: 1; }
.iv-bar button:hover { background: rgba(255,255,255,.22); }
.iv-pct { color: #fff; font-size: 13px; min-width: 52px; text-align: center; opacity: .9; }
