/* 浮层组件：模态框、抽屉、提示、命令面板、时间线、图表 */
.backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; padding: 20px; animation: fade-in .15s var(--ease);
}
.modal {
  width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }

.drawer-backdrop { place-items: stretch end; padding: 0; }
.drawer {
  width: min(560px, 100vw); height: 100vh; overflow-y: auto; background: var(--surface);
  box-shadow: var(--shadow-lg); animation: slide-in .22s var(--ease); display: flex; flex-direction: column;
}
.drawer .modal-body { flex: 1; }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

#toast-root { position: fixed; z-index: 120; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; padding: 12px 14px;
  background: var(--text); color: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: fade-in .2s var(--ease);
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success::before { content: "✓"; color: var(--success); font-weight: 700; }

/* 命令面板 / AI 助手 */
.palette-backdrop { place-items: start center; padding-top: 12vh; }
.palette { width: min(680px, 100%); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-input svg { width: 18px; height: 18px; color: var(--primary); }
.palette-input input { border: 0; box-shadow: none; height: 54px; font-size: 16px; padding: 0; }
.palette-input input:focus { box-shadow: none; }
.palette-list { max-height: 420px; overflow-y: auto; padding: 6px; }
.palette-list .group { padding: 8px 10px 4px; font-size: 11px; color: var(--text-3); font-weight: 600; letter-spacing: .05em; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.palette-item svg { width: 16px; height: 16px; color: var(--text-3); }
.palette-item.active { background: var(--primary-soft); color: var(--primary-text); }
.palette-item.active svg { color: var(--primary); }
.palette-item small { margin-left: auto; color: var(--text-3); }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); background: var(--surface-2); }

.answer { display: grid; gap: 14px; }
.answer .text { font-size: 15px; line-height: 1.7; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.metric { padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.metric span { font-size: 12px; color: var(--text-2); }
.metric b { display: block; font-size: 20px; margin-top: 2px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline small { display: block; color: var(--text-3); font-size: 12px; }

.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 3; }
.chart .axis { fill: var(--text-3); font-size: 11px; }
.chart .dot { transition: r .1s; }
.chart-tip {
  position: fixed; z-index: 130; pointer-events: none; padding: 8px 10px; border-radius: 8px; font-size: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); white-space: nowrap;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 150px) 1fr auto; gap: 10px; align-items: center; padding: 6px 0; }
.bar-track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--primary); transition: width .6s var(--ease); }
.progress { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.progress > i { display: block; height: 100%; background: var(--success); border-radius: 3px; }
