/* ============ 分分秒秒客服工单系统样式（黑金） ============ */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d1f24;
  --ink-2: #5b606b;
  --ink-3: #9aa0ab;
  --line: #e6e8ed;
  --gold: #b78a3f;
  --gold-deep: #9a6f2c;
  --gold-soft: #f7f1e6;
  --dark: #141519;
  --dark-2: #1e2027;
  --red: #d04848;
  --green: #2f9e63;
  --blue: #3367d6;
  --orange: #d08020;
  --purple: #6c4bd8;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(20, 21, 25, 0.08);
  font-size: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
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(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; width: 100%; background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; font-weight: 500; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 500;
  transition: all .15s; white-space: nowrap; background: #fff;
}
.btn-primary { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn-primary:hover { background: #000; }
.btn-gold { background: linear-gradient(135deg, #c39a4d, #a6792e); color: #fff; }
.btn-gold:hover { filter: brightness(1.06); }
.btn-ghost { border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-deep); }
.btn-danger { border-color: #f0caca; color: var(--red); }
.btn-danger:hover { background: #fdf1f1; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(ellipse at 70% -10%, #2a2c36 0%, #141519 55%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: #fff; border-radius: 16px; padding: 40px 34px 30px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  text-align: center;
}
.login-logo { display: block; height: 44px; margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 28px; }
.login-feishu {
  width: 100%; padding: 12px; border-radius: 10px; border: none;
  background: linear-gradient(135deg, #3370ff, #245bdb); color: #fff;
  font-size: 15px; font-weight: 600;
}
.login-feishu:hover { filter: brightness(1.05); }
.login-dev { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); }
.login-dev .dev-label { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.login-dev .btns { display: flex; gap: 8px; }
.login-dev .btn { flex: 1; }
.login-error {
  margin-top: 16px; padding: 10px 12px; border-radius: 8px;
  background: #fdf1f1; color: var(--red); font-size: 13px; display: none;
}
.login-note { margin-top: 20px; font-size: 12px; color: var(--ink-3); line-height: 1.7; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--dark); color: #c7cad3;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 18px 14px; display: flex; align-items: center; gap: 7px;
  border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap;
}
.sidebar .brand .brand-lockup { height: 26px; width: auto; display: block; flex-shrink: 0; }
.sidebar .brand .brand-mark { display: none; height: 30px; width: auto; }
.sidebar .brand b { color: #fff; font-size: 13px; line-height: 1.2; font-weight: 600; white-space: nowrap; letter-spacing: .3px; }
.side-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.side-nav .group { font-size: 11px; color: #6b6f7c; padding: 14px 10px 6px; letter-spacing: 1px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; font-size: 13.5px;
  color: #c7cad3; margin-bottom: 2px; transition: all .15s;
}
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: linear-gradient(135deg, rgba(195,154,77,.25), rgba(166,121,46,.15)); color: #e6c98c; }
.side-nav .ico { width: 18px; text-align: center; flex-shrink: 0; }
.side-nav .badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 11px; border-radius: 9px; padding: 1px 7px; font-weight: 600;
}
.side-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side-foot .u-row { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.side-foot .u-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #2c2f38;
  display: grid; place-items: center; color: #e6c98c; font-size: 13px; font-weight: 600;
  overflow: hidden;
}
.side-foot .u-avatar img { width: 100%; height: 100%; object-fit: cover; }
.side-foot .u-name { color: #fff; font-weight: 600; font-size: 12.5px; line-height: 1.3; }
.side-foot .u-role { color: #8b8f9b; font-size: 11.5px; }
.side-foot .logout { color: #8b8f9b; font-size: 12.5px; background: none; border: none; padding: 0; }
.side-foot .logout:hover { color: #e6c98c; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16.5px; }
.topbar .right { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 13px; }
#menuBtn { display: none; background: none; border: none; font-size: 20px; color: var(--ink); }
.content { padding: 22px 24px 48px; }

/* ---------- 卡片/表格 ---------- */
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.panel-head h3 { font-size: 15.5px; }
.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.toolbar .grow { flex: 1; min-width: 180px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; cursor: default; }
.stat-card.clickable { cursor: pointer; transition: transform .12s; }
.stat-card.clickable:hover { transform: translateY(-2px); }
.stat-card .k { color: var(--ink-3); font-size: 12.5px; margin-bottom: 7px; }
.stat-card .v { font-size: 27px; font-weight: 700; font-family: "DIN Alternate", Arial, sans-serif; }
.stat-card .v small { font-size: 12.5px; color: var(--ink-3); font-weight: 400; margin-left: 5px; }
.stat-card.gold .v { color: var(--gold-deep); }
.stat-card.green .v { color: var(--green); }
.stat-card.red .v { color: var(--red); }

/* 工作台双列 */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.dash-col .panel { margin: 0; }

/* 趋势 */
.trend-box { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.trend-title { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.trend-bars { display: flex; align-items: flex-end; gap: 8px; height: 92px; }
.tb-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tb-bar { width: 100%; max-width: 26px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #d8b574, #c39a4d); min-height: 6px; }
.tb-v { font-size: 11px; color: var(--ink-2); font-weight: 600; }
.tb-d { font-size: 10.5px; color: var(--ink-3); }

/* 分类负载 */
.job-load { margin-bottom: 14px; }
.job-load:last-child { margin-bottom: 0; }
.jl-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.jl-name { font-weight: 600; color: var(--ink); }
.jl-track { height: 8px; border-radius: 5px; background: #f2f3f5; overflow: hidden; margin-bottom: 4px; }
.jl-bar { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #d8b574, #c39a4d); }

/* 待办 */
.todo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.todo-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px; background: #fcfcfd;
  padding: 12px 14px; cursor: pointer; text-align: left; transition: all .15s;
}
.todo-item:hover { border-color: var(--gold); box-shadow: 0 4px 14px rgba(166,121,46,.12); }
.todo-item .td-label { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.todo-item .td-count { font-size: 20px; font-weight: 700; color: var(--ink); }
.todo-item .td-count small { font-size: 11.5px; color: var(--ink-3); font-weight: 400; margin-left: 2px; }
.todo-item.gold .td-count { color: var(--gold-deep); }
.todo-item.blue .td-count { color: var(--blue); }
.todo-item.red .td-count { color: var(--red); }

table { width: 100%; border-collapse: collapse; }
.tbl-wrap { overflow-x: auto; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--ink-3); font-weight: 500; font-size: 12px; white-space: nowrap; background: #fafafb; }
tbody tr.clickable { cursor: pointer; }
tr:hover td { background: #fcfcfa; }
td .sub { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 13px; }

/* ---------- 标签/状态 ---------- */
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; margin: 1px 3px 1px 0; background: var(--gold-soft); color: var(--gold-deep); }
.tag.blue { background: #eef4ff; color: var(--blue); }
.tag.gray { background: #f2f3f5; color: #8a8f97; }
.status { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }

/* 优先级标签 */
.pri-urgent { background: #fdf1f1; color: var(--red); }
.pri-high { background: #fff4e5; color: var(--orange); }
.pri-medium { background: #eef4ff; color: var(--blue); }
.pri-low { background: #f2f3f5; color: #8a8f97; }

/* 工单状态 */
.st-open { background: #eef4ff; color: var(--blue); }
.st-processing { background: #fff4e5; color: var(--orange); }
.st-resolved { background: #e8f7ef; color: var(--green); }
.st-closed, .st-disabled, .st-paused, .st-rejected { background: #f2f3f5; color: #8a8f97; }
.st-active, .st-done { background: #e8f7ef; color: var(--green); }
.st-scheduled { background: #fff4e5; color: var(--orange); }
.ok-dot { color: var(--green); font-weight: 600; }
.fail-dot { color: var(--red); font-weight: 600; }

/* SLA 标签 */
.sla-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; border-radius: 6px; padding: 2px 7px;
}
.sla-ok { background: #e8f7ef; color: #1d7d4d; }
.sla-warn { background: #fff4e5; color: var(--orange); }
.sla-over { background: #fdf1f1; color: var(--red); }

/* 回复气泡 */
.reply-bubble {
  border: 1px solid var(--line); border-radius: 10px; background: #fcfcfd;
  padding: 12px 14px; margin-bottom: 10px;
}
.reply-bubble.internal {
  background: #fdfaf3; border-color: #ece2cb;
}
.reply-bubble .rb-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px;
}
.reply-bubble .rb-name { font-weight: 600; font-size: 13px; }
.reply-bubble .rb-time { font-size: 11.5px; color: var(--ink-3); }
.reply-bubble .rb-text { font-size: 13.5px; line-height: 1.7; color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }
.reply-bubble .rb-tag {
  display: inline-block; margin-left: 6px; padding: 0 6px;
  font-size: 11px; font-weight: 600; border-radius: 4px;
  background: var(--gold-soft); color: var(--gold-deep); vertical-align: 1px;
}

/* ---------- 弹窗 / 抽屉 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,21,25,.5);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 36px 16px; overflow-y: auto;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 660px;
  padding: 22px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--ink-3); line-height: 1; }
.modal-close:hover { color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.dl { display: grid; grid-template-columns: 88px 1fr; gap: 9px 14px; font-size: 13.5px; }
.dl dt { color: var(--ink-3); }
.dl dd { word-break: break-all; }
.dl dd a { color: var(--blue); }

.section-title {
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  margin: 18px 0 10px; padding-left: 9px; border-left: 3px solid var(--gold);
}

/* 时间线 */
.timeline { list-style: none; }
.timeline li { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--gold);
}
.timeline li.term::before { background: var(--ink-3); }
.timeline .tl-time { font-size: 11.5px; color: var(--ink-3); }
.timeline .tl-text { font-size: 13px; margin-top: 2px; }
.timeline .tl-note { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: none; padding: 9px 18px; font-size: 13.5px;
  color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--gold-deep); border-bottom-color: var(--gold); font-weight: 600; }

/* Toast */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--dark); color: #fff; padding: 11px 22px; border-radius: 10px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 300;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }

.loading { text-align: center; color: var(--ink-3); padding: 50px 0; font-size: 13px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--ink-3); }
.gold-text { color: var(--gold-deep); font-weight: 600; }

/* ---------- 手机适配 ---------- */
@media (max-width: 860px) {
  #menuBtn { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    width: 230px; transform: translateX(-100%); transition: transform .2s;
  }
  .layout.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .nav-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; }
  .layout.nav-open .nav-mask { display: block; }
  .content { padding: 14px 12px 40px; }
  .topbar { padding: 0 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 45%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 13px 14px; }
  .stat-card .v { font-size: 22px; }
  .dash-grid { grid-template-columns: 1fr; }
  .todo-list { grid-template-columns: 1fr 1fr; }
  .panel { padding: 14px; }
  .modal-mask { padding: 0; }
  .modal { border-radius: 12px 12px 0 0; max-width: none; min-height: 50%; margin-top: auto; }
  .dl { grid-template-columns: 78px 1fr; }
  th, td { padding: 9px 8px; }
}

/* ---------- 最高管理员保护标识 ---------- */
.root-badge {
  display: inline-block; margin-left: 8px; padding: 1px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; border-radius: 4px;
  background: var(--gold-soft); color: var(--gold-deep); border: 1px solid var(--gold);
  vertical-align: 1px;
}
tr.root-row td { background: #fdfaf3; }
.imp-protected-note { font-size: 12px; color: var(--gold-deep); white-space: normal; line-height: 1.5; }

/* ---------- 飞书按部门导入器 ---------- */
.imp-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.imp-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
  margin-bottom: 10px; font-size: 13px;
}
.imp-switch { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); white-space: nowrap; }
.imp-depts { border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-width: 0; }
.dept-tree { max-height: 420px; overflow-y: auto; margin-top: 6px; }
.dept-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; font-size: 13px; color: var(--ink);
  border-radius: 6px; cursor: pointer; line-height: 1.35;
}
.dept-item:hover { background: #f6f7f9; }
.imp-wrap input[type="checkbox"] {
  width: auto; flex: none; margin: 0;
  padding: 0; border: none; border-radius: 0;
  background: none; accent-color: var(--gold);
}
.imp-main { min-width: 0; }
.imp-table-wrap { max-height: 380px; overflow-y: auto; }
.imp-summary { color: var(--gold-deep); font-weight: 600; font-size: 12.5px; }
.imp-exists-tag {
  display: inline-block; margin-left: 8px; padding: 0 7px;
  font-size: 11px; font-weight: 600; border-radius: 4px;
  background: #f2f3f5; color: #8a8f97; vertical-align: 1px;
}
tr.imp-row-exists { color: var(--ink-3); background: #fafafa; }
tr.imp-row-exists b { color: var(--ink-3); font-weight: 600; }
@media (max-width: 760px) {
  .imp-wrap { grid-template-columns: 1fr; }
  .dept-tree { max-height: 220px; }
}
