:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --line: #e2e8e3;
  --line-strong: #cfd8d2;
  --text: #1b2b22;
  --muted: #6c7d72;
  --primary: #177245;
  --primary-dark: #0f5a36;
  --primary-weak: #e4f3ea;
  --amber: #b7791f;
  --amber-weak: #fdf3e0;
  --red: #c0392b;
  --red-weak: #fdecea;
  --blue: #2563eb;
  --shadow: 0 6px 24px rgba(20, 45, 30, .10);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 220px; }

.logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(140deg, #1d8653, #0e5c35);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .5px;
  box-shadow: 0 3px 10px rgba(23, 114, 69, .28);
}

.brand h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }

.topbar-right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto; padding-left: 8px;
}

/* 发票管理页顶栏：用户标签 + 退出登录，恒定贴右，不换行不收缩 */
.userbox {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto; flex: 0 0 auto;
  padding-left: 8px; white-space: nowrap;
}
.userbox .btn { flex: none; }
.userbox #btnProfile { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: #fbfefc; }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(23, 114, 69, .2);
}
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--red-weak); color: var(--red); border-color: transparent; }
.btn.danger {
  border-color: #f5c9c3;
  background: var(--red-weak);
  color: var(--red);
}
.btn.danger:hover, .btn.danger:focus {
  background: #fadbd6;
  border-color: var(--red);
  color: var(--red);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 新增行：柔和浅绿填充，与白色默认按钮 / 深绿主按钮形成清晰区分。
   尺寸、圆角、内边距、禁用态等均继承 .btn，仅改配色。 */
#btnAdd {
  background: #e6f4ea;
  border-color: #bfe0cc;
  color: #177245;
  font-weight: 600;
}
#btnAdd:hover { background: #dcefE3; border-color: var(--primary); color: var(--primary); }
#btnAdd:active { background: #d4ead9; }

/* 添加到字典：柔和浅黄填充（低饱和暖色，避免刺眼）。
   文字用深琥珀色保证对比度 ≥ 4.5:1，边框比填充略深一档形成层次；
   尺寸/圆角/内边距/禁用态/换行策略全部继承 .btn，不改变任何布局与功能。
   用 id 选择器覆盖 .btn.ghost 的透明底与红色 hover，避免与其语义冲突。 */
#btnAddToDict {
  background: #fff8e1;
  border-color: #ecd79b;
  color: #7d6516;
  font-weight: 600;
}
#btnAddToDict:hover { background: #fdf2c8; border-color: #dcc06a; color: #6b560f; }
#btnAddToDict:active { background: #fae9ab; border-color: #d4b555; color: #5f4c0b; }
#btnAddToDict:focus-visible { outline: 2px solid #dcc06a; outline-offset: 2px; }
#btnAddToDict:disabled, #btnAddToDict:disabled:hover {
  background: #fff8e1; border-color: #ecd79b; color: #7d6516; opacity: .5;
}

/* 智能调数：淡红填充（与「添加到字典」浅黄、「新增行」浅绿形成色系区分）。
   尺寸/圆角/内边距继承 .btn，仅改配色与交互反馈。 */
#btnSmartAdjust {
  background: #fdecea;
  border-color: #f2b8ae;
  color: #b03a2e;
  font-weight: 600;
}
#btnSmartAdjust:hover { background: #fad9d4; border-color: #e08a7e; color: #93301f; transform: translateY(-1px); box-shadow: 0 2px 8px rgba(192, 57, 43, .16); }
#btnSmartAdjust:active { background: #f7c8c0; transform: none; box-shadow: none; }
#btnSmartAdjust:focus-visible { outline: 2px solid #e08a7e; outline-offset: 2px; }

