/* ============ 表格 / 弹窗 / 反馈层 ============
   依赖 app.css 的语义 token；宽表粘性首列、弹窗、toast、滚动条与动画。 */

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--edge-soft); border-top: none; }
table.ledger { width: 100%; border-collapse: collapse; font-size: 13px; }
.ledger th {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; color: var(--muted);
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--edge);
  background: var(--panel-2); white-space: nowrap; position: sticky; top: 0;
}
.ledger td { padding: 10px 14px; border-bottom: 1px solid var(--rule); color: var(--text-2); vertical-align: top; }
.ledger td.num, .ledger th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger td.mono { font-family: var(--font-mono); font-size: 12px; }
.ledger td .name { color: var(--text); font-weight: 600; }
.ledger td .desc { color: var(--muted); font-size: 12.5px; line-height: 1.7; display: block; width: 420px; white-space: pre-wrap; word-break: break-word; }
.ledger td .nil { color: var(--faint); }
.ledger td .price-val { color: var(--accent-hi); font-family: var(--font-mono); font-weight: 600; }
.ledger td a.link { color: var(--accent-hi); font-family: var(--font-mono); font-size: 12px; text-decoration-color: var(--tag-border); }
.ledger tbody tr { animation: rowIn .35s both; transition: background .15s; }
.ledger tbody tr:nth-child(even) { background: var(--stripe); }
.ledger tbody tr:hover { background: var(--hover-veil); }
.ledger tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--accent); }

/* 全参数宽表：横向/纵向滚动 + 首列与表头粘性固定 */
.table-wrap.wide { max-height: 70vh; overflow: auto; }
.table-wrap.wide table.ledger { width: auto; min-width: 100%; table-layout: auto; }
.table-wrap.wide th { z-index: 3; }
.table-wrap.wide th:first-child, .table-wrap.wide td:first-child {
  position: sticky; left: 0; z-index: 2; background: var(--panel);
  box-shadow: 1px 0 0 var(--edge-soft);
}
.table-wrap.wide th:first-child { background: var(--panel-2); z-index: 4; }
.table-wrap.wide tbody tr:nth-child(even) td:first-child { background: var(--stripe-cell); }
.table-wrap.wide tbody tr:hover td:first-child { background: var(--hover-cell); }
.table-wrap.wide th.num { text-align: right; }
/* 全参数表：数据格一律单行，避免 ID / 版本 / 日期在连字符处拆行 */
.table-wrap.wide .ledger td { white-space: nowrap; }
/* 标签类列反之：限定宽度后允许多行，使标签横向排布而非竖成一列 */
.table-wrap.wide .ledger th.cell-wrap, .table-wrap.wide .ledger td.cell-wrap {
  width: 232px; min-width: 232px; white-space: normal;
}
.table-wrap.wide .ledger td .desc { white-space: pre-wrap; }
.tag { display: inline-block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px; color: var(--accent-hi); border: 1px solid var(--tag-border); padding: 2px 7px; margin: 1px 3px 1px 0; border-radius: var(--r); white-space: nowrap; }
.keymask { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: .5px; word-break: break-all; }
.tag-plain { color: var(--muted); border-color: var(--edge); }
/* 嵌套对象列（inference_metadata）：保留原样 JSON 文本，限宽折行 */
.ledger .json-cell {
  display: block; max-width: 320px; font-family: var(--font-mono); font-size: 11px;
  line-height: 1.65; color: var(--muted); white-space: normal; word-break: break-all;
}
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* 空状态 */
.empty { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border: 1px dashed var(--edge); color: var(--faint);
  font-family: var(--font-display); font-size: 22px; margin-bottom: 16px; transform: rotate(-3deg);
}
.empty p { font-size: 13px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px 0; }
.pager-info { font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.pager-btns { display: flex; align-items: center; gap: 12px; }
.pager-no { font-family: var(--font-mono); font-size: 11px; color: var(--faint); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: var(--scrim); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; animation: fadeIn .2s both; }
.modal[hidden] { display: none; }
.modal-card {
  width: 460px; max-width: calc(100vw - 40px); background: var(--panel);
  border: 1px solid var(--edge); border-top: 2px solid var(--accent);
  padding: 26px 28px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 14px; animation: riseIn .3s cubic-bezier(.2, .8, .2, 1) both;
}
.modal-card h3 { font-family: var(--font-display); font-size: 20px; letter-spacing: 4px; margin-bottom: 4px; }
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; color: var(--faint); }
.modal-card label input, .modal-card label select { width: 100%; }
.keyline { display: flex; gap: 8px; }
.keyline input { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* 参数详情弹窗 */
.modal-card.modal-wide { width: 860px; max-height: 86vh; overflow: hidden; }
.detail-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
table.kv { border-collapse: collapse; font-size: 12.5px; width: 100%; table-layout: fixed; flex: none; }
table.kv th, table.kv td {
  text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--rule);
  vertical-align: top; word-break: break-word;
}
table.kv th {
  width: 210px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1px;
  color: var(--muted); font-weight: 400;
}
table.kv td { color: var(--text-2); }
table.kv td.mono { font-family: var(--font-mono); font-size: 12px; }
table.kv .nil { color: var(--faint); }
.json {
  flex: none; max-height: 320px; overflow: auto; margin: 0;
  background: var(--panel-3); border: 1px dashed var(--edge); border-radius: var(--r);
  padding: 14px 16px; font-family: var(--font-mono); font-size: 11.5px;
  line-height: 1.6; color: var(--jade); white-space: pre-wrap; word-break: break-all;
}

/* ---------- 提示 ---------- */
.toasts { position: fixed; right: 26px; bottom: 26px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--edge); border-left: 3px solid var(--jade);
  color: var(--text); font-size: 13px; padding: 12px 18px; min-width: 240px; max-width: 380px;
  box-shadow: var(--shadow-sm); animation: toastIn .3s cubic-bezier(.2, .8, .2, 1) both;
}
.toast.err { border-left-color: var(--cinnabar); }
.toast.warn { border-left-color: var(--accent); }

/* ---------- 滚动条（宽表横纵滚动时的观感） ---------- */
.table-wrap.wide::-webkit-scrollbar, .json::-webkit-scrollbar, .detail-body::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap.wide::-webkit-scrollbar-track, .json::-webkit-scrollbar-track, .detail-body::-webkit-scrollbar-track { background: var(--panel-3); }
.table-wrap.wide::-webkit-scrollbar-thumb, .json::-webkit-scrollbar-thumb, .detail-body::-webkit-scrollbar-thumb {
  background: var(--edge); border: 2px solid var(--panel-3); border-radius: 6px;
}
.table-wrap.wide::-webkit-scrollbar-thumb:hover, .json::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- 动画 ---------- */
@keyframes dropIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes rowIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
