/* ============================================================
   进销存管理系统 · 设计系统 v2（2026-11-18 视觉升级）
   参考主流进销存 SaaS（管家婆云/金蝶云星辰）的清爽企业风：
   浅灰画布 + 白卡片 + 靛蓝主色 + 深蓝导航，圆角、细边、轻阴影。
   兼容 app.js 既有全部类名与打印/移动端行为。
   ============================================================ */

:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --border: #e6eaf2;
  --border-strong: #d8dee9;
  --text: #16213a;
  --muted: #5d6b84;
  --primary: #3b5bdb;
  --primary-dark: #2c46b8;
  --primary-soft: #edf1ff;
  --primary-ring: rgba(59, 91, 219, .14);
  --success: #0e7a4f;
  --success-soft: #e7f6ef;
  --danger: #d64046;
  --danger-soft: #fdeeee;
  --warning: #996000;
  --warning-soft: #fdf3e1;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);
  --shadow: 0 1px 3px rgba(23, 32, 60, .07), 0 1px 2px rgba(23, 32, 60, .04);
  --shadow-md: 0 6px 18px rgba(23, 32, 60, .09);
  --shadow-lg: 0 20px 55px rgba(16, 25, 50, .2);
  --side-bg: linear-gradient(180deg, #1b2748 0%, #111a33 100%);
  --accent-grad: linear-gradient(135deg, #6d8bff, #3b5bdb);
  --font-num: "SF Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
::selection { background: rgba(59, 91, 219, .18); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9d2e0; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #aeb9cc; background-clip: content-box; }

/* ================= 布局 ================= */
.shell { display: flex; min-height: 100vh; }

/* ---------- 侧边栏（深蓝业务栏） ---------- */
.sidebar {
  width: 232px; background: var(--side-bg); border-right: 1px solid #0c1428;
  padding: 14px 12px 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  box-shadow: 1px 0 0 rgba(255, 255, 255, .05) inset;
}
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); background-clip: content-box; }
.brand {
  font-weight: 700; font-size: 17px; padding: 6px 10px 18px; color: #fff;
  display: flex; align-items: center; gap: 10px; letter-spacing: .5px;
}
.brand::before {
  content: ""; width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: var(--accent-grad);
  box-shadow: 0 3px 10px rgba(59, 91, 219, .55);
}
.nav-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: var(--radius-sm); color: #bcc6da;
  margin-bottom: 2px; font-size: 13.5px; transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(59, 91, 219, .95), rgba(59, 91, 219, .62));
  color: #fff; font-weight: 600;
  box-shadow: 0 3px 10px rgba(59, 91, 219, .4);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: #8fb0ff;
}

