/* 后台管理端样式 */
:root {
  --ink: #0d1726; --ink-2: #16243a; --muted: #5c6b80; --muted-2: #8b97a8;
  --line: #e2e7ee; --line-2: #eef1f5; --bg: #f6f8fa; --card: #fff;
  --brand: #d93a2b; --ok: #1f8a5b; --warn: #cf8a1f;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); background: var(--bg); color: var(--ink-2); font-size: 14px; line-height: 1.65; }
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; line-height: 1.3; font-weight: 700; color: var(--ink); }
button, input, select, textarea { font: inherit; }
input, select, textarea { color: var(--ink); }

/* 登录 */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(800px 400px at 70% 10%, #eef2f8, transparent), #f6f8fa; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(13,23,38,.08); }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card p { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.login-card .field { margin-bottom: 14px; }
.login-err { color: var(--brand); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* 布局 */
.app { display: none; min-height: 100dvh; }
.app.is-in { display: grid; grid-template-columns: 210px 1fr; }
.side { background: var(--ink); color: rgba(255,255,255,.66); padding: 18px 14px; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; }
.side__brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; color: #fff; }
.side__brand b { font-size: 14.5px; }
.side__brand span { font-size: 11px; color: rgba(255,255,255,.45); display: block; }
.side__dot { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(140deg, var(--brand), #f0664f); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.side nav { display: grid; gap: 3px; }
.side nav button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 10px 11px; border: 0; background: transparent; color: rgba(255,255,255,.66); border-radius: 8px; font-size: 13.5px; cursor: pointer; }
.side nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav button.is-active { background: var(--brand); color: #fff; font-weight: 600; }
.side__foot { margin-top: auto; padding-top: 16px; font-size: 12px; color: rgba(255,255,255,.35); display: grid; gap: 8px; }
.side__foot button { background: rgba(255,255,255,.08); border: 0; color: rgba(255,255,255,.8); padding: 8px; border-radius: 7px; cursor: pointer; font-size: 12.5px; }

.main { padding: 22px clamp(16px, 3vw, 32px) 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { font-size: 20px; }
.topbar p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.topbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13.5px; font-weight: 500; cursor: pointer; transition: .15s; }
.btn:hover { border-color: #cbd5e1; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: #bb2c1f; }
.btn--ghost { background: transparent; }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--danger { color: var(--brand); border-color: #f3d5d1; }
.btn--danger:hover { background: #fdf2f0; }

/* 卡片与统计 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.stat__label { font-size: 12.5px; color: var(--muted-2); margin-bottom: 6px; }
.stat__num { font-size: 27px; font-weight: 800; color: var(--ink); letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat__sub { font-size: 12px; color: var(--muted-2); margin-top: 5px; }
.stat--accent { background: linear-gradient(140deg, #16243a, #0d1726); border-color: transparent; }
.stat--accent .stat__label, .stat--accent .stat__sub { color: rgba(255,255,255,.55); }
.stat--accent .stat__num { color: #fff; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; }
.grid-2eq { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1080px) { .stats { grid-template-columns: repeat(2, 1fr); } .grid-2, .grid-2eq { grid-template-columns: 1fr; } }

.card h3 { font-size: 14.5px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card h3 small { font-weight: 400; color: var(--muted-2); font-size: 12px; }

/* 条形图 */
.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 150px 1fr 56px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar__label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__track { height: 8px; background: var(--line-2); border-radius: 5px; overflow: hidden; }
.bar__fill { height: 100%; background: linear-gradient(90deg, #e2604f, var(--brand)); border-radius: 5px; transition: width .5s; }
.bar__val { text-align: right; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.hours { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: 6px; }
.hours div { flex: 1; background: #dfe5ee; border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.hours div.on { background: var(--brand); }
.hours-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted-2); margin-top: 5px; }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfcfd; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:hover td { background: #fcfdfe; }
.tbl-wrap { overflow-x: auto; }
.mono { font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--muted); }
.tag--new { background: #fdf1ef; color: var(--brand); }
.tag--done { background: #eef9f3; color: var(--ok); }
.tag--auto { background: #eef4ff; color: #2c5fb3; }

/* 列表 */
.list { display: grid; gap: 12px; }
.item { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 14px 16px; }
.item__head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item__title { font-size: 14px; font-weight: 600; color: var(--ink); }
.item__meta { font-size: 12px; color: var(--muted-2); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.item__actions { display: flex; gap: 6px; flex-shrink: 0; }

/* 表单 */
.field { display: grid; gap: 6px; margin-bottom: 13px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); }
.field textarea { min-height: 70px; resize: vertical; }
.field textarea.code { min-height: 300px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.7; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .row-2 { grid-template-columns: 1fr; } }

/* 弹层 */
.modal { position: fixed; inset: 0; background: rgba(13,23,38,.45); display: none; z-index: 200; padding: 24px; overflow-y: auto; }
.modal.is-open { display: block; }
.modal__box { max-width: 820px; margin: 0 auto; background: #fff; border-radius: 14px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal__head h3 { margin: 0; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* 对话 */
.chatlist { display: grid; gap: 8px; max-height: 520px; overflow-y: auto; }
.chatrow { padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: #fff; }
.chatrow:hover { border-color: #cbd5e1; }
.chatrow.is-active { border-color: var(--brand); background: #fff9f8; }
.chatrow b { font-size: 13px; display: block; }
.chatrow span { font-size: 12px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.msgs { display: flex; flex-direction: column; gap: 10px; max-height: 380px; overflow-y: auto; padding: 12px; background: var(--bg); border-radius: 10px; }
.m { max-width: 82%; padding: 9px 12px; border-radius: 10px; font-size: 13px; background: #fff; border: 1px solid var(--line-2); white-space: pre-wrap; word-break: break-word; }
.m--user { margin-left: auto; background: var(--brand); color: #fff; border-color: transparent; }
.m--admin { background: #eef4ff; border-color: #dbe7fb; }
.m--sys { background: #eef9f3; border-color: #cfeade; color: #146c47; font-size: 12.5px; }
.reply { display: flex; gap: 8px; margin-top: 10px; }
.reply input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; }

.hint { font-size: 12.5px; color: var(--muted-2); line-height: 1.7; }
.toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 9px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: .24s; z-index: 300; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.panel { display: none; }
.panel.is-on { display: block; }

@media (max-width: 860px) {
  .app.is-in { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px; }
  .side nav { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .side nav button { white-space: nowrap; padding: 8px 12px; }
  .side__brand { padding-bottom: 12px; }
  .side__foot { display: none; }
  .bar { grid-template-columns: 92px 1fr 46px; }
}
