/* ==========================================================================
   银行 AI 智能体 · 演示界面
   风格取向：金融工具的克制感，不喧哗。分级用颜色承担语义：
   绿=自动放行 / 黄=需你确认 / 红=强验证。
   ========================================================================== */

:root {
  --bg:        #eceae5;
  --surface:   #ffffff;
  --surface-2: #f6f4f0;
  --line:      #e0dcd4;
  --line-2:    #c8c2b6;
  --ink:       #1f1b16;
  --ink-2:     #55504a;
  --ink-3:     #8a8378;

  --green:     #1c7a45;
  --green-bg:  #e8f5ec;
  --yellow:    #a86a00;
  --yellow-bg: #fdf3e0;
  --red:       #b3261e;
  --red-bg:    #fceceb;
  --brand:     #1b4d8f;

  --r:   14px;
  --r-s: 9px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --mono: "Consolas", "Cascadia Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.stage {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 22px;
  height: 100vh;
  padding: 20px;
  max-width: 1360px;
  margin: 0 auto;
}

/* ══════════════════ 手机 ══════════════════ */
.phone {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(40,34,26,.13);
  position: relative;
}
.phone__notch {
  height: 22px;
  background: var(--surface);
  flex: none;
}
.phone__notch::after {
  content: "";
  display: block;
  width: 78px; height: 5px;
  margin: 4px auto 0;
  background: #d8d4cc;
  border-radius: 3px;
}

