/* =========================================================
   KK AI Hub · 设计基础（主界面与管理后台共用）
   色彩取自快快兔：品牌蓝 + 青绿；页面安静、只在首页横幅用渐变
   ========================================================= */
:root {
  color-scheme: light;
  --paper: #f4f7fb;
  --surface: #ffffff;
  --sunk: #f7f9fc;
  --ink: #172440;
  --ink-2: #4a5878;
  --muted: #7b88a3;
  --line: #e3e9f2;
  --line-2: #eef2f8;
  --brand: #2f6bf0;
  --brand-d: #2257cf;
  --brand-soft: #eaf1ff;
  --mint: #0f9f8f;
  --mint-soft: #e3f7f3;
  --amber: #c9760f;
  --amber-soft: #fff3e0;
  --red: #d23f47;
  --red-soft: #fdecec;
  --violet: #5b4fd6;
  --violet-soft: #efedff;
  --grey-soft: #eef1f6;
  --grad: linear-gradient(118deg, #5b5ff0 0%, #3f86f2 40%, #22b9dc 76%, #3fd8c4 100%);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --shadow-1: 0 1px 2px rgba(23, 36, 64, 0.06);
  --shadow-2: 0 8px 28px rgba(23, 36, 64, 0.12);
  --shadow-3: 0 24px 64px rgba(23, 36, 64, 0.22);
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.6 var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none; /* 禁止选中复制（输入框除外） */
}
input, textarea, select { user-select: text; -webkit-user-select: text; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: 0.01em; }
a { color: var(--brand); text-decoration: none; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* 水印 */
.watermark {
  position: fixed; inset: 0; z-index: 9998; pointer-events: none; overflow: hidden;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  font-size: 13px; color: rgba(23, 36, 64, 0.075); letter-spacing: 1px;
}
.watermark span { margin: 48px 36px; white-space: nowrap; transform: rotate(-18deg); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: #c9d4e6; background: var(--sunk); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #f3c3c6; }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--grey-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 15px; border-radius: var(--r); }
.btn .ico { width: 16px; height: 16px; flex: none; }
.link { background: none; border: 0; padding: 0 4px; font: inherit; font-size: 13px; color: var(--brand); cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--red); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .label { font-size: 13px; color: var(--ink-2); }
.field > .label .req { color: var(--red); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 8px 10px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 107, 240, .14); }
.input[readonly] { background: var(--sunk); color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-size: 13px; font-weight: 600; color: var(--ink); padding-top: 6px; border-top: 1px solid var(--line-2); grid-column: 1 / -1; }
.form-section:first-child { border-top: 0; padding-top: 0; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* 分段选择（替代下拉，选项少时一眼看全） */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface); font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.seg label:hover { border-color: #c4d2ea; }
.seg input:checked + label { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-d); font-weight: 600; }
.seg input:focus-visible + label { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 搜索框 */
.search { position: relative; }
.search .input { padding-left: 32px; }
.search svg { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ---------- 徽标 / 标签 ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-gap { background: #fbe3e4; color: #a8232b; }
.b-tight { background: var(--red-soft); color: var(--red); }
.b-expand { background: var(--amber-soft); color: var(--amber); }
.b-normal, .b-sufficient { background: var(--brand-soft); color: var(--brand-d); }
.b-redundant { background: var(--mint-soft); color: var(--mint); }
.b-unfilled { background: var(--grey-soft); color: var(--muted); }
.b-admin { background: var(--violet-soft); color: var(--violet); }
.b-tech { background: var(--mint-soft); color: var(--mint); }
.b-manager { background: var(--amber-soft, #fff4e0); color: var(--amber, #c77700); }
.b-user { background: var(--brand-soft); color: var(--brand-d); }
.b-success { background: var(--mint-soft); color: var(--mint); }
.b-fail { background: var(--red-soft); color: var(--red); }
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; margin: 2px 4px 2px 0; border-radius: 4px; background: var(--grey-soft); color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.chip.more { background: transparent; color: var(--brand); cursor: pointer; border: 1px dashed #bcd0f3; }
.tier { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; background: var(--brand-soft); color: var(--brand-d); font-size: 12px; font-weight: 600; white-space: nowrap; }
.tier.hot { background: var(--mint-soft); color: var(--mint); }
.unfilled { color: var(--muted); font-size: 12.5px; }

/* ---------- 卡片 / 面板 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px 0; }
.card-head h2, .card-head h3 { font-size: 16px; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px 20px 20px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .search { width: 240px; }
.toolbar .select { width: auto; min-width: 128px; }
.toolbar .input[type=date] { width: 148px; }
.toolbar .count { color: var(--muted); font-size: 13px; }
.toolbar .spacer { flex: 1; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { position: sticky; top: 0; background: var(--sunk); color: var(--ink-2); font-weight: 600; font-size: 12.5px; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafcff; }
.tbl tr.clickable { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl td.wrap { min-width: 200px; max-width: 360px; white-space: normal; color: var(--ink-2); }
.tbl td.models { min-width: 220px; max-width: 420px; }
.tbl td.ops { white-space: nowrap; text-align: right; }
.tbl .strong { font-weight: 600; }
.tbl .sub { display: block; font-size: 12px; color: var(--muted); }
.tbl select.select { height: 30px; font-size: 13px; width: auto; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 12px; font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; }
.pager button { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; }
.pager button.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.pager button:disabled { opacity: .45; cursor: default; }
.pager .select { height: 30px; width: auto; font-size: 13px; }

/* ---------- 抽屉 / 弹窗 ---------- */
.overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(17, 27, 50, .38); display: flex; opacity: 0; transition: opacity .18s; }
.overlay.show { opacity: 1; }
.drawer { margin-left: auto; height: 100%; width: min(var(--w, 560px), 100vw); background: var(--surface); box-shadow: var(--shadow-3); display: flex; flex-direction: column; transform: translateX(24px); transition: transform .2s ease-out; }
.overlay.show .drawer { transform: none; }
.dialog { margin: auto; width: min(var(--w, 440px), calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); display: flex; flex-direction: column; transform: scale(.98); transition: transform .18s; }
.overlay.show .dialog { transform: none; }
.panel-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px 14px; border-bottom: 1px solid var(--line-2); }
.panel-head h3 { font-size: 17px; }
.panel-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.panel-head .x { margin-left: auto; width: 32px; height: 32px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.panel-head .x:hover { background: var(--grey-soft); color: var(--ink); }
.panel-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.panel-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line-2); background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.panel-foot .left { margin-right: auto; color: var(--muted); font-size: 12.5px; }

/* 提示条 */
.note { padding: 10px 14px; border-radius: var(--r); background: var(--brand-soft); color: var(--ink-2); font-size: 13px; line-height: 1.6; }
.note.warn { background: var(--amber-soft); }
.note.ok { background: var(--mint-soft); }
.note.danger { background: var(--red-soft); }
.note b { color: var(--ink); }

/* Toast */
.toasts { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: 520px; padding: 10px 16px; border-radius: var(--r); background: var(--ink); color: #fff; font-size: 13.5px; box-shadow: var(--shadow-2); animation: toastIn .2s ease-out; white-space: pre-line; }
.toast.ok::before { content: "✓"; color: #5fe3cf; font-weight: 700; }
.toast.err { background: #a8232b; }
.toast.err::before { content: "!"; font-weight: 700; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* 下拉菜单 */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 500; min-width: 180px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.menu button:hover, .menu a:hover { background: var(--grey-soft); }
.menu .sep { height: 1px; margin: 4px 0; background: var(--line-2); }
.menu .who { padding: 8px 10px 10px; font-size: 12.5px; color: var(--muted); }
.menu .who b { display: block; font-size: 14px; color: var(--ink); }

/* 会话倒计时 */
.session-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px; background: var(--grey-soft); color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.session-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }
.session-pill.warn { background: var(--amber-soft); color: var(--amber); }
.session-pill.warn::before { background: var(--amber); }

/* 头像 */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-d); font-weight: 600; font-size: 13px; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 4px; border: 0; border-radius: 20px; background: transparent; font: inherit; color: var(--ink); cursor: pointer; }
.user-btn:hover { background: var(--grey-soft); }
.user-btn .nm { font-size: 13.5px; }

/* ---------- 折线图 ---------- */
.chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 170px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-size: 12px; line-height: 1.7; box-shadow: var(--shadow-2); }
.chart-tip b { display: block; margin-bottom: 2px; font-size: 12.5px; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; vertical-align: 0; }
.series { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.series-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; }
.series-chip i { width: 8px; height: 8px; border-radius: 50%; background: #c8d0de; }
.series-chip.on { color: var(--ink); border-color: color-mix(in srgb, var(--c) 45%, white); background: color-mix(in srgb, var(--c) 8%, white); }
.series-chip.on i { background: var(--c); }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.metric-card { position: relative; padding: 12px 12px 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.metric-card h4 { font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.metric-card .now { font-size: 12px; color: var(--muted); }
@media (max-width: 860px) { .metric-grid { grid-template-columns: 1fr; } }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 3px; margin-right: 6px; border-radius: 2px; vertical-align: middle; }

/* 详情表 */
.kv { display: grid; grid-template-columns: 96px 1fr 96px 1fr; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; font-size: 13.5px; }
.kv > div { padding: 9px 12px; border-bottom: 1px solid var(--line-2); }
.kv > div:nth-child(odd) { background: var(--sunk); color: var(--muted); }
.kv > div.wide { grid-column: 2 / -1; }
@media (max-width: 640px) { .kv { grid-template-columns: 90px 1fr; } }
.section-title { margin: 20px 0 10px; font-size: 14px; font-weight: 600; }

/* 分组更新纪要 */
.cl { min-width: 260px; max-width: 460px; }
.cl summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: baseline; cursor: pointer; list-style: none; }
.cl summary::-webkit-details-marker { display: none; }
.cl summary .cl-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.cl summary .cl-more { font-size: 12px; color: var(--brand); white-space: nowrap; }
.cl summary .cl-more::after { content: " ▾"; }
.cl[open] summary .cl-more::after { content: " ▴"; }
.cl[open] summary .cl-sum { visibility: hidden; }
.cl-date { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cl-list { list-style: none; margin: 8px 0 8px 3px; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.cl-list li { position: relative; padding: 0 0 10px; }
.cl-list li::before { content: ""; position: absolute; left: -19px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.cl-list li + li::before { background: #c4cfe2; }
.cl-text { white-space: pre-wrap; color: var(--ink); line-height: 1.6; }
.cl-ops { margin-top: 2px; }
.cl-ops .link { padding-left: 0; padding-right: 8px; font-size: 12px; }
.cl-tag { display: inline-block; height: 18px; padding: 0 6px; border-radius: 9px; font-size: 11px; line-height: 18px; font-weight: 600; }
.cl-tag.new { background: var(--mint-soft); color: var(--mint); }
.cl-tag.soon { background: var(--amber-soft); color: var(--amber); }
