/**
 * 矩阵账号页 · 行内编辑样式（2026-11-20）
 *
 * 单独一个文件而不是塞进 clarity.css（73 KB）：
 *   · 只服务一个页面，出处清楚；
 *   · 将来矩阵页下线，删一个文件即可，不用在巨文件里翻找。
 *
 * 设计要点：
 *   · 可编辑单元格默认**看起来像普通文字**，只在 hover 时给底纹 + 铅笔提示 ——
 *     满屏都是"可点"的视觉噪音会让页面难读（实测 11,527 行 × 5 列）。
 *   · 编辑中：蓝框 + 白底，与周围拉开；
 *   · 成功：绿闪 1.2s；失败：红闪 1.6s。行内编辑没有弹层兜底，反馈必须留在原位。
 *   · 所有动效都在 prefers-reduced-motion 下关闭。
 */

/* ── 可编辑单元格 ───────────────────────────────────────────────── */
.matrix-cell-editable {
  cursor: pointer;
  position: relative;
  transition: background-color .12s ease;
}

.matrix-cell-editable:hover {
  background: #f1f8f4;
  box-shadow: inset 0 0 0 1px #cfe6da;
}

/* hover 时右侧出现一个淡铅笔，告诉用户"这里能改" */
.matrix-cell-editable:hover::after {
  content: '✎';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #8bb3a4;
  pointer-events: none;
}

/* 编辑中：撑满单元格的输入框 */
.matrix-cell-editable[data-editing="1"] {
  background: #eef6fb;
  box-shadow: inset 0 0 0 2px #6aa8d8;
  padding: 0;
}

.matrix-inline-input {
  width: 100%;
  box-sizing: border-box;
  border: 0;
  outline: 0;
  background: #fff;
  color: #1f3b3d;
  font: inherit;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 3px;
}

.matrix-inline-input:disabled {
  opacity: .6;
}

/* ── 提交反馈 ──────────────────────────────────────────────────── */
@keyframes cellOk {
  0%   { background: #d8f3e3; }
  100% { background: transparent; }
}

@keyframes cellFail {
  0%   { background: #fbdcdc; }
  100% { background: transparent; }
}

.matrix-cell-editable.cell-ok {
  animation: cellOk 1.2s ease-out;
}

.matrix-cell-editable.cell-fail {
  animation: cellFail 1.6s ease-out;
}

/* ── 分页器 ────────────────────────────────────────────────────── */
.matrix-pager {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px 4px 4px;
}

.matrix-pager .outline-button {
  min-width: 34px;
  padding: 5px 10px;
  font-size: 11px;
}

.matrix-pager .outline-button.active {
  background: #1f6f5c;
  color: #fff;
  border-color: #1f6f5c;
}

.matrix-pager .outline-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.matrix-pager .muted {
  margin-left: auto;
  font-size: 11px;
  color: #8ba3a0;
}

/* ── 通用小样式（本页用到，全站原先没有） ────────────────────────── */
.matrix-cell-editable .muted,
#page .muted {
  color: #a8bcba;
}

#page .pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef5f2;
  color: #3b6a5e;
  font-size: 10px;
  line-height: 1.6;
  white-space: nowrap;
}

#page td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: #4a6b68;
}

/* ── 无障碍：关掉动效 ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .matrix-cell-editable,
  .matrix-cell-editable.cell-ok,
  .matrix-cell-editable.cell-fail {
    animation: none !important;
    transition: none !important;
  }
}

/* ── 窄屏：编辑态输入框要够大，避免误触 ──────────────────────────── */
@media (max-width: 700px) {
  .matrix-inline-input {
    font-size: 16px;   /* iOS 上 <16px 会触发自动缩放 */
    padding: 8px;
  }
  .matrix-cell-editable:hover::after {
    display: none;     /* 触屏没有 hover，别显示铅笔 */
  }
  .matrix-pager {
    gap: 4px;
  }
  .matrix-pager .muted {
    width: 100%;
    margin-left: 0;
    margin-top: 6px;
  }
}

/* ── 批量新建弹层（2026-11-20）───────────────────────────────────── */
.matrix-drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 24px;
}

.matrix-drawer {
  background: #fff;
  border-radius: 14px;
  width: min(760px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 60px rgba(12, 40, 36, .28);
}

.matrix-drawer-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 22px 24px 16px;
  border-bottom: 1px solid #eaf0ec;
}

.matrix-drawer-head h3 {
  margin: 6px 0 6px;
  font-size: 17px;
  color: #1f3b3d;
}

.matrix-drawer-head p {
  margin: 0;
  font-size: 12px;
  color: #7f9794;
  line-height: 1.7;
  max-width: 520px;
}

.matrix-drawer-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 16px;
  color: #94a8a5;
  cursor: pointer;
  padding: 4px 8px;
}

.matrix-drawer-body {
  padding: 18px 24px;
  overflow: auto;
  flex: 1;
}

.mcd-field {
  display: block;
  margin-bottom: 14px;
}

.mcd-field > span {
  display: block;
  font-size: 11px;
  color: #6d8884;
  margin-bottom: 6px;
}

.mcd-field textarea,
.mcd-field input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d9e6e1;
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-size: 12px;
  color: #1f3b3d;
}

.mcd-field textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}

.mcd-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.mcd-error {
  background: #fbeeee;
  border: 1px solid #f0cfcf;
  color: #a94442;
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12px;
  margin-bottom: 12px;
}

