/* Tailwind CSS 本地化（2026-10-31）：原走 cdn.jsdelivr.net，国内网络频繁
   ERR_CONNECTION_RESET——@import 挂了整页样式静默缺一块，极难排查。
   与驾驶舱共用 web/cockpit/tailwind.min.css（同一 app 的 /static 挂载）。 */
@import url('/static/tailwind.min.css');

/* ============ 设计令牌 ============
   与驾驶舱同一套底色（两页平级，视觉必须是同一个产品），
   强调色从驾驶舱的蓝换成紫罗兰——监察页是"看系统有没有跑偏"的地方，
   配色上要跟"看经营数据"区分开，避免在大屏上认错页面。 */
:root {
  --c-primary: #7A5CFF;
  --c-primary-2: #9C86FF;
  --c-mint: #00D3A7;
  --c-blue: #2E7CFF;

  --bg-0: #0B1220;
  --bg-1: #141F35;
  --bg-2: #1B2740;

  --tx-1: #E8EEF7;
  --tx-2: #8A9AB5;
  --tx-3: #5B6A85;

  --fn-up: #00D6A4;
  --fn-warn: #FFB020;
  --fn-down: #FF5C5C;

  --glass-bg: rgba(27, 39, 64, 0.55);
  --glass-brd: rgba(138, 154, 181, 0.16);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.36);

  --radius: 14px;
  --gap: 16px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: linear-gradient(180deg, var(--bg-0) 0%, #0A101C 100%);
  color: var(--tx-1);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* 背景光晕：两团柔和的紫/青，纯 CSS，不吃性能 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(680px 420px at 12% -6%, rgba(122, 92, 255, .20), transparent 62%),
    radial-gradient(620px 400px at 92% 4%, rgba(0, 211, 167, .12), transparent 60%);
}

.wrap { position: relative; z-index: 1; max-width: 1440px; margin: 0 auto; padding: 0 20px 96px; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: rgba(11, 18, 32, .78);
  border-bottom: 1px solid var(--glass-brd);
}
.topbar-in {
  max-width: 1440px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-dot {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-mint) 100%);
  box-shadow: 0 4px 14px rgba(122, 92, 255, .45);
  display: grid; place-items: center;
  font-size: 15px;
}
.brand h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: .3px; }
.brand small { display: block; color: var(--tx-3); font-size: 11px; font-weight: 400; margin-top: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.link-back {
  color: var(--tx-2); text-decoration: none; font-size: 13px;
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--glass-brd); background: rgba(27, 39, 64, .5);
  transition: all .18s var(--ease);
}
.link-back:hover { color: var(--tx-1); border-color: rgba(122, 92, 255, .5); transform: translateY(-1px); }

.who { color: var(--tx-2); font-size: 12px; }

/* ============ 概览卡 ============ */
.cards {
  display: grid; gap: var(--gap); margin: 18px 0;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
}
.card {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 14px 16px;
  animation: rise .5s var(--ease) both;
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.card:hover { transform: translateY(-3px); border-color: rgba(122, 92, 255, .38); }
.card::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--c-primary), transparent 78%);
  opacity: .75;
}
.card .k { color: var(--tx-2); font-size: 12px; }
.card .v { font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.5px; }
.card .u { color: var(--tx-3); font-size: 11px; margin-top: 3px; }
.card.is-warn .v { color: var(--fn-warn); }
.card.is-bad .v { color: var(--fn-down); }
.card.is-good .v { color: var(--fn-up); }

/* ============ Tab ============ */
.tabs {
  display: flex; gap: 4px; margin: 8px 0 14px;
  border-bottom: 1px solid var(--glass-brd);
  overflow-x: auto;
}
.tab {
  position: relative; background: none; border: 0; cursor: pointer;
  color: var(--tx-2); font-size: 14px; font-weight: 500;
  padding: 10px 16px; border-radius: 10px 10px 0 0;
  transition: color .18s var(--ease), background .18s var(--ease);
  white-space: nowrap; font-family: inherit;
}
.tab:hover { color: var(--tx-1); background: rgba(122, 92, 255, .08); }
.tab.on { color: var(--tx-1); }
.tab.on::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--c-primary), var(--c-primary-2));
  border-radius: 2px;
  animation: slideIn .28s var(--ease) both;
}
.tab .cnt {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 20px;
  background: rgba(122, 92, 255, .18); color: var(--c-primary-2); font-size: 11px;
}

