/* ==========================================================================
   组件：按钮 / 徽标 / 卡片 / 表格 / 表单 / 弹窗 / 抽屉 / Toast / 空态 / 页签
   ========================================================================== */

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 13px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: #fff; color: var(--text); font-size: 12.5px; font-weight: 500;
  white-space: nowrap; transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--hover); border-color: #C9D2CE; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn-soft { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-deep); }
.btn-soft:hover { background: #D8EBEA; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { color: var(--danger); border-color: var(--danger-line); background: #fff; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-xs { height: 22px; padding: 0 7px; font-size: 11.5px; border-radius: var(--radius-xs); }
.btn-lg { height: 38px; padding: 0 18px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

/* ---------------------------------------------------------------- 徽标 */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px;
  border-radius: var(--radius-full); font-size: 11.5px; font-weight: 500; white-space: nowrap;
  background: var(--slate-bg); color: var(--slate); border: 1px solid var(--slate-line); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.blue { background: var(--blue-bg); color: var(--blue); border-color: var(--blue-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.bad { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.badge.violet { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-line); }
.badge.accent { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent-line); }
.badge.ghost { background: transparent; border-color: var(--line-strong); color: var(--muted); }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px;
  border-radius: var(--radius-full); background: var(--sunken); color: var(--muted); font-size: 11.5px;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--hover); color: var(--text); }
.chip.on { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent-line); font-weight: 600; }
.chip .n { color: var(--faint); font-size: 10.5px; }
.pill { display: inline-block; padding: 0 6px; height: 17px; line-height: 17px; border-radius: 4px;
  font-size: 10.5px; background: var(--sunken); color: var(--muted); font-weight: 500; }

.tag-p0 { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-line); }
.tag-p1 { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.tag-p2 { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-line); }

