/* 飞扬进销存 Web · 对齐采购智脑 3011-theme-c（qtech-new 生产版同款）
   R5 改版：紧凑高密度表格 / 分段统计条 / 胶囊chip / 导航激活竖条 / 斑马纹 / 骨架屏 */
:root {
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #0f1e33;
  --muted: #475e75;
  --border: #dce1e8;
  --border-2: #e9eef6;
  --border-strong: #c6d2e2;
  --accent: #0057d2;
  --accent-strong: #0040b0;
  --accent-soft: #e6f0fd;
  --accent-weak: rgba(0,87,210,.08);
  --ok: #059669;
  --ok-soft: #e9f7f1;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #2563eb;
  --info-bg: #e9f0fd;
  --topbar-grad: linear-gradient(90deg,#022879 0%,#0040b0 60%,#0a6ed1 100%);
  --topbar-h: 56px;
  --nav-w: 184px;
  --focus-ring: 0 0 0 2px #fff, 0 0 0 4px var(--accent);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-lg: 0 2px 8px rgba(16,24,40,.08);
  --shadow-xl: 0 8px 24px rgba(16,24,40,.10);
  --ease: cubic-bezier(.4,0,.2,1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ===== 顶栏（深蓝渐变，logo 块与侧栏对齐一体） ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-grad);
  color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px 0 0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(11,42,74,.22);
}
.topbar .brand {
  width: var(--nav-w); flex: none;
  display: flex; align-items: center; gap: 10px;
  padding-left: 16px;
  font-size: 15px; font-weight: 700; letter-spacing: .02em;
}
.topbar .brand svg { flex: none; }
.topbar .data-at { font-size: 11px; color: rgba(255,255,255,.65); white-space: nowrap; }
.topbar .spacer { flex: 1; }
.topbar .user {
  font-size: 12px; color: #fff;
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
  padding: 5px 14px; border-radius: 999px;
}
.topbar .user b { font-weight: 600; }
.topbar button.link {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  transition: background .15s;
}
.topbar button.link:hover { background: rgba(255,255,255,.22); }

/* ===== 布局 ===== */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidenav {
  width: var(--nav-w); flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 8px 10px 20px;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.sidenav .nav-group {
  font-size: 10.5px; font-weight: 600; letter-spacing: 1.2px;
  color: var(--muted); opacity: .85;
  padding: 14px 10px 5px; user-select: none;
}
.sidenav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  color: var(--muted); text-decoration: none;
  border-radius: 8px; font-size: 13.5px; line-height: 1;
  transition: background .15s, color .15s;
}
.sidenav a svg { flex: none; width: 17px; height: 17px; transition: transform .15s ease; }
.sidenav a:hover { background: var(--bg); color: var(--text); }
.sidenav a:hover svg { transform: translateX(1.5px); }
.sidenav a.active {
  background: var(--accent-weak); color: var(--accent); font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(0,87,210,.14);
}
.sidenav a.active::before {
  content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px;
  width: 3px; background: var(--accent); border-radius: 0 3px 3px 0;
}
.main { flex: 1; min-width: 0; padding: 20px 28px 56px; }
.main .page-head { animation: page-in .22s cubic-bezier(.16,1,.3,1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .main .page-head { animation: none; } }

/* ===== 页头 ===== */
.page-head { display: flex; align-items: baseline; gap: 12px; margin: 2px 0 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.02em; line-height: 1.15; }
.page-head .sub { color: var(--muted); font-size: 12.5px; }
.page-head .spacer { flex: 1; }

/* ===== 工具条（搜索框带图标） ===== */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; padding: 8px 0; position: sticky; top: var(--topbar-h); z-index: 40; background: var(--bg); }
.search-box { position: relative; width: 300px; }
.search-box input {
  width: 100%; height: 34px; padding: 0 12px 0 34px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; font-family: var(--font);
  transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); outline: none; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar input[type="date"], .toolbar select {
  height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; font-family: var(--font);
}
.toolbar input[type="date"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); outline: none; }
.date-sep { color: var(--muted); font-size: 12px; }