/* 可折叠分组标题（业务/财务/基础资料…）——带手感和键盘可达性 */
.nav-group {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; font-weight: 600;
  font-size: 11.5px; letter-spacing: .12em; padding: 15px 12px 7px; color: #7f8cab;
  border-radius: var(--radius-sm); transition: background .15s, color .15s;
}
.nav-group:hover { color: #c9d3e8; background: rgba(255, 255, 255, .04); }
.nav-group:focus-visible { outline: 2px solid #8fb0ff; outline-offset: 1px; }
.nav-group .caret {
  font-size: 10px; color: #7f8cab; transition: transform .18s ease, color .15s;
  transform-origin: center;
}
.nav-group:hover .caret { color: #c9d3e8; }
.nav-group.collapsed .caret { transform: rotate(-90deg); }

/* ---------- 顶栏 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 58px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; padding: 9px 22px; gap: 12px;
}
.topbar > div:first-child { font-size: 15px; font-weight: 650; color: var(--text); letter-spacing: -.1px; }
.topbar > div:last-child {
  display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px;
  background: #f6f8fc; border: 1px solid var(--border);
  padding: 4px 6px 4px 14px; border-radius: 999px;
}
.content { padding: 22px; flex: 1; }
.bottomnav { display: none; }

/* 移动端抽屉菜单（窄屏用汉堡按钮唤出完整导航） */
.menu-btn { display: none; }
.drawer-mask { display: none; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card > h2:first-child, .card > .row-between:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.kpi-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* KPI 卡片 */
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent-grad);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #dbe3ff; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value {
  font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px;
  font-variant-numeric: tabular-nums;
}
.kpi.danger::before { background: linear-gradient(180deg, #f2726f, #d64046); }
.kpi.danger .value { color: var(--danger); }
.kpi.warning::before { background: linear-gradient(180deg, #f5c25b, #e08c00); }
.kpi.warning .value { color: #a86a00; }

/* 标题层级 */
h2 { font-size: 18px; margin: 0 0 14px; font-weight: 700; letter-spacing: -.2px; }
h3 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn {
  background: var(--primary); color: #fff; border: 1px solid transparent;
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  transition: background .15s, box-shadow .15s, transform .08s, border-color .15s, color .15s;
}
.btn:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(59, 91, 219, .32); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #fff; color: var(--primary); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--primary-soft); border-color: var(--primary); box-shadow: none; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #c0353b; box-shadow: 0 4px 12px rgba(214, 64, 70, .3); }
.btn.sm { padding: 5px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 550; }
input, select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; background: #fff; color: var(--text); font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover, textarea:hover { border-color: #bcc7d8; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px var(--primary-ring);
}
input[type="checkbox"] { width: auto; accent-color: var(--primary); cursor: pointer; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237987a0' d='M6 8.2 2.4 4.6l.9-.9L6 6.4l2.7-2.7.9.9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select:hover { background-color: #fbfcfe; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin-bottom: 0; min-width: 140px; }
/* 单据下方的收款/付款选择区 */
.doc-pay {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 14px 0 4px;
  padding: 13px 15px; background: linear-gradient(180deg, #fafbff, #f4f6fc);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.doc-pay .field { margin-bottom: 0; min-width: 140px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th {
  color: var(--muted); font-weight: 600; font-size: 12.5px;
  background: #f7f9fd; border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }
tbody tr { transition: background .12s; }
tbody tr:nth-child(even) { background: #fbfcfe; }
tbody tr:hover { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-sm); }
tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius-sm); }
.clickable tbody tr { cursor: pointer; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num, th.num { text-align: right; }

.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--primary-soft); color: var(--primary);
}
.tag.low { background: var(--danger-soft); color: var(--danger); }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 22, 45, .52); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
  animation: fadeIn .16s ease;
}
.modal-mask.submodal { z-index: 70; }   /* 子弹窗（就地加下级类别）叠在普通弹窗之上 */
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; padding: 22px; box-shadow: var(--shadow-lg);
  animation: popIn .18s cubic-bezier(.2, .9, .3, 1.15);
}
.modal h3 { margin-top: 0; font-size: 16px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98) } to { opacity: 1; transform: none } }
.lines { margin: 10px 0; }
.line-row { display: grid; grid-template-columns: 1fr 80px 90px 36px; gap: 6px; margin-bottom: 6px; align-items: center; }
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #1b2440; color: #fff; padding: 11px 18px; border-radius: 12px;
  z-index: 99; font-size: 13.5px; box-shadow: var(--shadow-lg);
  animation: toastIn .2s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px) } to { opacity: 1; transform: translate(-50%, 0) } }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background:
    radial-gradient(1100px 520px at 50% -12%, #4b6ae0 0%, transparent 58%),
    linear-gradient(160deg, #eef2fb 0%, #e4eaf6 45%, #f3f5fa 100%);
}
.login-card {
  width: 100%; max-width: 376px; padding: 32px 30px; border: 1px solid #fff;
  box-shadow: 0 22px 60px rgba(23, 40, 92, .2); border-radius: 18px;
}
.login-card h2 {
  text-align: center; font-size: 21px; margin-bottom: 22px; color: var(--text);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.login-card h2::before {
  content: ""; width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: var(--accent-grad);
  box-shadow: 0 4px 14px rgba(59, 91, 219, .45);
}
.login-card .btn { width: 100%; padding: 10px; font-size: 15px; margin-top: 6px; }

/* 开单明细表格 */
.doc-table { margin: 10px 0; }
.doc-table input.num { width: 90px; text-align: right; }
.doc-table td .muted { color: var(--muted); }
.click-cell { cursor: pointer; color: var(--primary); text-decoration: none; font-weight: 500; border-bottom: 1px dashed var(--primary); }
.click-cell:hover { color: var(--primary-dark); }

/* 权限勾选网格 */
.perm-grid { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.perm-grid label { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }

/* 三级类别选择器与列表 */
.cat-cascade { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-cascade select { flex: 1; min-width: 90px; }
.cat-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.cat-node { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; background: #fbfcff; }
.cat-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-child { margin: 6px 0 0 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.muted { color: var(--muted); font-size: 12px; }

/* 商品检索下拉框（拼音/简拼） */
.combo { position: relative; }
.combo-in { width: 100%; }
.combo-pop {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60;
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto;
  animation: fadeIn .12s ease;
}
.combo-item { padding: 8px 12px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); }
.combo-item:last-child { border-bottom: none; }
.combo-item:hover { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- 移动端 ---------- */
@media (max-width: 800px) {
  /* 侧栏改为抽屉：不再隐藏，点汉堡按钮滑出完整菜单（28+ 页面在手机上可达） */
  .sidebar {
    display: block; position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease; height: 100vh;
    box-shadow: 2px 0 18px rgba(15, 22, 45, .3);
  }
  .sidebar.open { transform: translateX(0); }
  .drawer-mask.open {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(15, 22, 45, .48);
  }
  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px;
    background: #fff; font-size: 16px; cursor: pointer;
  }
  .shell { flex-direction: column; }
  .main { padding-bottom: 64px; width: 100%; }
  /* 宽表格横向滚动，避免手机上表格被压扁看不清 */
  .content .card { overflow-x: auto; }
  .content table { min-width: 520px; }
  .content table.doc-table { min-width: 0; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
    border-top: 1px solid var(--border); z-index: 40;
    box-shadow: 0 -2px 14px rgba(15, 22, 45, .08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a {
    flex: 1; text-align: center; padding: 9px 2px; font-size: 12px; color: var(--muted);
    transition: color .15s;
  }
  .bottomnav a.active { color: var(--primary); font-weight: 600; }
  .content { padding: 12px; }
  .kpi .value { font-size: 19px; }
  .topbar { padding: 8px 14px; }
  .card { padding: 14px; border-radius: 12px; }
}

/* 可折叠(手风琴)导航的展开/收起动画基线（展开高度由内容撑开，收起仅隐藏菜单项） */

/* 工具栏（导出/打印） */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

/* 打印：仅打印内容区，隐藏导航与工具栏按钮 */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .bottomnav, .no-print, .toolbar, .nav-group { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  table { font-size: 12px; }
  th, td { border-bottom: 1px solid #ddd; }
  th { position: static; }
}
/* 仅打印单据区域（保存后“是否打印”） */
body.printing-doc * { visibility: hidden; }
body.printing-doc #print_doc, body.printing-doc #print_doc * { visibility: visible; }
body.printing-doc #print_doc {
  position: fixed; left: 0; top: 0; width: 100%; z-index: 999;
  background: #fff; padding: 12px; box-shadow: none;
}

/* 标签页（期初初始化） */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 10px 0 14px; flex-wrap: wrap; }
.tabs a {
  padding: 8px 15px; border-radius: var(--radius-sm) var(--radius-sm) 0 0; color: var(--muted);
  cursor: pointer; font-size: 14px; transition: background .15s, color .15s;
}
.tabs a:hover { background: var(--primary-soft); color: var(--primary); }
.tabs a.active { color: var(--primary); border-bottom: 2px solid var(--primary); font-weight: 600; }

/* 徽标 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }

/* 角色权限管理 */
.role-card { margin-bottom: 14px; }
.role-perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; }
.perm-group { margin-bottom: 6px; }
.perm-group-title { font-weight: 600; color: var(--muted); font-size: 12px; margin: 6px 0 2px; }

/* 服务协同 / 工作台 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.kv {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px;
}
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }
.profile-head { font-size: 15px; font-weight: 650; margin-bottom: 12px; color: var(--primary); }
.files { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.filechip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--primary-soft);
  color: var(--primary); border-radius: 999px; padding: 4px 12px; margin: 3px 6px 3px 0; font-size: 12px;
}
.filechip a { cursor: pointer; font-weight: 500; }
.filechip a.del { color: var(--danger); }

/* ================= 报表中心折叠面板（rep-group 此前无样式，统一补齐） ================= */
.rep-group {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 8px; overflow: hidden; background: #fff;
}
.rep-group-hd {
  display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  padding: 9px 13px; font-size: 13px; font-weight: 600; color: var(--text);
  background: #f7f9fd; transition: background .15s;
}
.rep-group-hd:hover { background: var(--primary-soft); color: var(--primary); }
.rep-group-hd .caret { font-size: 10px; color: var(--muted); transition: transform .18s ease; }
.rep-group.open .rep-group-hd .caret { transform: rotate(90deg); }
.rep-group.open .rep-group-hd { background: var(--primary-soft); color: var(--primary-dark); }
.rep-group-body { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--border); }

/* ================= 细节打磨 ================= */

/* 卡片主标题：左侧渐变色条，强化层级（限定 .content 内，避免影响登录卡片） */
.content .card > h2, .content .card .row-between > h2 { position: relative; padding-left: 13px; }
.content .card > h2::before, .content .card .row-between > h2::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 17px; border-radius: 2px;
  background: var(--accent-grad);
}

/* 空状态：整行仅一个单元格且非展开明细行时，呈现为居中空态 */
tbody td[colspan]:only-child:not([data-detail]) {
  text-align: center; padding: 36px 12px 32px; color: #98a3b5; font-size: 13px;
  background: #fbfcfe; border-bottom: none;
}
tbody td[colspan]:only-child:not([data-detail])::before {
  content: ""; display: block; width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 50%;
  background: #eef1f7 center/22px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a8b3c2' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7h18v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z'/%3E%3Cpath d='M3 7l2.6-3h12.8L21 7'/%3E%3Cpath d='M9 12h6'/%3E%3C/svg%3E");
}

/* 禁用态：排序/不可用按钮给出明确反馈 */
button:disabled, .btn:disabled {
  opacity: .42; cursor: not-allowed; box-shadow: none; transform: none; filter: none;
}
.btn:disabled:hover { background: var(--primary); box-shadow: none; filter: none; transform: none; }
.btn.ghost:disabled:hover { background: #fff; color: var(--primary); border-color: var(--border-strong); }
.btn.danger:disabled:hover { background: var(--danger); }

/* 键盘可访问性：清晰的焦点环 */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px;
}
.nav-item:focus-visible, .bottomnav a:focus-visible, .nav-group:focus-visible { outline-color: #8fb0ff; }

/* 合计/总计行：强调收尾 */
tfoot td {
  font-weight: 600; background: #f7f9fd;
  border-top: 1px solid var(--border-strong); border-bottom: none;
}

/* 表格在窄屏自适应，避免横向溢出 */
@media (max-width: 800px) {
  th { white-space: normal; }
  th, td { padding: 8px 9px; font-size: 12.5px; }
  .content .card > h2, .content .card .row-between > h2 { padding-left: 10px; }
}

/* ================= 易用性增强 ================= */

/* 1) 提示条：按类型着色、可换行、可点击关闭、可带操作按钮 */
.toast {
  display: flex; align-items: flex-start; gap: 8px;
  max-width: min(560px, calc(100vw - 32px));
  border-radius: 12px; padding: 12px 16px; line-height: 1.5;
  white-space: normal; word-break: break-word; text-align: left;
  bottom: calc(34px + env(safe-area-inset-bottom)); cursor: pointer;
}
.toast::before { font-size: 14px; line-height: 1.3; font-weight: 700; flex: none; }
.toast.info::before { content: "i"; color: #9db8ff; }
.toast.ok { background: #10281d; }
.toast.ok::before { content: "✓"; color: #4ade80; }
.toast.err { background: #2c1416; }
.toast.err::before { content: "!"; color: #ff8b8f; }
.toast.warn { background: #2b2210; }
.toast.warn::before { content: "▲"; color: #ffc44d; }
.toast .toast-act {
  margin-left: 6px; color: #9db8ff; text-decoration: underline;
  white-space: nowrap; cursor: pointer;
}
.toast .toast-act:hover { color: #c5d6ff; }

/* 2) 侧栏数字角标（待审 / 预警） */
.nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  flex: none;
}
.nav-badge.soft { background: rgba(255, 255, 255, .2); color: #fff; }

/* 3) 字段行内错误：红框 + 文案，定位到具体输入框 */
.field.invalid > label { color: var(--danger); }
input.invalid, select.invalid, textarea.invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(214, 64, 70, .12);
}
.field-err { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-err {
  background: var(--danger-soft); color: #a32a2e; border: 1px solid #f5c2c3;
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 10px 0;
}

/* 4) 术语提示（鼠标悬停/长按看解释） */
.tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; margin-left: 4px;
  background: #e8edf7; color: #5b6b82; font-size: 10px; font-weight: 700;
  cursor: help; vertical-align: middle; user-select: none;
}
.tip:hover { background: var(--primary-soft); color: var(--primary); }

/* 5) 分页条 */
.pager {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  justify-content: flex-end; margin-top: 10px;
}
.pager .muted { margin-right: auto; }
.pager button { min-width: 32px; padding: 5px 9px; }
.pager .cur { background: var(--primary); color: #fff; border-color: transparent; }

/* 6) 加载骨架 */
.loading-row { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.sk {
  height: 14px; border-radius: 6px;
  background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 50%, #eef1f6 75%);
  background-size: 200% 100%; animation: sk 1.1s infinite;
}
@keyframes sk { from { background-position: 200% 0 } to { background-position: -200% 0 } }

/* 7) 空状态：图标 + 说明 + 下一步动作 */
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }
.empty .empty-icon { font-size: 26px; opacity: .55; line-height: 1; }
.empty h4 { margin: 10px 0 4px; font-size: 14px; color: var(--text); font-weight: 600; }
.empty p { margin: 0 0 12px; font-size: 12.5px; }

/* 8) 表单网格：窄屏自动单列 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 12px; }

/* 9) 移动端：提示条避开底部导航，录入表格加大点击区域 */
.scroll-hint { display: none; }
@media (max-width: 800px) {
  .toast {
    left: 12px; right: 12px; transform: none; max-width: none;
    bottom: calc(66px + env(safe-area-inset-bottom));
    animation: toastInMobile .2s ease;
  }
  .scroll-hint { display: block; font-size: 11.5px; color: var(--muted); margin: 4px 2px 0; }
  .doc-table input, .doc-table select { padding: 8px; font-size: 13px; }
  .modal { padding: 16px; border-radius: 12px; }
  .pager { justify-content: center; }
}
@keyframes toastInMobile { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }

/* 10) 开单 / 查询 分栏 Tab */
.tabbar {
  display: flex; gap: 4px; margin-bottom: 12px;
  background: #e9edf5; padding: 4px; border-radius: 11px; width: fit-content;
}
.tabbar .tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 18px; border-radius: 8px; font-size: 13.5px;
  cursor: pointer; font-family: inherit; font-weight: 500;
  transition: background .15s, color .15s;
}
.tabbar .tab.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(20, 30, 60, .12); }

/* 11) 刘海屏安全区（配合 viewport-fit=cover） */
@media (max-width: 800px) {
  .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
  /* 横向滚动时首列（单号）与末列（操作）吸附（卡片模式除外） */
  .content table:not(.cards) th:first-child, .content table:not(.cards) td:first-child {
    position: sticky; left: 0; background: inherit; z-index: 2;
  }
  .content table:not(.cards) th:last-child, .content table:not(.cards) td:last-child {
    position: sticky; right: 0; background: inherit; z-index: 2;
  }
  .content table tr { background: #fff; }
}

/* 12) 平板横屏：收窄侧栏，避免表格被挤成竖条 */
@media (min-width: 801px) and (max-width: 1100px) {
  .sidebar { width: 176px; flex: none; }
  .content { padding: 18px 16px; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 9px; }
  .filters .field input, .filters .field select { min-width: 110px; }
}

/* 13) 尊重系统「减少动效」设置 */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* 14) 全局搜索 */
.gsearch { position: relative; flex: 1; max-width: 380px; margin: 0 12px; }
.gsearch input {
  width: 100%; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: #fff; font-size: 13px;
}
.gsearch input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.gsearch-pop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 80;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .14); max-height: 62vh; overflow-y: auto;
}
.gs-h { padding: 8px 12px 4px; font-size: 11.5px; color: var(--muted); background: #fafbfe; }
.gs-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f2f4f9;
}
.gs-item:hover, .gs-item:focus { background: var(--primary-soft); outline: none; }
.gs-item span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.gs-empty { padding: 16px 12px; color: var(--muted); font-size: 13px; text-align: center; }
@media (max-width: 800px) {
  .gsearch { display: none; }   /* 手机端空间有限，用菜单进入各页查询 */
}

/* 15) 批量操作条 */
.batch-bar {
  display: none; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 8px 0; padding: 8px 12px; border-radius: 10px;
  background: var(--primary-soft); border: 1px solid #d8e0ff; font-size: 13px;
}
.batch-bar.on { display: flex; }
.batch-bar .muted { margin-right: auto; }

/* 16) 手机端表格卡片化（列表加 class="cards" + td 的 data-label） */
@media (max-width: 640px) {
  table.cards { display: block; border: 0; }
  table.cards thead { display: none; }
  table.cards tbody { display: block; }
  table.cards tr {
    display: block; border: 1px solid var(--border); border-radius: 12px;
    margin-bottom: 10px; padding: 6px 12px; background: #fff;
  }
  table.cards tr:nth-child(2n) { background: #fff; }
  table.cards td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border: 0; padding: 6px 0; text-align: right; font-size: 13px;
    position: static !important;
  }
  table.cards td::before {
    content: attr(data-label); color: var(--muted); font-size: 12px;
    text-align: left; flex: none; font-weight: 400;
  }
  table.cards td[colspan] { display: block; text-align: left; }
  table.cards td[colspan]::before { content: ""; }
  table.cards tr[data-detail] { border-style: dashed; }
}