/* ---------------------------------------------------------------- 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.card-title .n { color: var(--faint); font-weight: 400; font-size: 11.5px; }
.card-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.card-body { padding: 12px 14px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 8px 14px; border-top: 1px solid var(--line); background: #FBFCFB; display: flex; gap: 8px; align-items: center; }
.card-hover:hover { box-shadow: var(--shadow-hover); border-color: var(--line-strong); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 11px 14px; cursor: default; }
.kpi.click { cursor: pointer; }
.kpi.click:hover { border-color: var(--accent-line); box-shadow: var(--shadow-hover); }
.kpi .k { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.kpi .v { font-size: 22px; font-weight: 700; letter-spacing: -.4px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 12px; font-weight: 500; color: var(--faint); margin-left: 3px; }
.kpi .d { font-size: 11px; color: var(--faint); }
.kpi .v.bad { color: var(--danger); }
.kpi .v.ok { color: var(--ok); }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px;
  padding: 8px 10px; background: #FAFCFB; border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; z-index: 1; }
table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:hover { background: #FBFDFC; }
table.tbl tbody tr.on { background: var(--accent-soft); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .ops { white-space: nowrap; text-align: right; }
table.tbl .ops .btn { margin-left: 4px; }
.tbl-empty { padding: 34px 10px; text-align: center; color: var(--faint); font-size: 12.5px; }
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--text); }

/* 列表行（卡片式） */
.list { display: flex; flex-direction: column; }
.list-item { padding: 9px 4px; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.list-item .t { font-size: 12.5px; font-weight: 500; line-height: 1.5; }
.list-item .s { font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.list-item .go { margin-left: auto; flex: 0 0 auto; }

/* 时间线 */
.timeline { position: relative; padding-left: 16px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 12px 8px; }
.tl-item::before { content: ""; position: absolute; left: -15px; top: 6px; width: 7px; height: 7px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent-line); }
.tl-item.hot::before { border-color: var(--accent); background: var(--accent); }
.tl-item .tl-t { font-size: 12.5px; }
.tl-item .tl-s { font-size: 11px; color: var(--faint); }

/* ---------------------------------------------------------------- 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field-row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-row > label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field-row > label .req { color: var(--danger); margin-left: 2px; }
.field-row .hint { font-size: 11px; color: var(--faint); }
.input, .select, .textarea {
  width: 100%; min-height: 34px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 6px 10px; background: #fff; font-size: 13px; transition: border-color .12s, box-shadow .12s;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.7; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--sunken); color: var(--muted); }
.input.sm, .select.sm { height: 30px; min-height: 30px; font-size: 12.5px; }
.form-error { color: var(--danger); font-size: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 130px; height: 32px; min-height: 32px; font-size: 12.5px; }
.toolbar .grow { flex: 1 1 200px; min-width: 160px; }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(12,25,39,.42); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; padding: 5vh 20px; z-index: 200; overflow-y: auto; }
.modal-card { width: 100%; max-width: 680px; background: #fff; border-radius: var(--radius-xl);
  box-shadow: var(--shadow-float); display: flex; flex-direction: column; max-height: 90vh; overflow: hidden;
  animation: pop .16s ease-out; }
@keyframes pop { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-card.wide { max-width: 880px; }
.modal-card.narrow { max-width: 460px; }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.modal-title { font-size: 15.5px; font-weight: 700; }
.modal-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-x { margin-left: auto; border: 0; background: transparent; color: var(--faint); padding: 4px; border-radius: 6px; }
.modal-x:hover { background: var(--hover); color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1 1 auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end;
  background: #FBFCFB; flex: 0 0 auto; }
.modal-foot .left { margin-right: auto; color: var(--faint); font-size: 11.5px; align-self: center; }

/* ---------------------------------------------------------------- 抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(12,25,39,.3); z-index: 190; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 760px; max-width: 94vw; background: #fff;
  box-shadow: var(--shadow-float); z-index: 191; display: flex; flex-direction: column; animation: slidein .18s ease-out; }
@keyframes slidein { from { transform: translateX(24px); opacity: .7; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.drawer-title { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.drawer-tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.drawer-tab { padding: 9px 12px; font-size: 12.5px; color: var(--muted); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.drawer-tab:hover { color: var(--text); }
.drawer-tab.on { color: var(--accent-deep); font-weight: 600; border-bottom-color: var(--accent); }
.drawer-tab .n { font-size: 10.5px; color: var(--faint); margin-left: 3px; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 18px 40px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 10px 18px; display: flex; gap: 8px; justify-content: flex-end; }

/* ---------------------------------------------------------------- Toast / 提示条 */
#toast-root { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 400;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #14232E; color: #fff; padding: 9px 16px; border-radius: var(--radius);
  font-size: 12.5px; box-shadow: var(--shadow-pop); max-width: 76vw; line-height: 1.6;
  animation: toastin .18s ease-out; }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast.err { background: #7A1B13; }
.toast.ok { background: #14532D; }
.toast.warn { background: #6B4A08; }
.banner { display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; border-radius: var(--radius);
  font-size: 12.5px; margin-bottom: 12px; border: 1px solid; }
.banner.info { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-deep); }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.banner.bad { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.banner.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.banner .x { margin-left: auto; cursor: pointer; opacity: .6; }
.note { font-size: 12px; color: var(--muted); background: #FBFCFB; border: 1px dashed var(--line-strong);
  border-radius: var(--radius); padding: 8px 10px; line-height: 1.7; }
.note b { color: var(--text); }

/* ---------------------------------------------------------------- 空态 / 加载 */
.empty { padding: 44px 20px; text-align: center; color: var(--faint); }
.empty .ico { font-size: 30px; opacity: .5; margin-bottom: 8px; }
.empty .t { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.empty .d { font-size: 12px; max-width: 420px; margin: 0 auto 12px; line-height: 1.7; }
.loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 40px; color: var(--muted); font-size: 12.5px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent-line);
  border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, #EEF2F0 25%, #F7FAF8 37%, #EEF2F0 63%);
  background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 6px; height: 12px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------------------------------------------------------- 差异 / 对照 */
.dc-pane { font-size: 13px; line-height: 1.9; }
.dc-p { padding: 2px 6px; border-radius: 3px; border-left: 3px solid transparent; }
.dc-p:hover { background: #F8FAF9; }
.dc-p.mod { background: #FFF3D6; border-left-color: #E0A800; }
.dc-p.add { background: #E7F5EC; border-left-color: #2AA05A; }
.dc-p.rem { background: #FDECEA; border-left-color: #D9534F; }
.dc-p .dc-no { font-size: 10.5px; color: var(--faint); margin-right: 6px; font-family: var(--mono); }
.dc-ins { background: #D6F0E0; color: #12653B; text-decoration: none; }
.dc-del { background: #FBD9D5; color: #8F2A21; text-decoration: line-through; }
table.diff4 { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.diff4 th { background: #FAFCFB; border: 1px solid var(--line); padding: 7px 9px; text-align: left; font-size: 11.5px; color: var(--muted); }
table.diff4 td { border: 1px solid var(--line); padding: 7px 9px; vertical-align: top; line-height: 1.7; }
table.diff4 tr.same td { color: var(--muted); }
table.diff4 td.clause { width: 90px; font-weight: 600; white-space: nowrap; }
table.diff4 td.note { width: 200px; color: var(--muted); font-size: 11.5px; }

/* 编辑器 */
.editor { width: 100%; min-height: 420px; border: 0; outline: none; resize: none; font-size: 14.5px;
  line-height: 2.05; padding: 18px 22px; font-family: var(--font); color: var(--text); background: #fff; }
.editor-meta { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-top: 1px solid var(--line);
  background: #FBFCFB; font-size: 11.5px; color: var(--faint); }

/* 打印 */
@media print {
  #sidebar, #topbar, .page-actions, .modal-foot, .drawer-foot, #toast-root { display: none !important; }
  #app { display: block; height: auto; }
  #view { overflow: visible; padding: 0; }
}

/* ============ 原格式联动（写作助手）：全宽弹窗 + 左右分栏 ============ */
.modal-card.split-wide { width: min(1560px, 96vw); max-width: min(1560px, 96vw); }
.modal-card.split-wide .modal-body { padding: 10px 12px 14px; }
.split-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px;
  height: calc(100vh - 230px); height: calc(100dvh - 230px); min-height: 420px; }
.split-pane { display: flex; flex-direction: column; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; background: #fff; min-width: 0; }
.split-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: #F7F9F8; border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 600; }
.split-head .spacer { flex: 1; }
.split-body { flex: 1; overflow: auto; padding: 10px 12px; min-height: 0; }
.split-iframe { padding: 0; overflow: hidden; }
.split-iframe iframe { width: 100%; height: 100%; border: 0; display: block; }
.split-p { display: flex; gap: 8px; padding: 4px 2px; border-bottom: 1px dashed #EDF1EF; line-height: 1.85; }
.split-p:hover { background: #F5FAF9; }
.split-n { flex: 0 0 26px; text-align: right; color: var(--faint); font-size: 11px; user-select: none; }
.split-t { flex: 1; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
@media (max-width: 900px) {
  .split-wrap { grid-template-columns: 1fr; height: auto; }
  .split-body { max-height: 42vh; }
}

/* ---------------------------------------------------------------- 试用反馈 */
.fb-kinds { display: flex; gap: 8px; }
.fb-kind { height: 30px; padding: 0 14px; border: 1px solid var(--line-strong); background: #fff;
  border-radius: var(--radius-full); font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.fb-kind:hover { border-color: var(--accent); color: var(--accent); }
.fb-kind.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.fb-list { display: flex; flex-direction: column; gap: 10px; max-height: 56vh; overflow: auto; }
.fb-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fff; }
.fb-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.fb-mod { color: var(--text-2); }
.fb-kind-tag { padding: 0 6px; border-radius: 3px; background: var(--sunken); }
.fb-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.fb-body { margin-top: 6px; font-size: 13px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.fb-reply { margin-top: 8px; padding: 8px 10px; background: var(--ok-bg, #EFF9F2); border-radius: var(--radius-sm);
  font-size: 12.5px; line-height: 1.7; }
@media (max-width: 768px) {
  .fb-kinds { flex-wrap: wrap; }
  .fb-list { max-height: 62vh; }
}