.mcd-result {
  border-top: 1px dashed #e4eeea;
  padding-top: 14px;
}

.mcd-summary {
  font-size: 12px;
  color: #4a6b68;
  margin-bottom: 10px;
}

.mcd-summary b {
  color: #1f6f5c;
}

.mcd-warn {
  color: #b8791f;
  margin-left: 8px;
}

.mcd-table {
  max-height: 280px;
  overflow: auto;
  border: 1px solid #eaf0ec;
  border-radius: 8px;
}

.mcd-table table {
  width: 100%;
  font-size: 11px;
}

.mcd-table th {
  position: sticky;
  top: 0;
  background: #f6faf8;
  z-index: 1;
}

.mcd-table tr.bad td {
  background: #fdf1f1;
}

.mcd-table tr.skip td {
  background: #fbf8ec;
  color: #97865c;
}

.matrix-drawer-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid #eaf0ec;
}

.matrix-drawer-foot > div {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.matrix-drawer-foot .muted {
  font-size: 11px;
  color: #8ba3a0;
}

@media (max-width: 700px) {
  .mcd-fields {
    grid-template-columns: 1fr;
  }
  .matrix-drawer-mask {
    padding: 0;
  }
  .matrix-drawer {
    max-height: 100vh;
    border-radius: 0;
    width: 100%;
  }
}

/* 弹层页脚按钮：不许换行（1440 宽下「确认新建」被折成两行，实测截图发现） */
.matrix-drawer-foot button {
  white-space: nowrap;
  min-width: 72px;
}

.matrix-drawer-foot > div {
  flex-shrink: 0;
}

.matrix-drawer-foot .muted {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── 结算旁路健康徽章（2026-11-21）──────────────────────────────────
 *
 * 复用 .stale-badge 的骨架（同样是顶栏右侧的圆角提示），但用 data-level
 * 区分两档严重度。刻意与 stale-badge 的红色同色系、同位置 —— 用户不需要
 * 学两套视觉语言，只需要知道"右上角红了就是有问题"。
 *
 * 正常状态完全隐藏（不占位、不显示）。徽章常亮等于没亮。
 */

.settle-badge[data-level="warn"] {
  background: #fff6e5;
  color: #9a6b16;
  border-color: #f0dcae;
}

.settle-badge[data-level="warn"]:hover {
  background: #fdedd2;
}

.settle-badge[data-level="error"] {
  background: #fbeaf0;
  color: #b43941;
  border-color: #f0c7d2;
}

.settle-badge[data-level="error"]:hover {
  background: #f7d9e3;
}

/* 顶栏在窄屏会挤：徽章文字过长时省略，title 里有完整信息 */
@media (max-width: 900px) {
  .settle-badge {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ── 结算数据卡片（2026-11-21）──────────────────────────────────────
 *
 * 核心约束：**「0 元」不能被读成「系统坏了」**。
 * 所以失效单（voidCount）必须与有效结算并列显示，字号不能太小。
 * 卡片用中性色，不跟主报表的 stat-grid 抢视觉焦点 —— 它是旁路数据。
 */

.settle-panel {
  margin-top: 18px;
}

.settle-body {
  padding: 16px 24px 8px;
}

.settle-headline {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settle-headline strong {
  font-size: 26px;
  color: #1f3b3d;
  letter-spacing: -.5px;
}

/* 有效结算为 0 时用中性灰，不用红 —— 没钱结算不是错误 */
.settle-headline strong.settle-zero {
  color: #8ba3a0;
}

.settle-headline > span {
  font-size: 12px;
  color: #6d8884;
}

.settle-void {
  display: inline-block;
  font-size: 11px;
  color: #97865c;
  background: #fbf8ec;
  border: 1px solid #f0e6c8;
  border-radius: 6px;
  padding: 3px 9px;
  align-self: flex-start;
}

.settle-table-wrap {
  margin-top: 14px;
  border: 1px solid #eaf0ec;
  border-radius: 8px;
  overflow: auto;
  max-height: 260px;
}

.settle-table {
  width: 100%;
  font-size: 11px;
}

.settle-table th {
  position: sticky;
  top: 0;
  background: #f6faf8;
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: #4a6b68;
  z-index: 1;
}

.settle-table td {
  padding: 7px 12px;
  border-top: 1px solid #f0f5f2;
  color: #3d5c59;
}

.settle-table td.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  color: #5a7a77;
}

.settle-table th.num,
.settle-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.settle-note {
  margin: 0;
  padding: 0 24px 16px;
  font-size: 11px;
  line-height: 1.8;
  color: #94a8a5;
}

/* 失败态：明确说"不可用"，绝不用 0 冒充 */
.settle-bad {
  color: #b43941 !important;
  font-weight: 600;
}

.settle-fail {
  margin: 0;
  padding: 4px 24px 0;
  font-size: 12px;
  color: #b43941;
}

.settle-fail-detail {
  margin: 0;
  padding: 6px 24px 16px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #a0a8a6;
  word-break: break-all;
}

@media (max-width: 700px) {
  .settle-body { padding: 14px 16px 8px; }
  .settle-headline strong { font-size: 22px; }
  .settle-note { padding: 0 16px 14px; }
}

/* 首次加载中（不是失败） */
.settle-loading {
  margin: 0;
  padding: 4px 24px 18px;
  font-size: 12px;
  color: #8ba3a0;
}
