/* 授信问答库 —— 深色 PRTS 风（星空 + 流星 + 磨砂玻璃） */
:root {
  --bg: #12141a;
  --bg2: #161922;
  --fg: #ffffff;
  --muted: #9aa4b8;
  --accent: #6f8cff;
  --accent2: #7ce0ff;
  --card: rgba(30, 32, 40, .72);
  --card-border: rgba(166, 180, 230, .16);
  --hit: #4ac97e;
  --review: #f0a63c;
  --miss: #ef6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 700px at 78% -10%, #1d2440 0%, #12141a 55%, #0d0f14 100%);
  color: var(--fg);
  font-family: 'MiSans', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-size: 14px;
}

#sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.app-layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.glass {
  background: var(--card);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .06);
}

/* ---------------- 侧栏 ---------------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  margin: 14px 0 14px 14px; padding: 18px 14px;
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 10px; background: #fff;
  display: grid; place-items: center; font-size: 20px; color: #111;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.brand h1 { font-size: 16px; margin: 0; color: #fff; letter-spacing: .5px; }
.brand .sub { margin: 2px 0 0; font-size: 10px; color: var(--muted); letter-spacing: 1px; }
nav { display: flex; flex-direction: column; gap: 6px; }
nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: 13.5px;
  border: 1px solid transparent; transition: .16s;
}
nav a:hover { color: #fff; background: rgba(111, 140, 255, .12); }
nav a.active {
  color: #fff; background: rgba(111, 140, 255, .18);
  border-color: rgba(140, 165, 255, .35);
}
nav a svg { width: 16px; height: 16px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-foot .hint { font-size: 11px; color: var(--muted); line-height: 1.6; }

/* ---------------- 内容区 ---------------- */
.content { padding: 20px 22px 42px; display: flex; flex-direction: column; gap: 16px; }
.page-head h2 { margin: 0; font-size: 20px; color: #fff; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }

.card { padding: 16px 18px; }
.card h3 {
  margin: 0 0 12px; font-size: 14.5px; color: #fff;
  display: flex; align-items: center; gap: 8px;
}
.card h3 svg { width: 16px; height: 16px; color: var(--accent2); }

/* 统计卡 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 11.5px; color: var(--muted); letter-spacing: .4px; }
.stat .v { font-size: 24px; font-weight: 700; color: #fff; margin-top: 6px; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }

/* 表单 */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(166, 180, 230, .2);
  color: #fff; border-radius: 9px; padding: 9px 11px; font-size: 13px;
  font-family: inherit; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(140, 165, 255, .6); background: rgba(111, 140, 255, .1);
}
textarea { resize: vertical; line-height: 1.6; }
select option { background: #1b1e27; }
label.fld { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.grow { flex: 1; min-width: 180px; }

button {
  background: rgba(111, 140, 255, .2); color: #fff;
  border: 1px solid rgba(140, 165, 255, .4);
  padding: 9px 15px; border-radius: 9px; cursor: pointer; font-size: 13px;
  font-family: inherit; display: inline-flex; align-items: center; gap: 6px;
  transition: .15s;
}
button:hover { background: rgba(111, 140, 255, .32); }
button.primary { background: linear-gradient(135deg, #5a76ff, #7ce0ff); border: none; color: #0d1220; font-weight: 600; }
button.ghost { background: transparent; border-color: rgba(166, 180, 230, .25); color: var(--muted); }
button.ghost:hover { color: #fff; }
button.danger { background: rgba(239, 107, 107, .16); border-color: rgba(239, 107, 107, .4); }
button svg { width: 15px; height: 15px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(166, 180, 230, .12); }
th { color: #fff; font-weight: 600; font-size: 12.5px; background: rgba(255, 255, 255, .04); }
tbody tr:hover { background: rgba(111, 140, 255, .07); }
td.q { max-width: 320px; }
td.a { max-width: 460px; color: #dfe4f0; white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; border: 1px solid transparent; white-space: nowrap;
}
.tag.cat { color: #cbd7ff; background: rgba(111, 140, 255, .14); border-color: rgba(140, 165, 255, .3); }
.tag.hit { color: var(--hit); background: rgba(74, 201, 126, .14); border-color: rgba(74, 201, 126, .38); }
.tag.review { color: var(--review); background: rgba(240, 166, 60, .14); border-color: rgba(240, 166, 60, .38); }
.tag.miss { color: var(--miss); background: rgba(239, 107, 107, .14); border-color: rgba(239, 107, 107, .38); }
.tag.strict { color: #ffd479; background: rgba(255, 212, 121, .12); border-color: rgba(255, 212, 121, .32); }

/* 匹配结果卡 */
.result { border-left: 3px solid var(--accent); padding: 14px 16px; }
.result.hit { border-left-color: var(--hit); }
.result.review { border-left-color: var(--review); }
.result.miss { border-left-color: var(--miss); }
.result .ans { white-space: pre-wrap; line-height: 1.75; margin: 10px 0 8px; font-size: 13.5px; }
.result .meta { font-size: 11.5px; color: var(--muted); }

/* 上传区 */
.drop {
  border: 1.5px dashed rgba(140, 165, 255, .45); border-radius: 12px;
  padding: 26px; text-align: center; color: var(--muted); cursor: pointer;
  background: rgba(111, 140, 255, .05); transition: .18s;
}
.drop:hover, .drop.over { border-color: var(--accent2); background: rgba(124, 224, 255, .09); color: #fff; }
.drop svg { width: 26px; height: 26px; margin-bottom: 8px; color: var(--accent2); }

.progress-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--card-border); }
.chip.hit { color: var(--hit); border-color: rgba(74, 201, 126, .4); }
.chip.review { color: var(--review); border-color: rgba(240, 166, 60, .4); }
.chip.miss { color: var(--miss); border-color: rgba(239, 107, 107, .4); }
.chip.total { color: #fff; }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(6, 8, 14, .68); z-index: 60;
  display: grid; place-items: center; padding: 24px;
}
.modal { width: min(880px, 96vw); max-height: 88vh; overflow: auto; padding: 20px 22px; }
.modal h3 { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .full { grid-column: 1 / -1; }
.hidden { display: none !important; }

/* 加载遮罩 / 提示 */
#loading-mask {
  position: fixed; inset: 0; z-index: 80; background: rgba(8, 10, 16, .55);
  display: grid; place-items: center; gap: 12px; grid-auto-flow: row;
  backdrop-filter: blur(3px);
}
#loading-mask .box { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .16); border-top-color: var(--accent2);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-mask span { color: var(--muted); font-size: 12.5px; }

#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 90; padding: 11px 18px; border-radius: 10px; font-size: 13px;
  background: rgba(24, 27, 36, .95); border: 1px solid var(--card-border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45); color: #fff;
}
#toast.err { border-color: rgba(239, 107, 107, .5); color: #ffd7d7; }
#toast.ok { border-color: rgba(74, 201, 126, .5); color: #d6ffe4; }

/* 登录页 */
.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; }
.login-card { width: min(400px, 92vw); padding: 32px 30px; text-align: center; }
.login-card .logo {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 16px; background: #fff;
  display: grid; place-items: center; font-size: 30px; color: #111;
}
.login-card h2 { margin: 0 0 4px; color: #fff; font-size: 19px; }
.login-card p.sub { color: var(--muted); font-size: 12px; margin: 0 0 20px; }
.login-card input { width: 100%; margin-bottom: 10px; }
.login-card button { width: 100%; justify-content: center; margin-top: 6px; }
.login-err { color: #ffb3b3; font-size: 12.5px; margin-bottom: 8px; }

.bar { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #5a76ff, #7ce0ff); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 12.5px; }
.kv .k { color: var(--muted); }
details summary { cursor: pointer; color: #cbd7ff; font-size: 12.5px; }
details { margin-top: 6px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; margin: 12px; }
}

/* ---------------- 数据可视化页 ---------------- */
.entry-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
a.entry-card {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  text-decoration: none; color: #fff; transition: .16s;
}
a.entry-card:hover { transform: translateY(-2px); border-color: rgba(140, 165, 255, .45); }
a.entry-card > svg:first-child { width: 22px; height: 22px; color: var(--accent2); flex: 0 0 auto; }
a.entry-card b { display: block; font-size: 13.5px; color: #fff; }
a.entry-card span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
a.entry-card .arw { width: 16px; height: 16px; margin-left: auto; color: var(--muted); }

.hint-inline { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.hint-inline b { font-weight: 600; }
.viz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
/* 关键：1fr 子项默认 min-width:auto，会被 Chart.js 显式宽度的 canvas 撑破 → 整页横向溢出 */
.viz-grid > * { min-width: 0; }
.viz-grid .span2 { grid-column: 1 / -1; }
#kpi-strip { grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); }
#kpi-strip .stat .k { display: flex; flex-direction: column; gap: 1px; }
#kpi-strip .stat .k2 { font-size: 10px; opacity: .62; letter-spacing: .2px; }
.chart-wrap { position: relative; height: 300px; min-width: 0; overflow: hidden; }
.chart-wrap.short { height: 232px; }
.legend-hint { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.legend-hint .lg { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.legend-hint .lg i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: 0 0 auto; }
.legend-hint .lg b { color: #fff; font-variant-numeric: tabular-nums; }
.legend-hint .lg em { font-style: normal; margin-left: auto; }
.heat { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.heat-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.heat-row .hl { width: 34px; font-size: 11.5px; flex: 0 0 auto; }
.heat-row .chip { font-style: normal; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--card-border); color: var(--muted); }
.chip.ok { color: #bff5d4; border-color: rgba(74, 201, 126, .45); background: rgba(74, 201, 126, .12); }
.chip.thin { color: #ffe0b0; border-color: rgba(240, 166, 60, .45); background: rgba(240, 166, 60, .12); }
.chip.gap { color: #ffc9c9; border-color: rgba(239, 107, 107, .45); background: rgba(239, 107, 107, .12); }
.low-list table td { font-size: 12.5px; }
.recent-list { display: flex; flex-direction: column; gap: 9px; }
.recent-item { font-size: 12.5px; color: #dfe4f0; line-height: 1.55; display: block; }
.recent-item .q { margin-left: 6px; }
.recent-item .tag { flex: 0 0 auto; }
.scorebar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .08); overflow: hidden; margin: 8px 0 2px; }
.scorebar > i { display: block; height: 100%; border-radius: 999px; }
a.ghost-link { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 9px; border: 1px solid rgba(166, 180, 230, .25); color: var(--muted); text-decoration: none; font-size: 13px; }
a.ghost-link:hover { color: #fff; background: rgba(111, 140, 255, .12); }
a.ghost-link svg { width: 15px; height: 15px; }
/* 热词云（自绘 canvas） */
.wordcloud-wrap { position: relative; height: 340px; min-width: 0; }
.wordcloud-wrap canvas { display: block; width: 100%; height: 100%; }
.wordcloud-wrap canvas.hot { cursor: pointer; }
.wc-tip { position: absolute; z-index: 6; pointer-events: none; padding: 5px 9px; border-radius: 8px;
  background: rgba(20, 22, 30, .96); border: 1px solid var(--card-border); color: #fff; font-size: 11.5px;
  white-space: nowrap; opacity: 0; transform: translate(-50%, -150%); transition: opacity .12s; }
.wc-tip.on { opacity: 1; }
.wc-tip em { font-style: normal; color: var(--muted); }

@media (max-width: 1100px) { .viz-grid { grid-template-columns: 1fr; } }
