:root {
  --bg: #f5f6f8;
  --card: #fff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #006eff;
  --primary-h: #0052cc;
  --primary-soft: #e6f0ff;
  --danger: #dc2626;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --sidebar-w: 210px;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15,23,42,.04);
  --sidebar-bg: #ffffff;
  --sidebar-text: #475569;
  --sidebar-active: #eef4ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.muted { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.danger-text { color: var(--danger); }
.ok-text { color: var(--green); }
.warn-text { color: var(--amber); }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; gap: 18px;
  align-items: center; justify-content: center; padding: 24px 16px;
  background: linear-gradient(135deg, #006eff 0%, #0052cc 50%, #003d99 100%);
}
/* ICP 备案号（工信部要求：底栏展示并链接到备案系统） */
.login-icp {
  font-size: 12px; color: rgba(255,255,255,.78); text-decoration: none;
  letter-spacing: .3px; line-height: 1.6;
}
.login-icp:hover { color: #fff; text-decoration: underline; }
.side-icp {
  font-size: 11px; color: var(--muted); text-align: center; text-decoration: none;
  opacity: .8; letter-spacing: .2px; padding-top: 2px;
}
.side-icp:hover { color: var(--primary); opacity: 1; }
.login-card {
  background: var(--card); padding: 44px 36px; border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); width: 360px; text-align: center;
}
.login-logo { margin-bottom: 8px; line-height: 0; }
.login-logo svg { width: 46px; height: 46px; }
.login-card h1 { font-size: 21px; margin-bottom: 6px; font-weight: 600; }
.login-card .sub { color: var(--muted); margin-bottom: 26px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 14px; margin-bottom: 14px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,110,255,.15); outline: none; }
.login-card .err { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 16px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }

