﻿/* ========== 多级任务管理系统 全局样式 ========== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warn: #d97706;
  --warn-light: #fffbeb;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%); padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.role-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.role-chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 5px 14px; font-size: 12px; color: var(--muted);
  transition: all .15s;
}
.role-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.form-item { margin-bottom: 14px; }
.form-item label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-item input, .form-item textarea, .form-item select {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; outline: none; background: #fff;
  transition: border-color .15s;
}
.form-item input:focus, .form-item textarea:focus, .form-item select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 500;
  background: var(--primary); color: #fff; transition: opacity .15s, background .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-top: 8px; text-align: center; }

/* ---------- 布局 ---------- */
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; padding: 10px 20px;
}
.topbar .brand { font-size: 17px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.topbar .user-box { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.role-tag { display: inline-block; font-size: 11px; padding: 2px 10px; border-radius: 999px; background: var(--primary-light); color: var(--primary); }
.role-tag.super { background: #fef3c7; color: #92400e; }
.role-tag.super2 { background: #ede9fe; color: #5b21b6; }
.role-tag.admin { background: #dbeafe; color: #1e40af; }
.role-tag.audit { background: #fce7f3; color: #9d174d; }
.role-tag.user { background: #dcfce7; color: #166534; }
.wrap { max-width: 1100px; margin: 20px auto; padding: 0 16px; }

/* 账号管理树形 */
.tree-toggle { background: none; border: none; cursor: pointer; font-size: 12px; color: #495057; width: 18px; height: 18px; line-height: 16px; padding: 0; margin-right: 2px; border-radius: 4px; }
.tree-toggle:hover { background: #e9ecef; }
.tree-dot { display: inline-block; width: 18px; color: #adb5bd; text-align: center; font-size: 12px; }
.tree-row td { border-bottom: 1px solid #f1f3f5; }
.tree-row:hover { background: #f8f9fa; }

/* 置顶消息 */
.pin-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a); border: 1px solid #fcd34d; border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.pin-banner .pin-title { font-weight: 700; color: #92400e; font-size: 14px; }
.pin-banner .pin-content { color: #78350f; font-size: 13px; margin-top: 2px; white-space: pre-wrap; }
.pin-banner .pin-time { color: #a16207; font-size: 12px; margin-top: 4px; }

/* 导航按钮 */
.nav-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.nav-tabs .nav-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 12px 22px; font-size: 15px; font-weight: 600; color: var(--muted);
  transition: all .15s; flex: 1; min-width: 100px; text-align: center;
}
.nav-tabs .nav-btn:hover { border-color: var(--primary); color: var(--primary); }
.nav-tabs .nav-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(37,99,235,.3); }
.nav-tabs .nav-btn .badge { display: block; font-size: 11px; font-weight: 400; opacity: .85; margin-top: 2px; }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h3 { font-size: 16px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card .muted { color: var(--muted); font-size: 13px; }
.tip { font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; background: #f8fafc; white-space: nowrap; }
.tbl tr:hover td { background: #f8fafc; }
.tbl .empty { text-align: center; color: var(--muted); padding: 26px 0; }
.row-hover { cursor: pointer; }

/* 徽章 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.yes { background: var(--danger-light); color: var(--danger); }
.badge.no { background: var(--success-light); color: var(--success); }
.badge.info { background: var(--primary-light); color: var(--primary); }
.badge.warn { background: var(--warn-light); color: var(--warn); }

/* 图片墙 */
.img-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.img-grid .img-item { position: relative; }
.img-grid img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }
.img-grid .del-img {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none; font-size: 12px; line-height: 1;
}
.file-list { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.file-list a { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }

/* 模版画廊 */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tpl-card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tpl-card img { width: 100%; height: 160px; object-fit: cover; display: block; }
.tpl-card .tpl-body { padding: 12px 14px; }
.tpl-card .tpl-title { font-weight: 600; margin-bottom: 6px; }
.tpl-card .tpl-content { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.tpl-card .tpl-foot { font-size: 11px; color: #94a3b8; margin-top: 8px; }

/* 模版多选下发对象 */
.tpl-targets { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
.tpl-target-item { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.tpl-target-item input { accent-color: var(--primary); }
.tpl-target-item:has(input:checked) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* 两栏布局（用户详情） */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.split .side { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.split .side .side-item { padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px; }
.split .side .side-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sub-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.sub-btns .sub-btn { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 16px; font-size: 13px; color: var(--muted); }
.sub-btns .sub-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 520px; max-height: 86vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal h3 { margin-bottom: 16px; }

/* 模糊搜索框 */
.search-input {
  width: 100%; max-width: 340px; padding: 8px 12px; margin: 10px 0 4px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px; box-sizing: border-box; background: #fff;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

/* 扣单三卡片 */
.deduct-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.deduct-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: #fff; }
.deduct-card h4 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.deduct-card .big-status { font-size: 26px; font-weight: 800; text-align: center; padding: 12px 0; }

/* Toast */
#toast-box { position: fixed; top: 18px; right: 18px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: slideIn .25s ease; max-width: 320px;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 管理端侧栏 */
.admin-body { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #0f172a; color: #cbd5e1; flex-shrink: 0; padding: 16px 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .s-brand { font-size: 16px; font-weight: 700; color: #fff; padding: 6px 20px 16px; }
.sidebar .s-item { display: block; width: 100%; text-align: left; background: none; border: none; color: #cbd5e1; padding: 11px 20px; font-size: 14px; transition: all .15s; border-left: 3px solid transparent; }
.sidebar .s-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .s-item.active { background: rgba(37,99,235,.25); color: #fff; border-left-color: var(--primary); }
.sidebar .s-foot { padding: 14px 20px; font-size: 12px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); margin-top: 10px; }
.main { flex: 1; padding: 20px; min-width: 0; }
.page-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* 上传区 */
.upload-zone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted);
  cursor: pointer; transition: all .15s; background: #f8fafc; margin-bottom: 10px;
}
.upload-zone:hover { border-color: var(--primary); color: var(--primary); }

/* 小工具 */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.flex1 { flex: 1; }
.text-right { text-align: right; }
.link-chip { background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 6px; font-size: 12px; word-break: break-all; }
/* 报量等需保留换行的内容：一行一个 */
.pre-line { white-space: pre-line; word-break: break-all; }
@media (max-width: 1100px) {
  .split { grid-template-columns: 200px 1fr; }
}
@media (max-width: 820px) {
  .admin-body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; display: flex; flex-wrap: wrap; padding: 8px; overflow-x: auto; }
  .sidebar .s-brand { width: 100%; }
  .sidebar .s-item { width: auto; border-left: none; border-bottom: 3px solid transparent; padding: 8px 14px; }
  .sidebar .s-foot { display: flex; width: 100%; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 4px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 8px; }
  .sidebar .s-foot .mt8 { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0; }
  .split { grid-template-columns: 1fr; }
  .nav-tabs .nav-btn { min-width: 30%; }
  .main { padding: 12px; }
  .wrap { margin: 12px auto; padding: 0 10px; }
  .card { padding: 14px; }
  .modal { max-width: 100%; padding: 18px; }
  /* 表格在手机上横向滚动，避免撑破页面 */
  table.tbl { display: block; overflow-x: auto; width: 100%; white-space: nowrap; }
  table.tbl .pre-line { white-space: pre-line; }
  .topbar { padding: 8px 12px; }
  .topbar .user-box { font-size: 12px; gap: 8px; }
  .topbar .brand { font-size: 15px; }
  .tpl-card img { height: 120px; }
  .img-grid img { width: 88px; height: 88px; }
  .tpl-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .toast { max-width: 260px; right: 10px; top: 10px; }
  .tpl-targets { padding: 8px; }
  .login-card { padding: 26px 20px; }
  .upload-zone { padding: 14px; }
}

/* ========== 实时对话 ========== */
.chat-wrap { display: flex; gap: 12px; align-items: stretch; min-height: 480px; height: calc(100vh - 190px); }
.chat-contacts { width: 240px; min-width: 200px; border: 1px solid var(--border); border-radius: 10px; background: #fff; display: flex; flex-direction: column; overflow: hidden; }
.chat-c-title { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--border); font-size: 13px; }
.chat-contact-list { flex: 1; overflow-y: auto; }
.chat-contact { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.chat-contact:hover { background: var(--primary-light); }
.chat-contact.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
.cc-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.cc-sub { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-main { flex: 1; border: 1px solid var(--border); border-radius: 10px; background: #fff; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.chat-head { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; background: #f8fafc; }
.chat-msg { margin-bottom: 12px; }
.chat-msg.me { text-align: right; }
.cm-head { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.chat-msg.me .cm-head { text-align: right; }
.cm-bubble { display: inline-block; max-width: 76%; padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; text-align: left; }
.chat-msg.other .cm-bubble { background: #fff; border: 1px solid var(--border); }
.chat-msg.me .cm-bubble { background: var(--primary); color: #fff; }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; outline: none; font-size: 13px; }
.chat-input-row input:focus { border-color: var(--primary); }
.unread-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; margin-left: 5px; vertical-align: middle; }
@media (max-width: 720px) {
  .chat-wrap { flex-direction: column; height: auto; min-height: 70vh; }
  .chat-contacts { width: 100%; min-width: 0; max-height: 200px; }
  .chat-main { min-height: 380px; }
}

/* 启动加载遮罩 */
.loading-mask{position:fixed;inset:0;z-index:9999;background:linear-gradient(135deg,#1e3a8a,#3b82f6);display:flex;align-items:center;justify-content:center}
.loading-box{color:#fff;font-size:16px;background:rgba(255,255,255,.12);padding:16px 28px;border-radius:12px}
/* 账号备注 */
.note-text { display: inline-block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; color: #495057; font-size: 12px; }
