/* 企服云 EMS · 管理后台样式（依赖 tokens.css） */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-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.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }
::-webkit-scrollbar-track { background: transparent; }

.app { display: flex; min-height: 100vh; }

/* ---------------- sidebar（墨石底 + 香槟金点缀） ---------------- */
.sidebar {
  width: 236px; flex: 0 0 236px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-line);
  padding: 18px 14px 24px;
}
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); }

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: var(--radius); flex: 0 0 38px;
  background: linear-gradient(140deg, var(--accent) 0%, #D9BC8A 55%, var(--accent-hover) 100%);
  color: #1B1408; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
  box-shadow: 0 6px 16px rgba(176, 138, 79, .35);
}
.brand-name { font-size: 16.5px; font-weight: 600; letter-spacing: .6px; color: var(--on-dark); }
.brand-sub { font-size: 11px; color: var(--on-dark-muted); margin-top: 3px; letter-spacing: .3px; }

.nav-group { margin-bottom: 6px; }
.nav-group-title {
  font-size: 10.5px; color: rgba(152, 162, 179, .78); letter-spacing: 1.2px; padding: 12px 12px 6px;
  text-transform: uppercase; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 1px 0;
  border-radius: var(--radius-sm); color: rgba(249, 250, 251, .78); font-size: 13.5px;
  transition: background .16s ease, color .16s ease; position: relative;
}
.nav-item svg { width: 17px; height: 17px; opacity: .8; flex: 0 0 17px; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--on-dark); }
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--sidebar-active); color: #F3E6CB; font-weight: 600;
}
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item.active svg { opacity: 1; color: var(--accent); }

/* ---------------- main / topbar ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 26px; height: 62px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: .2px; }
.topbar-title span { color: var(--muted-light); font-weight: 400; margin-left: 10px; font-size: 12.5px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar-clock { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm); transition: background .16s; }
.user-menu summary:hover { background: var(--ink-100); }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(140deg, var(--ink-800), var(--ink-600));
  color: #F9FAFB; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255, 255, 255, .12);
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--muted); }
.dropdown {
  position: absolute; right: 0; top: 48px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 156px; padding: 5px; z-index: 50;
}
.dropdown a { display: block; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-sub); }
.dropdown a:hover { background: var(--ink-100); color: var(--text); }

.content { padding: 22px 26px 44px; max-width: 1650px; width: 100%; margin: 0 auto; }

/* ---------------- page header / cards ---------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 21px; color: var(--text); font-weight: 600; letter-spacing: -.2px; }
.page-head .desc { margin-top: 6px; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); padding: 20px; margin-bottom: 18px;
}
.card-title { font-size: 14.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; margin-bottom: 16px; letter-spacing: .1px; }
.card-title .sub { font-weight: 400; font-size: 12px; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  padding: 18px 20px; position: relative; overflow: hidden; transition: box-shadow .18s, border-color .18s;
}
.stat-card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.stat-card::after {
  content: ""; position: absolute; right: -30px; top: -38px; width: 108px; height: 108px; border-radius: 50%;
  background: radial-gradient(circle, rgba(176, 138, 79, .10), transparent 70%);
}
.stat-label { color: var(--muted); font-size: 12.5px; letter-spacing: .2px; }
.stat-value { font-size: 27px; font-weight: 700; margin-top: 8px; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.stat-extra { color: var(--muted); font-size: 12px; margin-top: 8px; }
.stat-icon {
  position: absolute; right: 16px; bottom: 14px; width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent-ink); display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }

/* ---------------- buttons / toolbar ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--card); color: var(--text-sub); font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .16s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-400); color: var(--text); background: var(--ink-50); }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #241A09; font-weight: 600; }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--red); border-color: var(--red-line); background: var(--card); }
.btn-danger:hover { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.btn-sm { height: 30px; padding: 0 11px; border-radius: var(--radius-sm); font-size: 12.5px; }
.btn-link { border: none; background: none; color: var(--accent-ink); cursor: pointer; padding: 0 4px; font-size: 13px; }
.btn-link:hover { color: var(--accent-hover); text-decoration: underline; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.search-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------------- forms ---------------- */
.input, select.input, textarea.input {
  height: 36px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card);
  padding: 0 12px; font-size: 13px; color: var(--text); outline: none;
  transition: border-color .16s, box-shadow .16s; min-width: 0;
  font-family: inherit;
}
textarea.input { height: auto; min-height: 92px; padding: 10px 12px; line-height: 1.6; }
.input:hover { border-color: var(--ink-400); }
.input:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.input::placeholder { color: var(--muted-light); }
select.input { padding-right: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 18px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; color: var(--text-sub); font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--muted-light); }
.field.full { grid-column: 1 / -1; }
.check-row { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 6px 0; }
.check-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
details.form-panel { margin-bottom: 16px; }
details.form-panel > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent-ink); font-size: 13.5px; padding: 8px 0; font-weight: 500;
}
details.form-panel > summary::-webkit-details-marker { display: none; }
details.form-panel > summary::before { content: "+"; font-weight: 700; }
details.form-panel[open] > summary::before { content: "−"; }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
table.table thead th {
  background: var(--card-sub); color: var(--muted); font-weight: 600; text-align: left;
  padding: 11px 14px; white-space: nowrap; border-bottom: 1px solid var(--line); font-size: 12px;
  letter-spacing: .3px; text-transform: none;
}
table.table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--text-sub); white-space: nowrap; }
table.table tbody td.wrap { white-space: normal; min-width: 160px; }
table.table tbody tr:hover td { background: var(--bg-soft); }
table.table tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; color: var(--text-sub); }
.muted { color: var(--muted); }
.strong { font-weight: 600; color: var(--text); }
.actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions form { display: inline; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--ink-100); color: var(--text-sub); font-size: 11.5px; }