/* ============ 应用外壳：左侧导航 + 内容区（无顶部栏） ============ */
/* 外壳固定：左侧菜单不随内容滚动，只有 .content 内部滚动 */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.app-body { display: flex; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.main-col { flex: 1 1 auto; min-width: 0; height: 100%; display: flex; flex-direction: column; }

/* ---- 侧栏品牌区（原顶部栏的品牌与版本挪到这里） ---- */
.side-brand {
  height: 52px; flex: 0 0 auto; display: flex; align-items: center; gap: 9px;
  padding: 0 14px; border-bottom: 1px solid var(--border);
}
.side-logo { width: 20px; height: 20px; line-height: 1; display: flex; align-items: center; }
.side-logo svg { width: 20px; height: 20px; }
.side-name { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
.side-ver {
  font-size: 11px; color: var(--muted); background: #f1f5f9;
  padding: 1px 7px; border-radius: 8px; font-weight: 500;
}

/* ---- 侧栏底部用户区（原顶部栏的用户名/角色/退出） ---- */
.side-user {
  flex: 0 0 auto; border-top: 1px solid var(--border);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
}
.side-user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.side-user-name {
  font-size: 13px; color: var(--text); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-logout {
  width: 100%; background: none; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
  transition: all .15s;
}
.side-logout:hover { color: var(--danger); border-color: var(--danger); }

/* ---- 浅色侧栏：白底 + 分组标题 + 蓝色选中胶囊 ---- */
.sidebar {
  width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border);
  flex: 0 0 var(--sidebar-w); height: 100%; overflow: hidden;
  padding: 0; display: flex; flex-direction: column;
  overscroll-behavior: contain;
}
#nav { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 12px; }
#nav::-webkit-scrollbar { width: 6px; }
#nav::-webkit-scrollbar-thumb { background: #dde3ea; border-radius: 3px; }
#nav::-webkit-scrollbar-thumb:hover { background: #cbd4df; }
#nav::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; border: 2px solid var(--bg); }
.content::-webkit-scrollbar-thumb:hover { background: #aebccb; }
.content::-webkit-scrollbar-track { background: transparent; }

.nav-search { padding: 10px 12px 6px; flex: 0 0 auto; }
.nav-search input {
  width: 100%; height: 32px; padding: 0 10px 0 30px; font-size: 12.5px;
  border: 1px solid #e6ebf2; border-radius: 6px; background-color: #f7f9fb;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M16.5 16.5 21 21'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 9px center; background-size: 14px;
}
.nav-search input:focus { background-color: #fff; }
.nav-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

#nav a {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 10px;
  margin: 1px 0; border-radius: 6px; cursor: pointer; text-decoration: none;
  color: var(--sidebar-text); font-size: 13.5px; transition: background .12s, color .12s;
}
#nav a .nav-ico {
  width: 16px; height: 16px; flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; color: #7c8b9d;
}
#nav a .nav-ico svg { width: 16px; height: 16px; }
#nav a .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav a:hover { background: #f2f5f9; color: #1f2937; }
#nav a:hover .nav-ico { color: #51647a; }
#nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
#nav a.active .nav-ico { color: var(--primary); }
#nav a[data-perm-hidden="1"] { display: none !important; }
.nav-sec-plain { padding-bottom: 2px; }
.nav-group {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 10px 5px; font-size: 11px; color: #9aa7b8; font-weight: 600;
  letter-spacing: .08em; cursor: pointer; user-select: none;
}
.nav-group:hover { color: #6b7c90; }
.nav-caret { width: 12px; height: 12px; position: relative; flex-shrink: 0; }
.nav-caret::before {
  content: ''; position: absolute; left: 3px; top: 2px; width: 5px; height: 5px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform .15s;
}
.nav-sec.collapsed .nav-caret::before { transform: rotate(-45deg); }
.nav-sec.collapsed .nav-items { display: none; }

.role-tag { background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }

.content {
  flex: 1 1 auto; min-height: 0; padding: 18px 22px 28px; overflow-y: auto;
  min-width: 0; background: var(--bg); overscroll-behavior: contain;
}
.page-title {
  font-size: 19px; font-weight: 600; margin-bottom: 14px; color: #0f172a; letter-spacing: -.01em;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.page-title + .muted { margin-top: -8px; margin-bottom: 14px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px;
}
.card h2 { font-size: 14px; margin-bottom: 10px; font-weight: 600; color: #1f2937; }

.btn {
  padding: 7px 13px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px;
  background: #f1f4f8; color: var(--text); transition: all .15s; font-weight: 500;
}
.btn:hover { background: #e6ebf2; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.danger:hover { background: #fecaca; }
.btn.small { padding: 3px 9px; font-size: 12px; border-radius: 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* 表格操作列：默认是轻量文字按钮，悬停才出底色，避免每行一排彩色块 */
td .btn.small { background: transparent; color: var(--primary); padding: 2px 6px; }
td .btn.small:hover { background: var(--primary-soft); }
td .btn.small.danger { background: transparent; color: var(--danger); }
td .btn.small.danger:hover { background: #fee2e2; }
/* 表格操作列按钮紧凑排列 */
td .btn.small + .btn.small { margin-left: 5px; }

input, select, textarea {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px;
  font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,110,255,.12);
}
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 200px; min-width: 200px; }
.field input, .field select { width: 100%; }
.field input[type="date"], .field input[type="number"] { width: auto; min-width: 140px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #eef2f6; font-size: 13px; }
th { background: #f8fafc; color: #64748b; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #fafbfc; }

/* ===== 列表页表格：只保留横线（去掉满屏竖线和斑马纹，信息更干净）=====
   .sheet-* 是单据录入的紧凑表格，不受影响 */
table:not(.sheet-items):not(.sheet-head):not(.sheet-sub):not(.sheet-foot):not(.p-items):not(.p-head):not(.p-fee) {
  border: none;
}
table:not(.sheet-items):not(.sheet-head):not(.sheet-sub):not(.sheet-foot):not(.p-items):not(.p-head):not(.p-fee) th,
table:not(.sheet-items):not(.sheet-head):not(.sheet-sub):not(.sheet-foot):not(.p-items):not(.p-head):not(.p-fee) td {
  border: none;
  border-bottom: 1px solid #eef2f6;
  padding: 8px 10px;
  font-size: 13px;
}
table:not(.sheet-items):not(.sheet-head):not(.sheet-sub):not(.sheet-foot):not(.p-items):not(.p-head):not(.p-fee) th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid #e6ecf3;
}
table:not(.sheet-items):not(.sheet-head):not(.sheet-sub):not(.sheet-foot):not(.p-items):not(.p-head):not(.p-fee) th.num {
  text-align: right;
}
table:not(.sheet-items):not(.sheet-head):not(.sheet-sub):not(.sheet-foot):not(.p-items):not(.p-head):not(.p-fee) tbody tr:hover td {
  background: #f7faff;
}
/* 单据列表里的「商品明细」列：绿色、紧凑 */
.item-cell { color: #0b8a4a; font-size: 12px; line-height: 1.6; }
.item-cell .qty { color: #b45309; font-weight: 600; margin-left: 2px; }

/* 列表表头筛选行：紧凑输入框，不撑高表头 */
.filter-row th { padding: 4px 6px; background: #f8fafc; font-weight: 400; }
.filter-row input, .filter-row select {
  width: 100%; height: 26px; border: 1px solid var(--border); border-radius: 5px;
  background: #fff; color: var(--text); font-size: 12px; padding: 0 5px;
}
.filter-row .btn { height: 26px; padding: 0 8px; font-size: 12px; }
.filter-row th:empty { background: #f8fafc; }

/* 列表关键列（日期 / 客户 / 单号）：加粗放大，一眼定位 */
td.cell-strong { font-weight: 600; color: #334155; font-size: 13px; white-space: nowrap; }
td.cell-party { font-weight: 700; color: #0f172a; font-size: 13.5px; white-space: nowrap; }
td.cell-no { font-weight: 600; font-size: 13px; white-space: nowrap; }
td.cell-no .doc-link { font-weight: 600; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--red); }
.neg { color: var(--green); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.tag.warn { background: #fef3c7; color: #92400e; }
.tag.ok { background: #dcfce7; color: #166534; }
.tag.info { background: #dbeafe; color: #1e40af; }
.tag.danger { background: #fee2e2; color: #b91c1c; }
.sa-stock { color: var(--muted); }

/* 已付/未付/部分付 红绿标志（中国习惯：红=未付欠款，绿=已付） */
.pay-paid, .pay-unpaid, .pay-partial {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.pay-paid { background: #16a34a; color: #fff; }
.pay-unpaid { background: #dc2626; color: #fff; }
.pay-partial { background: #d97706; color: #fff; }

/* ===== 多标签页：轻量胶囊，不再是浏览器标签造型 ===== */
.tabbar {
  display: flex; align-items: center; gap: 4px;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 6px 14px; overflow-x: auto; overflow-y: hidden; flex-shrink: 0;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { height: 0; }
.tab {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  font-size: 12.5px; color: #64748b; cursor: pointer; white-space: nowrap;
  user-select: none; transition: background .12s, color .12s;
}
.tab:hover { background: #f3f6fa; color: #1f2937; }
.tab.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tab-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  font-size: 12px; line-height: 1; color: #9aa9b8; flex-shrink: 0; opacity: .55;
}
.tab:hover .tab-close, .tab.active .tab-close { opacity: 1; }
.tab-close:hover { background: #e11d48; color: #fff; opacity: 1; }
.tab-dirty { color: #d97706; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* 统一日期筛选条（所有列表通用） */
.df-wrap {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px;
}
.df-wrap .df-label { font-size: 12px; color: var(--muted); }
.df-wrap .df-sep { font-size: 12px; color: var(--muted); }
.df-wrap input[type="date"] {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px; background: #fff; color: var(--text); height: 28px;
}
.df-wrap .df-quick { padding: 4px 8px; font-size: 12px; height: 28px; }
.df-wrap .df-quick.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.df-wrap .df-count { font-size: 12px; color: var(--muted); margin: 0; white-space: nowrap; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary .stat { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 13px 15px; border-left: 3px solid var(--primary); }
.summary .stat .label { font-size: 12px; color: var(--muted); }
.summary .stat .value { font-size: 20px; font-weight: 600; margin-top: 3px; color: #0f172a; }
/* 只有两三张卡的行：别拉满整行，避免出现大片空白 */
.summary.tight { grid-template-columns: repeat(auto-fit, minmax(150px, 200px)); justify-content: start; }
.summary .stat.primary { border-left-color: var(--primary); }
.summary .stat.warn { border-left-color: var(--amber); }
.summary .stat.danger { border-left-color: var(--danger); }
.summary .stat.ok { border-left-color: var(--green); }
.summary .stat.pos { border-left-color: var(--red); }
.summary .stat.pos .value { color: var(--red); }
.summary .stat.neg { border-left-color: var(--green); }
.summary .stat.neg .value { color: var(--green); }
/* 资金看板：6 张卡片，金额带负号也不换行 */
.summary.cash { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.summary.cash .stat { padding: 13px 15px; }
.summary.cash .stat .value { font-size: 19px; white-space: nowrap; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.credit-box { background: #f0f7ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
.credit-label { color: var(--text); }

.toast { position: fixed; top: 20px; right: 20px; background: #1f2937; color: #fff; padding: 12px 20px; border-radius: 8px; z-index: 999; opacity: 0; transition: opacity .3s; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.show { opacity: 1; }

.mobile-nav { display: none; }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-w)); top: 0; bottom: 0; z-index: 100; transition: left .2s; box-shadow: 2px 0 12px rgba(0,0,0,.1); }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .mobile-nav {
    display: flex; gap: 8px; padding: 8px 16px; background: #fff; color: var(--text);
    align-items: center; font-size: 14px; border-bottom: 1px solid var(--border);
  }
  .mobile-nav .menu-btn { cursor: pointer; font-size: 20px; }
}

/* ---------- 编辑弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex;
  align-items: center; justify-content: center; z-index: 500; padding: 16px;
}
.modal {
  background: var(--card); border-radius: 12px; padding: 24px; width: 100%; max-width: 560px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2); max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 16px; margin-bottom: 16px; }
.modal .row { margin-bottom: 4px; }
.modal .field input, .modal .field select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- 可搜索下拉 ---------- */
.field { position: relative; }
.ss-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 300;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  max-height: 280px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  display: none; margin-top: 2px;
}
.ss-item {
  padding: 8px 12px; cursor: pointer; font-size: 13px; display: flex;
  justify-content: space-between; gap: 8px; align-items: center;
}
.ss-item:hover { background: #f3f4f6; }
.ss-extra { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ss-hidden { display: none; }

/* ---------- 表格合计行 + 分页条（全列表通用） ---------- */
tfoot td {
  background: #f9fafb; font-weight: 600; border-top: 2px solid var(--border);
  border-bottom: none; white-space: nowrap;
}
tfoot td.tk-sum { color: var(--text); }
.tk-pager {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
  padding: 10px 2px 2px; font-size: 12px; flex-wrap: wrap;
}
.tk-pager select { padding: 3px 6px; font-size: 12px; border-radius: 6px; height: 28px; }
.tk-pager .tk-info { color: var(--muted); }
.tk-pager .muted { margin: 0; }

/* ============================================================
   单据表格制式（参考主流 ERP 单据界面：单据头网格 + 明细表 + 合计 + 底部信息）
   用于采购入库 / 销售开单 / 退货 / 核价 / 收付款 / 冲抵 / 盘点
   ============================================================ */
.sheet {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; margin-bottom: 16px;
}
.sheet-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: #fafbfc; border-bottom: 1px solid var(--border);
}
.sheet-bar .spacer { flex: 1; }
.sheet-bar .sheet-no { font-size: 12px; color: var(--muted); }
.sheet-bar .sheet-no strong { color: var(--text); font-weight: 600; }

/* ---- 单据头：标签 + 控件 网格 ---- */
.sheet-head { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sheet-head th {
  width: 88px; background: #f8fafc; color: #4b5563; font-weight: 500; font-size: 12.5px;
  text-align: right; padding: 0 8px; height: 36px; border: 1px solid var(--border);
  white-space: nowrap;
}
.sheet-head th.req::before { content: '*'; color: var(--danger); margin-right: 2px; }
.sheet-head td {
  padding: 0 6px; height: 36px; border: 1px solid var(--border); background: #fff;
}
.sheet-head td input, .sheet-head td select, .sheet-head td .ss-wrap input {
  width: 100%; height: 32px; border: none; background: transparent;
  font-size: 13px; padding: 0 4px; color: var(--text);
}
.sheet-head td input:focus, .sheet-head td select:focus { outline: none; background: #eff6ff; border-radius: 4px; }

/* ---- 明细表 ---- */
.sheet-scroll { overflow-x: auto; }
/* table-layout:fixed 让 thead 的列宽严格生效，tfoot 的 colspan 合计行
   不会反过来撑宽某几列导致与表头列边界错位 */
.sheet-items { width: 100%; border-collapse: collapse; min-width: 900px; table-layout: fixed; }
.sheet-items thead th {
  background: #f8fafc; border: 1px solid var(--border); font-size: 12px; font-weight: 600;
  color: #374151; padding: 7px 6px; white-space: nowrap; text-align: center;
}
.sheet-items thead th .sub { display: block; font-weight: 400; color: var(--muted); font-size: 10.5px; }
.sheet-items tbody td {
  border: 1px solid var(--border); height: 34px; padding: 1px 4px; font-size: 13px;
  vertical-align: middle;
}
.sheet-items tbody td input, .sheet-items tbody td select {
  width: 100%; height: 30px; border: none; background: transparent; font-size: 13px;
  padding: 0 4px; color: var(--text); text-align: right;
}
.sheet-items tbody td input.txt, .sheet-items tbody td select { text-align: left; }
.sheet-items tbody td input:focus, .sheet-items tbody td select:focus {
  outline: none; background: #eff6ff; border-radius: 4px;
}
.sheet-items tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-items tbody td.ctr { text-align: center; }
.sheet-items tbody td.sn { text-align: center; color: var(--muted); font-size: 12px; width: 40px; }
.sheet-items tbody tr:hover td { background: #fcfdff; }
.sheet-items tfoot td {
  border: 1px solid var(--border); background: #f8fafc; font-weight: 600; font-size: 13px;
  height: 34px; padding: 2px 8px;
}
.sheet-items tfoot td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-items .row-del {
  border: 1px solid #fca5a5; background: #fff; color: var(--danger); border-radius: 4px;
  width: 22px; height: 22px; line-height: 1; cursor: pointer; font-size: 13px;
}
.sheet-items .row-del:hover { background: #fef2f2; }

/* ---- 底部信息网格（结算 / 备注 / 附加）---- */
.sheet-foot { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sheet-foot th {
  width: 88px; background: #f8fafc; color: #4b5563; font-weight: 500; font-size: 12.5px;
  text-align: right; padding: 0 8px; height: 36px; border: 1px solid var(--border);
  white-space: nowrap;
}
.sheet-foot td { padding: 0 6px; height: 36px; border: 1px solid var(--border); }
.sheet-foot td input, .sheet-foot td select {
  width: 100%; height: 32px; border: none; background: transparent; font-size: 13px; padding: 0 4px;
}
.sheet-foot td input:focus, .sheet-foot td select:focus { outline: none; background: #eff6ff; border-radius: 4px; }
.sheet-foot td .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.sheet-foot td .amt.primary { color: var(--primary); }

/* 单据汇总条（右侧合计显示，紧凑） */
.sheet-totals {
  display: flex; justify-content: flex-end; gap: 22px; padding: 10px 14px;
  background: #fafbfc; border-top: 1px solid var(--border); font-size: 13px; flex-wrap: wrap;
}
.sheet-totals .t { display: flex; gap: 6px; align-items: baseline; }
.sheet-totals .t span:first-child { color: var(--muted); font-size: 12px; }
.sheet-totals .t span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.sheet-totals .t.big span:last-child { font-size: 16px; color: var(--primary); }

/* 单据表格内的可搜索下拉需要定位上下文 */
.sheet-head td, .sheet-foot td, .sheet-items tbody td { position: relative; }
.sheet-items tbody td .ss-list { min-width: 220px; right: auto; }
.sheet-items tbody td .ss-list .ss-item { padding: 6px 10px; }
.sheet-head td .ss-list { min-width: 240px; right: auto; }
/* 子表（其他费用等） */
.sheet-sub { width: 100%; border-collapse: collapse; }
.sheet-sub thead th {
  background: #f8fafc; border: 1px solid var(--border); font-size: 12px; font-weight: 600;
  padding: 6px; color: #374151;
}
.sheet-sub tbody td { border: 1px solid var(--border); height: 34px; padding: 1px 4px; }
.sheet-sub tbody td input, .sheet-sub tbody td select {
  width: 100%; height: 30px; border: none; background: transparent; font-size: 13px; padding: 0 4px;
}
.sheet-sub tbody td input:focus, .sheet-sub tbody td select:focus { outline: none; background: #eff6ff; }
.sel-fuzzy {
  width: 100%; margin-bottom: 4px; padding: 4px 8px; font-size: 12px;
  border: 1px dashed var(--border); border-radius: 6px; background: #fafbfc;
}
.sel-fuzzy:focus { border-style: solid; border-color: var(--primary); background: #fff; outline: none; }
.sheet-sub .row-del {
  border: 1px solid #fca5a5; background: #fff; color: var(--danger); border-radius: 4px;
  width: 22px; height: 22px; line-height: 1; cursor: pointer;
}
.sheet-sub-title {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fafbfc;
  border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; color: #374151;
}
.sheet-sub-title .muted { margin: 0; font-weight: 400; }

/* ============================================================
   开单内联新增客户 / 供应商（客户/供应商栏后面的「+」按钮）
   ============================================================ */
.party-pick { display: flex; align-items: center; gap: 4px; position: relative; }
.party-pick > input, .party-pick > select { flex: 1 1 auto; min-width: 0; }
.sheet-head td .party-pick input,
.sheet-head td .party-pick select { width: auto; flex: 1 1 auto; }
.party-add {
  flex: 0 0 auto; width: 24px; height: 24px; padding: 0; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #bfdbfe; background: #eff6ff; color: var(--primary);
  border-radius: 6px; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background .15s, color .15s;
}
.party-add:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.party-add:disabled { opacity: .45; cursor: not-allowed; background: #f3f4f6; border-color: var(--border); color: var(--muted); }
/* 新增主体弹窗：两列表单 */
.pm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.pm-grid .field { margin: 0; }
.pm-grid .field.full { grid-column: 1 / -1; }
.pm-tip { font-size: 12px; color: var(--muted); margin: -4px 0 12px; line-height: 1.5; }

/* ============================================================
   单据详情页（P1）：抬头 + 状态条 + 金额条 + 关联单据
   ============================================================ */
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.doc-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-no { font-size: 22px; font-weight: 600; letter-spacing: .5px; }
.doc-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.doc-actions { display: flex; gap: 8px; flex-shrink: 0; }
/* 统一制式的单据正文（A4 纸张观感，样式见 css/paper.css） */
.doc-paper-wrap { margin-bottom: 16px; }
.doc-paper-wrap .paper { margin: 0 auto; box-shadow: 0 2px 10px rgba(16,24,40,.07); }

/* 状态条：开单 → 提货 → 定价 → 收款 */
.flow {
  display: flex; align-items: stretch; gap: 0; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px;
}
.flow-step { display: flex; align-items: center; gap: 10px; flex: 1 1 0; min-width: 0; }
.flow-dot {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  border: 2px solid #d1d5db; color: #9ca3af; background: #fff;
}
.flow-step.done .flow-dot { border-color: var(--green); background: var(--green); color: #fff; }
.flow-step.doing .flow-dot { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.flow-step.warn .flow-dot { border-color: var(--danger); color: var(--danger); background: #fee2e2; }
.flow-body { min-width: 0; }
.flow-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.flow-step.done .flow-label, .flow-step.doing .flow-label { color: var(--text); }
.flow-meta { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.flow-arrow { flex: 0 0 24px; height: 2px; background: var(--border); align-self: center; margin: 0 6px; }

/* 金额条配色 */
.summary .stat.ok-stat { border-left-color: var(--green); }
.summary .stat.warn-stat { border-left-color: var(--amber); }
.summary .stat.danger-stat { border-left-color: var(--danger); }
.summary .stat.muted-stat { border-left-color: #d1d5db; }
.summary .stat .value small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }

/* 主体余额横幅 */
.banner {
  background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 13px; color: var(--text); margin-bottom: 16px;
}
.muted-inline { color: var(--muted); font-size: 12px; font-weight: 400; }
.muted-cell { color: var(--muted); }
.doc-foot { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.doc-note { margin-top: 6px; color: var(--text); }
a.doc-link:hover { text-decoration: underline; }

/* ============================================================
   页签（退货与红冲等把相关操作收在一个入口）
   ============================================================ */
.tabs {
  display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.tabs a {
  display: flex; align-items: baseline; gap: 6px; padding: 10px 16px;
  font-size: 14px; color: var(--muted); cursor: pointer; margin-bottom: -1px;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.tabs .tab-icon { font-size: 15px; line-height: 1; }
.tabs .tab-hint { font-size: 11px; color: #9ca3af; font-weight: 400; }
.tabs a.active .tab-hint { color: var(--primary); opacity: .75; }

/* 页内说明 */
.page-note { font-size: 13px; color: var(--muted); line-height: 1.75; margin: -4px 0 14px; }
.page-note strong { color: var(--text); font-weight: 600; }

/* ============================================================
   往来一张纸（P4）：客户视图 / 供应商视图
   ============================================================ */
.pv-sub {
  font-size: 13px; font-weight: 600; color: var(--text); margin: 16px 0 8px;
  padding-top: 12px; border-top: 1px dashed var(--border);
}
.card > .pv-sub:first-of-type { margin-top: 4px; padding-top: 0; border-top: none; }

/* 账龄四格 */
.aging {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 8px;
  align-items: center; margin: 4px 0 12px;
}
.aging-title { font-size: 12px; color: var(--muted); }
.aging-cell { background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.aging-cell.d60 { background: #fffbeb; border-color: #fde68a; }
.aging-cell.d90, .aging-cell.over { background: #fef2f2; border-color: #fecaca; }
.aging-label { font-size: 11px; color: var(--muted); }
.aging-value { font-size: 14px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .aging { grid-template-columns: 1fr 1fr; }
  .aging-title { grid-column: 1 / -1; }
}

/* 近 12 个月走势 */
.trend { display: flex; flex-direction: column; gap: 6px; }
.trend-row { display: flex; align-items: center; gap: 10px; }
.trend-m { width: 52px; flex: 0 0 52px; font-size: 12px; color: var(--muted); }
.trend-bars { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.trend-bar {
  height: 14px; border-radius: 3px; min-width: 2px; position: relative;
  transition: width .3s;
}
.trend-bar span {
  position: absolute; left: calc(100% + 6px); top: 0; font-size: 11px;
  color: var(--muted); white-space: nowrap; line-height: 14px;
}
.trend-bar.sold { background: #fca5a5; }
.trend-bar.bought { background: #93c5fd; }
.trend-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.trend-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; }
.trend-legend .dot.sold { background: #fca5a5; }
.trend-legend .dot.bought { background: #93c5fd; }

/* 工具栏里的小勾选 */
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.chk input { width: auto; }

/* ============================================================
   单据打印预览（应用内弹层，不依赖新窗口，避免被拦弹窗）
   ============================================================ */
.print-overlay { z-index: 900; background: rgba(15,23,42,.55); padding: 18px; }
.print-modal {
  width: 960px; max-width: 97vw; height: 94vh; background: #fff;
  border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
}
.print-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #f8fafc; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.print-bar .spacer { flex: 1; }
.print-bar-title { font-size: 14px; font-weight: 600; color: var(--text); }
.print-frame { flex: 1 1 auto; width: 100%; border: 0; background: #eef2f7; }
@media print { .print-overlay { display: none !important; } }

/* ============================================================
   系统更新（系统设置里）
   ============================================================ */
.upd-new {
  margin-top: 12px; padding: 14px 16px; border: 1px solid #bfdbfe;
  background: #f5f9ff; border-radius: 8px;
}
.upd-new-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.upd-new-head b { font-size: 15px; color: #1d4ed8; }
.upd-notes {
  margin: 8px 0 12px; font-size: 13px; color: #374151; line-height: 1.75;
  white-space: pre-wrap; max-height: 220px; overflow-y: auto;
}
.upd-running { display: flex; align-items: center; gap: 14px; margin-top: 12px; padding: 14px 16px;
  border: 1px solid #fde68a; background: #fffbeb; border-radius: 8px; }
.upd-spinner {
  width: 20px; height: 20px; border: 3px solid #fcd34d; border-top-color: #d97706;
  border-radius: 50%; animation: upd-spin .8s linear infinite; flex: 0 0 auto;
}
@keyframes upd-spin { to { transform: rotate(360deg); } }

/* 数据与备份：键值列表 */
.kv-list { display: grid; gap: 7px; font-size: 13px; }
.kv-list > div { display: flex; gap: 12px; align-items: baseline; }
.kv-list > div > span:first-child { flex: 0 0 96px; color: var(--muted); }
.kv-list code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  color: #374151; word-break: break-all; background: #f6f8fb; padding: 1px 6px; border-radius: 4px;
}

/* ============================================================
   用户与权限 / 系统初始化
   ============================================================ */
/* 权限标签 */
.perm-tags { font-size: 12.5px; color: #374151; }
/* 弹窗里的权限勾选区 */
.perm-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 16px 0 8px; }
.perm-mode { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.perm-mode input { margin: 0; }
.perm-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px 12px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 8px; background: #fafcff; max-height: 220px; overflow-y: auto;
}
.perm-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.perm-item input { margin: 0; }
.perm-grid.perm-locked { background: #f6f8fb; }
.perm-grid.perm-locked .perm-item { color: var(--muted); cursor: default; }

/* 危险区域（系统初始化） */
.card.danger-zone { border: 1px solid #fecaca; background: #fffafa; }
.card.danger-zone h2 { color: #b91c1c; }
.reset-opts { display: grid; gap: 8px; margin: 14px 0; }
.reset-opts label {
  display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer;
}
.reset-opts label:hover { border-color: #fca5a5; }
.reset-opts input { margin: 3px 0 0; }
.reset-opts b { display: block; font-size: 13px; color: var(--text); }
.reset-opts em { font-style: normal; font-size: 12px; color: var(--muted); }
.reset-confirm { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 12px; border-top: 1px dashed #f3d0d0; font-size: 13px; }
/* 危险操作只在这个区块用实心红；列表里的「删除」保持轻量文字按钮 */
.card.danger-zone .btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.card.danger-zone .btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.card.danger-zone .btn.danger:disabled { background: #f3b4b4; border-color: #f3b4b4; cursor: not-allowed; }

/* 手机版入口提示（系统设置 → 我的账号） */
.m-v-hint {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: #475569;
}
.m-v-hint code {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: #f4f7fb;
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; color: #1d4ed8;
}

/* ===== 库存台账 ===== */
.subtabs {
  display: flex; gap: 4px; margin: 0 0 16px;
  border-bottom: 1px solid var(--border);
}
.subtab {
  padding: 9px 18px; background: none; border: none;
  border-bottom: 2px solid transparent; color: #64748b;
  font-size: 14px; cursor: pointer; transition: color .12s, border-color .12s;
}
.subtab:hover { color: var(--primary); }
.subtab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.card-head h2 { margin: 0; }
.card-head .muted { font-size: 12px; }

.stk-table-wrap { max-height: 380px; overflow: auto; }
.stk-table-wrap thead th, .table-scroll thead th {
  position: sticky; top: 0; z-index: 2; background: #f8fafc;
}
.stk-row { cursor: pointer; }
.stk-row:hover { background: #f8fafc; }
.stk-row.sel { background: #eff6ff; }
.stk-row.sel td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

.stk-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin: 4px 0 14px;
}
.stk-stat {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
}
.stk-stat span { display: block; font-size: 12px; color: var(--muted); }
.stk-stat b { display: block; font-size: 15px; margin-top: 2px; }
.stk-stat small { font-size: 11px; color: var(--muted); }

.table-scroll { max-height: 560px; overflow: auto; }
.stk-foot {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
  padding: 10px 4px 2px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); margin-top: 4px;
}
.stk-foot b { color: var(--text); font-size: 13px; }

/* ===== AI 助手 ===== */
.ai-layout { display: flex; flex-direction: column; gap: 16px; max-width: 1000px; }
.ai-chat-card { display: flex; flex-direction: column; }
.ai-chat-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.ai-chat-head b { font-size: 15px; margin-right: 6px; }
.ai-log {
  height: min(52vh, 460px); overflow-y: auto;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.ai-msg { display: flex; gap: 8px; align-items: flex-start; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-avatar {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
  background: #e2e8f0; color: #475569; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700;
}
.ai-msg.user .ai-avatar { background: var(--primary); color: #fff; }
.ai-bubble {
  max-width: 78%; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px;
  line-height: 1.65; white-space: pre-wrap; word-break: break-word;
}
.ai-msg.user .ai-bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.ai-bubble.error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.ai-welcome { color: var(--text); font-size: 13px; line-height: 1.7; }
.ai-welcome-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.ai-quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.ai-chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 12px; color: #475569; cursor: pointer;
}
.ai-chip:hover { border-color: var(--primary); color: var(--primary); }
.ai-input-row { display: flex; gap: 8px; align-items: flex-end; }
.ai-input-row textarea {
  flex: 1; resize: none; min-height: 40px; max-height: 120px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; line-height: 1.5; font-family: inherit;
}
.ai-input-row textarea:focus { outline: none; border-color: var(--primary); }
.ai-tip { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.ai-typing i {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #94a3b8; margin-right: 4px;
  animation: ai-bounce 1s infinite;
}
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.ai-cfg-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px;
}
.ai-cfg-grid .field.full { grid-column: 1 / -1; }
@media (max-width: 700px) {
  .ai-cfg-grid { grid-template-columns: 1fr; }
  .ai-bubble { max-width: 86%; }
  .ai-log { height: 46vh; }
}

/* hidden 属性要压过 .toolbar 等 display:flex */
[hidden] { display: none !important; }

/* ===== 页面级操作条：标题 + 一句话说明 + 右侧动作 ===== */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.page-head .page-title { margin-bottom: 2px; }
.page-sub { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions .btn { white-space: nowrap; }
@media (max-width: 760px) {
  .page-head { flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
}

/* 行内复选框（如「手动指定单据」） */
.inline-check {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text); margin: 0; cursor: pointer; font-weight: 500;
}
.inline-check input { width: auto; margin: 0; }

/* ===== 每日简报 / 催款清单 ===== */
.brief-top {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px; margin-bottom: 16px;
}
.brief-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.brief-card-head h2 { margin: 0; }
.brief-points { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 7px; }
.brief-points li {
  position: relative; padding-left: 18px; font-size: 13.5px;
  line-height: 1.7; color: #334155;
}
.brief-points li::before {
  content: ''; position: absolute; left: 2px; top: 9px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
}
.brief-ai-box { border-top: 1px dashed var(--border); padding-top: 10px; }
.brief-ai-text {
  font-size: 13.5px; line-height: 1.8; color: #0f172a; white-space: pre-wrap;
  background: #f7fbff; border: 1px solid #dbeafe; border-radius: 8px; padding: 10px 12px;
}
.brief-ai-empty { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.brief-ai-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.brief-todos { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.brief-todo {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  font-size: 13px; transition: border-color .15s, background .15s;
}
.brief-todo:hover { border-color: var(--primary); background: #f8fbff; }
.brief-todo-label { flex: 1; color: var(--text); }
.brief-todo-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.brief-todo-arrow { color: #94a3b8; }
.brief-mini { border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 8px; }
.brief-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); padding: 3px 0; }
.brief-kv b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.brief-filter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brief-filter #bf-search {
  width: 220px; height: 32px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; background: #fff;
}
.brief-filter #bf-search:focus { outline: none; border-color: var(--primary); }
.brief-kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.brief-kpi { background: #f8fafc; border-radius: 8px; padding: 9px 12px; }
.brief-kpi span { font-size: 12px; color: var(--muted); display: block; }
.brief-kpi b { font-size: 16px; font-weight: 600; margin-top: 3px; display: block; font-variant-numeric: tabular-nums; }
.brief-empty { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px 0; }
@media (max-width: 980px) {
  .brief-top { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .brief-filter { width: 100%; }
  .brief-filter #bf-search { width: 100%; }
  .brief-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 系统设置 · 版本历史（缩略） ===== */
.upd-hist-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin: 16px 0 6px; font-size: 13px; font-weight: 600;
}
.upd-hist-head .muted { font-weight: 400; margin: 0; }
.upd-hist { border-top: 1px solid var(--border); }
.upd-item { border-bottom: 1px solid #eef2f6; }
.upd-item-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 2px;
  font-size: 12.5px; cursor: pointer; user-select: none;
}
.upd-item-head:hover { background: #fafbfc; }
.upd-item-head b { font-size: 13px; min-width: 52px; }
.upd-item-head .muted { margin: 0; white-space: nowrap; }
.upd-summary {
  flex: 1; min-width: 0; color: #475569; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.upd-caret { color: #94a3b8; transition: transform .15s; flex: 0 0 auto; }
.upd-item-head.open .upd-caret { transform: rotate(180deg); }
.upd-full {
  margin: 0 0 10px 60px; padding: 10px 12px; background: #f8fafc;
  border: 1px solid #eef2f6; border-radius: 8px;
  font-size: 12.5px; line-height: 1.75; color: #334155;
  white-space: pre-wrap; word-break: break-word;
}
.upd-hist + .btn { margin-top: 10px; }

/* 只读账号提示条 */
.readonly-note {
  margin: 0 0 12px; padding: 8px 12px; border-radius: 8px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  font-size: 12.5px; line-height: 1.6;
}

/* 只读账号：隐藏页面级主操作按钮（新增/登记/保存入口），写入仍由后端拦截 */
body[data-role="readonly"] .page-actions .btn.primary,
body[data-role="readonly"] .page-actions .btn.danger { display: none; }

/* ===== 发票 / 税点台账 ===== */
.seg-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.seg-tabs button {
  height: 32px; padding: 0 14px; border: 1px solid var(--border); background: #fff;
  border-radius: 999px; font-size: 13px; color: #475569; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.seg-tabs button:hover { border-color: var(--primary); color: var(--primary); }
.seg-tabs button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.card-head { display: flex; align-items: baseline; gap: 8px; }
.card-head .muted { margin: 0; font-size: 12.5px; }
.form-table th { width: 104px; background: #f8fafc; white-space: nowrap; font-weight: 500; }
.form-table td { vertical-align: top; }
.form-table input, .form-table select { width: 100%; }
.form-table .muted { margin: 0; }

/* 资金看板：负余额提示 */
.warn-note {
  padding: 9px 12px; border-radius: 8px; background: #fffbeb;
  border: 1px solid #fde68a; color: #92400e; font-size: 12.5px; line-height: 1.7;
}