/* ===== 按钮 ===== */
.btn {
  height: 32px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: var(--font); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0) scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }

/* ===== 分段统计条（summary-bar 同款：等分+竖分隔+mono大数字） ===== */
.sumbar {
  display: flex; align-items: stretch;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; margin-bottom: 12px;
}
.sumbar .item { flex: 1; text-align: center; padding: 10px 8px; position: relative; font-size: 11px; color: var(--muted); font-weight: 500; }
.sumbar .item + .item::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 1px; background: var(--border); }
.sumbar .item b {
  display: block; font-size: 18px; font-weight: 800; color: var(--text);
  font-variant-numeric: tabular-nums; font-family: var(--mono); letter-spacing: -.02em;
  margin-bottom: 2px;
}
.sumbar .item.accent b { color: var(--info); }
.sumbar .item.warn b { color: var(--warn); }
.sumbar .item.danger b { color: var(--danger); }

/* ===== 表格（丘钛同款：11px表头/斑马纹/实色sticky/柔和hover） ===== */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 300px);
}
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
/* 列宽按内容自适应: 长客户名撑宽、短状态列收窄, 避免固定均分留大白 */
table.grid.auto { table-layout: auto; }
table.grid th {
  text-align: left; padding: 9px 10px;
  background: #f7f9fc; color: var(--muted);
  font-weight: 600; font-size: 11px; letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 6; white-space: nowrap;
  box-shadow: 0 1px 0 var(--border), 0 8px 8px -8px rgba(16,24,40,.10);
}
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--border-2); white-space: nowrap; }
table.grid tbody tr { transition: background-color .12s; }
table.grid tbody tr:nth-child(even) { background: #fbfcfe; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.clip { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
table.grid td.empty { color: var(--border-strong); }
table.grid td.date { font-variant-numeric: tabular-nums; color: var(--muted); }
table.grid td.num.zero { color: var(--border-strong); }
table.grid td.num.strong { font-weight: 600; }
table.grid td.num.due { color: var(--danger); }
.age { font-variant-numeric: tabular-nums; }
.age.age-mid { color: var(--warn); font-weight: 600; }
.age.age-old { color: var(--danger); font-weight: 700; }
.mono { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
table.grid td.mono { font-weight: 600; }

/* 多行单据（丘钛同款）: 主行汇总+展开子表 */
.multi-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 700;
  color: var(--accent); cursor: pointer; font-family: var(--font);
  font-variant-numeric: tabular-nums; transition: background .15s, border-color .15s;
}
.multi-toggle:hover { background: var(--accent-soft); border-color: var(--accent); }
.multi-toggle .caret { font-size: 10px; }
.multi-sum { color: var(--muted); font-size: 12px; }
table.grid td .unit { color: var(--muted); font-size: 11.5px; }
table.grid tr.multi-main > td { font-weight: 500; }
table.grid tr.multi-main.expanded { background: var(--accent-weak); }
/* hidden 属性必须压过一切 display 规则(否则折叠态仍占位/被点) */
[hidden] { display: none !important; }
table.grid tr.lines-row > td { background: var(--surface-2); padding: 0 0 0 34px; white-space: normal; }
table.sub-grid { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.sub-grid th { position: static; box-shadow: none; background: transparent; padding: 6px 10px; border-bottom: 1px solid var(--border); }
table.sub-grid td { padding: 5px 10px; border-bottom: 1px solid var(--border-2); white-space: nowrap; }
table.sub-grid td.num, table.sub-grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.sub-grid tr.sub-total td { font-weight: 700; border-bottom: none; background: transparent; color: var(--text); }

/* 状态胶囊（浅底深字，全站同一套） */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.6; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.info { background: var(--accent-soft); color: var(--accent-strong); }
.tag.mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ===== 筛选 chips（胶囊 999px，选中浅蓝底+蓝字+蓝描边） ===== */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.chip {
  height: 28px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 12.5px; font-family: var(--font); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.chip:hover { border-color: var(--muted); color: var(--text); transform: translateY(-1px); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-sep { width: 1px; height: 16px; background: var(--border-strong); margin: 0 4px; }

/* ===== 年月分组（丘钛同款） ===== */
.year-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; margin: 12px 0 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; user-select: none;
  transition: background .15s, transform .15s;
}
.year-header:first-child { margin-top: 0; }
.year-header:hover { background: #f8fafc; transform: translateX(2px); }
.year-header b { font-size: 14px; font-weight: 700; }
.year-header .caret, .month-header .caret { color: var(--muted); font-size: 11px; width: 12px; flex: none; }
.ymeta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ysum { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--warn); font-variant-numeric: tabular-nums; font-family: var(--mono); }
.month-group { margin: 0 0 6px; }
.month-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; cursor: pointer; user-select: none;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.month-header:hover { background: var(--accent-weak); }
.month-header b { font-size: 13px; font-weight: 700; }
.month-group.open .month-header { background: var(--accent-weak); border-color: rgba(0,87,210,.14); }
.month-body { padding: 6px 0 4px; }
/* 月组不限高: 整页自然滚动(灵哥 10:16 明确要求), 表头随页面滚出可接受 */
.month-body .table-wrap { max-height: none; overflow: visible; }
.more-hint { padding: 8px 14px; font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 0 0 8px 8px; }
.chip .cnt { font-weight: 700; font-variant-numeric: tabular-nums; opacity: .8; }
.chip.active .cnt { opacity: .9; }

/* 悬浮合计胶囊（丘钛 foot-sum 同款） */
.foot-sum {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 10px 30px rgba(15,23,42,.14);
  padding: 8px 18px; display: inline-flex; align-items: center;
  font-size: 12.5px; color: var(--muted);
}
.foot-sum b { color: var(--text); font-variant-numeric: tabular-nums; font-family: var(--mono); margin-left: 4px; font-size: 13.5px; }
.foot-sum .fsep { width: 1px; height: 14px; background: var(--border); margin: 0 12px; }

/* 已筛选提示条(丘钛 filterBar 同款) */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8;
  border-radius: 10px; padding: 7px 14px; margin-bottom: 10px; font-size: 12.5px;
}
.filter-bar b { font-weight: 700; }
.filter-bar .fb-btn {
  margin-left: auto; border: 1px solid #93c5fd; background: #fff; color: #1d4ed8;
  border-radius: 8px; padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s;
}
.filter-bar .fb-btn:hover { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

/* 回到顶部 */
.back-top {
  position: fixed; right: 18px; bottom: 64px; z-index: 80;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(255,255,255,.94);
  color: var(--muted); font-size: 16px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(15,23,42,.14);
  transition: color .15s, border-color .15s, transform .15s;
}
.back-top:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }

/* 移动端底部导航(拇指可达; 横向滑动看全部模块) */
.mobile-tabs {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
  background: rgba(255,255,255,.97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(15,23,42,.06);
  overflow-x: auto; white-space: nowrap; scrollbar-width: none;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.mobile-tabs::-webkit-scrollbar { display: none; }
.mobile-tabs a {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  min-width: 64px; padding: 4px 8px; border-radius: 8px;
  font-size: 10.5px; color: var(--muted); text-decoration: none;
}
.mobile-tabs a svg { width: 19px; height: 19px; }
.mobile-tabs a.on { color: var(--accent); background: var(--accent-weak); font-weight: 600; }

/* ===== 移动端列表卡片 ===== */
.m-list { display: flex; flex-direction: column; gap: 8px; padding: 2px 0 10px; }
.m-card {
  display: block; width: 100%; text-align: left; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-family: var(--font); cursor: pointer;
  transition: background .15s, border-color .15s;
}
.m-card:active { background: var(--surface-2); border-color: var(--border-strong); }
.mc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mc-no { font-weight: 700; font-size: 13px; }
.mc-mid { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 13px; }
.mc-party { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-date { color: var(--muted); font-size: 12px; flex: none; font-variant-numeric: tabular-nums; }
.mc-bot { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.mc-prod { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-amt { font-family: var(--mono); font-weight: 700; color: var(--text); font-size: 14px; flex: none; font-variant-numeric: tabular-nums; }

/* ===== 分页 ===== */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager .pg-jump input { width: 56px; height: 28px; border: 1px solid var(--border-strong); border-radius: 6px; text-align: center; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pager .pg-size select { height: 28px; border: 1px solid var(--border-strong); border-radius: 6px; font-size: 12.5px; padding: 0 4px; }
.pager .pg-jump, .pager .pg-size { margin-left: 6px; font-size: 12px; }
.pager button { min-width: 30px; height: 30px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; cursor: pointer; color: var(--text); transition: border-color .15s, color .15s; }
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .cur { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== 空态/加载/骨架屏 ===== */
.state-box { padding: 48px 20px; text-align: center; color: var(--muted); }
.state-box .title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.state-box.error .title { color: var(--danger); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -4px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { position: relative; overflow: hidden; background: #edf1f7; border-radius: 4px; }
.skeleton::after { content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.55); animation: sk-pulse 1.4s ease-in-out infinite; }
@keyframes sk-pulse { 0%, 100% { opacity: .2; } 50% { opacity: .85; } }
.sk-table { padding: 10px; }
.sk-row { display: flex; gap: 14px; padding: 9px 4px; }
.sk-row .skeleton { height: 14px; }

/* ===== 登录页 ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--topbar-grad); }
.login-card { width: 400px; max-width: calc(100vw - 32px); background: var(--surface); border-radius: 16px; padding: 34px 36px 26px; box-shadow: 0 16px 48px rgba(0,0,0,.28); }
.login-logo { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.login-card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 24px; }
.login-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border-2); font-size: 11.5px; color: var(--muted); text-align: center; }
.login-card .field { margin-bottom: 14px; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.login-card input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 14px; font-family: var(--font); }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); outline: none; }
.login-card .btn.primary { width: 100%; height: 38px; font-size: 14px; margin-top: 6px; justify-content: center; }
.login-card .err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 10px; }

/* ===== 工作台 ===== */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
/* 工作台: 待办条 + 经营概览条(同一表面内分栏, 不做等尺寸卡片堆) */
.focus-bar, .stat-strip { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.focus-item, .stat-strip .st { flex: 1; min-width: 0; padding: 13px 18px; position: relative; }
.focus-item + .focus-item::before, .stat-strip .st + .st::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 1px; background: var(--border-2); }
.focus-item { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--text); transition: background .15s; }
.focus-item:hover { background: var(--surface-2); }
.focus-k { font-size: 12.5px; color: var(--muted); flex: none; }
.focus-v { font-size: 22px; font-weight: 800; font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.focus-note { margin-left: auto; font-size: 12px; color: var(--accent); white-space: nowrap; }
.focus-item.on .focus-v { color: var(--warn); }
.focus-item.danger .focus-v { color: var(--danger); }
.stat-strip .st .k { display: block; font-size: 12px; color: var(--muted); }
.stat-strip .st .v { display: block; margin-top: 2px; font-size: 20px; font-weight: 800; font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-strip .st .m { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.stat-strip .st.warn .v { color: var(--warn); }
.stat-strip .st.danger .v { color: var(--danger); }
.quick-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.qa { display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 12.5px; transition: border-color .15s, background .15s, color .15s; }
.qa:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; transition: border-color .15s, box-shadow .15s;
}
.panel:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 12.5px; margin: 0 0 10px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.panel .big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; font-family: var(--mono); letter-spacing: -.02em; }
.panel .cap { font-size: 12px; color: var(--muted); margin-top: 3px; }
.panel .cap a { color: var(--accent); text-decoration: none; font-weight: 600; }
.panel .cap a:hover { text-decoration: underline; }
.panel.attention { border-color: var(--warn); background: linear-gradient(180deg, var(--warn-soft) 0%, var(--surface) 55%); }
.warn-c { color: var(--warn); }
.danger-c { color: var(--danger); }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 12px; }
.bar-row .lbl { width: 52px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.bar-row .track { flex: 1; height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s cubic-bezier(.16,1,.3,1); }
.bar-row .val { width: 100px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }

/* ===== 来单接入 ===== */
.intake-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 14px; align-items: start; }
.intake-ta { width: 100%; min-height: 230px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: var(--text); background: var(--surface); resize: vertical; }
.intake-ta:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); outline: none; }
.intake-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.intake-actions .spacer { flex: 1; }
.intake-warn { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
.intake-pick { border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 999px; padding: 2px 9px; margin: 2px; font-size: 12px; cursor: pointer; font-family: var(--font); }
.intake-pick:hover { background: rgba(217,119,6,.1); }
.intake-lines td { vertical-align: middle; }
.intake-lines input { height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: var(--font); width: 92px; text-align: right; }
.intake-lines input:focus { border-color: var(--accent); outline: none; }
.intake-lines select, #in-partner { height: 30px; max-width: 170px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; font-family: var(--font); background: var(--surface); color: var(--text); }
#in-partner { width: 100%; height: 34px; }
.intake-lines .tag { max-width: 150px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
@media (max-width: 900px) { .intake-grid { grid-template-columns: 1fr; } .intake-ta { min-height: 160px; font-size: 13px; } }

/* ===== 弹层 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(10,22,40,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { width: 420px; max-width: calc(100vw - 40px); background: var(--surface); border-radius: 14px; padding: 24px 26px; box-shadow: var(--shadow-xl); }
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal .field { margin-bottom: 12px; }
.modal label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.modal input, .modal select { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13.5px; font-family: var(--font); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal .err { color: var(--danger); font-size: 12.5px; min-height: 17px; }
.modal .note { font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; }

/* ===== 命令面板(Ctrl+K) ===== */
.cmd-mask { position: fixed; inset: 0; z-index: 300; background: rgba(10,22,40,.45); display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.cmd-box { width: 560px; max-width: calc(100vw - 28px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.28); overflow: hidden; }
.cmd-box input { width: 100%; height: 48px; border: none; border-bottom: 1px solid var(--border); padding: 0 16px; font-size: 15px; font-family: var(--font); color: var(--text); outline: none; }
.cmd-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.cmd-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 9px 12px; border: none; background: transparent; border-radius: 8px; text-align: left; font-size: 13.5px; font-family: var(--font); color: var(--text); cursor: pointer; }
.cmd-item em { font-style: normal; font-size: 11.5px; color: var(--muted); flex: none; }
.cmd-item:hover, .cmd-item.sel { background: var(--accent-weak); color: var(--accent); }
.cmd-empty { padding: 18px 12px; color: var(--muted); font-size: 13px; text-align: center; }

/* ===== toast（右上深色胶囊，丘钛/规范同款） ===== */
.toast {
  position: fixed; top: 68px; right: 18px;
  background: rgba(15,30,51,.92); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 200;
  box-shadow: 0 6px 20px rgba(0,0,0,.28);
  animation: toast-in .22s cubic-bezier(.16,1,.3,1);
}
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ===== 待审核徽标 ===== */
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; font-variant-numeric: tabular-nums;
}
table.grid tbody tr.row-open { cursor: pointer; }

/* ===== 详情抽屉 ===== */
.drawer-mask { position: fixed; inset: 0; background: rgba(10,22,40,.35); z-index: 110; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 94vw;
  background: var(--surface); z-index: 115;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.18);
  animation: drawer-in .22s cubic-bezier(.16,1,.3,1);
}
.drawer.wide { width: 760px; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.drawer-title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.drawer-title[title]:hover { color: var(--accent); }
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--muted); padding: 5px; border-radius: 6px; display: inline-flex; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 24px 24px; }
.drawer-foot { padding: 12px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.foot-note { font-size: 12px; color: var(--muted); margin-right: auto; }
.drawer-sec { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--muted); margin: 20px 0 8px; }
.drawer-sec-empty { color: var(--muted); font-size: 12.5px; padding: 10px 0; }
.table-wrap.flat { box-shadow: none; border-radius: 8px; max-height: none; }
#df-lines-wrap { overflow: visible; }

/* 字段网格 */
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border-2); font-size: 13px; min-width: 0; }
.kv-k { color: var(--muted); flex: none; }
.kv-v { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num-v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ===== 开单表单 ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 6px; }
.form-grid .field.span2 { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-grid input, .form-grid select { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13.5px; font-family: var(--font); background: var(--surface); color: var(--text); }
.form-grid input:focus, .form-grid select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); outline: none; }
#df-lines input { height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: var(--font); width: 100%; }
#df-lines input:focus { border-color: var(--accent); outline: none; }
#df-lines .num-in { text-align: right; font-variant-numeric: tabular-nums; width: 90px; }
#df-lines td { vertical-align: top; }
.doc-total { text-align: right; margin-top: 10px; font-size: 13px; color: var(--muted); }
.doc-total b { font-size: 19px; color: var(--text); font-variant-numeric: tabular-nums; font-family: var(--mono); margin-left: 8px; }
.err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 8px; }

/* ===== 自动完成 ===== */
.autocomplete { position: relative; }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 120; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow-xl); max-height: 240px; overflow-y: auto; margin-top: 3px; }
#df-lines .ac-list { right: auto; width: 640px; max-width: calc(94vw - 60px); min-width: 100%; }
#df-lines .ac-item b { max-width: none; }
#df-lines .ac-item { gap: 10px; }
.ac-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; font-size: 12.5px; }
.ac-item:hover, .ac-item.sel { background: var(--accent-weak); }
.ac-item.first b::after { content: "↵"; color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 11px; }
.ac-item b { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item .mono { color: var(--muted); flex: none; }
.ac-stock { color: var(--ok); font-size: 11.5px; flex: none; }
.ac-price { color: var(--accent-strong); font-size: 11.5px; flex: none; font-variant-numeric: tabular-nums; }
.ac-empty { padding: 9px 12px; color: var(--muted); font-size: 12.5px; }

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .sidenav { display: none; }
  .mobile-tabs { display: flex; }
  .main { padding: 14px 12px calc(80px + env(safe-area-inset-bottom)); }
  .toolbar { position: static; padding: 0; }
  .btn { height: 38px; padding: 0 14px; }
  .chip { height: 32px; padding: 0 14px; }
  .search-box input, .toolbar input[type="date"], .toolbar select { height: 38px; font-size: 16px; }
  .form-grid input, .form-grid select, .modal input, .modal select { height: 42px; font-size: 16px; }
  #df-lines input { height: 36px; font-size: 15px; }
  .page-head h1 { font-size: 20px; }
  #f-export { display: none; }
  .drawer-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; justify-content: flex-start; }
  .drawer-foot .btn { flex: 1 1 auto; justify-content: center; }
  .drawer-foot .foot-note { flex-basis: 100%; margin-bottom: 4px; }
  .back-top { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .foot-sum { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .focus-bar, .stat-strip { flex-wrap: wrap; }
  .focus-item, .stat-strip .st { flex: 1 1 50%; }
  .focus-item + .focus-item::before, .stat-strip .st + .st::before { display: none; }
  .search-box { width: 100%; }
  .drawer, .drawer.wide { width: 100vw; max-width: 100vw; }
  .kv-grid, .form-grid { grid-template-columns: 1fr; }
  .drawer-body { overflow-x: auto; }
  .table-wrap { max-height: none; }
  /* 窄屏明细表保最小宽: 抽屉体横向滚动兕底, 金额列不被压没 */
  #df-lines { min-width: 520px; }
  .topbar .brand { width: auto; }
  .topbar .data-at { display: none; }
}

/* 客户/供应商 chip 行（丘钛 cust-chip 同款） */
.party-chips { gap: 6px; }
.cust-bar-lbl { font-size: 11.5px; color: var(--muted); margin-right: 2px; flex: none; }
.cust-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px;
  border-radius: 999px; background: transparent; border: 1px solid var(--border);
  cursor: pointer; font-size: 11.5px; color: var(--muted); font-family: var(--font);
  transition: background .15s, border-color .15s, color .15s;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cust-chip b { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.cust-chip:hover { border-color: var(--muted); color: var(--text); background: var(--bg); }
.cust-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.cust-chip.on b { color: var(--accent); }

/* 列设置弹层 */
.col-list { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; max-height: 320px; overflow-y: auto; }
.col-item { display: flex; align-items: center; gap: 7px; padding: 5px 2px; font-size: 13px; cursor: pointer; color: var(--text); }
.col-item input { accent-color: var(--accent); }

/* 客户归属快捷点选 chips */
.tag-quick { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag-chip {
  padding: 2px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 11.5px; cursor: pointer;
  font-family: var(--font); transition: background .15s, color .15s, border-color .15s;
}
.tag-chip b { font-weight: 600; opacity: .6; font-variant-numeric: tabular-nums; }
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* 单据附件 */
.att-box { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.att-item { display: flex; align-items: center; gap: 9px; padding: 8px 12px; border-bottom: 1px solid var(--border-2); font-size: 12.5px; }
.att-item:last-child { border-bottom: none; }
.att-ic { flex: none; font-size: 10px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 4px; padding: 2px 5px; letter-spacing: .02em; }
.att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.att-meta { flex: none; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.att-acts { flex: none; display: inline-flex; gap: 8px; }
.att-acts a { color: var(--accent); text-decoration: none; font-size: 12px; }
.att-acts a:hover { text-decoration: underline; }
.att-del { border: none; background: none; color: var(--danger); font-size: 12px; cursor: pointer; padding: 0; font-family: var(--font); }
.att-del:hover { text-decoration: underline; }
.att-empty { padding: 14px 12px; color: var(--muted); font-size: 12.5px; }
.att-up { position: relative; overflow: hidden; margin-top: 8px; display: inline-flex; }

/* 打印预览弹窗 */
.print-mask { position: fixed; inset: 0; background: rgba(10,22,40,.5); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 24px; }
.print-dlg { width: min(980px, 96vw); height: min(92vh, 1000px); background: var(--surface); border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.35); display: flex; flex-direction: column; overflow: hidden; }
.print-dlg-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.print-dlg-head b { font-size: 14px; }
.print-hint { font-size: 12px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.print-dlg-body { flex: 1; background: #525659; }
.print-dlg-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
@media print { .print-mask { display: none !important; } }

/* 打印模板设置 */
.tpl-wrap { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: start; }
.tpl-list { display: flex; flex-direction: column; gap: 6px; }
.tpl-item { text-align: left; padding: 10px 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text); font-family: var(--font); display: flex; justify-content: space-between; align-items: center; }
.tpl-item:hover { border-color: var(--accent); }
.tpl-item.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tpl-item i { font-style: normal; font-size: 10.5px; color: var(--ok); }
.tpl-form { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.tpl-form .field { margin-bottom: 12px; }
.tpl-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.tpl-form input[type=text], .tpl-form input:not([type]), .tpl-form textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 13px; font-family: var(--font); }
.tpl-form textarea { resize: vertical; }
.tpl-opts { display: flex; flex-wrap: wrap; gap: 14px; }
.tpl-opts label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); margin: 0; }
.tpl-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
@media (max-width: 900px) { .tpl-wrap { grid-template-columns: 1fr; } }

/* 数据恢复页 */
.restore-status { margin-bottom: 12px; padding: 9px 14px; border-radius: 8px; font-size: 12.5px; }
.restore-status.ok { background: var(--ok-soft); color: var(--ok); }
.restore-status.bad { background: var(--danger-soft); color: var(--danger); }