/* ============ 面板 ============ */
.panel {
  border-radius: var(--radius);
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  animation: rise .45s var(--ease) both;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--glass-brd);
}
.panel-head h2 { font-size: 16px; font-weight: 500; margin: 0; }
.panel-head .sp { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* 工具条 */
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--glass-brd); }
input, select, textarea {
  background: rgba(11, 18, 32, .72);
  border: 1px solid var(--glass-brd);
  color: var(--tx-1);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(122, 92, 255, .6);
  box-shadow: 0 0 0 3px rgba(122, 92, 255, .14);
}
input::placeholder { color: var(--tx-3); }
label.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--tx-2); font-size: 13px; cursor: pointer; }

.btn {
  border: 1px solid var(--glass-brd);
  background: rgba(27, 39, 64, .6);
  color: var(--tx-1);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.btn:hover { background: rgba(122, 92, 255, .16); border-color: rgba(122, 92, 255, .45); }
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2)); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--fn-down); border-color: rgba(255, 92, 92, .38); }
.btn.danger:hover { background: rgba(255, 92, 92, .14); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ============ 列表 ============ */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--tx-3);
  padding: 10px 14px; border-bottom: 1px solid var(--glass-brd);
  background: rgba(11, 18, 32, .4);
  position: sticky; top: 0;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid rgba(138, 154, 181, .08); vertical-align: top; }
.tbl tbody tr { cursor: pointer; transition: background .15s var(--ease); }
.tbl tbody tr:hover { background: rgba(122, 92, 255, .09); }
.tbl .t-time { color: var(--tx-3); font-size: 12px; white-space: nowrap; }
.tbl .t-who { color: var(--tx-1); white-space: nowrap; }
.tbl .t-who small { display: block; color: var(--tx-3); font-size: 11px; }
.tbl .t-q { max-width: 420px; }
.tbl .t-a { color: var(--tx-2); font-size: 12px; max-width: 420px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* 截断格子的查看：hover 出浮层看全文，点击就地展开/收起 */
.clamp { cursor: zoom-in; }
.clamp:hover { color: var(--tx-1); }
.clamp.open {
  display: block; -webkit-line-clamp: unset; overflow: visible;
  white-space: pre-wrap; word-break: break-all; cursor: zoom-out;
}
.tip {
  display: none; position: fixed; z-index: 99;
  max-width: 680px; padding: 10px 12px;
  background: linear-gradient(180deg, #1B2740 0%, #141F35 100%);
  border: 1px solid rgba(138, 154, 181, .35); border-radius: 8px;
  color: var(--tx-1); font-size: 12px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-all;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); pointer-events: none;
}

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; line-height: 18px; white-space: nowrap;
  border: 1px solid transparent;
}
.pill.tool { background: rgba(46, 124, 255, .16); color: #7FB0FF; border-color: rgba(46, 124, 255, .3); }
.pill.guard { background: rgba(255, 176, 32, .16); color: var(--fn-warn); border-color: rgba(255, 176, 32, .3); }
.pill.err { background: rgba(255, 92, 92, .16); color: var(--fn-down); border-color: rgba(255, 92, 92, .3); }
.pill.ok { background: rgba(0, 214, 164, .14); color: var(--fn-up); border-color: rgba(0, 214, 164, .28); }
.pill.mute { background: rgba(138, 154, 181, .12); color: var(--tx-2); border-color: var(--glass-brd); }
.pill.actor-llm { background: rgba(122, 92, 255, .16); color: var(--c-primary-2); }
.pill.actor-human { background: rgba(0, 211, 167, .14); color: var(--c-mint); }

.empty { padding: 48px 16px; text-align: center; color: var(--tx-3); }
.empty .big { font-size: 15px; color: var(--tx-2); margin-bottom: 6px; }

/* 骨架屏 */
.sk { padding: 16px; }
.sk-row { height: 14px; border-radius: 7px; margin-bottom: 12px; background: linear-gradient(90deg, rgba(138,154,181,.10) 25%, rgba(138,154,181,.20) 37%, rgba(138,154,181,.10) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite linear; }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: var(--tx-2); font-size: 12px; }
.pager .sp { margin-left: auto; display: flex; gap: 8px; }

/* ============ 详情抽屉 ============ */
.mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 9, 16, .62);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .24s var(--ease);
}
.mask.on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(880px, 94vw);
  background: linear-gradient(180deg, #131E33 0%, #0D1524 100%);
  border-left: 1px solid var(--glass-brd);
  box-shadow: -18px 0 48px rgba(0, 0, 0, .5);
  transform: translateX(102%);
  transition: transform .3s var(--ease);
  display: flex; flex-direction: column;
}
.drawer.on { transform: translateX(0); }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--glass-brd); display: flex; gap: 12px; align-items: flex-start; }
.drawer-head h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; line-height: 1.45; }
.drawer-head .meta { color: var(--tx-3); font-size: 12px; }
.drawer-body { overflow-y: auto; padding: 16px 18px 40px; flex: 1; }
.x {
  margin-left: auto; flex: none; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--glass-brd); background: rgba(27, 39, 64, .6);
  color: var(--tx-2); cursor: pointer; font-size: 16px; line-height: 1;
  transition: all .18s var(--ease);
}
.x:hover { color: var(--tx-1); background: rgba(255, 92, 92, .16); }

