/* ==========================================================================
   进销存管理系统 · 主样式表
   设计目标：清爽、克制、信息密度高；支持浅色/深色主题与 A4 打印
   ========================================================================== */

:root {
  color-scheme: light only;
  --bg: #f2f4f9;
  --bg-soft: #e9edf5;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --ink: #141c2b;
  --ink-2: #42526b;
  --muted: #7d8aa0;
  --line: #e6eaf3;
  --line-strong: #d4dcec;
  --brand: #3565f6;
  --brand-d: #2450d8;
  --brand-soft: #a8c0ff;
  --brand-tint: #edf2ff;
  --accent: #7c5cff;
  --ok: #16a05c;
  --ok-tint: #e5f6ec;
  --warn: #e0870a;
  --warn-tint: #fff4e3;
  --danger: #d93a5b;
  --danger-tint: #fde9ef;
  --shadow-sm: 0 1px 2px rgba(19, 30, 55, .06);
  --shadow: 0 1px 2px rgba(19, 30, 55, .05), 0 8px 24px -12px rgba(19, 30, 55, .18);
  --shadow-lg: 0 24px 60px -20px rgba(12, 20, 40, .38);
  --radius: 14px;
  --radius-sm: 10px;
  --side-w: 236px;
  --side-bg: linear-gradient(180deg, #131d36 0%, #101828 55%, #0c1424 100%);
  --side-ink: #b9c5d8;
  --side-ink-dim: #74869f;
  --side-active: linear-gradient(90deg, rgba(80, 130, 255, .42), rgba(80, 130, 255, .10));
  --topbar-bg: rgba(255, 255, 255, .86);
}

[data-theme="dark"] {
  color-scheme: dark only;
  --bg: #0d131f;
  --bg-soft: #121a29;
  --panel: #161f30;
  --panel-2: #1b2537;
  --ink: #e9eff8;
  --ink-2: #b5c2d4;
  --muted: #8495ac;
  --line: #253349;
  --line-strong: #304059;
  --brand: #6b95ff;
  --brand-d: #5585ff;
  --brand-soft: #31467a;
  --brand-tint: #1a2740;
  --accent: #9b82ff;
  --ok: #33c47f;
  --ok-tint: #122a1f;
  --warn: #eda93a;
  --warn-tint: #2b2113;
  --danger: #f4608a;
  --danger-tint: #2e1620;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px -14px rgba(0, 0, 0, .55);
  --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, .7);
  --side-bg: linear-gradient(180deg, #0f1726 0%, #0b1220 100%);
  --topbar-bg: rgba(20, 28, 44, .82);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s ease, color .18s ease;
}
button, a, .nav-item, .tab, .link, .icon-btn, .close-x, .pager button { touch-action: manipulation; }
.hidden { display: none !important; }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--brand); color: #fff; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ 登录 */
.login-wrap {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; padding: 24px;
  background:
    radial-gradient(1000px 520px at 8% -10%, rgba(70, 115, 235, .28), transparent 62%),
    radial-gradient(820px 460px at 104% 108%, rgba(60, 150, 215, .20), transparent 60%),
    linear-gradient(155deg, #0b1428 0%, #12224a 48%, #1c3c7c 100%);
}
.login-wrap::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .45;
  background-image:
    linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(820px 560px at 50% 45%, #000 25%, transparent 80%);
}
.login-bg { position: absolute; inset: 0; pointer-events: none; }
/* 两团柔光，慢速漂移；reduced-motion 下静止 */
.login-bg i {
  position: absolute; border-radius: 50%; filter: blur(60px); opacity: .30;
  background: radial-gradient(circle at 30% 30%, #6f9dff, transparent 70%);
  animation: float 22s ease-in-out infinite;
}
.login-bg i:nth-child(1) { width: 520px; height: 520px; top: -180px; left: -120px; }
.login-bg i:nth-child(2) { width: 420px; height: 420px; bottom: -200px; right: -120px; animation-delay: -8s; opacity: .22; }
@keyframes float { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-26px) scale(1.05); } }