/* ---------------- badges ---------------- */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; line-height: 1.35; white-space: nowrap; font-weight: 500; border: 1px solid transparent; }
.badge-green { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.badge-orange { background: var(--orange-soft); color: var(--orange); border-color: var(--orange-line); }
.badge-red { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-line); }
.badge-gray { background: var(--ink-100); color: var(--muted); border-color: var(--line); }
.badge-purple { background: var(--purple-soft); color: var(--purple); border-color: var(--purple-line); }
.badge-gold { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent-line); }

/* ---------------- pager ---------------- */
.pager { display: flex; align-items: center; gap: 8px; padding: 16px 4px 4px; flex-wrap: wrap; }
.pager-total { color: var(--muted); font-size: 12.5px; margin-right: auto; }
.pager-btn {
  min-width: 32px; height: 32px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; color: var(--text-sub); background: var(--card);
  transition: all .16s;
}
.pager-btn:hover { border-color: var(--ink-400); color: var(--text); }
.pager-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager-btn.disabled { opacity: .45; pointer-events: none; }

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 16px; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------------- dashboard widgets ---------------- */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.dash-grid .full { grid-column: 1 / -1; }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding: 6px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; }
.bar-stack { width: 100%; max-width: 34px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 6px; overflow: hidden; }
.bar-seg { width: 100%; }
.bar-seg.normal { background: var(--ink-800); }
.bar-seg.late { background: var(--accent); }
.bar-seg.out { background: var(--blue); }
.bar-seg.other { background: var(--ink-200); }
.bar-label { font-size: 11px; color: var(--muted-light); white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { width: 150px; height: 150px; border-radius: 50%; position: relative; flex: 0 0 150px; }
.donut::after { content: ""; position: absolute; inset: 32px; background: var(--card); border-radius: 50%; }
.donut-list { display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; color: var(--text-sub); }
.donut-list i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.greeting {
  background: linear-gradient(115deg, #FFFFFF 0%, var(--bg-soft) 55%, var(--accent-soft) 130%);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px 26px; margin-bottom: 18px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; box-shadow: var(--shadow-xs);
  position: relative; overflow: hidden;
}
.greeting::after {
  content: ""; position: absolute; right: -60px; top: -80px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(176, 138, 79, .10), transparent 70%);
}
.greeting h2 { margin: 0; font-size: 21px; color: var(--text); font-weight: 600; letter-spacing: -.2px; }
.greeting p { margin: 7px 0 0; color: var(--muted); font-size: 12.5px; }
.greeting .page-actions { margin-left: auto; position: relative; z-index: 1; }

/* ---------------- detail grids / timeline ---------------- */
.desc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 18px; }
.desc-item { background: var(--card-sub); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; }
.desc-item .k { color: var(--muted); font-size: 11.5px; margin-bottom: 5px; }
.desc-item .v { color: var(--text); font-size: 13px; word-break: break-all; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px 10px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tl-time { font-size: 11.5px; color: var(--muted); }
.tl-title { font-size: 13.5px; margin: 3px 0; color: var(--text); }
.tl-desc { font-size: 12.5px; color: var(--text-sub); }
.img-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.img-grid a { display: block; }
.img-grid img { width: 108px; height: 78px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.notice-content { line-height: 1.9; color: var(--text-sub); white-space: pre-wrap; }
.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.alert-success { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.alert-info { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-line); }
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999;
  background: rgba(16, 24, 40, .94); color: #fff; padding: 10px 20px; border-radius: var(--radius-sm); font-size: 13px;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, .08);
}
.toast.error { background: rgba(180, 35, 24, .96); }

/* ---------------- modal ---------------- */
dialog.modal { border: none; border-radius: var(--radius-lg); padding: 0; width: min(720px, 92vw); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(11, 18, 32, .45); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15.5px; color: var(--text); font-weight: 600; }
.modal-body { padding: 18px 20px; max-height: 68vh; overflow: auto; }
.modal-close { border: none; background: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

/* 新增 / 编辑表单悬浮窗 */
dialog.form-dialog { width: min(880px, 94vw); }
dialog.form-dialog .modal-body { max-height: 76vh; }
dialog.form-dialog .modal-body > .card {
  margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
@media (max-width: 640px) {
  dialog.form-dialog {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0;
    border-radius: 0; display: flex; flex-direction: column;
  }
  dialog.form-dialog .modal-body { flex: 1; max-height: none; }
}

/* 详情悬浮窗 */
dialog.detail-modal { width: min(960px, 94vw); }
dialog.detail-modal .modal-head h3 { display: flex; align-items: center; gap: 8px; }
.modal-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 11px 20px; border-bottom: 1px solid var(--line); background: var(--bg-soft);
}
.modal-bar .desc { font-size: 12.5px; color: var(--muted); }
.modal-bar .page-actions { margin-left: auto; }
.modal-bar .page-actions form { display: flex; align-items: center; gap: 8px; margin: 0; }
dialog.detail-modal .modal-body { max-height: 72vh; }
dialog.detail-modal .modal-body > .card { margin-bottom: 14px; }
dialog.detail-modal .modal-body > .card:last-child { margin-bottom: 0; }
.detail-loading { padding: 40px 0; text-align: center; color: var(--muted); font-size: 13px; }
@media (max-width: 640px) {
  dialog.detail-modal[open] { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; display: flex; flex-direction: column; }
  dialog.detail-modal .modal-body { flex: 1; max-height: none; }
  dialog.detail-modal .modal-bar { padding: 10px 16px; }
}

/* 图片画廊 */
dialog.lightbox {
  inset: 0; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0; padding: 0; border: 0;
  background: rgba(8, 24, 42, .93); color: #fff; overflow: hidden;
}
dialog.lightbox::backdrop { background: transparent; }
.lb-img {
  position: absolute; inset: 0; margin: auto; max-width: 90vw; max-height: 84vh;
  border-radius: 10px; box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.lb-close {
  position: absolute; top: 14px; right: 18px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 64px; border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 28px; line-height: 1; cursor: pointer;
}
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .26); }
.lb-bar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: rgba(255, 255, 255, .85);
}
.lb-origin { color: rgba(255, 255, 255, .85); text-decoration: underline; }
.lb-origin:hover { color: #fff; }

/* ---------------- IM / AI chat ---------------- */
.im-layout { display: grid; grid-template-columns: 288px minmax(0, 1fr); gap: 0; height: calc(100vh - 162px); min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--card); box-shadow: var(--shadow-xs); }
@supports (height: 100dvh) { .im-layout { height: calc(100dvh - 162px); } }
/* 让 IM 面板精确占满首屏剩余高度，避免外层出现第二条滚动条 */
.content:has(.im-layout) { display: flex; flex-direction: column; height: calc(100dvh - 62px); padding-bottom: 20px; }
.content:has(.im-layout) > .page-head { flex: 0 0 auto; }
.content:has(.im-layout) .im-layout { flex: 1 1 auto; height: auto; min-height: 0; }