/* ---------- 智能凑数弹窗 ---------- */
.sa-option {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: .15s ease;
}
.sa-option:hover { border-color: var(--line-strong); background: #fbfefc; }
.sa-option.active { border-color: var(--primary); background: #fbfefc; box-shadow: 0 0 0 2px var(--primary-weak); }
.sa-option input[type="radio"] { accent-color: var(--primary); margin: 0; }
.sa-option .sa-label { font-size: 13px; }
.sa-option .sa-warn { color: var(--red); font-size: 12px; }
.sa-stepper {
  display: inline-flex; align-items: stretch; margin-left: auto;
  border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden;
  background: #fff;
}
.sa-stepper .sa-btn {
  width: 32px; border: none; background: #f7faf8; cursor: pointer;
  font-size: 15px; color: var(--primary); font-weight: 600;
}
.sa-stepper .sa-btn:hover { background: var(--primary-weak); }
.sa-stepper .sa-btn:active { background: #d4ead9; }
.sa-stepper .sa-input {
  width: 120px; border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  text-align: right; padding: 6px 8px; font-size: 13px;
  font-variant-numeric: tabular-nums; outline: none;
}
.sa-stepper .sa-input:focus { box-shadow: inset 0 0 0 2px var(--primary-weak); }
.sa-stepper.sa-invalid { border-color: var(--red); }
.sa-stepper.sa-invalid .sa-input { color: var(--red); }
.sa-hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.sa-hint.bad { color: var(--red); }
.sa-sum { display: flex; gap: 18px; align-items: baseline; font-size: 13px; margin: 10px 0 6px; }
.sa-sum b { font-variant-numeric: tabular-nums; }
.sa-sum .ok { color: var(--primary); font-weight: 600; }
.sa-sum .bad { color: var(--red); font-weight: 600; }
.sa-table th, .sa-table td { text-align: right; }
.sa-table th:nth-child(-n+2), .sa-table td:nth-child(-n+2) { text-align: left; }
.sa-table .sa-changed { background: #fdf6f4; }
.sa-table .sa-delta { color: var(--red); font-weight: 600; }
.sa-table input.sa-cell {
  width: 90px; padding: 3px 6px; border: 1px solid var(--line-strong); border-radius: 6px;
  text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; outline: none;
}
.sa-table input.sa-cell:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.sa-table input.sa-cell:disabled { background: #f4f6f4; color: var(--muted); border-color: var(--line); }
.sa-skipped { font-size: 12px; color: var(--amber); margin: 6px 0 0; }

.divider { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* 撤销 / 恢复（图标按钮，与 .btn 同尺寸同圆角） */
.hist-btn {
  width: 36px; height: 36px; padding: 0; flex: 0 0 auto;
  justify-content: center; border-radius: 9px; color: var(--muted);
}
.hist-btn svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.hist-btn:hover:not(:disabled) {
  border-color: var(--primary); color: var(--primary); background: #fbfefc;
}
.hist-btn:active:not(:disabled) {
  background: var(--primary-weak); border-color: var(--primary); transform: translateY(1px);
}
.hist-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hist-btn:disabled {
  opacity: .45; background: #f7f8f7; color: #9aa8a0;
  cursor: not-allowed; transform: none;
}

.user-area { display: inline-flex; align-items: center; gap: 6px; padding: 0 2px; }
.user-name {
  font-size: 13px; color: var(--primary); font-weight: 600;
  padding: 4px 10px; background: #f0f7f3; border-radius: 16px;
  border: 1px solid #c9e7d6; cursor: pointer;
}
.user-name:hover { background: #e2f2e9; }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; font-size: 13px; }
.profile-grid > div {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 10px; background: #f6f8f7; border-radius: 8px;
}
.profile-grid span { color: var(--muted); white-space: nowrap; }
.profile-grid b { color: var(--text); font-weight: 600; text-align: right; word-break: break-all; }
@media (max-width: 720px) { .profile-grid { grid-template-columns: 1fr; } }

.private-dicts { margin-top: 14px; }
.private-dicts-head { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pd-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 10px; background: #f6f8f7; border-radius: 8px; margin-bottom: 6px; font-size: 13px;
}
.pd-item small { color: var(--muted); }
.pd-empty { font-size: 12px; color: var(--muted); padding: 6px 2px; }
.dict-picker { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dict-picker-label { font-size: 12px; }
.dict-select {
  padding: 5px 8px; font-size: 12px; border: 1px solid #d4e1da;
  border-radius: 6px; background: #fff; cursor: pointer; outline: none;
  min-width: 160px; max-width: 200px;
}
.dict-select:focus { border-color: var(--primary); }
.admin-entry { text-decoration: none; }
.admin-entry:hover { background: #f0f7f3; color: var(--primary); }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px 0;
  flex-wrap: wrap;
}
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.chip b { color: var(--text); font-weight: 650; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.chip.warn .dot { background: var(--amber); }
.chip.bad .dot { background: var(--red); }

/* 可点击的统计卡片：筛选 + 定位入口 */
.chip[data-status-focus] { cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.chip[data-status-focus]:hover { border-color: var(--primary); background: var(--primary-weak); }
.chip[data-status-focus]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.chip.active {
  border-color: var(--primary); background: var(--primary-weak);
  box-shadow: 0 0 0 2px rgba(23,114,69,.12);
}

/* 统计标签旁的链接式筛选开关按钮 */
.chip-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 2px;
  border: none; border-radius: 50%;
  background: transparent; color: var(--muted);
  cursor: pointer; padding: 0;
  transition: background .12s, color .12s, transform .08s;
}
.chip-link:hover { background: rgba(23,114,69,.12); color: var(--primary); }
.chip-link:active { transform: scale(.85); }                 /* 点击反馈 */
.chip-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.chip.active .chip-link { color: var(--primary); background: rgba(23,114,69,.16); }  /* 激活高亮 */

/* 定位到的记录：整行高亮 + 左侧色条 */
#grid tbody tr.located > td {
  background: #e6f4ea !important;
  transition: background .25s;
}
#grid tbody tr.located > td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

.spacer { flex: 1; }

.field-inline { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.field-inline select {
  padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
}

.search-box { position: relative; }
.search-box input {
  width: 240px;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  outline: none;
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }
.search-box input.has-filter { padding-right: 30px; border-color: var(--primary); }
.search-box::before {
  content: "⌕";
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 16px;
}
/* 筛选条件清除按钮：仅有筛选时显示，避免「以为在看全量、实际被过滤」 */
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; padding: 0; border: none; border-radius: 50%;
  background: var(--line-strong); color: #fff; font-size: 10px; line-height: 18px;
  cursor: pointer; display: none; align-items: center; justify-content: center;
}
.search-clear.show { display: flex; }
.search-clear:hover { background: var(--muted); }

/* ---------- 表格 ---------- */
main { padding: 12px 20px 24px; }
.table-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 45, 30, .03);
  overflow: auto;
  max-height: calc(100vh - 270px);
}
table { width: max-content; min-width: 2130px; border-collapse: separate; border-spacing: 0; }

thead th {
  position: sticky; top: 0; z-index: 20;
  background: #eef3ef;
  color: #46564c;
  font-size: 12px;
  font-weight: 600;
  /* 表头字段名：水平左右居中 + 垂直上下居中，与发票管理页表头保持一致 */
  text-align: center;
  vertical-align: middle;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
/* 必填星号 / 排序箭头不占布局宽度：只画在字段名右侧，
   不参与 text-align:center 的宽度计算，避免字段名被角标带偏 */
thead th .req {
  color: var(--red);
  display: inline-block; width: 0; overflow: visible;
  margin-left: 2px; margin-right: -2px;
}

/* 复选列 */
th.check, td.check { width: 40px; text-align: center; }
td.check { padding: 3px 4px !important; }
th.check input, td.check input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }

/* 列宽拖拽手柄 */
thead th { position: sticky; }
th .col-resize {
  position: absolute; top: 0; right: -4px;
  width: 9px; height: 100%;
  cursor: col-resize; z-index: 25;
  touch-action: none;
}
th .col-resize:hover, body.col-resizing th .col-resize {
  background: linear-gradient(to left, var(--primary) 0 2px, transparent 2px);
}
body.col-resizing { cursor: col-resize !important; user-select: none !important; }
body.col-resizing * { cursor: col-resize !important; }

/* 只读联动单元格（库存） */
input.cell.ro {
  background: #f4f7f4;
  color: var(--muted);
  cursor: default;
}

/* 可排序表头 */
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { background: #e2ece5; color: var(--primary-dark); }
thead th.sortable.sorted { color: var(--primary-dark); background: #e2ece5; }
thead th .sort-ic {
  display: inline-block; width: 0; overflow: visible;
  margin-left: 3px; margin-right: -3px;
  font-style: normal; font-size: 10px; color: var(--primary);
}

/* 筛选行 */
thead tr.filter-row th {
  top: 37px; z-index: 35;
  background: #f7faf6;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line-strong);
}
.f-input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  outline: none;
  min-width: 0;
}
.f-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.f-input.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 列筛选·下拉多选（枚举/状态字段）：按钮外观与 .f-input 保持一致 */
.f-ms { position: relative; }
.f-ms-btn {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  color: var(--muted);
  cursor: pointer;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.f-ms-btn::after { content: '▾'; float: right; opacity: .45; font-size: 10px; line-height: 1.8; }
.f-ms-btn:hover { border-color: var(--primary); }
.f-ms-btn.active { color: var(--text); border-color: var(--primary); font-weight: 600; }
.f-ms.open .f-ms-btn { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); color: var(--text); }
.f-ms-pop {
  display: none;
  position: fixed;          /* fixed 脱离表格 overflow 裁剪，由 JS 按按钮位置定位 */
  top: 0;
  left: 0;
  min-width: 150px;
  max-width: 240px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
  z-index: 60;
  padding: 6px;
  font-weight: normal;
  text-align: left;
}
.f-ms.open .f-ms-pop { display: block; }
.f-ms-tools {
  display: flex;
  justify-content: space-between;
  padding: 2px 4px 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.f-ms-tools span { color: var(--primary); cursor: pointer; font-size: 11px; }
.f-ms-tools span:hover { text-decoration: underline; }
.f-ms-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
.f-ms-item:hover { background: var(--primary-weak); }
.f-ms-item input { margin: 0; flex: none; }
.f-ms-item .v { overflow: hidden; text-overflow: ellipsis; }
.f-ms-empty { padding: 10px 6px; color: var(--muted); font-size: 12px; text-align: center; }

.no-filter-hit { text-align: center; color: var(--muted); padding: 24px !important; }

/* 底部统计栏 */
.footerbar {
  position: sticky; bottom: 0; z-index: 30;
  padding: 10px 20px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.footer-center {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 12px 22px;
}
.export-group { display: flex; flex-wrap: wrap; gap: 8px; }
.footer-left { display: flex; flex-wrap: wrap; gap: 8px; padding-right: 14px; border-right: 1px solid var(--line); }
.pager { display: flex; align-items: center; gap: 6px; }
.page-info { white-space: nowrap; font-variant-numeric: tabular-nums; }
.page-info b { color: var(--text); }
.footer-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.btn.small { padding: 4px 9px; font-size: 12px; min-width: 28px; line-height: 1.5; }
.footerbar b { color: var(--text); font-weight: 650; margin-left: 5px; font-variant-numeric: tabular-nums; }
.footerbar .sel b { color: var(--primary); }

tbody td {
  padding: 3px 5px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  background: var(--surface);
}
tbody tr:hover td { background: #fafdfb; }
tbody tr.selected td { background: #f3faf6; }
/* 勾选商品行：整行淡黄底 + 全行文字加粗（.cell 背景透明，故底色可见） */
tbody tr.row-checked td { background: #fffbe6; }
tbody tr.row-checked td,
tbody tr.row-checked td input,
tbody tr.row-checked td select { font-weight: 700; }

td.idx { text-align: center; color: var(--muted); font-size: 12px; width: 46px; }
td.actions { white-space: nowrap; width: 74px; text-align: center; }

.cell {
  width: 100%;
  padding: 6px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  outline: none;
  min-width: 0;
}
.cell:hover { border-color: var(--line); background: #fff; }
.cell:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-weak); }
.cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell.code { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; letter-spacing: .2px; }
.cell.invalid { border-color: var(--red); background: var(--red-weak); }

.code-wrap { display: flex; gap: 4px; align-items: center; }
.code-wrap .cell { flex: 1; }
.icon-btn {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
}
.icon-btn:hover { background: var(--primary-weak); color: var(--primary); border-color: #c9e7d6; }
.icon-btn.danger:hover { background: var(--red-weak); color: var(--red); border-color: #f5c9c3; }

.status { display: flex; flex-direction: column; gap: 2px; min-width: 108px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  width: fit-content;
  white-space: nowrap;
}
.badge.high { background: var(--primary-weak); color: var(--primary); }
.badge.medium { background: var(--amber-weak); color: var(--amber); }
.badge.low { background: var(--red-weak); color: var(--red); }
.badge.none { background: #eef1ee; color: var(--muted); }
/* 智能匹配徽标：复用绿色主色，配蓝色描边区分人工确认态 */
.badge.smart { background: #e8f2ff; color: #1b5fa8; border: 1px solid #bcd8f7; }
.mini-btn {
  align-self: flex-start;
  margin-top: 2px;
  padding: 1px 8px;
  font-size: 11px;
  line-height: 18px;
  border-radius: 7px;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.mini-btn:hover { background: var(--primary); color: #fff; }

/* 匹配规则弹窗 */
.rule-group { border: 1px solid #e3e9e5; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.rule-group h4 { margin: 0 0 8px; font-size: 13px; color: #22372b; display: flex; align-items: baseline; gap: 8px; }
.rule-group h4 small { font-weight: 400; color: var(--muted); font-size: 11px; }
.rule-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; max-height: 132px; overflow-y: auto; }
.rule-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 8px; border-radius: 999px;
  background: #f1f6f2; border: 1px solid #d7e0da; font-size: 12px; color: #2d4436;
}
.rule-tag button {
  border: none; background: transparent; color: #8c9a90;
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.rule-tag button:hover { color: var(--red); }
.rule-add { display: flex; gap: 8px; }
.rule-add .f-input { flex: 1; }
.status small { color: var(--muted); font-size: 11px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

select.cell.select { appearance: auto; padding-right: 4px; }

.empty {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  background: var(--surface);
  z-index: 5;
  padding: 40px;
  text-align: center;
}
.empty.show { display: flex; }
.empty .big { font-size: 34px; opacity: .45; }
.empty h3 { margin: 0; font-size: 16px; color: var(--text); font-weight: 600; }
.empty p { margin: 0; font-size: 13px; }
.empty .hint { margin-top: 6px; font-size: 12px; color: #93a29a; }

.table-wrap.drag-over { outline: 2px dashed var(--primary); outline-offset: -6px; background: #f7fdf9; }

/* ---------- 字典抽屉 ---------- */
.picker {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(20, 45, 30, .08);
  transform: translateX(105%);
  transition: transform .22s ease;
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.picker.open { transform: none; }
.picker-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.picker-head h3 { margin: 0; font-size: 14px; }
.picker-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.picker-body { padding: 12px 16px; overflow: auto; flex: 1; }
.picker-dict-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--line);
}
.picker-dict-bar .dict-select { min-width: 200px; flex: 1; }
.picker-dict-empty { font-size: 12px; color: var(--muted); }
.picker-body .search-box input { width: 100%; }
.picker-tip { font-size: 12px; color: var(--muted); margin: 10px 0 8px; }
.dict-item {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: .12s;
  background: #fff;
}
.dict-item:hover { border-color: var(--primary); background: #fafdfb; }
.dict-item .code { font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; color: var(--blue); }
.dict-item .name { font-weight: 600; margin: 2px 0; }
.dict-item .desc { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dict-item .meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.dict-item .short { background: #f0f4f1; padding: 0 6px; border-radius: 6px; }
.picker-foot { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* ---------- 弹层 ---------- */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 30, 22, .38);
  z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: min(860px, 94vw);
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal.small { width: min(560px, 94vw); }
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  background: #fbfcfb;
}
.modal-foot .left { margin-right: auto; font-size: 12px; color: var(--muted); }

/* ---------- 可拖动弹窗 ---------- */
.modal.draggable .modal-head { cursor: grab; user-select: none; touch-action: none; }
.modal.dragging { will-change: transform; opacity: .94; box-shadow: 0 14px 40px rgba(20, 45, 30, .22); }
.modal.dragging .modal-head { cursor: grabbing; }

textarea.paste-area {
  width: 100%;
  min-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  outline: none;
}
textarea.paste-area:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-weak); }

.preview-wrap { margin-top: 12px; border: 1px solid var(--line); border-radius: 9px; overflow: auto; max-height: 260px; }
.preview-table { min-width: 100%; width: max-content; border-collapse: collapse; }
.preview-table th, .preview-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 12px; }
.preview-table th { background: #f4f7f5; position: sticky; top: 0; }
.preview-table select { padding: 3px 4px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; font-size: 12px; }

.issues { display: flex; flex-direction: column; gap: 6px; }
.issue {
  display: flex; gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  background: var(--red-weak);
  color: #8c2a1f;
  line-height: 1.45;
}
.issue.warning { background: var(--amber-weak); color: #8a5d12; }
.issue .rowno {
  flex: none; font-weight: 700; min-width: 44px;
}
.issue .field { flex: none; opacity: .8; }

.add-report { display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text); }
.add-report b { color: var(--primary); font-size: 16px; margin: 0 3px; }
.add-report .hint { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* ---- 多字典写入：目标字典复选框列表 ---- */
.dict-pick-list { display: flex; flex-direction: column; gap: 6px; }
.dict-pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: background .12s;
}
.dict-pick-row:hover { background: var(--hover); }
.dict-pick-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.dict-pick-name { flex: 1; font-weight: 500; color: var(--text); }
.dict-pick-meta { font-size: 12px; color: var(--muted); }

/* ---- 多字典写入结果报告：按字典分组展示 ---- */
.add-report-dicts { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.add-report-dict {
  padding: 8px 12px; background: var(--hover); border-radius: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.add-report-dict-name { font-weight: 600; color: var(--text); font-size: 13px; }
.add-report-dict-stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.add-report-dict-stats b { color: var(--primary); font-size: 14px; margin: 0 2px; }


/* ---- 新增行引导提示气泡（3 秒或首次输入后自动消失） ---- */
.newrow-hint {
  position: fixed; z-index: 180;
  padding: 7px 14px;
  background: #177245; color: #fff;
  font-size: 13px; border-radius: 8px;
  box-shadow: 0 6px 18px rgba(16, 70, 40, .28);
  pointer-events: none;               /* 不挡住输入框，纯展示 */
  animation: newrow-hint-in .18s ease;
  white-space: nowrap;
}
.newrow-hint .hint-arrow {
  position: absolute; left: 18px; bottom: -5px;
  width: 10px; height: 10px; background: #177245;
  transform: rotate(45deg);
}
@keyframes newrow-hint-in { from { opacity: 0; transform: translateY(5px); } }

.radio-line { display: flex; align-items: center; gap: 16px; margin: 6px 0 0; }
.radio-line label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }

.field-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---------- toast ---------- */
#toastRoot { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 9px 16px;
  border-radius: 9px;
  background: rgba(24, 39, 30, .92);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}
.toast.error { background: rgba(160, 43, 30, .95); }
.toast.warn { background: rgba(150, 96, 12, .95); }
.toast.success { background: rgba(18, 100, 60, .95); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 非模态提示弹窗（不阻塞页面，可关闭 / 自动消失） ---------- */
.hint-dialog {
  position: fixed; left: 50%; top: 15%;
  transform: translateX(-50%);
  z-index: 190;
  width: min(400px, 90vw);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
  animation: hint-dialog-in .18s ease;
}
@keyframes hint-dialog-in { from { opacity: 0; transform: translate(-50%, -8px); } }
.hint-dialog-head { display: flex; align-items: flex-start; gap: 10px; }
.hint-dialog-title { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.hint-dialog-close {
  flex: none; width: 22px; height: 22px; padding: 0;
  border: none; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer;
  transition: background .12s, color .12s;
}
.hint-dialog-close:hover { background: #eef2ef; color: var(--text); }
.hint-dialog-body { margin: 6px 0 0; font-size: 13px; line-height: 1.55; color: #4a5750; }
.hint-dialog-tip { margin: 8px 0 0; font-size: 11px; color: var(--muted); }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd6ce; border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: #aebdb2; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1100px) {
  .brand { min-width: 0; }
  .brand p { display: none; }
  .actions .btn span.txt { display: none; }
  .table-wrap { max-height: calc(100vh - 258px); }
}

/* ---------- 模块切换卡片（位于顶栏内，扁平单行） ---------- */
.module-switch {
  display: flex; gap: 8px; align-items: center;
  padding: 0;
}
.module-card {
  flex: 0 1 auto; display: flex; align-items: center; gap: 8px;
  padding: 4px 18px; border-radius: 10px; text-decoration: none;
  background: #fff; border: 1px solid #e3e8e5; color: #2f3d36;
  transition: all .18s ease; box-shadow: 0 1px 2px rgba(20,40,30,.04);
}
.module-card:hover { border-color: #9fc9b1; box-shadow: 0 4px 12px rgba(20,80,45,.10); }
.module-card.active { border-color: #177245; background: #f2fbf6; box-shadow: 0 3px 10px rgba(23,114,69,.13); }
.module-card .m-icon { font-size: 17px; line-height: 1; }
.module-card .m-body { display: flex; flex-direction: row; align-items: center; gap: 8px; min-width: 0; }
.module-card .m-body b { font-size: 13px; color: #177245; white-space: nowrap; line-height: 1; }
.module-card .m-body small { font-size: 11px; color: #7a8a81; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1; }
.module-card.active .m-body b::after { content: " · 当前"; font-size: 10px; color: #4c9b74; font-weight: 500; }

/* ---------- 主操作栏（原顶栏按钮组，移出到顶栏下方） ---------- */
.action-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  width: 100%;
  padding: 12px 20px 0;
}
.action-bar .spacer { flex: 1; }

@media (max-width: 760px) {
  .module-switch { flex-direction: column; gap: 6px; margin-left: 0; width: 100%; }
  .module-card { flex: 1 1 auto; justify-content: center; }
  .action-bar { padding: 10px 12px 0; }
}

/* ---- 十字高亮：行/列/交叉格三层深绿，hover 触发 ---- */
#grid tbody tr.xh-row > td { background: #cde8d6 !important; }
#grid tbody tr.xh-row > td.xh-col, #grid tbody tr > td.xh-col { background: #b6dfc4 !important; }
#grid tbody tr.xh-row > td.xh-cell, #grid tbody tr > td.xh-cell { background: #93cfa9 !important; font-weight: 600; }
#grid tbody td { transition: background-color .15s ease; }

/* ---- 开票助手：右键列配置 ---- */
.ctx-menu { position: fixed; z-index: 260; min-width: 180px; padding: 6px; background: #fff; border: 1px solid #d7e0da; border-radius: 9px; box-shadow: 0 12px 32px rgba(10,30,20,.22); font-size: 13px; color: #22352b; }
.ctx-menu .ctx-t { font-size: 12px; color: #7a8a81; padding: 4px 10px 7px; border-bottom: 1px solid #eef2ef; margin-bottom: 4px; }
.ctx-menu label { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px; cursor: pointer; user-select: none; }
.ctx-menu label:hover { background: #f0f7f3; }
.ctx-menu input { accent-color: #177245; }
#grid[data-hide~=idx] [data-col=idx], #grid[data-hide~=name] [data-col=name], #grid[data-hide~=code] [data-col=code], #grid[data-hide~=short] [data-col=short], #grid[data-hide~=spec] [data-col=spec], #grid[data-hide~=unit] [data-col=unit], #grid[data-hide~=qty] [data-col=qty], #grid[data-hide~=stock] [data-col=stock], #grid[data-hide~=qty_issued] [data-col=qty_issued], #grid[data-hide~=qty_total] [data-col=qty_total], #grid[data-hide~=price] [data-col=price], #grid[data-hide~=amount] [data-col=amount], #grid[data-hide~=tax_rate] [data-col=tax_rate], #grid[data-hide~=tax_included] [data-col=tax_included], #grid[data-hide~=category] [data-col=category], #grid[data-hide~=mnemonic] [data-col=mnemonic], #grid[data-hide~=policy_type] [data-col=policy_type], #grid[data-hide~=status] [data-col=status], #grid[data-hide~=act] [data-col=act] { display: none; }

/* ================= 用户存储空间：顶栏进度条 ================= */
.storage-widget {
  display: flex; flex-direction: column; gap: 4px; width: 214px;
  padding: 5px 10px; margin-right: 4px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.storage-widget:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(23,114,69,.12); }
.storage-widget .sw-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.storage-widget .sw-top span, .storage-widget .sw-top b { white-space: nowrap; }
.storage-widget .sw-top b { font-size: 11px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.storage-widget .sw-bar { display: block; height: 6px; border-radius: 4px; background: #edf1ee; overflow: hidden; }
.storage-widget .sw-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, #2f8f5e, #57b981); transition: width .35s ease, background .2s ease; }
.storage-widget.warn .sw-bar i { background: linear-gradient(90deg, #d69416, #efbf52); }
.storage-widget.warn .sw-top b { color: var(--amber); }
.storage-widget.full .sw-bar i { background: linear-gradient(90deg, #c0392b, #e4584a); }
.storage-widget.full .sw-top b { color: var(--red); }
.storage-widget.full { border-color: #e6b4ad; animation: swPulse 1.6s ease-in-out infinite; }
@keyframes swPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); } 50% { box-shadow: 0 0 0 4px rgba(192,57,43,.14); } }
@media (max-width: 760px) { .storage-widget { width: 156px; } }

/* ================= 用户存储空间：文件管理弹窗 ================= */
.fm-summary { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 10px 12px; margin-bottom: 12px; background: #f6faf7; border: 1px solid var(--line); border-radius: 10px; font-size: 12px; color: var(--muted); }
.fm-summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.fm-summary .fm-bar { flex: 1 1 160px; min-width: 120px; height: 8px; border-radius: 5px; background: #e6ece8; overflow: hidden; }
.fm-summary .fm-bar i { display: block; height: 100%; width: 0; border-radius: 5px; background: linear-gradient(90deg, #2f8f5e, #57b981); transition: width .35s ease; }
.fm-summary.warn .fm-bar i { background: linear-gradient(90deg, #d69416, #efbf52); }
.fm-summary.full .fm-bar i { background: linear-gradient(90deg, #c0392b, #e4584a); }
.fm-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.fm-toolbar .spacer { flex: 1; }
.fm-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 13px; }
.fm-table th { position: sticky; top: 0; padding: 7px 8px; text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); background: #f5f8f5; border-bottom: 1px solid var(--line); }
.fm-table td { padding: 7px 8px; border-bottom: 1px solid #f0f3f0; vertical-align: middle; }
.fm-table tbody tr:hover td { background: #fafcf9; }
.fm-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fm-table td.act { white-space: nowrap; }
.fm-table td.act .btn { margin-left: 4px; }
.fm-name { font-weight: 500; word-break: break-all; }
.fm-kind { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: #eef4ef; color: #4a5d51; }
.fm-kind.dict { background: #e4f3ea; color: #177245; }
.fm-kind.list { background: #e8f2ff; color: #1b5fa8; }
.fm-kind.config { background: #fdf3e0; color: #9a6a08; }
.fm-empty { padding: 30px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.fm-logs { margin-top: 14px; max-height: 180px; overflow: auto; border-top: 1px dashed var(--line); padding-top: 10px; font-size: 12px; color: var(--muted); }
.fm-logs div { padding: 3px 0; border-bottom: 1px dotted #eef2ef; }
.fm-logs b { color: var(--text); font-weight: 500; }
.fm-form { display: flex; flex-direction: column; gap: 10px; }
.fm-form label { font-size: 12px; color: var(--muted); }
.fm-form input, .fm-form select { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; font-size: 13px; }
.fm-form input:focus, .fm-form select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,114,69,.12); }
.fm-hint { font-size: 12px; color: var(--muted); }
.fm-layer { position: fixed; inset: 0; z-index: 320; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(18,32,24,.45); }
.fm-check { width: 30px; text-align: center; }
.fm-check input { accent-color: var(--primary); cursor: pointer; }
.fm-prog { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; }
.fm-prog-bar { height: 100%; background: var(--primary); transition: width .2s; }
.fm-prog-text { font-size: 12.5px; color: var(--muted); }
.fm-prog-sub { font-size: 12px; color: var(--muted); word-break: break-all; }
.fm-dellist { max-height: 200px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.fm-delitem { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; }
.fm-pick-tree { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.fm-list-wrap { max-height: 55vh; overflow: auto; }

/* ================= 资源管理器：目录树 + 列表视图 ================= */
.fm-modal { width: min(1080px, 96vw); }
.fm-explorer { display: flex; gap: 12px; align-items: stretch; min-height: 360px; }
.fm-tree { width: 216px; flex: 0 0 216px; border: 1px solid var(--line); border-radius: 10px; background: #fbfdfb; overflow: auto; max-height: 470px; }
.fm-tree-head { position: sticky; top: 0; padding: 8px 12px; font-size: 12px; color: var(--muted); background: #f5f8f5; border-bottom: 1px solid var(--line); }
.fm-tree-body { padding: 6px; }
.fm-tree-ul { list-style: none; margin: 0; padding: 0; }
.fm-tree-ul[data-depth="1"] { padding-left: 14px; }
.fm-tree-row {
  display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 7px;
  cursor: pointer; font-size: 13px; color: var(--text);
  transition: background .12s ease, color .12s ease;
}
.fm-tree-row:hover { background: #eef5f0; }
.fm-tree-row.selected { background: #e2f2e8; color: #146139; font-weight: 600; }
.fm-tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-tree-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fm-tree-empty { padding: 14px 8px; text-align: center; color: var(--muted); font-size: 12px; }
.fm-caret {
  position: relative; flex: 0 0 14px; width: 14px; height: 14px; padding: 0;
  border: none; background: transparent; cursor: pointer;
}
.fm-caret::before {
  content: ''; position: absolute; left: 4px; top: 3px;
  border-left: 5px solid #8ba295; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .15s ease;
}
.fm-caret.open::before { transform: rotate(90deg); }
.fm-caret.none { visibility: hidden; }
/* 纯 CSS 图标：文件夹 / 文件 */
.fm-ico { position: relative; display: inline-block; width: 16px; height: 14px; flex: 0 0 16px; margin-right: 6px; vertical-align: -2px; }
.fm-ico.dir { background: linear-gradient(#e8c26a, #d8ab45); border-radius: 2px; }
.fm-ico.dir::before { content: ''; position: absolute; left: 1px; top: -3px; width: 7px; height: 4px; background: #d8ab45; border-radius: 2px 2px 0 0; }
.fm-ico.file { background: #fff; border: 1px solid #b9c8bf; border-radius: 2px; }
.fm-ico.file::after { content: ''; position: absolute; left: 3px; top: 4px; width: 8px; height: 1px; background: #b9c8bf; box-shadow: 0 3px 0 #b9c8bf; }
.fm-main { flex: 1; min-width: 0; }
.fm-crumbrow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.fm-up, .fm-tree-toggle {
  padding: 4px 10px; font-size: 12px; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--primary);
}
.fm-up:hover, .fm-tree-toggle:hover { background: #f0f7f3; }
.fm-up:disabled { color: #a9b7ae; cursor: not-allowed; background: #f7f9f7; }
.fm-tree-toggle { display: none; }
.fm-crumb { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; min-width: 0; }
.fm-crumb-item {
  max-width: 220px; padding: 3px 7px; font-size: 12px; border: none; border-radius: 6px;
  background: transparent; color: var(--primary); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fm-crumb-item:hover:not(:disabled) { background: #eef5f0; text-decoration: underline; }
.fm-crumb-item.current { color: var(--text); font-weight: 600; cursor: default; }
.fm-crumb-sep { color: #b6c4bb; font-size: 12px; }
.fm-list-wrap {
  position: relative; min-height: 160px; max-height: 420px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
}
.fm-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 40px 12px; color: var(--muted); font-size: 13px; }
.fm-spin { width: 14px; height: 14px; border: 2px solid #d8e5dd; border-top-color: var(--primary); border-radius: 50%; animation: fmSpin .7s linear infinite; }
@keyframes fmSpin { to { transform: rotate(360deg); } }
.fm-row { cursor: pointer; }
.fm-row:hover td { background: #f4faf6; }
.fm-row.selected td { background: #e2f2e8; }
.fm-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.fm-cell-name { display: flex; align-items: center; }
.fm-kind.folder { background: #fdf0d8; color: #8a6414; }
@media (max-width: 860px) {
  .fm-explorer { position: relative; }
  .fm-tree {
    display: none; position: absolute; left: 0; top: 0; bottom: 0; z-index: 5;
    width: 240px; flex-basis: 240px; background: #fff; box-shadow: 0 8px 24px rgba(20,40,28,.18);
  }
  .fm-tree.open { display: block; }
  .fm-tree-toggle { display: inline-block; }
  .fm-list-wrap { max-height: 50vh; }
}

/* ================= 统一「本地存储 / 云端存储」选择器 ================= */
.sc-layer {
  position: fixed; inset: 0; z-index: 360; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(18,32,24,.45); animation: scFade .16s ease;
}
.sc-card {
  width: min(520px, 94vw); background: #fff; border-radius: 14px; padding: 22px 24px 16px;
  box-shadow: 0 24px 70px rgba(10,30,18,.28); animation: scIn .18s ease;
}
.sc-head h3 { font-size: 17px; color: var(--primary); margin-bottom: 6px; }
.sc-head p { font-size: 13px; color: var(--muted); line-height: 1.65; }
.sc-options { display: grid; gap: 10px; margin-top: 16px; }
.sc-option {
  display: flex; align-items: flex-start; gap: 12px; text-align: left;
  padding: 14px 16px; border: 1px solid #d7e3db; border-radius: 11px; background: #fff;
  cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
}
.sc-option:hover { border-color: #4c9b74; background: #f5fbf7; box-shadow: 0 6px 18px rgba(23,114,69,.1); transform: translateY(-1px); }
.sc-option:active { transform: translateY(0); }
.sc-option:focus-visible { outline: 2px solid #4c9b74; outline-offset: 2px; }
.sc-ico { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.sc-ico.local { background: #eaf1fb; }
.sc-ico.cloud { background: #e8f5ed; }
.sc-body b { display: block; font-size: 14px; color: #24352b; margin-bottom: 3px; }
.sc-body small { font-size: 12px; color: var(--muted); line-height: 1.5; }
.sc-file {
  margin-top: 12px; padding: 8px 10px; font-size: 12px; color: var(--muted);
  background: #f5f8f5; border-radius: 7px; word-break: break-all;
}
.sc-file b { color: var(--text); font-weight: 600; }
.sc-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.sc-layer.closing { animation: scFadeOut .14s ease forwards; }
@keyframes scFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes scFadeOut { to { opacity: 0; } }
@keyframes scIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

/* 云端目录选择（选择存储位置弹窗第二步） */
.sc-dir-current {
  margin-top: 12px; padding: 8px 10px; font-size: 12px; color: var(--muted);
  background: #f5f8f5; border: 1px dashed #cfdcd3; border-radius: 7px; word-break: break-all;
}
.sc-dir-current.ok { background: #eef7f1; border-color: #9cc8ae; color: #146139; }
.sc-dir-current b { color: inherit; font-weight: 600; }
.sc-dir-tree {
  margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fbfdfb;
  max-height: 240px; overflow: auto; padding: 6px;
}
.sc-dir-newrow { margin-top: 10px; min-height: 30px; display: flex; align-items: center; }
.sc-dir-mkdir { display: flex; gap: 8px; width: 100%; }
.sc-dir-mkdir input {
  flex: 1; min-width: 0; padding: 6px 10px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 7px; outline: none;
}
.sc-dir-mkdir input:focus { border-color: #4c9b74; box-shadow: 0 0 0 2px rgba(76,155,116,.15); }
.sc-dir-err { width: 100%; margin-top: 6px; font-size: 12px; color: #c0392b; }