/* 两栏：左品牌区（深色，与侧栏同色系）+ 右表单区；窄屏收成单栏 */
.login-card {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.02fr 1fr;
  width: 920px; max-width: 100%;
  border-radius: 20px; overflow: hidden; background: #fff;
  box-shadow: 0 34px 80px -34px rgba(4, 12, 30, .8), 0 0 0 1px rgba(255, 255, 255, .10);
  animation: pop .3s cubic-bezier(.2, .9, .3, 1.05);
  /* 登录卡片固定浅色：卡片是白底，若跟随深色主题，文字会变成浅色压在白底上（对比度崩坏）。
   * color 必须显式声明：未声明 color 的后代（如 h2）继承的是 body 的计算色，不吃这里的变量覆盖。 */
  color-scheme: light; color: #141c2b;
  --ink: #141c2b; --ink-2: #42526b; --muted: #7d8aa0;
  --line: #e6eaf3; --line-strong: #d4dcec; --panel-2: #f7f9fc;
  --brand: #3565f6; --brand-d: #2450d8; --danger: #d93a5b;
}
@keyframes pop { from { transform: translateY(14px) scale(.985); opacity: 0; } }
.login-hero {
  position: relative; display: flex; flex-direction: column;
  padding: 40px 36px; color: #e8eefb;
  background: linear-gradient(160deg, #10203f, #16305e 55%, #1c4084);
}
.login-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: radial-gradient(420px 300px at 85% 100%, #000, transparent 75%);
}
.hero-mark {
  width: 46px; height: 46px; border-radius: 13px; color: #8fb6ff;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16);
}
.hero-mark svg.ico { width: 25px; height: 25px; }
.login-hero h1 { margin: 24px 0 0; font-size: 21px; line-height: 1.35; color: #fff; letter-spacing: .2px; }
.hero-sub { margin: 9px 0 0; font-size: 12.5px; color: #9fb4d8; letter-spacing: .3px; }
.hero-points { list-style: none; margin: 30px 0 0; padding: 0; display: flex; flex-direction: column; gap: 15px; }
.hero-points li { display: flex; gap: 10px; font-size: 13px; line-height: 1.55; color: #c6d5ee; }
.hero-points svg.ico { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 3px; color: #6f9dff; }
.hero-foot { margin-top: auto; padding-top: 30px; font-size: 11.5px; color: #7f93b8; }
.login-side { padding: 40px 36px 26px; }
.login-head h2 { margin: 0; font-size: 19px; }
.login-head p { margin: 6px 0 22px; color: var(--muted); font-size: 12.5px; }
.login-card label {
  position: relative; display: block; margin-bottom: 14px;
  font-size: 12.5px; color: var(--ink-2); font-weight: 500;
}
.login-card input, .login-card select {
  width: 100%; margin-top: 7px; padding: 12px 13px 12px 38px;
  border: 1px solid var(--line); border-radius: 11px; font-size: 14px;
  background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.login-card input:hover, .login-card select:hover { border-color: #c3ccdb; }
.login-card input:focus, .login-card select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(53, 101, 246, .13);
}
.login-card select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b94a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 15px;
}
.input-ico {
  position: absolute; left: 12px; bottom: 12px; opacity: .5;
  pointer-events: none; display: inline-flex; align-items: center;
}
.input-ico svg.ico { width: 16px; height: 16px; }
.pass-eye {
  position: absolute; right: 9px; bottom: 8px; width: 30px; height: 30px;
  border: none; background: none; cursor: pointer; color: var(--ink-2);
  border-radius: 8px; opacity: .55;
  display: inline-flex; align-items: center; justify-content: center;
}
.pass-eye svg.ico { width: 16px; height: 16px; }
.pass-eye:hover { opacity: 1; background: var(--panel-2); }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; }
.login-tip { color: var(--muted); font-size: 11.5px; margin: 16px 0 0; line-height: 1.65; }
/* 登录按钮用品牌色实色：比渐变更克制，也让首屏视觉重心落在表单 */
#login-btn {
  background: var(--brand); background-image: none;
  box-shadow: 0 10px 24px -12px rgba(53, 101, 246, .9);
}
#login-btn:hover { background: var(--brand-d); filter: none; transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) {
  .login-bg i, .login-card { animation: none; }
  #login-btn:hover { transform: none; }
}
/* 品牌标记：登录页与侧栏共用 */
.logo {
  width: 46px; height: 46px; flex: 0 0 46px; border-radius: 14px;
  background: linear-gradient(140deg, #3565f6, #45c0ff);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px;
  box-shadow: 0 6px 16px -6px rgba(53, 101, 246, .7);
}
@media (max-width: 880px) {
  .login-card { grid-template-columns: 1fr; width: 432px; }
  .login-hero { padding: 26px 26px 24px; }
  .login-hero h1 { margin-top: 16px; font-size: 18px; }
  .hero-points, .hero-foot { display: none; }
  .login-side { padding: 26px 26px 20px; }
}

/* ------------------------------------------------------------------ 布局 */
.app { display: flex; min-height: 100%; }
#scrim { position: fixed; inset: 0; background: rgba(10, 16, 28, .5); z-index: 19; display: none; }
#scrim.show { display: block; }

.sidebar {
  width: var(--side-w); background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 20;
  transition: width .18s ease, transform .2s ease;
}
.side-head {
  display: flex; gap: 11px; align-items: center;
  padding: 18px 14px; border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.side-title { flex: 1; min-width: 0; }
.side-title b {
  display: block; font-size: 15px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-title small { color: var(--side-ink-dim); font-size: 11px; }
.side-head .logo { width: 38px; height: 38px; flex: 0 0 38px; font-size: 19px; border-radius: 11px; }
.collapse { color: var(--side-ink-dim); }
.collapse:hover { color: #fff; }

#nav { flex: 1; overflow-y: auto; padding: 10px 0 18px; }
#nav::-webkit-scrollbar { width: 6px; }
/* 内联 SVG 图标统一尺寸；颜色走 currentColor，跟随所在区域的前景色 */
svg.ico { width: 17px; height: 17px; display: block; flex: 0 0 auto; }

.nav-plain { margin-bottom: 4px; }

/* ---- 侧栏目录树：外层只显示分类，点击展开子项 ---- */
.nav-sec { margin: 1px 0 2px; }
.nav-sec-head {
  position: relative;
  display: flex; align-items: center; gap: 10px; width: calc(100% - 20px);
  margin: 0 10px; padding: 9px 12px;
  background: none; border: none; cursor: pointer; text-align: left;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--side-ink);
  border-radius: 10px; transition: background .14s ease, color .14s ease;
}
.nav-sec-head .ni {
  width: 26px; height: 26px; flex: 0 0 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(255, 255, 255, .05);
  transition: background .14s ease;
}
.nav-sec-head .nl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-sec-head .chev { opacity: .5; transition: transform .18s ease; }
.nav-sec.open > .nav-sec-head .chev { transform: rotate(90deg); }
.nav-sec-head:hover { background: rgba(255, 255, 255, .07); color: #fff; }
/* 当前页藏在哪个分类里就把那个分类点亮，收起状态也能定位自己 */
.nav-sec.has-active > .nav-sec-head { color: #fff; }
.nav-sec.has-active > .nav-sec-head .ni { background: rgba(110, 160, 255, .22); }

.nav-sec-body { max-height: 0; overflow: hidden; transition: max-height .2s ease; }
.nav-sec.open .nav-sec-body { max-height: 520px; }
.nav-sec-inner {
  margin: 2px 10px 4px 25px; padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, .12);
}
.nav-sec-inner .nav-item { margin: 1px 0; }
.nav-sec-inner .nav-item.active::before { left: -11px; }

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px; margin: 2px 10px; padding: 9px 12px;
  cursor: pointer; font-size: 13.5px; border-radius: 10px;
  transition: background .14s ease, color .14s ease;
}
.nav-item .ni {
  width: 26px; height: 26px; flex: 0 0 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(255, 255, 255, .05);
  transition: background .14s ease, transform .14s ease;
}
.nav-item .nl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item:hover .ni { background: rgba(255, 255, 255, .10); }
.nav-item.active {
  background: var(--side-active); color: #fff; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(120, 165, 255, .28);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 20%; bottom: 20%; width: 3px;
  border-radius: 0 3px 3px 0; background: linear-gradient(180deg, #6ea0ff, #45c0ff);
  box-shadow: 0 0 8px rgba(90, 150, 255, .8);
}
.nav-item.active .ni { background: rgba(110, 160, 255, .28); }
.side-foot {
  padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: 12px; color: var(--side-ink-dim);
  display: flex; align-items: center; gap: 8px;
}
#side-user { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%;
  background: linear-gradient(140deg, #4f7dff, #45c0ff); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .14);
}
#side-user .who { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; }
#side-user .who b {
  color: #e7edf6; font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#side-user .who small { color: var(--side-ink-dim); font-size: 11px; }
.side-foot .link { color: #93b4ff; background: none; border: none; cursor: pointer; font-size: 12px; }
.side-foot .link:hover { color: #fff; }

/* 图标条模式：只留分类图标；点分类会先展开侧栏再展开该类（见 main.js） */
body.nav-collapsed .sidebar { width: 66px; }
body.nav-collapsed .side-title,
body.nav-collapsed #side-user .who,
body.nav-collapsed .side-foot .link { display: none; }
body.nav-collapsed .nav-sec-body { display: none; }
body.nav-collapsed .nav-sec-head { justify-content: center; width: calc(100% - 12px); margin: 0 6px; padding: 10px 0; }
body.nav-collapsed .nav-sec-head .nl,
body.nav-collapsed .nav-sec-head .chev { display: none; }
body.nav-collapsed .nav-item { justify-content: center; padding: 10px 0; }
body.nav-collapsed .nav-item .nl { display: none; }
body.nav-collapsed .main { margin-left: 66px; }
body.nav-collapsed .side-head { justify-content: center; padding: 18px 6px; }
body.nav-collapsed .side-foot { justify-content: center; }
body.nav-collapsed #side-user { flex: 0 0 auto; }

.main { flex: 1; margin-left: var(--side-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; background: var(--topbar-bg); backdrop-filter: blur(10px) saturate(1.4);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 12;
  border-bottom: 1px solid var(--line);
}
.title-block { flex: 1; min-width: 0; }
.topbar h2 { font-size: 18px; margin: 0; letter-spacing: .2px; line-height: 1.25; }
.crumb { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.crumb .sep { margin: 0 5px; color: var(--line-strong); }
.crumb b { color: var(--ink-2); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  background: none; border: none; font-size: 19px; cursor: pointer; color: var(--ink-2);
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn svg.ico { width: 19px; height: 19px; }
.icon-btn.theme { font-size: 16px; }
.money-badge { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2);
  white-space: nowrap;
}
.pill i { font-style: normal; font-size: 12px; opacity: .85; display: inline-flex; align-items: center; }
.pill i svg.ico { width: 13px; height: 13px; }
.pill b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pill.in b { color: var(--danger); }
.pill.out b { color: var(--warn); }
.pill.cash b { color: var(--ok); }
.content { padding: 20px 22px 48px; }

/* ------------------------------------------------------------------ 卡片 */
/* 工作台直达入口 */
.quick-panel { margin-bottom: 18px; }
.quick-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 10px; padding: 14px;
}
.quick {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.quick:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-1px); }
.quick:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.quick .qi {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-tint); color: var(--brand);
}
.quick .qi svg.ico { width: 19px; height: 19px; }
.quick .qt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.quick .qt b { font-size: 13.5px; font-weight: 600; }
.quick .qt small { font-size: 11.5px; color: var(--muted); }
.quick .qgo { opacity: 0; transform: translateX(-4px); transition: opacity .14s ease, transform .14s ease; }
.quick:hover .qgo { opacity: 1; transform: none; color: var(--brand); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  position: relative; background: var(--panel); border-radius: var(--radius);
  padding: 15px 16px 14px; box-shadow: var(--shadow);
  border: 1px solid var(--line); overflow: hidden;
  transition: transform .14s ease, box-shadow .14s ease;
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--accent, #7c5cff));
  opacity: 0; transition: opacity .16s ease;
}
.card:hover::before { opacity: 1; }
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(19, 30, 55, .06), 0 16px 34px -18px rgba(19, 30, 55, .28);
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .label { color: var(--muted); font-size: 12px; }
.card .card-icon {
  font-size: 14px; width: 30px; height: 30px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-tint);
}
.card .card-icon svg.ico { width: 17px; height: 17px; }
.card.up .card-icon { background: var(--ok-tint); }
.card.down .card-icon { background: var(--danger-tint); }
.card.warn .card-icon { background: var(--warn-tint); }
.card .value {
  font-size: 22px; font-weight: 700; margin-top: 8px;
  letter-spacing: -.2px; font-variant-numeric: tabular-nums;
}
.card .sub { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.card.up .value { color: var(--ok); }
.card.down .value { color: var(--danger); }
.card.warn .value { color: var(--warn); }

.panel {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 18px; border: 1px solid var(--line);
}
.panel h3 { margin: 0; font-size: 15px; font-weight: 600; position: relative; padding-left: 12px; }
.panel h3::before {
  content: ""; position: absolute; left: 0; top: 3px; bottom: 3px; width: 4px;
  border-radius: 4px; background: linear-gradient(180deg, var(--brand), #45c0ff);
}
.panel-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  padding-bottom: 12px; border-bottom: 1px dashed var(--line);
}
.panel-head .hint { margin-left: auto; max-width: 60%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
.loading-panel {
  display: flex; align-items: center; gap: 10px; color: var(--muted);
  justify-content: center; padding: 40px;
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--brand);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th, td {
  padding: 10px 11px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
th {
  color: var(--muted); font-weight: 600; font-size: 12px;
  background: linear-gradient(180deg, var(--panel-2), color-mix(in srgb, var(--panel-2) 88%, var(--brand) 4%));
  position: sticky; top: 0; z-index: 2;
  letter-spacing: .3px;
  border-bottom: 1px solid var(--line-strong);
}
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--brand-tint); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td.num { font-weight: 600; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 30px; opacity: .5; margin-bottom: 6px; }
.empty p { margin: 0; }
.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.txt-danger { color: var(--danger); }
.txt-ok { color: var(--ok); }
.txt-warn { color: var(--warn); }
.txt-muted { color: var(--muted); }

/* 标签 */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px;
  background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line);
}
.tag.svc { background: #f0e9ff; color: #6d3fd6; border-color: #e0d4ff; }
.tag.goods { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.tag.kind-sale { background: var(--brand-tint); color: var(--brand); border-color: transparent; }
.tag.kind-purchase { background: var(--ok-tint); color: var(--ok); border-color: transparent; }
.tag.kind-sale_return { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.tag.kind-purchase_return { background: var(--warn-tint); color: var(--warn); border-color: transparent; }
[data-theme="dark"] .tag.svc { background: #241b3a; color: #b79bff; border-color: #322650; }

/* ------------------------------------------------------------------ 筛选/工具条 */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow, .filter-bar .grow { flex: 1; }
.toolbar input, .toolbar select, .filter-bar input, .filter-bar select {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); font-size: 13px; color: var(--ink); font-family: inherit;
}
.toolbar input:focus, .toolbar select:focus,
.filter-bar input:focus, .filter-bar select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(53, 101, 246, .14);
}
.toolbar input[type=search], .filter-bar input[type=search] { width: 200px; }
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 14px;
  padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px;
}
.filter-bar input[type=search] { width: 210px; }
.check {
  display: inline-flex; gap: 5px; align-items: center;
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.hint { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------------ 按钮 */
.btn {
  padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 500;
  transition: .14s ease; box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--accent, #7c5cff));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px -8px rgba(53, 101, 246, .8);
}
.btn.primary:hover { color: #fff; filter: brightness(1.06); }
.btn.ghost { background: var(--panel-2); border-color: transparent; color: var(--ink-2); box-shadow: none; }
.btn.ghost:hover { color: var(--brand); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { color: #fff; filter: brightness(1.06); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.link {
  background: none; border: none; color: var(--brand); cursor: pointer;
  padding: 0 5px; font-size: 13px; border-radius: 6px;
}
.link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); }
.link.print { color: var(--ink-2); }
.link.print:hover { color: var(--brand); }

/* ------------------------------------------------------------------ 徽标 */
.badge { display: inline-block; padding: 2.5px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; }
.badge.draft { background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); }
.badge.confirmed, .badge.paid { background: var(--ok-tint); color: var(--ok); }
.badge.cancelled, .badge.unpaid { background: var(--danger-tint); color: var(--danger); }
.badge.low, .badge.partial { background: var(--warn-tint); color: var(--warn); }
.badge.void { background: var(--panel-2); color: var(--muted); }
/* 开票 × 收款的四类组合（app/services/invoices.py 的 doc_states.combo）：
   已开票未收款 = 该催的钱 → 红；未开票未收款 = 待开票又挂应收 → 橙；
   已开票已收款 = 两清 → 绿；未开票已收款 = 钱已收只欠票 → 灰。 */
.badge.invoiced_unpaid { background: var(--danger-tint); color: var(--danger); }
.badge.invoiced_paid { background: var(--ok-tint); color: var(--ok); }
.badge.uninvoiced_unpaid { background: var(--warn-tint); color: var(--warn); }
.badge.uninvoiced_paid { background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); }

/* ------------------------------------------------------------------ 分页 */
.pager {
  display: flex; gap: 8px; align-items: center; justify-content: flex-end;
  margin-top: 14px; font-size: 12.5px; color: var(--muted);
}
.pager button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 5px 11px; cursor: pointer; color: var(--ink-2);
}
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager button:disabled { opacity: .4; cursor: default; }

/* ------------------------------------------------------------------ 弹窗/表单 */
.mask {
  position: fixed; inset: 0; background: rgba(9, 15, 27, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--panel); border-radius: 16px; width: 580px; max-width: 100%; max-height: 92vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  animation: rise .2s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes rise { from { transform: translateY(16px) scale(.985); opacity: 0; } }
.modal.wide { width: 1100px; }
.modal.head { padding: 0; }
.modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 15.5px; flex: 1; font-weight: 600; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 9px; background: var(--panel-2);
  border-radius: 0 0 16px 16px;
}
.close-x {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--muted); line-height: 1;
}
.close-x:hover { color: var(--danger); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 15px; }
.fields.one { grid-template-columns: 1fr; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: var(--panel); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(53, 101, 246, .14);
}
.field.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; padding-bottom: 6px; }
.field.checkbox input { width: auto; }
.field.checkbox label { margin: 0; font-weight: 400; }
.field.span2 { grid-column: span 2; }
.field .hint { margin-top: 4px; }

/* ------------------------------------------------------------------ 单据编辑 */
.line-table input, .line-table select {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; width: 100%;
  background: var(--panel); color: var(--ink);
}
.line-table input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(53, 101, 246, .14);
}
.line-table td { padding: 5px 6px; }
.totals {
  display: flex; gap: 24px; justify-content: flex-end; align-items: center;
  padding: 14px 6px 2px; font-size: 13.5px; color: var(--ink-2);
  border-top: 1px dashed var(--line); margin-top: 8px;
}
.totals b { font-size: 17px; color: var(--brand-d); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ Tab */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 15px; border-radius: 999px; background: var(--panel); cursor: pointer; font-size: 12.5px;
  border: 1px solid var(--line); color: var(--ink-2); transition: .14s;
}
.tab:hover { border-color: var(--brand); color: var(--brand); }
.tab.active {
  background: linear-gradient(135deg, var(--brand), var(--accent, #7c5cff)); color: #fff;
  border-color: transparent; box-shadow: 0 6px 14px -8px rgba(53, 101, 246, .8); font-weight: 500;
}

/* ------------------------------------------------------------------ 图表 */
.chart { width: 100%; height: 200px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ------------------------------------------------------------------ Toast */
#toast-root {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: #22304a; color: #fff; padding: 12px 15px; border-radius: 12px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); max-width: 420px;
  animation: slide .2s cubic-bezier(.2, .9, .3, 1.2);
}
.toast .ti { font-size: 15px; line-height: 1.2; }
.toast.err { background: linear-gradient(135deg, #d0304f, #b3213c); }
.toast.ok { background: linear-gradient(135deg, #17a35e, #0f8a4d); }
.toast.warn { background: linear-gradient(135deg, #e0870a, #c0720a); }
.toast.out { animation: slideOut .22s ease forwards; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes slideOut { to { transform: translateX(24px); opacity: 0; } }

/* ------------------------------------------------------------------ 详情列表 */
.detail-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.detail-list > div {
  font-size: 13.5px; padding: 9px 11px; background: var(--panel-2);
  border-radius: 10px; border: 1px solid var(--line);
}
.detail-list span { color: var(--muted); display: block; font-size: 11.5px; margin-bottom: 3px; }

/* ------------------------------------------------------------------ 往来台账 */
.ledger-table td, .ledger-table th { padding: 9px 10px; }
tr.group-row { cursor: pointer; background: var(--panel-2); }
tr.group-row:hover { background: var(--brand-tint); }
tr.group-row td { border-bottom: 1px solid var(--line); }
tr.group-row .expander { color: var(--muted); font-size: 11px; text-align: center; }
tr.doc-row td { background: var(--panel); }
tr.doc-row:hover td { background: var(--brand-tint); }
.sub-cell { padding-left: 26px !important; }
.sub-cell .tag, .sub-cell .mono, .sub-cell .hint { margin-right: 8px; }
.ledger-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 12.5px; color: var(--muted);
}

/* ------------------------------------------------------------------ 响应式 */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* 平板 / 窄窗口（≤960px）：侧栏改抽屉、顶栏可换行、点击区域加大 */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: .22s ease; width: var(--side-w) !important; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .collapse { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 40px; }
  .money-badge .pill { font-size: 11px; padding: 4px 8px; }
  body.nav-collapsed .main { margin-left: 0; }
  .fields { grid-template-columns: 1fr; }
  .field.span2 { grid-column: span 1; }
  #menu-btn { display: inline-flex; }
  .nav-item, .nav-sec-head { margin: 2px 8px; padding: 11px 12px; font-size: 14px; }
  /* 抽屉模式一律按展开态显示：窄栏里折叠没有意义（也修掉旧版手机上只剩图标的问题） */
  body.nav-collapsed .nav-sec-body { display: block; }
  body.nav-collapsed .nav-sec-head { justify-content: flex-start; width: calc(100% - 16px); margin: 2px 8px; }
  body.nav-collapsed .nav-sec-head .nl,
  body.nav-collapsed .nav-sec-head .chev,
  body.nav-collapsed .nav-item .nl { display: block; }
  body.nav-collapsed .nav-item { justify-content: flex-start; }
  #nav { overscroll-behavior: contain; }
  .topbar { flex-wrap: wrap; height: auto; min-height: 58px; row-gap: 8px; padding: 8px 14px; }
}
@media (min-width: 961px) {
  #menu-btn { display: none; }
}

/* 手机（≤640px）：弹窗底部抽屉、表格卡片化、筛选控件全宽 */
@media (max-width: 640px) {
  .content { padding: 12px 10px 36px; }
  .topbar { padding: 8px 10px; }
  .topbar h2 { font-size: 16px; }
  .crumb { display: none; }
  .money-badge .pill { font-size: 10.5px; padding: 3px 7px; gap: 4px; }
  .panel { padding: 13px 12px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
  .card { padding: 12px; }
  .card .value { font-size: 18px; }

  /* 触控友好：控件加大 */
  .btn { padding: 10px 14px; font-size: 14px; }
  .btn.sm { padding: 8px 12px; font-size: 13px; }
  .link { padding: 8px 9px; font-size: 14px; }
  .tab { padding: 9px 14px; }
  .icon-btn { width: 40px; height: 40px; }
  .close-x { width: 36px; height: 36px; }
  .pager { justify-content: center; flex-wrap: wrap; }
  .pager button { padding: 9px 16px; }

  /* 表单控件 16px，避免 iOS 聚焦时自动放大页面 */
  .toolbar input, .toolbar select, .filter-bar input, .filter-bar select,
  .field input, .field select, .field textarea,
  .line-table input, .line-table select, .login-card input { font-size: 16px; }
  .check, .hint { font-size: 13px; }
  .filter-bar .check { padding: 9px 0; }
  .check input[type=checkbox], .hint input[type=checkbox] { width: 19px; height: 19px; }
  .field input[type=checkbox], .line-table input[type=checkbox] { width: 19px; height: 19px; transform: scale(1.05); }

  /* 筛选 / 工具条：搜索占整行，下拉与日期两列排布 */
  .filter-bar { padding: 10px 10px; }
  .toolbar > input[type=search], .filter-bar > input[type=search] { flex: 1 1 100%; width: 100%; }
  .toolbar > select, .filter-bar > select,
  .toolbar > input[type=date], .filter-bar > input[type=date] { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .toolbar > span.hint, .filter-bar > span.hint { flex: 1 1 100%; }

  /* 弹窗：底部抽屉式，操作按钮铺满一行并避开底部安全区 */
  .mask { align-items: flex-end; padding: 0; }
  .modal, .modal.wide {
    width: 100%; max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh; max-height: 92dvh;
  }
  .modal-head { padding: 13px 16px; }
  .modal-body { padding: 14px 14px 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .modal-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
  .modal-foot .btn { flex: 1; padding: 11px 8px; }

  /* 数据表格：手机上从横向滚动改为卡片流（一行一卡，字段名 + 值） */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table-wrap table:not(.line-table) { display: block; width: 100%; }
  .table-wrap table:not(.line-table) thead { display: none; }
  .table-wrap table:not(.line-table) tbody { display: block; }
  .table-wrap table:not(.line-table) tr {
    display: block; background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 12px; padding: 8px 12px; margin-bottom: 10px;
  }
  .table-wrap table:not(.line-table) tr:last-child { margin-bottom: 0; }
  .table-wrap table:not(.line-table) td {
    display: block; width: auto; border: none; padding: 3px 0;
    text-align: left; white-space: normal; font-size: 13px; background: transparent;
  }
  .table-wrap table:not(.line-table) td::before {
    content: attr(data-label); color: var(--muted);
    font-size: 11.5px; letter-spacing: .3px; margin-right: 10px;
  }
  .table-wrap table:not(.line-table) td:empty { display: none; }

  /* 明细表（单据编辑 / 盘点）：卡片 + 带标签输入框 */
  .line-table { display: block; width: 100%; }
  .line-table thead { display: none; }
  .line-table tbody { display: block; }
  .line-table tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; align-items: center;
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 12px; padding: 10px 12px; margin-bottom: 10px;
  }
  .line-table td {
    display: block; width: auto; border: none; padding: 1px 0;
    text-align: left; white-space: normal; background: transparent;
  }
  .line-table td::before {
    content: attr(data-label); display: block;
    color: var(--muted); font-size: 11.5px; margin-bottom: 3px;
  }
  .totals { flex-wrap: wrap; gap: 6px 20px; justify-content: flex-end; font-size: 13px; padding: 10px 4px 2px; }

  /* 详情列表：单列，并修正内联 span 造成的横向溢出 */
  .detail-list { grid-template-columns: 1fr; gap: 8px; }
  .detail-list > div { grid-column: span 1 !important; padding: 8px 10px; }

  /* 登录卡片 */
  .login-card { padding: 26px 20px 18px; border-radius: 16px; }
  .login-brand h1 { font-size: 17px; }

  /* 提示条全宽 */
  #toast-root { left: 12px; right: 12px; top: 12px; }
  .toast { max-width: none; }
}

/* 触屏设备：取消悬停位移 / 高亮，避免点击后状态残留 */
@media (hover: none) {
  .card:hover { transform: none; box-shadow: var(--shadow); }
  tbody tr:hover { background: transparent; }
  tr.group-row:hover { background: transparent; }
  tr.doc-row:hover td { background: transparent; }
  .nav-item:hover:not(.active) { background: transparent; }
  .nav-item:active { background: rgba(255, 255, 255, .12); }
  .nav-sec-head:hover { background: transparent; }
  .nav-sec-head:active { background: rgba(255, 255, 255, .12); }
  .quick:hover { transform: none; box-shadow: var(--shadow); }
  .tab:hover:not(.active) { border-color: var(--line); color: var(--ink-2); }
}

/* ==========================================================================
   打印（出库单 / 入库单 / 退货单）
   ========================================================================== */
#print-root { display: none; }

/* A4 一页优先。@page margin 设为 0，浏览器就不绘制页眉页脚（标题 / 网址 / 页码都在那里），
 * 页边距改由 .print-sheet 的 padding 控制，正文不会贴边。
 * 宽高各留 2mm 余量：浏览器对 mm 有舍入，撑满 210×297 反而会被挤到第二页。 */
.print-sheet {
  width: 208mm; min-height: 295mm; box-sizing: border-box;
  padding: 15mm 14mm 12mm; color: #111; font-size: 10.5pt;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}
.ps-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8mm; }
.ps-co h1 { font-size: 16.5pt; margin: 0 0 1.5mm; letter-spacing: .3px; font-weight: 700; }
.ps-co-info { margin: 0; font-size: 8.5pt; color: #555; line-height: 1.55; }
.ps-docno { flex: 0 0 auto; text-align: right; }
.ps-docno label { display: block; font-size: 8pt; letter-spacing: .6px; color: #666; }
.ps-docno b { font-size: 11.5pt; letter-spacing: .5px; }
.ps-badge {
  display: inline-block; margin-top: 1.5mm; font-size: 8.5pt; color: #666;
  border: 1px solid #999; border-radius: 3px; padding: .5mm 2mm; white-space: nowrap;
}
.ps-title {
  text-align: center; font-size: 14pt; font-weight: 700; letter-spacing: 6px;
  margin: 6mm 0 4mm; padding-bottom: 2mm; border-bottom: 1.5px solid #111;
}
.ps-meta {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1mm 8mm;
  font-size: 9.5pt; margin-bottom: 4mm;
}
.ps-meta > div { display: flex; gap: 2mm; padding: .8mm 0; border-bottom: 1px dotted #ddd; }
.ps-meta .wide { grid-column: span 2; }
.ps-meta label { flex: 0 0 18mm; color: #666; }
.ps-meta b { font-weight: 600; }

.ps-table { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 2mm; }
.ps-table th, .ps-table td {
  border: 1px solid #888; padding: 1.6mm 2mm; font-size: 9.5pt; text-align: left;
  word-break: break-word; overflow-wrap: anywhere;
}
.ps-table th { background: #eef1f5; font-weight: 600; text-align: center; }
.ps-table td.r, .ps-table th.r { text-align: right; }
.ps-table td.c { text-align: center; }
.ps-table .c-no { width: 7%; } .ps-table .c-code { width: 15%; }
.ps-table .c-unit { width: 8%; } .ps-table .c-qty { width: 10%; }
.ps-table .c-price { width: 13%; } .ps-table .c-amount { width: 15%; }
.ps-table .spec { color: #666; font-size: 8.5pt; }
.ps-table .svc-tag {
  display: inline-block; margin-left: 2mm; font-size: 8pt; border: 1px solid #999;
  border-radius: 2px; padding: 0 1mm; color: #555;
}
.ps-table tbody tr.blank td { height: 7mm; }
.ps-table tfoot td { font-weight: 500; }
.ps-table tfoot tr.grand td { background: #f2f4f7; font-weight: 700; font-size: 11pt; }
.ps-table tfoot tr.grand td.upper { font-size: 9pt; font-weight: 600; color: #333; }
.ps-note { margin-top: 3mm; font-size: 9.5pt; }
.ps-note label { color: #666; }
.ps-sign {
  display: flex; justify-content: space-between; gap: 6mm;
  margin-top: 12mm; font-size: 10pt;
}
.ps-sign .line { display: inline-block; width: 26mm; border-bottom: 1px solid #555; margin-left: 1mm; }
.ps-tail { margin-top: 8mm; font-size: 8pt; color: #777; }

/* ------------------------------------------------------------------ 打印风格选择 */
.style-pick { display: grid; gap: 8px; }
.style-chip {
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; background: var(--panel-2); cursor: pointer;
}
.style-chip:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.style-chip input { margin-top: 2px; }
.style-chip b { font-size: 13px; }
.style-chip i { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.style-remember { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ------------------------------------------------------------------ 简约无框风格 */
.print-sheet.st-simple { font-size: 10.5pt; }
.st-simple .ps-co h1 { font-size: 14pt; letter-spacing: 0; }
.st-simple .ps-badge { border-color: #bbb; color: #777; }
.st-simple .ps-title {
  font-size: 12pt; font-weight: 600; letter-spacing: 2px; text-align: left;
  margin: 5mm 0 3mm; padding-bottom: 1.5mm; border-bottom: 1px solid #333;
}
.st-simple .ps-table th { border: none; border-bottom: 1.2px solid #333; background: none; color: #444; }
.st-simple .ps-table td { border: none; border-bottom: 1px solid #ddd; }
.st-simple .ps-table tfoot td { border-bottom: none; }
.st-simple .ps-table tfoot tr.grand td { background: none; border-top: 1.2px solid #333; }

/* ------------------------------------------------------------------ 红头单据风格 */
.st-formal .ps-head { flex-direction: column; align-items: center; text-align: center; gap: 1.5mm; }
.st-formal .ps-co h1 { color: #b03028; font-size: 19pt; letter-spacing: 2px; }
.st-formal .ps-docno { text-align: center; }
.st-formal .ps-title {
  color: #b03028; font-size: 15pt; letter-spacing: 8px;
  border-bottom: 2.5px double #b03028;
}
.st-formal .ps-table th, .st-formal .ps-table td { border-width: 1.2px; border-color: #555; }
.st-formal .ps-table th { background: #fbeee9; }
.st-formal .ps-table tfoot tr.grand td { background: #fbeee9; }
.ps-seal {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26mm; height: 15mm; margin-left: 3mm;
  border: 1.2px dashed #b03028; border-radius: 50%; color: #b03028; font-size: 8.5pt;
  vertical-align: middle;
}

/* ------------------------------------------------------------------ 角色权限矩阵 */
.perm-matrix { display: grid; gap: 10px; max-height: 52vh; overflow: auto; padding-right: 4px; }
.perm-group { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.perm-group-head { font-size: 13px; }
.perm-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 16px; margin-top: 8px; padding-left: 24px; }

@media print {
  /* margin 0：浏览器不再绘制页眉页脚（页面标题、网址、页码都在那里）；
     页边距由 .print-sheet 的 padding 提供，正文不会贴边。 */
  @page { size: A4 portrait; margin: 0; }
  /* 弹窗打开时 lockScroll() 会把 body 设为 overflow:hidden；不解除的话超出部分会被裁在一页里，
     既不分页也丢掉签字区。html/body 的 height:100% 同样要放开。 */
  html, body { background: #fff; height: auto !important; overflow: visible !important; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  .sidebar, .topbar, .toolbar, .filter-bar, .pager, .tabs { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  .panel { box-shadow: none; border: none; }
  /* 明细多时允许跨页：表头每页重复，合计/签字不被切断，行不被拦腰截断 */
  .ps-table { page-break-inside: auto; }
  .ps-table thead { display: table-header-group; }
  .ps-table tfoot { display: table-row-group; }
  .ps-table tr { page-break-inside: avoid; break-inside: avoid; }
  .ps-meta, .ps-note, .ps-sign, .ps-tail { break-inside: avoid; }
  .ps-title { break-after: avoid; }
}