.sec { margin-bottom: 18px; }
.sec > h4 {
  margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--tx-2);
  display: flex; align-items: center; gap: 8px;
}
.sec > h4::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: linear-gradient(180deg, var(--c-primary), var(--c-mint)); }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--tx-3); }
.kv .v { color: var(--tx-1); word-break: break-all; }

.answer-box {
  background: rgba(0, 214, 164, .07);
  border: 1px solid rgba(0, 214, 164, .2);
  border-radius: 12px; padding: 12px 14px; line-height: 1.7; white-space: pre-wrap;
}

/* 时间轴 */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: rgba(138, 154, 181, .2); }
.tl-item { position: relative; margin-bottom: 12px; animation: rise .35s var(--ease) both; }
.tl-item::before {
  content: ""; position: absolute; left: -20px; top: 8px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--tx-3); box-shadow: 0 0 0 3px rgba(11, 18, 32, .9);
}
.tl-item.k-task::before { background: var(--c-blue); }
.tl-item.k-l1_parse::before { background: var(--c-primary-2); }
.tl-item.k-l2_recall::before { background: #2e7cff; }
.tl-item.k-l3_select::before { background: #b36bff; }
.tl-item.k-l5_feedback::before { background: #7fb0ff; }
.tl-item.k-think::before { background: var(--tx-2); }
.tl-item.k-tool_call::before { background: var(--c-mint); }
.tl-item.k-tool_result::before { background: rgba(0, 211, 167, .55); }
.tl-item.k-answer::before { background: var(--c-primary); }
.tl-item.k-guard::before { background: var(--fn-warn); }
.tl-item.k-error::before { background: var(--fn-down); }

.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-kind { font-size: 12px; font-weight: 500; }
.tl-name { font-size: 12px; color: var(--tx-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tl-ms { margin-left: auto; color: var(--tx-3); font-size: 11px; }
.tl-body {
  margin-top: 6px; background: rgba(11, 18, 32, .68);
  border: 1px solid var(--glass-brd); border-radius: 10px;
  padding: 10px 12px; font-size: 12px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 260px; overflow: auto; color: var(--tx-1);
}
.tl-body.fold { max-height: 76px; overflow: hidden; position: relative; cursor: pointer; }
.tl-body.fold::after {
  content: "展开 ▾"; position: absolute; right: 8px; bottom: 6px;
  background: rgba(19, 30, 51, .9); padding: 1px 8px; border-radius: 8px;
  color: var(--c-primary-2); font-size: 11px; font-family: inherit;
}
.tl-item.k-guard .tl-body { border-color: rgba(255, 176, 32, .34); background: rgba(255, 176, 32, .06); }

/* 新链路（L1 诉求 → L2 召回 → L3 裁决 → L5 回写）结构化卡片 */
.tl-struct { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.tl-sub { background: rgba(11, 18, 32, .5); border: 1px solid var(--glass-brd); border-radius: 8px; padding: 8px 10px; }
.tl-frag { font-size: 12px; color: var(--tx-1); font-weight: 500; }
.tl-para { font-size: 12px; color: var(--tx-2); margin-top: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-label { font-size: 12px; color: var(--tx-3); flex-shrink: 0; }
.tl-reason { font-size: 12px; color: var(--tx-1); line-height: 1.6; }
.tl-cand { margin-top: 6px; width: 100%; border-collapse: collapse; font-size: 12px; }
.tl-cand th, .tl-cand td { padding: 4px 8px; border-bottom: 1px solid var(--glass-brd); text-align: left; }
.tl-cand th { color: var(--tx-3); font-weight: 500; }
.tl-cand .r { text-align: right; }
.tl-cand .m { color: var(--tx-3); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ============ 复盘 / 记忆 / 地图改动 卡片 ============ */
/* 三处共用同一张卡：复盘一条、记忆一条、地图一次改动。只读，所以没有操作区 */
.rev {
  border: 1px solid var(--glass-brd); border-radius: 12px;
  background: rgba(11, 18, 32, .5);
  padding: 13px 14px; margin: 0 14px 12px;
  animation: rise .4s var(--ease) both;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.rev:hover { border-color: rgba(122, 92, 255, .34); transform: translateY(-2px); }
/* 历史遗留（旧链路记忆）：整体压暗，别跟"当前会被用到的记忆"抢注意力 */
.rev.is-legacy { opacity: .62; }
.rev.is-legacy:hover { opacity: .85; }

.rev-count { padding: 10px 16px 2px; color: var(--tx-3); font-size: 12px; }
#mapList, #memList, #legacyList { padding-top: 14px; }
#revList { padding-top: 14px; }

/* 复盘 tab 里的两个分区之间加一道分隔（第二个 panel-head 不贴顶） */
.panel-head.sub { margin-top: 6px; border-top: 1px solid var(--glass-brd); }

.legacy-wrap { border-top: 1px dashed var(--glass-brd); padding-bottom: 8px; }
.legacy-head { padding: 12px 16px 0; color: var(--tx-3); font-size: 12px; }

/* 抽屉里的复盘结论块 */
.rv-block {
  border: 1px solid rgba(122, 92, 255, .3); background: rgba(122, 92, 255, .07);
  border-radius: 12px; padding: 11px 13px;
}
.rv-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rv-txt { margin-top: 8px; color: var(--tx-2); font-size: 12px; line-height: 1.7; }
.rv-txt b {
  display: inline-block; min-width: 34px; margin-right: 8px;
  color: var(--tx-3); font-weight: 500;
}
.rev-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rev-title { font-size: 14px; font-weight: 500; }
.rev-sub { color: var(--tx-3); font-size: 11px; margin-top: 3px; }
.rev-acts { margin-left: auto; display: flex; gap: 8px; }

.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.diff > div {
  border-radius: 10px; padding: 9px 11px; font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  max-height: 150px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.diff .old { background: rgba(255, 92, 92, .08); border: 1px solid rgba(255, 92, 92, .22); }
.diff .new { background: rgba(0, 214, 164, .08); border: 1px solid rgba(0, 214, 164, .22); }
.diff .lb { display: block; font-size: 11px; margin-bottom: 4px; font-family: inherit; }
.diff .old .lb { color: var(--fn-down); }
.diff .new .lb { color: var(--fn-up); }

.reason {
  color: var(--tx-2); font-size: 12px; line-height: 1.65; margin-top: 8px;
  border-left: 2px solid rgba(122, 92, 255, .45); padding-left: 10px;
  white-space: pre-wrap; max-height: 120px; overflow: auto;
}

/* ============ Toast ============ */
.toast-box { position: fixed; z-index: 90; right: 20px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 11px 16px; border-radius: 12px; font-size: 13px;
  background: rgba(19, 30, 51, .96); border: 1px solid var(--glass-brd);
  box-shadow: var(--glass-shadow); color: var(--tx-1);
  animation: rise .3s var(--ease) both; max-width: 420px;
}
.toast.ok { border-color: rgba(0, 214, 164, .45); }
.toast.bad { border-color: rgba(255, 92, 92, .5); }

/* ============ 图表 ============ */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.chart { height: 240px; }

/* ============ 动画 ============ */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes slideIn { from { transform: scaleX(.3); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }

@media (max-width: 720px) {
  .wrap { padding: 0 12px 88px; }
  .tbl .t-q, .tbl .t-a { max-width: 180px; }
  .diff { grid-template-columns: 1fr; }
  .card .v { font-size: 22px; }
}
