/* 谷创科技数字化办公平台 —— 全局样式
   设计目标：专业、克制、信息密度高；浅色为主，蓝色主色，符合企业办公系统习惯 */

:root {
  --brand: #1f6feb;
  --brand-2: #2f7ef7;
  --brand-dark: #1653b8;
  --brand-soft: #e8f1ff;
  --ok: #18a058;
  --ok-soft: #e7f6ee;
  --warn: #f59e0b;
  --warn-soft: #fef3e2;
  --danger: #f5222d;
  --danger-soft: #fdecec;
  --info: #6b7280;

  --bg: #f2f4f7;
  --panel: #ffffff;
  --border: #e4e7ed;
  --border-2: #eef0f4;
  --text: #1f2329;
  --text-2: #5a6472;
  --text-3: #8a94a6;

  --side-bg: #21334d;
  --side-bg-2: #1a2941;
  --side-text: #c3ccda;
  --side-active: #2f7ef7;
  --side-active-soft: rgba(47,126,247,.18);

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9cfd8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aab2bd; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- 登录 */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(47,126,247,.16), transparent 60%),
    radial-gradient(900px 500px at 85% 85%, rgba(24,160,88,.12), transparent 60%),
    linear-gradient(135deg, #17305a 0%, #1f4b8f 45%, #2f7ef7 100%);
  padding: 24px;
}
.login-box {
  width: 100%; max-width: 940px; background: #fff; border-radius: 14px;
  box-shadow: var(--shadow-lg); display: grid; grid-template-columns: 1.05fr .95fr;
  overflow: hidden; min-height: 500px;
}
.login-side {
  background: linear-gradient(160deg, #1f4b8f, #2f7ef7);
  color: #fff; padding: 40px 36px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-side h1 { font-size: 26px; margin: 0 0 10px; letter-spacing: 1px; font-weight: 600; }
.login-side .sub { opacity: .85; font-size: 13px; line-height: 1.9; }
.login-side .feat { margin-top: 26px; display: grid; gap: 10px; }
.login-side .feat div {
  background: rgba(255,255,255,.12); border-radius: var(--radius);
  padding: 9px 12px; font-size: 13px; backdrop-filter: blur(2px);
}
.login-side .foot { font-size: 12px; opacity: .7; }
.login-form { padding: 44px 40px; display: flex; flex-direction: column; justify-content: center; }
.login-form h2 { margin: 0 0 6px; font-size: 20px; }
.login-form .tip { color: var(--text-3); font-size: 13px; margin-bottom: 26px; }
.login-form .btn-login { margin-top: 8px; height: 42px; font-size: 15px; }
.login-form .err {
  color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px; margin-bottom: 14px; display: none;
}
.login-form .err.show { display: block; }
@media (max-width: 860px) {
  .login-box { grid-template-columns: 1fr; }
  .login-side { display: none; }
}

/* ---------------------------------------------------------------- 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; flex: 0 0 216px; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30;
}
.sidebar .logo {
  height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: var(--side-bg-2); color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .5px;
}
.sidebar .logo .dot {
  width: 26px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, var(--brand-2), #18a058);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.side-nav { flex: 1; overflow-y: auto; padding: 8px 0 20px; }
/* 一级菜单（大类）：可点击展开/收起 */
.side-group {
  display: flex; align-items: center; gap: 9px;
  margin: 3px 8px; padding: 10px 10px; border-radius: 7px;
  font-size: 13.5px; font-weight: 500; color: #c6d0de; cursor: pointer;
  user-select: none; transition: background .15s, color .15s;
}
.side-group:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-group .sg-ico { width: 17px; text-align: center; opacity: .85; font-size: 13px; }
.side-group .sg-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-group .sg-count {
  min-width: 18px; padding: 0 5px; height: 16px; line-height: 16px; text-align: center;
  font-size: 10.5px; border-radius: 8px; background: rgba(255,255,255,.1); color: #9fb0c6;
}
.side-group .sg-arrow { font-size: 13px; color: #7c8ba1; transition: transform .2s ease; transform: rotate(0deg); }
.side-group.open { color: #fff; }
.side-group.open .sg-arrow { transform: rotate(90deg); }
/* 「当前模块」的大类才有底色；只是展开不算选中 */
.side-group.current { background: var(--side-active-soft, rgba(47,126,247,.18)); color: #fff; }
.side-group.current .sg-count { background: rgba(255,255,255,.16); color: #e6edf7; }
/* 二级菜单容器：默认收起 */
.side-sub { max-height: 0; overflow: hidden; transition: max-height .22s ease; }
.side-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 34px; cursor: pointer;
  font-size: 13px; color: #aebbcb; border-left: 3px solid transparent; white-space: nowrap;
}
/* 二级分组标题（财务管理 → 资金往来 / 会计核算 …）：比子项更暗更小，只作分隔 */
.side-sub-title {
  padding: 8px 14px 4px 30px; font-size: 11px; letter-spacing: .5px;
  color: #6b7a90; text-transform: none; user-select: none;
}
.side-sub-title:not(:first-child) { margin-top: 4px; border-top: 1px solid rgba(255,255,255,.06); padding-top: 8px; }
.side-item .dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .45; flex: none; }
.side-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-item.active { background: var(--side-active-soft, rgba(47,126,247,.18)); color: #fff; border-left-color: var(--side-active); }
.side-item.active .dot { opacity: 1; background: var(--side-active); }
.side-foot {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: #7c8ba1;
}
.side-foot-links { display: flex; gap: 14px; margin-top: 6px; }
.side-foot-links a { color: #9fb0c4; text-decoration: none; cursor: pointer; }
.side-foot-links a:hover { color: #fff; }
.side-foot-links a.danger:hover { color: #ff9c9c; }

.main { flex: 1; margin-left: 216px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { font-size: 15px; font-weight: 600; }
.topbar .crumb small { font-weight: 400; color: var(--text-3); font-size: 12px; margin-left: 8px; }
.topbar .spacer { flex: 1; }
.topbar .search {
  width: 260px; height: 32px; border: 1px solid var(--border); border-radius: 16px;
  padding: 0 12px; font-size: 13px; outline: none; background: #fafbfc;
}
.topbar .search:focus { border-color: var(--brand); background: #fff; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: transparent;
  cursor: pointer; color: var(--text-2); font-size: 16px; position: relative;
}
.icon-btn:hover { background: var(--border-2); }
.badge-dot {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; text-align: center; padding: 0 4px;
}
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 18px; }
.user-chip:hover { background: var(--border-2); }
.user-chip .uc-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip .uc-name { font-size: 13px; color: var(--text); }
.user-chip .uc-role { font-size: 11px; color: var(--text-3); }
.user-chip .uc-caret { font-size: 10px; color: var(--text-3); margin-left: 2px; }

/* 账号下拉菜单 */
.user-wrap { position: relative; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 198px; z-index: 60;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(16,24,40,.14); padding: 6px; display: none;
}
.user-menu.show { display: block; }
.user-menu .um-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border-2); margin-bottom: 6px; }
.user-menu .um-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-menu .um-sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.user-menu .um-item { padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.user-menu .um-item:hover { background: var(--border-2); color: var(--text); }
.user-menu .um-item.danger { color: var(--danger); }
.user-menu .um-item.danger:hover { background: var(--danger-soft); color: var(--danger); }
.user-menu .um-sep { height: 1px; background: var(--border-2); margin: 6px 4px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
/* ------------------------------------------------- 多页面标签工作区 */
/* 电脑端把每个业务页面开成一个标签：切页不重画，筛选与滚动位置都留着。
   手机 / 窄屏空间不够，标签栏自动隐藏（由 tabsEnabled() 控制）。 */
.content { padding: 0; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tabhost { flex: 1; min-height: 0; overflow: auto; padding: 16px 20px 40px; }
.tabview { display: none; }
.tabview.active { display: block; }
.tabview > .loading { margin: 40px 0; }

.tabbar {
  display: none; align-items: center; gap: 6px;
  padding: 6px 14px 0; background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden; flex: none;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { height: 0; }
.tabbar.show { display: flex; }

.tab {
  display: flex; align-items: center; gap: 6px; flex: none;
  height: 32px; padding: 0 10px; max-width: 180px;
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 7px 7px 0 0; background: #f7f8fa;
  color: var(--text-2); font-size: 13px; cursor: pointer;
  position: relative; top: 1px; user-select: none;
  transition: background .15s, color .15s;
}
.tab:hover { background: #eef1f5; color: var(--text); }
.tab.active {
  background: var(--panel); color: var(--brand); font-weight: 600;
  border-color: var(--border); box-shadow: 0 -2px 6px rgba(16, 24, 40, .04);
}
.tab.active::after {
  content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 2px;
  background: var(--brand); border-radius: 2px 2px 0 0;
}
.tab.pinned { background: #f0f5ff; }
.tab.dragging { opacity: .45; }
.tab.over { border-color: var(--brand); }
.tab-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px;
}
.tab-pin { font-size: 10px; }
.tab-x {
  width: 16px; height: 16px; line-height: 15px; text-align: center; border-radius: 50%;
  color: var(--text-3); font-size: 14px; flex: none;
}
.tab-x:hover { background: var(--border); color: var(--text); }
.tab.active .tab-x:hover { background: var(--danger-soft); color: var(--danger); }

.tab-tools { margin-left: auto; display: flex; gap: 2px; padding-left: 8px; flex: none; }
.tab-tool {
  width: 26px; height: 26px; border: none; background: transparent; border-radius: 6px;
  color: var(--text-3); font-size: 14px; cursor: pointer;
}
.tab-tool:hover { background: var(--border-2); color: var(--text); }

.tab-menu {
  position: fixed; z-index: 200; min-width: 148px; padding: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.tab-menu-item {
  padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--text-2); cursor: pointer;
}
.tab-menu-item:hover { background: var(--border-2); color: var(--text); }
.tab-menu-item.disabled { color: var(--text-3); cursor: not-allowed; }
.tab-menu-item.disabled:hover { background: transparent; color: var(--text-3); }
.tab-menu-sep { height: 1px; background: var(--border-2); margin: 4px 2px; }

/* 窄屏 / 手机：退回单页面布局 */
@media (max-width: 820px) {
  .tabbar { display: none !important; }
  .tabhost { padding: 12px 12px calc(20px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------------------------------------------------------------- 组件 */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1280px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g6 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 900px) { .g2, .g3, .g4, .g6 { grid-template-columns: 1fr; } }

.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .label { color: var(--text-3); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 6px; letter-spacing: -.5px; }
.stat .value.up { color: var(--danger); }
.stat .value.down { color: var(--ok); }
.stat .sub { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.stat .bar { height: 4px; border-radius: 2px; background: var(--border-2); margin-top: 10px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--brand); }

.btn {
  height: 32px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer; font-size: 13px; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f5c6c7; }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ok { color: var(--ok); border-color: #bfe5cd; }
.btn.ok:hover { background: var(--ok-soft); border-color: var(--ok); }
.btn.sm { height: 26px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 38px; padding: 0 20px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.input, .select, .textarea {
  width: 100%; height: 32px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 10px; font-size: 13px; font-family: inherit; color: var(--text); background: #fff; outline: none;
}
.textarea { height: auto; min-height: 72px; padding: 8px 10px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(47,126,247,.12); }
.input:disabled, .select:disabled { background: #f5f6f8; color: var(--text-3); }
label.fl { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; }
label.fl .req { color: var(--danger); }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters .input, .filters .select { width: auto; min-width: 130px; }

/* ---------------------------------------------------------- 可检索下拉 */
/* 结构是「输入框 + 箭头 + 隐藏的原生 select 承载真实值」。
   菜单挂在 body 上固定定位，避免被弹窗/滚动容器的 overflow 裁掉。 */
.combo { position: relative; width: 100%; }
.combo .combo-in { padding-right: 26px; cursor: text; }
.combo.open .combo-in { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(47,126,247,.12); }
.combo-caret {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-3); pointer-events: none; transition: transform .15s;
}
.combo.open .combo-caret { transform: translateY(-50%) rotate(180deg); }
.combo-menu {
  position: fixed; z-index: 3000; overflow-y: auto; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15,23,42,.14); padding: 4px;
}
.combo-item {
  display: flex; align-items: baseline; gap: 8px; padding: 7px 10px;
  border-radius: 4px; font-size: 13px; color: var(--text); cursor: pointer;
}
.combo-item.on { background: #eaf2ff; color: #1a4fd6; }
.combo-item .combo-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-item .combo-kw { flex: 0 0 auto; font-size: 11.5px; color: var(--text-3); }
.combo-item.on .combo-kw { color: #4a7ae0; }
.combo-empty { padding: 10px; font-size: 12.5px; color: var(--text-3); text-align: center; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 10px 12px; background: #fafbfc; color: var(--text-2);
  font-weight: 600; font-size: 12.5px; border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl .center { text-align: center; }
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); }
.table-foot {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-top: 1px solid var(--border-2); font-size: 12.5px; color: var(--text-2);
}
.table-foot .spacer { flex: 1; }
.pager { display: flex; gap: 4px; align-items: center; }
.pager button {
  min-width: 28px; height: 28px; border: 1px solid var(--border); background: #fff;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px; color: var(--text-2);
}
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px;
  background: var(--border-2); color: var(--text-2); white-space: nowrap;
}
.tag.blue { background: var(--brand-soft); color: var(--brand); }
.tag.green { background: var(--ok-soft); color: var(--ok); }
.tag.orange { background: var(--warn-soft); color: #b26a00; }
.tag.red { background: var(--danger-soft); color: var(--danger); }
.tag.gray { background: #f1f2f4; color: var(--text-3); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs .tab {
  padding: 8px 16px; cursor: pointer; font-size: 13.5px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--brand); }
.tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.empty { padding: 48px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.empty .big { font-size: 34px; opacity: .35; margin-bottom: 8px; }

/* 弹窗 / 抽屉 */
.mask { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 100; display: flex; }
.mask.center { align-items: center; justify-content: center; }
.modal {
  background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg);
  width: 560px; max-width: calc(100vw - 40px); max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; animation: pop .16s ease-out;
}
.modal.wide { width: 880px; }
.modal.narrow { width: 420px; }
/* 附件预览：大窗 + 无内边距，PDF 交给浏览器内置阅读器渲染 */
.modal.viewer { width: 94vw; max-width: 1320px; height: 91vh; }
.modal.viewer .modal-body { padding: 0; display: flex; overflow: hidden; }
.viewer { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; }
.viewer-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  border-bottom: 1px solid var(--border-2); background: #fafbfc; flex: none;
}
.viewer-bar .vb-name { font-size: 13px; font-weight: 600; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .vb-meta { white-space: nowrap; }
.viewer-bar .spacer { flex: 1; }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; background: #525659; }
.viewer-frame { flex: 1; width: 100%; height: 100%; border: 0; background: #525659; }
.viewer-img { flex: 1; width: 100%; height: 100%; object-fit: contain; background: #1c1f24; }
.viewer-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  gap: 8px; color: #dfe4ea; font-size: 13px; background: #525659; z-index: 2;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border-2); font-size: 15px; font-weight: 600;
  display: flex; align-items: center;
}
.modal-head .spacer { flex: 1; }
.modal-head .x { cursor: pointer; color: var(--text-3); font-size: 18px; line-height: 1; }
.modal-head .x:hover { color: var(--text); }
.modal-body { padding: 18px; overflow: auto; flex: 1; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--border-2); display: flex; justify-content: flex-end; gap: 8px;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 620px; max-width: calc(100vw - 40px);
  background: #fff; box-shadow: var(--shadow-lg); z-index: 101; display: flex; flex-direction: column;
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 300; display: grid; gap: 8px; }
.toast {
  background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 10px 18px; font-size: 13.5px;
  animation: pop .16s ease-out; min-width: 200px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

/* 图表 */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

/* 时间线 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: var(--border); }
.timeline .item { position: relative; padding-bottom: 16px; }
.timeline .item::before {
  content: ''; position: absolute; left: -19px; top: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
}
.timeline .item .t { font-size: 12.5px; color: var(--text-3); }
.timeline .item .c { font-size: 13.5px; margin-top: 3px; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv .k { color: var(--text-3); }
.desc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.desc-item { border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.desc-item .k { font-size: 12px; color: var(--text-3); }
.desc-item .v { font-size: 14px; margin-top: 3px; }

.progress { height: 6px; background: var(--border-2); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); }
.progress.ok i { background: var(--ok); }
.progress.warn i { background: var(--warn); }

.loading { padding: 40px; text-align: center; color: var(--text-3); font-size: 13px; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.list-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-2); font-size: 13px; }
.list-item:last-child { border-bottom: none; }
.list-item .spacer { flex: 1; }
.list-item .tt { color: var(--text); }
.list-item .mm { color: var(--text-3); font-size: 12px; }

.section-title { font-size: 13px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ''; width: 3px; height: 13px; background: var(--brand); border-radius: 2px; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex .spacer { flex: 1; }

/* ============================================================
 * 财务报表（金蝶风格版式）
 * ============================================================ */
.rpt {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 26px 18px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.rpt-head { text-align: center; margin: 4px 0 14px; }
.rpt-title { font-size: 22px; font-weight: 700; letter-spacing: 8px; margin: 0 0 10px; color: var(--text-1); }
.rpt-sub { display: flex; justify-content: space-between; font-size: 12.5px; color: #475467; padding: 0 4px; }
.rpt-table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: #fff; }
.rpt-table th, .rpt-table td { border: 1px solid #d5dbe7; padding: 6px 9px; line-height: 1.5; }
.rpt-table thead th { background: #f3f6fb; font-weight: 600; color: #344054; text-align: center; white-space: nowrap; }
.rpt-table td.num, .rpt-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rpt-table .center { text-align: center; }
.rpt-table td.strong { font-weight: 700; }
.rpt-table tbody tr.rpt-total { background: #fafcff; }
.rpt-table tbody tr.rpt-total td { font-weight: 700; }
.rpt-table tbody tr.rpt-group td { background: #eef3fa; font-weight: 700; }
.rpt-table .line { color: #667085; width: 52px; }
.rpt-table .name.lv2 { padding-left: 26px; }
.rpt-table .name.lv3 { padding-left: 44px; }
.rpt-table tbody tr:hover { background: #f7fbff; }
.rpt-check {
  display: flex; gap: 28px; flex-wrap: wrap; align-items: center;
  margin-top: 12px; font-size: 12.5px; color: #475467;
}
.rpt-check b { color: #101828; font-variant-numeric: tabular-nums; }
.rpt-check .ok { color: #15803d; font-weight: 600; }
.rpt-check .bad { color: #b42318; font-weight: 600; }
.rpt-foot { display: flex; justify-content: space-between; margin-top: 14px; font-size: 11.5px; color: #98a2b3; }
.rpt-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.rpt-toolbar .spacer { flex: 1; }
table.table.vt td { vertical-align: middle; }

/* 期末结账检查清单 */
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-2); background: #fbfcfe;
}
.check-item .ico { width: 20px; text-align: center; font-weight: 700; }
.check-item .tt { font-weight: 500; }
.check-item .dd { margin-left: auto; font-size: 12px; }
.check-item.ok { border-color: #bbf7d0; background: #f6fef9; }
.check-item.ok .ico { color: #15803d; }
.check-item.bad { border-color: #fecdca; background: #fffbfa; }
.check-item.bad .ico { color: #b42318; }

/* 打印：只输出报表本体，隐藏导航与工具栏 */
@media print {
  .sidebar, .topbar, .page-head, .rpt-toolbar, .table-foot, .toast-wrap { display: none !important; }
  .app { display: block; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; }
  .tabhost { padding: 0 !important; }
  .rpt { border: 0; border-radius: 0; box-shadow: none; padding: 0; }
  .rpt-table th, .rpt-table td { border-color: #666; }
  body { background: #fff; }
}

/* ============================================================
 * 合同附件 / OCR / 付款条款 / 合同执行
 * ============================================================ */

/* 通用小尺寸按钮、提示条 */
.btn.xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 5px; }
.mb12 { margin-bottom: 12px; }
.text-danger { color: var(--danger); }
.alert { padding: 9px 12px; border-radius: 7px; font-size: 12.5px; line-height: 1.6; }
.alert.err { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecdca; }
.alert.warn { background: var(--warn-soft); color: #b26a00; border: 1px solid #fde3b0; }

/* 分段切换（执行中 / 已执行完毕） */
.seg { display: inline-flex; background: #f1f3f7; border-radius: 8px; padding: 3px; gap: 2px; }
.seg-btn {
  border: 0; background: transparent; padding: 6px 16px; border-radius: 6px;
  font-size: 13px; color: var(--text-2); cursor: pointer; font-family: inherit;
}
.seg-btn:hover { color: var(--brand); }
.seg-btn.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 3px rgba(16,24,40,.1); }
.exec-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; flex-wrap: wrap; }
.exec-head .spacer { flex: 1; }

/* 附件 */
.attach { border: 1px solid var(--border); border-radius: 9px; background: #fff; overflow: hidden; }
.attach-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px 0; }
.attach-bar .spacer { flex: 1; }
.attach-drop {
  margin: 10px; padding: 16px; border: 1.5px dashed #cbd3e1; border-radius: 8px;
  text-align: center; cursor: pointer; background: #fbfcfe; transition: .15s;
  font-size: 13px; color: var(--text-2); line-height: 1.7;
}
.attach-drop:hover, .attach-drop.over { border-color: var(--brand); background: #f5f9ff; }
.attach-drop .ad-ico { font-size: 20px; color: var(--brand); opacity: .8; margin-bottom: 2px; }
.attach-drop.busy { opacity: .7; pointer-events: none; }
.attach-tip { padding: 0 12px 8px; }
.attach-list { border-top: 1px solid var(--border-2); }
.attach-empty { padding: 18px; text-align: center; color: var(--text-3); font-size: 12.5px; }
.attach-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-bottom: 1px solid var(--border-2); font-size: 13px;
}
.attach-row:last-child { border-bottom: 0; }
.attach-row:hover { background: #fafbfd; }
.attach-main { min-width: 0; flex: 1; }
.attach-main .an { color: var(--text-1); text-decoration: none; display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-main .an:hover { color: var(--brand); text-decoration: underline; }
.attach-meta { margin-top: 2px; }
.attach-status { flex: none; }
.attach-row .aa { display: flex; gap: 6px; flex: none; }
.attach.compact .attach-drop { padding: 12px; }

/* OCR 结果 */
.ocr-text {
  max-height: 300px; overflow: auto; background: #fafbfd; border: 1px solid var(--border-2);
  border-radius: 7px; padding: 10px 12px; font-size: 12px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word; color: var(--text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ocr-badge { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ocr-stage { margin-top: 12px; }
.ocr-loading { padding: 18px; text-align: center; color: var(--text-2); font-size: 13px; }

/* 付款比例编辑器 */
.terms-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: #fbfcfe; }
.terms-head, .terms-row {
  display: grid; grid-template-columns: 1fr 100px 100px 34px; gap: 8px; align-items: center;
}
.terms-head { font-size: 11.5px; color: var(--text-3); padding: 0 2px 6px; }
.terms-row { margin-bottom: 6px; }
.terms-row .input { height: 30px; font-size: 12.5px; }
.terms-row .input.num { text-align: right; }
.terms-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.terms-foot .spacer { flex: 1; }
.terms-sum { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.terms-sum.ok { color: #15803d; }
.terms-sum.bad { color: var(--danger); }
.terms-bar { display: block; height: 4px; border-radius: 2px; background: var(--border-2); margin-top: 8px; overflow: hidden; }
.terms-bar i { display: block; height: 100%; width: 0; background: var(--danger); transition: width .2s; }
.terms-bar.ok i { background: #18a058; }

/* ---------------- 企业微信登录入口 ---------------- */
.wecom-sep { display: flex; align-items: center; gap: 10px; margin: 16px 0 12px; color: #98a2b3; font-size: 12px; }
.wecom-sep::before, .wecom-sep::after { content: ''; flex: 1; height: 1px; background: var(--border-2, #e7eaf0); }
.wecom-btn {
  width: 100%; height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #fff; color: #1a7f5a; border: 1px solid #cfe9de; font-weight: 600;
}
.wecom-btn:hover { background: #f2fbf7; border-color: #1a7f5a; }
.wecom-btn::before {
  content: ''; width: 16px; height: 16px; border-radius: 4px;
  background: #1a7f5a;
  -webkit-mask: radial-gradient(circle at 50% 50%, #000 40%, transparent 41%);
}
.wx-bound { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------- 手机端适配（企业微信工作台内打开） ---------------- */
.menu-btn { display: none; }
.side-mask { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }
  .sidebar {
    width: 240px; flex: 0 0 240px;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .side-mask {
    display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45);
    z-index: 29; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .side-mask.show { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0 !important; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .search { display: none; }
  .crumb { font-size: 13px; }
  .tbl-wrap, .table-wrap { overflow-x: auto; }
  .drawer, .modal { width: 96vw !important; max-width: 96vw !important; }
  .viewer { width: 96vw !important; height: 94vh !important; }
  .grid.g2, .grid.g3, .grid.g4, .grid.g6 { grid-template-columns: 1fr; }
  .desc-list { grid-template-columns: 1fr; }
}

/* ============================================================
 * 手机端增强适配（微信 / 企业微信内置浏览器直接打开）
 * ------------------------------------------------------------
 * 本节全部为「追加」规则，不改动上方任何既有样式，只复用既有类名。
 * 依赖 main.js 启动时给 <html> 打上的 is-mobile / is-wechat / is-wxwork。
 * ============================================================ */

/* ------------------------------ 全局 ------------------------------ */
html {
  /* 禁止 iOS 横屏时自动放大字号 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  /* 禁止整页橡皮筋，避免下拉时带动整个页面（微信里尤其明显） */
  overscroll-behavior-y: contain;
}
body { -webkit-tap-highlight-color: transparent; }
a, button, .btn, .tab, .side-item, .side-group { touch-action: manipulation; }

/* 微信 / 企业微信内置浏览器：底部留出安全区 + 缓冲，避免被工具栏或 Home 指示条压住 */
html.is-wechat body,
html.is-wxwork body { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }

/* 移动端：横向滚动容器各自消化滚动，不要把整页带着走（防误触发侧滑返回） */
html.is-mobile .table-wrap,
html.is-mobile .tbl-wrap,
html.is-mobile .tabs,
html.is-mobile .filter-bar { overscroll-behavior-x: contain; }

/* --------------------------- ≤820px 主体 --------------------------- */
@media (max-width: 820px) {
  /* ---- 布局 ---- */
  .app { min-height: 100vh; min-height: 100dvh; }
  .content { padding: 0; }
  .tabhost { padding: 12px 12px calc(20px + env(safe-area-inset-bottom, 0px)); }
  .card { margin-bottom: 12px; border-radius: 10px; }
  .card-head { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .card-body { padding: 12px; }

  /* ---- 卡头筛选区：搜索框 / 下拉自适应宽度，按钮不缩 ---- */
  .card-head .input,
  .card-head .select {
    width: auto !important; min-width: 100px; flex: 1 1 140px;
    height: 40px; font-size: 16px;
  }
  .card-head .btn { flex: none; }
  .card-head h3 { font-size: 14px; }
  .filters { gap: 8px; }
  .filters .input, .filters .select { width: auto; min-width: 100px; flex: 1 1 140px; }
  /* 筛选条：整体横向滚动，不撑破卡片 */
  .filter-bar {
    display: flex; align-items: center; gap: 8px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .filter-bar > * { flex: none; }
  .filter-bar::-webkit-scrollbar { display: none; }

  /* ---- 表格：横向滚动 + 首列（单号 / 名称）冻结 ---- */
  .table-wrap, .tbl-wrap {
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    max-height: calc(100vh - 210px);
    max-height: calc(100dvh - 210px);
  }
  /* 让表格能被内容撑开，从而产生横向滚动，而不是把列挤变形 */
  .table-wrap .tbl, .tbl-wrap .tbl { width: auto; min-width: 100%; }
  .table-wrap .tbl th, .table-wrap .tbl td,
  .tbl-wrap .tbl th, .tbl-wrap .tbl td { padding: 10px; }
  .table-wrap .tbl thead th:first-child,
  .table-wrap .tbl tbody td:first-child,
  .tbl-wrap .tbl thead th:first-child,
  .tbl-wrap .tbl tbody td:first-child {
    position: sticky; left: 0; z-index: 2;
    background: var(--panel);
    /* border-collapse 下 sticky 单元格边框会丢，用阴影补一条分隔线 */
    box-shadow: inset -1px 0 0 var(--border);
  }
  .table-wrap .tbl thead th:first-child,
  .tbl-wrap .tbl thead th:first-child { z-index: 3; background: #fafbfc; }
  .table-wrap .tbl tbody tr:hover td:first-child,
  .tbl-wrap .tbl tbody tr:hover td:first-child { background: #f8fafc; }

  /* ---- 表单：全部单列，字号 ≥16px 防 iOS 聚焦自动放大 ---- */
  .form-grid, .grid { grid-template-columns: 1fr; }
  .form-grid { gap: 12px; }
  .input, .select, .textarea {
    font-size: 16px !important;   /* < 16px 时 iOS 聚焦会整页放大 */
    height: 40px;
  }
  .textarea { height: auto; min-height: 88px; line-height: 1.6; }
  label.fl { display: block; margin-bottom: 6px; font-size: 13.5px; }
  /* 付款比例编辑器：窄屏收紧列宽，否则 4 列会撑破卡片 */
  .terms-head, .terms-row { grid-template-columns: 1fr 72px 72px 30px; gap: 6px; }
  .terms-row .input { height: 38px; font-size: 16px; }

  /* ---- 按钮：手指可点 ---- */
  .btn { min-height: 40px; padding: 0 16px; font-size: 14px; }
  .btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
  .btn.xs { min-height: 30px; padding: 0 10px; }
  .btn.lg { min-height: 44px; padding: 0 20px; }
  .btn-group { gap: 8px; }

  /* ---- 行操作按钮：竖排换行，不再挤成一条 ---- */
  .tbl tbody td.right.nowrap,
  .row-actions {
    white-space: normal;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
    gap: 6px;
  }
  .tbl tbody td.right.nowrap .btn,
  .row-actions .btn { margin-left: 0 !important; margin-right: 0 !important; }

  /* ---- 顶部栏：标题省略号 + 搜索框独占一行（右侧仅 通知 / 账号 两个图标） ---- */
  .topbar {
    height: auto; min-height: 52px;
    flex-wrap: wrap; row-gap: 4px;
    padding: 6px 12px;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
  }
  .topbar .crumb {
    flex: 1 1 auto; min-width: 0; font-size: 15px;
    display: flex; align-items: baseline; gap: 6px;
    overflow: hidden; white-space: nowrap;
  }
  .topbar .crumb > span:first-child {
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .topbar .crumb small { display: none; }
  .topbar .spacer { display: none; }
  .topbar .search {
    display: block; flex: 1 0 100%; order: 10;
    width: 100% !important; height: 38px; font-size: 16px;
    border-radius: 19px; padding: 0 14px;
  }
  .topbar .icon-btn { width: 38px; height: 38px; font-size: 18px; flex: none; }
  .topbar .user-chip { padding: 2px 6px; flex: none; }
  .topbar .user-chip .uc-role { display: none; }

  /* ---- 统计卡 / 网格：小指标两列，图表类单列 ---- */
  .grid.g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { gap: 12px; }
  .stat { padding: 12px 14px; }
  .stat .value { font-size: 21px; }
  .stat .sub { font-size: 11.5px; }
  .desc-list { gap: 10px; }
  .kv { grid-template-columns: 88px 1fr; }

  /* ---- 弹窗：96vw / 92vh，内部滚动，按钮吸底且避开安全区 ---- */
  .modal {
    width: 96vw !important; max-width: 96vw !important;
    max-height: 92vh;
    max-height: 92dvh;
  }
  .modal.narrow, .modal.wide { width: 96vw !important; max-width: 96vw !important; }
  .modal-head { padding: 12px 14px; font-size: 15px; }
  .modal-head .x { font-size: 22px; padding: 0 2px; }
  .modal-body {
    padding: 14px;
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  }
  .modal-foot {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    flex-wrap: wrap; gap: 8px;
  }
  .modal-foot .btn { flex: 1 1 96px; justify-content: center; }

  /* ---- 抽屉：全屏化 ---- */
  .drawer {
    width: 100vw !important; max-width: 100vw !important;
    height: 100vh; height: 100dvh;
  }

  /* ---- 页签：横向滚动 ---- */
  .tabs {
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { padding: 10px 14px; white-space: nowrap; }

  /* ---- 分页 / 表尾：按钮加大 ---- */
  .table-foot { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .pager { flex-wrap: wrap; }
  .pager button { min-width: 40px; height: 40px; font-size: 14px; }

  /* ---- 侧栏：底部避开 Home 指示条 ---- */
  .side-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

  /* ---- 其它 ---- */
  .login-wrap { padding: 12px; }
  .login-form { padding: 24px 20px; }
  .empty { padding: 32px 12px; }
  .toast-wrap { top: 10px; width: 92vw; max-width: 92vw; }
  .toast { min-width: 0; font-size: 13px; }
  .attach-drop { padding: 14px 10px; }
  .attach-row { flex-wrap: wrap; }
  .attach-row .aa { flex-wrap: wrap; }
  .ocr-text { max-height: 200px; }
  .viewer-bar .vb-name { max-width: 50%; }

  /* ---- 财务报表：版式收紧 + 横向滚动 ---- */
  .rpt { padding: 12px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rpt-table { width: auto; min-width: 100%; }
  .rpt-title { font-size: 18px; letter-spacing: 4px; }
  .rpt-toolbar { gap: 6px; }
}

/* --------------------------- ≤480px 收紧 --------------------------- */
@media (max-width: 480px) {
  .content { padding: 0; }
  .tabhost { padding: 10px 10px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .card { margin-bottom: 10px; border-radius: 8px; }
  .card-head { padding: 8px 10px; row-gap: 6px; }
  .card-body { padding: 10px; }
  .grid { gap: 10px; }

  .table-wrap .tbl th, .table-wrap .tbl td,
  .tbl-wrap .tbl th, .tbl-wrap .tbl td { padding: 8px 9px; font-size: 12.5px; }

  /* 数值不换行，避免金额被折断成两行 */
  .stat { padding: 10px 12px; }
  .stat .value { font-size: 19px; white-space: nowrap; }
  .stat .label { font-size: 12px; }

  .btn { min-height: 38px; padding: 0 12px; font-size: 13.5px; }
  .btn.sm { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
  .input, .select { height: 38px; }
  .textarea { min-height: 76px; }

  .modal-head { padding: 10px 12px; font-size: 14.5px; }
  .modal-body { padding: 12px; }
  .modal-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .desc-item { padding: 8px 10px; }
  .tabs .tab { padding: 9px 12px; font-size: 13px; }
  .pager button { min-width: 36px; height: 38px; }
  .login-form { padding: 20px 16px; }
  .login-form h2 { font-size: 18px; }
}

/* ------------------- 横屏（手机横过来时压缩纵向占用） ------------------- */
@media (max-height: 480px) and (orientation: landscape) {
  .topbar {
    min-height: 44px; height: auto;
    padding: 4px 10px; row-gap: 2px;
    padding-top: calc(4px + env(safe-area-inset-top, 0px));
  }
  .topbar .crumb { font-size: 14px; }
  .topbar .search { height: 32px; font-size: 16px; }
  .topbar .icon-btn { width: 32px; height: 32px; font-size: 16px; }
  .content { padding: 0; }
  .tabhost { padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .card { margin-bottom: 8px; }
  .card-head { padding: 6px 10px; row-gap: 4px; }
  .card-body { padding: 8px 10px; }
  .card-head .input, .card-head .select { height: 34px; }
  .table-wrap, .tbl-wrap { max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); }
  .modal { max-height: 88vh; max-height: 88dvh; }
  .modal-head { padding: 8px 12px; }
  .modal-body { padding: 10px 12px; }
  .modal-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .tabs { margin-bottom: 8px; }
  .tabs .tab { padding: 8px 12px; }
  .empty { padding: 20px 12px; }
  .rpt { padding: 10px; }
}

/* ------------------------------------------------------------
   审批人分级选择：多选下拉（select[multiple]）
   ------------------------------------------------------------ */
.select.multi {
  height: auto;
  min-height: 92px;
  padding: 6px 8px;
  line-height: 1.7;
  background-image: none;
}
.select.multi option { padding: 3px 6px; border-radius: 4px; }
.select.multi option:checked { background: #e8f1ff linear-gradient(0deg, #e8f1ff, #e8f1ff); color: #1a4fd6; font-weight: 600; }
.text-danger { color: #d4380d; }

/* ------------------------------------------------------------
   合同产品明细 / 采购-销售合同关联 / 财务体检
   ------------------------------------------------------------ */
.link-picker {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfcfe;
}
.link-list {
  max-height: 240px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-top: 1px solid var(--border-2);
  padding-top: 6px;
}
.link-item {
  display: grid;
  grid-template-columns: 18px 132px 1fr 150px 110px 96px;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.link-item:hover { background: #f1f4f9; }
.link-item.on { background: var(--brand-soft); }
.link-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.health-list { display: flex; flex-direction: column; gap: 8px; }
.health-item {
  border-left: 3px solid var(--border);
  background: #fafbfd;
  padding: 7px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.health-item.error { border-color: var(--danger); background: var(--danger-soft); }
.health-item.warn { border-color: var(--warn); background: var(--warn-soft); }
.health-item.info { border-color: var(--brand); background: var(--brand-soft); }
.health-title { font-weight: 600; font-size: 13px; }

@media (max-width: 820px) {
  .link-item { grid-template-columns: 18px 1fr 84px; }
  .link-item .small.muted:nth-of-type(2),
  .link-item .small.muted:nth-of-type(3) { display: none; }
}

/* ============================================================
 * 单据打印（销售订单 / 报价单）
 *   #/print/so/:id、#/print/quote/:id
 * ============================================================ */

/* 打印模式下把应用外壳收起来，让纸张独占屏幕 */
body.print-mode .sidebar,
body.print-mode .topbar,
body.print-mode .side-mask { display: none !important; }
body.print-mode .main { margin-left: 0 !important; }
body.print-mode .content { padding: 0 !important; background: #eef1f5; }
body.print-mode .tabhost { padding: 0 !important; }

.print-wrap { padding: 18px 12px 40px; display: flex; flex-direction: column; align-items: center; }
.print-toolbar {
  width: 210mm; max-width: 100%; display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding: 10px 12px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 1px 3px rgba(16,24,40,.06); flex-wrap: wrap;
}
.print-toolbar .spacer { flex: 1; }

/* A4 纸：210 × 297mm，装订边距 14mm */
.print-doc {
  width: 210mm; min-height: 297mm; box-sizing: border-box;
  background: #fff; padding: 14mm 14mm 12mm;
  box-shadow: 0 6px 24px rgba(16,24,40,.12); border-radius: 2px;
  color: #1f2329; font-size: 12.5px; line-height: 1.6;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
}

/* 抬头 */
.doc-head { position: relative; border-bottom: 2px solid #1f2329; padding-bottom: 10px; margin-bottom: 12px; }
.doc-company { display: flex; gap: 10px; align-items: flex-start; }
.doc-logo {
  width: 38px; height: 38px; border-radius: 8px; background: #1f6feb; color: #fff;
  font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.doc-logo-img { height: 46px; width: auto; max-width: 170px; object-fit: contain; flex: 0 0 auto; }
.doc-stamp { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px; }
/* 发货专用章：公司提供的椭圆章图片——下移避开「发货单位」文字，右移盖在空白区 */
.doc-seal-img { width: 132px; height: auto; object-fit: contain; opacity: .96; transform: rotate(-3deg); margin: 3px 0 0 30px; }
.doc-stamp-label { font-size: 11.5px; font-weight: 600; }
@media print { .doc-seal-img { opacity: 1; } }
.doc-cname { font-size: 15px; font-weight: 700; letter-spacing: .5px; }
.doc-cmeta { font-size: 11px; color: #5a6472; line-height: 1.5; }
.doc-title {
  text-align: center; font-size: 24px; font-weight: 700; letter-spacing: 8px;
  margin: 10px 0 4px; color: #1f2329;
}
.doc-no { text-align: center; font-size: 11.5px; color: #5a6472; font-family: Consolas, Menlo, monospace; }

/* 抬头信息表 */
.doc-info { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.doc-info th, .doc-info td {
  border: 1px solid #b9bfc9; padding: 5px 8px; font-size: 11.5px; vertical-align: middle;
}
.doc-info th { background: #f4f6f9; font-weight: 600; white-space: nowrap; width: 68px; color: #3a4351; }
.doc-info td { min-width: 90px; }

/* 明细表 */
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th, .doc-table td { border: 1px solid #b9bfc9; padding: 5px 6px; font-size: 11.5px; }
.doc-table thead th { background: #f4f6f9; font-weight: 600; text-align: center; color: #3a4351; }
.doc-table .c { text-align: center; }
.doc-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.doc-table tbody tr:nth-child(even) td { background: #fbfcfe; }
.doc-table tfoot td { background: #f7f9fc; font-weight: 600; }
.doc-table .muted { color: #8a94a6; font-weight: 400; }

/* 合计 / 备注 / 签章 */
.doc-upper {
  margin-top: 10px; padding: 7px 10px; background: #f7f9fc; border: 1px solid #d7dce4;
  border-radius: 4px; font-size: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.doc-upper .doc-balance { margin-left: auto; color: #b42318; font-weight: 600; }
.doc-notes { margin-top: 10px; font-size: 11px; line-height: 1.75; color: #3a4351; }
.doc-sign {
  margin-top: 26px; display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 10px 18px; font-size: 11.5px;
}
.doc-sign > div { display: flex; align-items: baseline; gap: 4px; }
.doc-sign i { flex: 1; border-bottom: 1px solid #8a94a6; min-width: 50px; height: 16px; font-style: normal; }

/* 对外单据结尾落款：公司全称 + 日期（采购订单等） */
.doc-signoff {
  margin-top: 34px; text-align: right; padding-right: 34px;
  font-size: 14px; font-weight: 600; letter-spacing: 1px;
}
.doc-signoff-date { font-weight: 400; font-size: 11.5px; color: #555; margin-top: 4px; }

/* ------------------------------------------------------------
 * 单据水印：公司名称 + 打印人（+ 时间）
 *
 * 用真实 DOM 文字铺满，不用 background-image —— 浏览器打印默认不输出背景图，
 * 背景图水印上了纸就整片消失。文字节点屏幕与纸面表现一致。
 * 打印时略微加深一点：屏幕上看得清就行，纸上要能压得住复印和拍照。
 * ------------------------------------------------------------ */
.doc-watermark {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  z-index: 5; opacity: .11;
}
.doc-watermark .wm-cell {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  white-space: nowrap; line-height: 1.25; user-select: none;
  transform: rotate(-28deg); transform-origin: center;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}
.doc-watermark .wm-main { font-size: 15px; font-weight: 700; color: #1f2329; letter-spacing: 1px; }
.doc-watermark .wm-sub { font-size: 10px; color: #1f2329; opacity: .85; font-variant-numeric: tabular-nums; }

/* 打印输出：只留纸张，去掉工具栏、阴影与背景 */
@media print {
  @page { size: A4 portrait; margin: 0; }
  body.print-mode { background: #fff !important; }
  body.print-mode .print-toolbar { display: none !important; }
  body.print-mode .print-wrap { padding: 0 !important; }
  body.print-mode .print-doc {
    width: auto; min-height: auto; box-shadow: none; border-radius: 0; padding: 12mm 12mm 10mm;
  }
  body.print-mode .content { background: #fff !important; }
  .doc-table thead { display: table-header-group; }
  .doc-table tr { page-break-inside: avoid; }
  .doc-sign { page-break-inside: avoid; }
  /* 水印上纸：加深并强制输出颜色，否则部分浏览器会把它当背景淡色丢掉 */
  .doc-watermark { opacity: .16; }
  .doc-watermark .wm-main, .doc-watermark .wm-sub {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}

/* ============================================================
 * 档案共享（客户 / 供应商）
 * ============================================================ */
.share-current { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.share-picker {
  margin-top: 8px; max-height: 260px; overflow: auto;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px; padding: 6px;
}
.share-person {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px;
  cursor: pointer; font-size: 13px; border: 1px solid transparent;
}
.share-person:hover { background: #f5f8ff; }
.share-person.on { background: var(--brand-soft); border-color: #c7ddff; }
.share-person input { width: 14px; height: 14px; }
.share-person .sp-name { font-weight: 500; }
.share-person .sp-dept { margin-left: auto; font-size: 11.5px; color: var(--text-3); }

/* 渠道总览：业务流程说明 */
.steps-vertical { display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; line-height: 1.6; }
.steps-vertical b { color: var(--primary, #1f6feb); margin-right: 6px; }

/* ---------- 工作汇报：汇报对象多选 + 标记 ---------- */
.pill {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 11px; line-height: 18px; white-space: nowrap;
}
.pp { border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #fff; }
.pp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 22px; align-items: center; }
.pp-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--brand-soft); color: var(--brand);
  border-radius: 12px; padding: 2px 8px; font-size: 12px;
}
.pp-chip .x { cursor: pointer; opacity: .6; font-size: 13px; }
.pp-chip .x:hover { opacity: 1; }
.pp-list { max-height: 228px; overflow: auto; margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 4px; }
.pp-group { margin-bottom: 4px; }
.pp-gt { font-size: 12px; color: var(--text-3); padding: 4px 2px; font-weight: 600; }
.pp-item { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.pp-item:hover { background: #f7f8fa; }
.pp-name { min-width: 60px; }
.pp-sub { color: var(--text-3); font-size: 12px; }

/* ---------- 报价专用章（矢量） ---------- */
.doc-seal-box { margin: 2px 0 0 14px; transform: rotate(-4deg); line-height: 0; }
.doc-seal-box svg { width: 116px; height: 116px; display: block; }
.doc-seal-box.draft svg { opacity: .95; }
.doc-seal-tip { font-size: 9px; color: #b42318; margin-top: 2px; line-height: 1.4; }
@media print {
  .doc-seal-box svg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------------- 角色授权：最下级菜单权限树 ---------------- */
.perm-tip {
  font-size: 12px; color: var(--text-3); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; margin-bottom: 10px; line-height: 1.6;
}
.perm-mod {
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 10px; background: var(--panel); overflow: hidden;
}
.perm-mod-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.perm-mod-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.perm-group { padding: 6px 12px 2px; }
.perm-group-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-3); margin: 4px 0 2px; cursor: pointer;
}
.perm-group-title.ops { color: var(--brand); font-weight: 600; }
.perm-leaves { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 2px 0 6px; }
.perm-leaf {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; padding: 3px 8px; border-radius: 5px; cursor: pointer;
}
.perm-leaf:hover { background: var(--bg); }
.perm-leaf em { font-style: normal; font-size: 11px; }

/* ---------------------------------------------------------------- 主题（10 色） */
/* 每套主题只覆盖品牌色 + 侧边栏配色两组变量，全局 UI 自动跟随。
   默认经典蓝已写在 :root，这里不重复。 */
html[data-theme="indigo"] {
  --brand: #4f46e5; --brand-2: #6366f1; --brand-dark: #4338ca; --brand-soft: #eef2ff;
  --side-bg: #262a52; --side-bg-2: #1f2245; --side-text: #c5c8e6;
  --side-active: #818cf8; --side-active-soft: rgba(129,140,248,.22);
}
html[data-theme="emerald"] {
  --brand: #059669; --brand-2: #10b981; --brand-dark: #047857; --brand-soft: #e7f8f1;
  --side-bg: #1d3a33; --side-bg-2: #16302b; --side-text: #b8d2c9;
  --side-active: #34d399; --side-active-soft: rgba(52,211,153,.20);
}
html[data-theme="teal"] {
  --brand: #0d9488; --brand-2: #14b8a6; --brand-dark: #0f766e; --brand-soft: #e6f7f5;
  --side-bg: #1e3b3a; --side-bg-2: #17312f; --side-text: #b3cfcc;
  --side-active: #2dd4bf; --side-active-soft: rgba(45,212,191,.20);
}
html[data-theme="cyan"] {
  --brand: #0891b2; --brand-2: #06b6d4; --brand-dark: #0e7490; --brand-soft: #e6f7fb;
  --side-bg: #17333d; --side-bg-2: #122a33; --side-text: #b0c9d4;
  --side-active: #22d3ee; --side-active-soft: rgba(34,211,238,.20);
}
html[data-theme="amber"] {
  --brand: #d97706; --brand-2: #f59e0b; --brand-dark: #b45309; --brand-soft: #fef3e2;
  --side-bg: #3d2f16; --side-bg-2: #312612; --side-text: #d8c9a6;
  --side-active: #fbbf24; --side-active-soft: rgba(251,191,36,.20);
}
html[data-theme="red"] {
  --brand: #dc2626; --brand-2: #ef4444; --brand-dark: #b91c1c; --brand-soft: #feecec;
  --side-bg: #3c1f1f; --side-bg-2: #311818; --side-text: #d9bcbc;
  --side-active: #f87171; --side-active-soft: rgba(248,113,113,.20);
}
html[data-theme="purple"] {
  --brand: #7c3aed; --brand-2: #8b5cf6; --brand-dark: #6d28d9; --brand-soft: #f1ecfe;
  --side-bg: #2b2347; --side-bg-2: #231c3a; --side-text: #c7c0e0;
  --side-active: #a78bfa; --side-active-soft: rgba(167,139,250,.22);
}
html[data-theme="rose"] {
  --brand: #e11d48; --brand-2: #f43f5e; --brand-dark: #be123c; --brand-soft: #ffeef1;
  --side-bg: #3d2028; --side-bg-2: #321920; --side-text: #ddbcc5;
  --side-active: #fb7185; --side-active-soft: rgba(251,113,133,.20);
}
html[data-theme="slate"] {
  --brand: #475569; --brand-2: #64748b; --brand-dark: #334155; --brand-soft: #eef2f6;
  --side-bg: #1f2833; --side-bg-2: #181f28; --side-text: #b9c2cd;
  --side-active: #94a3b8; --side-active-soft: rgba(148,163,184,.22);
}

/* 主题选择器（账号下拉菜单里） */
.user-menu .um-label {
  padding: 8px 10px 2px; font-size: 11px; letter-spacing: .5px;
  color: var(--text-3); user-select: none;
}
.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; padding: 8px 10px 10px; }
.theme-dot {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer; display: block;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.10);
  transition: transform .12s ease;
}
.theme-dot:hover { transform: scale(1.15); }
.theme-dot.on { border-color: var(--text); }