.im-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--card); }
.im-side-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text); font-size: 13.5px; }
.im-side-head summary { padding: 3px 10px; border: 1px solid var(--accent-line); border-radius: 999px; background: var(--accent-soft); white-space: nowrap; }
.im-side-head summary:hover { background: var(--accent-soft); color: var(--accent-ink); }
.im-side-head .dropdown { top: 30px; width: 232px; max-height: min(320px, 55vh); }
.im-side-head .dropdown a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-convs { overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
/* 会话条目是 <a>，必须转成块级，否则上下内边距不参与高度计算 */
.im-conv { display: block; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--line-soft); transition: background .16s; }
.im-conv:hover { background: var(--bg-soft); }
.im-conv.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.im-conv .c-name { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.im-conv .c-name > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-conv .c-last { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.im-conv .c-last-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-conv .c-last .badge { flex: 0 0 auto; }
.im-conv .c-time { font-size: 11px; color: var(--muted-light); font-weight: 400; flex: 0 0 auto; }
.im-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.im-head { padding: 10px 18px; min-height: 50px; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.im-head-avatar { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.im-head .im-status { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
.im-msgs { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px; background: var(--bg-soft); display: flex; flex-direction: column; gap: 12px; }
.im-msgs-empty { margin: auto; padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.msg { display: flex; gap: 10px; max-width: 76%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink-100); color: var(--text-sub); display: flex; align-items: center; justify-content: center; font-size: 12px; flex: 0 0 32px; }
.msg.mine .msg-avatar { background: var(--primary); color: #fff; }
/* 气泡容器需要 min-width:0，否则长串字符会撑破 76% 的上限 */
.msg > div:not(.msg-avatar) { display: flex; flex-direction: column; min-width: 0; }
.msg-bubble { background: var(--card); border: 1px solid var(--line); padding: 9px 13px; border-radius: var(--radius); font-size: 13px; line-height: 1.6; word-break: break-word; color: var(--text); max-width: 100%; }
.msg.mine .msg-bubble { background: var(--primary); border-color: var(--primary); color: #fff; }
.msg-time { font-size: 10.5px; color: var(--muted-light); margin-top: 4px; }
.msg.mine .msg-time { text-align: right; }
.im-input { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: flex-end; gap: 10px; background: var(--card); }
.im-input textarea { flex: 1; min-width: 0; resize: none; height: 44px; min-height: 44px; max-height: 120px; }
.im-input .btn { flex: 0 0 auto; }
.im-empty { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.chat-box { height: calc(100vh - 210px); min-height: 420px; overflow-y: auto; padding: 16px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-lg); display: flex; flex-direction: column; gap: 14px; }
.ai-msg { max-width: 78%; background: var(--card); border: 1px solid var(--line); padding: 12px 15px; border-radius: var(--radius-lg); font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; color: var(--text); box-shadow: var(--shadow-xs); }
.ai-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-color: var(--primary); }
.ai-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ai-links a { background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 5px 12px; font-size: 12px; border: 1px solid var(--accent-line); }
.ai-suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ai-suggest button { border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--text-sub); cursor: pointer; transition: all .16s; }
.ai-suggest button:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

/* ---------------- misc ---------------- */
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.col { flex: 1; min-width: 280px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.text-red { color: var(--red); } .text-green { color: var(--green); } .text-orange { color: var(--orange); }
.sidebar-toggle { display: none; border: none; background: none; font-size: 20px; color: var(--text); cursor: pointer; }
@media (max-width: 1180px) {
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -240px; z-index: 100; transition: left .2s ease; }
  body.sidebar-open .sidebar { left: 0; box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: inline-block; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  /* 窄屏：会话列表改为顶部横向条，保证仍可切换会话 */
  .im-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-height: 320px; }
  .im-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 184px; }
  .im-side-head { padding: 10px 14px; }
  .im-convs { display: flex; flex-direction: row; gap: 8px; padding: 10px 12px; overflow-x: auto; overflow-y: hidden; }
  .im-conv { flex: 0 0 210px; border: 1px solid var(--line); border-radius: var(--radius); }
  .im-conv.active { box-shadow: none; border-color: var(--accent); }
  .im-msgs { padding: 14px; }
  .msg { max-width: 86%; }
}

/* ---------------- login（墨石渐变 + 香槟金） ---------------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(900px 520px at 18% 0%, rgba(176, 138, 79, .10) 0%, transparent 55%),
    radial-gradient(760px 520px at 100% 100%, rgba(16, 24, 40, .06) 0%, transparent 60%),
    var(--bg);
}
.login-card {
  width: min(880px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; background: var(--card);
  border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.login-hero {
  background:
    radial-gradient(520px 320px at 100% 0%, rgba(176, 138, 79, .28) 0%, transparent 62%),
    linear-gradient(155deg, #0B1220 0%, #1D2939 62%, #243447 100%);
  color: var(--on-dark); padding: 46px 40px; display: flex; flex-direction: column; justify-content: space-between; min-height: 460px;
  position: relative;
}
.login-hero h1 { margin: 0; font-size: 29px; letter-spacing: .8px; font-weight: 600; line-height: 1.35; }
.login-hero h1 em { font-style: normal; color: var(--accent); }
.login-hero p { color: rgba(249, 250, 251, .74); line-height: 1.9; font-size: 13px; margin-top: 14px; }
.login-feature { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
.login-feature div { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(249, 250, 251, .86); }
.login-feature span.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .95; flex: 0 0 7px; }
.login-form { padding: 44px 40px; }
.login-form h2 { margin: 0 0 6px; font-size: 21px; color: var(--text); font-weight: 600; }
.login-form .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 26px; }
.login-form .field { margin-bottom: 16px; }
.login-form .input { height: 44px; }
.login-form .btn { height: 44px; width: 100%; font-size: 14px; margin-top: 8px; }
.login-error { background: var(--red-soft); border: 1px solid var(--red-line); color: var(--red); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 14px; }
.login-demo { margin-top: 22px; border-top: 1px dashed var(--line-strong); padding-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.9; }
.login-demo b { color: var(--text); font-weight: 600; }
@media (max-width: 760px) {
  .login-card { grid-template-columns: 1fr; }
  .login-hero { min-height: auto; padding: 28px 24px; }
  .login-hero h1 { font-size: 23px; }
  .login-feature { display: none; }
  .login-form { padding: 28px 24px; }
}

/* ---------------- AI 审核 ---------------- */
.audit-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.audit-level { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid transparent; }
.audit-level.is-low { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.audit-level.is-medium { background: var(--orange-soft); color: var(--orange); border-color: var(--orange-line); }
.audit-level.is-high { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }
.audit-score { font-size: 12.5px; color: var(--muted); }
.audit-score b { color: var(--text); font-size: 17px; font-weight: 600; margin-right: 2px; }
.audit-meter { flex: 1 1 220px; min-width: 160px; height: 6px; border-radius: 999px; background: var(--ink-100); overflow: hidden; }
.audit-meter i { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.audit-meter i.is-medium { background: var(--orange); }
.audit-meter i.is-high { background: var(--red); }
.audit-summary { margin-top: 14px; font-size: 13px; line-height: 1.85; color: var(--text); }
.audit-note { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 12.5px; line-height: 1.85; color: var(--accent-ink); }
.audit-note b { font-weight: 600; }
.audit-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.audit-issue { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius-sm); background: var(--card); }
.audit-issue .tag-lv { flex: 0 0 auto; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin-top: 1px; }
.audit-issue .txt { font-size: 12.5px; line-height: 1.75; }
.audit-issue .txt b { display: block; font-weight: 600; color: var(--text); }
.audit-issue .txt span { color: var(--muted); }
.audit-issue.is-high { border-left-color: var(--red); }
.audit-issue.is-high .tag-lv { background: var(--red-soft); color: var(--red); }
.audit-issue.is-medium { border-left-color: var(--orange); }
.audit-issue.is-medium .tag-lv { background: var(--orange-soft); color: var(--orange); }
.audit-issue.is-low { border-left-color: var(--accent); }
.audit-issue.is-low .tag-lv { background: var(--accent-soft); color: var(--accent-ink); }
.audit-meta { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; gap: 18px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }

/* ---------------- settings tabset (pure CSS) ---------------- */
.tabset { position: relative; }
.tabset > input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.tabset-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabset-nav label {
  padding: 10px 16px; font-size: 13.5px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; transition: color .15s;
}
.tabset-nav label:hover { color: var(--text); }
.tabset-pane { display: none; }
/* 第 N 个单选框对应第 N 个标签与第 N 个面板，不依赖具体 id，可在任意页面复用 */
.tabset > input[type="radio"]:nth-of-type(1):checked ~ .tabset-nav > label:nth-of-type(1),
.tabset > input[type="radio"]:nth-of-type(2):checked ~ .tabset-nav > label:nth-of-type(2),
.tabset > input[type="radio"]:nth-of-type(3):checked ~ .tabset-nav > label:nth-of-type(3),
.tabset > input[type="radio"]:nth-of-type(4):checked ~ .tabset-nav > label:nth-of-type(4),
.tabset > input[type="radio"]:nth-of-type(5):checked ~ .tabset-nav > label:nth-of-type(5),
.tabset > input[type="radio"]:nth-of-type(6):checked ~ .tabset-nav > label:nth-of-type(6) {
  color: var(--text); border-bottom-color: var(--accent); font-weight: 600;
}
.tabset > input[type="radio"]:nth-of-type(1):checked ~ .tabset-panes > .tabset-pane:nth-child(1),
.tabset > input[type="radio"]:nth-of-type(2):checked ~ .tabset-panes > .tabset-pane:nth-child(2),
.tabset > input[type="radio"]:nth-of-type(3):checked ~ .tabset-panes > .tabset-pane:nth-child(3),
.tabset > input[type="radio"]:nth-of-type(4):checked ~ .tabset-panes > .tabset-pane:nth-child(4),
.tabset > input[type="radio"]:nth-of-type(5):checked ~ .tabset-panes > .tabset-pane:nth-child(5),
.tabset > input[type="radio"]:nth-of-type(6):checked ~ .tabset-panes > .tabset-pane:nth-child(6) { display: block; }
@media (max-width: 640px) {
  .tabset-nav label { padding: 9px 12px; font-size: 13px; }
}

/* ---------------- 页面整理通用类（呈现层） ---------------- */
/* 搜索/筛选输入框统一宽度，替代行内 width */
.input.w-140 { width: 140px; }
.input.w-150 { width: 150px; }
.input.w-170 { width: 170px; }
.input.w-180 { width: 180px; }
.input.w-190 { width: 190px; }
.input.w-200 { width: 200px; }
.input.w-220 { width: 220px; }
.input.w-230 { width: 230px; }
.input.w-240 { width: 240px; }
.input.w-250 { width: 250px; }
.input.w-260 { width: 260px; }
.input.w-full { width: 100%; }
.search-form .input, .toolbar .input { max-width: 100%; }

/* 详情栅格整行项 */
.desc-item.full { grid-column: 1 / -1; }
.desc-item.full .v { white-space: pre-wrap; line-height: 1.75; }

/* 快捷入口按钮网格 */
.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quick-actions .btn { width: 100%; }
@media (max-width: 760px) { .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 顶栏下拉（IM 会话切换等） */
.dropdown.dropdown-scroll { right: 0; top: 22px; max-height: 300px; overflow: auto; }
.form-inline { margin: 0; }
.link-block { display: block; padding: 8px 12px; font-size: 12.5px; border-radius: var(--radius-sm); color: var(--text-sub); }
.link-block:hover { background: var(--ink-100); color: var(--text); }

/* 宽表单元格省略 */
.cell-ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center-block { margin-left: auto; margin-right: auto; }

/* 错误 / 空状态页 */
.page-error { text-align: center; padding: 60px 20px; }
.page-error .icon { font-size: 46px; line-height: 1; }
.page-error h1 { font-size: 20px; margin: 14px 0 8px; }
.page-error .desc { color: var(--muted); font-size: 13px; }
.empty-state { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 13px; }


/* 上传控件即时预览 */
.upload-preview { margin-top: 10px; }
.upload-preview[hidden] { display: none; }
.upload-thumb {
  display: inline-block; line-height: 0; padding: 3px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color .15s;
}
.upload-thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; display: block; }
.upload-thumb:hover { border-color: var(--accent-line); }
.upload-file {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card-sub);
  font-size: 13px; color: var(--text-sub);
}
.upload-file:hover { border-color: var(--accent-line); color: var(--accent-ink); }
.upload-file-icon {
  flex: 0 0 auto; min-width: 34px; padding: 2px 5px; border-radius: 4px; text-align: center;
  background: var(--primary-soft); color: var(--primary); font-size: 10.5px; font-weight: 600; letter-spacing: .3px;
}
.upload-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-file-meta { flex: 0 0 auto; color: var(--muted-light); font-size: 12px; }