.app-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 6px 16px 10px;
  flex: none;
}
.app-bar__user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  width: 34px; height: 34px; flex: none;
  display: grid; place-content: center;
  border-radius: 50%;
  background: var(--brand); color: #fff;
  font-weight: 700; font-size: 14px;
}
.app-bar__user b { display: block; font-size: 14px; }
.app-bar__user small { display: block; font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
.iconbtn {
  width: 34px; height: 34px; flex: none;
  display: grid; place-content: center;
  background: transparent; border: 1px solid var(--line);
  border-radius: 9px; color: var(--ink-3); cursor: pointer;
  transition: all .16s var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.iconbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor;
               stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* 余额卡 */
.balance-card {
  margin: 0 16px 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  background: linear-gradient(135deg, #1b4d8f, #2b6bb8);
  color: #fff;
  flex: none;
}
.balance-card__label { margin: 0; font-size: 11.5px; opacity: .82; }
.balance-card__amount {
  margin: 2px 0 8px;
  font-size: 30px; font-weight: 700; letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.balance-card__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11.5px;
}
.balance-card__limit { opacity: .85; }
.chip {
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.2);
}
.chip--ok { background: rgba(255,255,255,.24); }
.chip--warn { background: #d97706; }
.chip--bad { background: #b3261e; }

/* 对话区 */
.chat {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 4px 16px 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { display: flex; gap: 8px; }
.msg__av {
  width: 26px; height: 26px; flex: none;
  display: grid; place-content: center;
  border-radius: 50%; font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.msg__body { min-width: 0; max-width: 88%; }
.msg__bubble {
  padding: 9px 12px; border-radius: 12px;
  background: var(--surface-2);
  font-size: 13.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
.msg--me { flex-direction: row-reverse; }
.msg--me .msg__body { max-width: 82%; }
.msg--me .msg__bubble { background: var(--brand); color: #fff; border-radius: 12px 12px 3px 12px; }
.msg--ai .msg__bubble { border-radius: 12px 12px 12px 3px; }
.msg__bubble b { font-weight: 700; }
.msg__bubble code {
  font-family: var(--mono); font-size: .92em;
  background: rgba(0,0,0,.06); padding: .5px 4px; border-radius: 4px;
}
.msg--me .msg__bubble code { background: rgba(255,255,255,.2); }

/* 分级拦截卡 */
.tiercard {
  border: 1px solid var(--line-2);
  border-left-width: 4px;
  border-radius: var(--r-s);
  background: var(--surface);
  overflow: hidden;
  font-size: 13px;
}
.tiercard--green  { border-left-color: var(--green);  background: var(--green-bg); }
.tiercard--yellow { border-left-color: var(--yellow); background: var(--yellow-bg); }
.tiercard--red    { border-left-color: var(--red);    background: var(--red-bg); }

.tiercard__head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px 8px;
}
.tiercard__badge {
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; color: #fff;
}
.tiercard--green  .tiercard__badge { background: var(--green); }
.tiercard--yellow .tiercard__badge { background: var(--yellow); }
.tiercard--red    .tiercard__badge { background: var(--red); }
.tiercard__title { font-weight: 700; font-size: 13.5px; }

.tiercard__body { padding: 0 11px 10px; }
.tiercard__why {
  margin: 0 0 8px;
  padding: 7px 9px;
  background: rgba(255,255,255,.72);
  border-radius: 6px;
  font-size: 12px; line-height: 1.6; color: var(--ink-2);
}
.tiercard__why b { color: var(--ink); }
.tiercard__why ul { margin: 3px 0 0; padding-left: 15px; }
.tiercard__why li { margin-bottom: 1px; }

.details { display: grid; gap: 3px; margin-bottom: 10px; }
.details__row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12.5px;
  padding-bottom: 3px;
  border-bottom: 1px dashed rgba(0,0,0,.09);
}
.details__row:last-child { border-bottom: 0; }
.details__row dt { color: var(--ink-3); }
.details__row dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.tiercard__actions { display: flex; gap: 7px; }
.btn {
  padding: 7px 13px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: all .16s var(--ease);
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: #17417a; }
.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { background: #96170f; }
.btn--ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn--ghost:hover { background: rgba(0,0,0,.04); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.txn {
  margin-top: 7px; padding: 7px 9px;
  background: rgba(255,255,255,.75); border-radius: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
}

/* 快捷输入 */
.quick {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 0 16px 8px; flex: none;
}
.quick__chip {
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit; font-size: 11.5px; color: var(--ink-2);
  cursor: pointer; transition: all .16s var(--ease);
}
.quick__chip:hover { background: #fff; border-color: var(--line-2); color: var(--ink); }
.quick__chip--atk { border-color: #e6b8b4; color: var(--red); background: var(--red-bg); }
.quick__chip--atk:hover { background: #f9dedb; }

.composer {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 16px 16px; flex: none;
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1; min-width: 0;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit; font-size: 13.5px; color: var(--ink);
}
.composer input:focus { outline: none; border-color: var(--brand); background: #fff; }
.composer button {
  width: 40px; height: 40px; flex: none;
  display: grid; place-content: center;
  background: var(--brand); color: #fff;
  border: 0; border-radius: 50%; cursor: pointer;
  transition: background .16s var(--ease);
}
.composer button:hover { background: #17417a; }
.composer button:disabled { opacity: .5; cursor: not-allowed; }
.composer button svg { width: 18px; height: 18px; }

/* ══════════════════ 安全控制台 ══════════════════ */
.console {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  overflow: hidden;
}
.console__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.console__bar h1 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.console__stat { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot--ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.dot--bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }

.console__tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); flex: none; }
.tab {
  padding: 7px 13px; background: transparent; border: 0;
  border-bottom: 2px solid transparent;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-3);
  cursor: pointer; transition: all .16s var(--ease);
}
.tab:hover { color: var(--ink-2); }
.tab.is-on { color: var(--brand); border-bottom-color: var(--brand); }

.console__body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 18px; }
.pane { display: none; }
.pane.is-on { display: block; }
.empty { color: var(--ink-3); font-size: 13px; line-height: 1.8; margin: 6px 0; }

/* 决策链路 */
.step {
  display: grid; grid-template-columns: 26px minmax(0,1fr);
  gap: 10px; padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}
.step:last-child { border-bottom: 0; }
.step__n {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-content: center;
  background: var(--surface-2); border: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--ink-2);
}
.step--ok .step__n  { background: var(--green-bg);  border-color: var(--green);  color: var(--green); }
.step--warn .step__n{ background: var(--yellow-bg); border-color: var(--yellow); color: var(--yellow); }
.step--bad .step__n { background: var(--red-bg);    border-color: var(--red);    color: var(--red); }
.step__t { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.step__d { font-size: 12.5px; color: var(--ink-2); line-height: 1.65; }
.step__d code {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--surface-2); padding: 1px 4px; border-radius: 4px;
}
.step__time { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-left: 6px; font-weight: 400; }

/* 审计 */
.audit__head {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 9px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3);
}
.audit { list-style: none; margin: 0; padding: 0; }
.audit li {
  display: grid; grid-template-columns: 42px 150px minmax(0,1fr) 84px;
  gap: 8px; align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid #f2f0ec;
  font-size: 12px;
}
.audit li:last-child { border-bottom: 0; }
.audit__seq { font-family: var(--mono); color: var(--ink-3); font-size: 11px; }
.audit__ev { font-family: var(--mono); font-size: 11px; font-weight: 700; }
.audit__ev[data-k="tier"], .audit__ev[data-k="guard"] { color: var(--yellow); }
.audit__ev[data-k="verify"], .audit__ev[data-k="confirm"] { color: var(--brand); }
.audit__ev[data-k="exec"] { color: var(--green); }
.audit__ev[data-k="breaker"], .audit__ev[data-k="reject"] { color: var(--red); }
.audit__f { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit__h { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); text-align: right; }

/* 规则 */
.rules__note {
  margin: 0 0 12px; padding: 10px 12px;
  background: var(--surface-2); border-radius: var(--r-s);
  font-size: 12.5px; line-height: 1.7; color: var(--ink-2);
}
.rules__note b { color: var(--ink); }
.rules { display: grid; gap: 10px; }
.rule { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--r-s); padding: 10px 12px; }
.rule--green  { border-left-color: var(--green); }
.rule--yellow { border-left-color: var(--yellow); }
.rule--red    { border-left-color: var(--red); }
.rule__head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.rule__badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #fff; }
.rule--green  .rule__badge { background: var(--green); }
.rule--yellow .rule__badge { background: var(--yellow); }
.rule--red    .rule__badge { background: var(--red); }
.rule__policy { font-size: 12px; color: var(--ink-2); }
.rule__list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.rule__item {
  padding: 3px 8px; border-radius: 6px;
  background: var(--surface-2); font-size: 11.5px; color: var(--ink-2);
}
.rules__cap {
  margin-top: 12px; padding: 10px 12px;
  background: var(--yellow-bg); border-radius: var(--r-s);
  font-size: 12.5px; line-height: 1.7; color: var(--ink-2);
}
.rules__cap b { color: var(--ink); }

/* ══════════════════ 强验证弹窗 ══════════════════ */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center;
  background: rgba(30,26,20,.44);
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal__box {
  width: min(360px, 92vw);
  background: var(--surface); border-radius: var(--r);
  padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal__box h2 { margin: 0 0 8px; font-size: 17px; }
.modal__desc { margin: 0 0 12px; font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.modal__desc b { color: var(--red); }
.modal__demo {
  margin: 0 0 12px; padding: 9px 11px;
  background: var(--yellow-bg); border-radius: var(--r-s);
  font-size: 12.5px; color: var(--ink-2);
}
.modal__demo code {
  font-family: var(--mono); font-size: 17px; font-weight: 700;
  letter-spacing: 2px; color: var(--ink);
}
.modal__demo small { color: var(--ink-3); }
.modal__input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  font: inherit; font-size: 19px; font-family: var(--mono);
  letter-spacing: 7px; text-align: center;
}
.modal__input:focus { outline: none; border-color: var(--brand); }
.modal__err { min-height: 18px; margin: 6px 0 0; font-size: 12.5px; color: var(--red); }
.modal__row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal__hint { margin: 12px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--ink-3); }
.modal__hint b { color: var(--ink-2); }

/* 小屏：上下堆叠，控制台仍在下方可滚动 */
@media (max-width: 980px) {
  .stage { grid-template-columns: 1fr; height: auto; padding: 12px; }
  .phone { height: 82vh; }
  .console { min-height: 60vh; }
}
