/* ============================================================
   Tool Management System · UI styles
   ============================================================ */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #e4e9ee;
  --line-strong: #d5dde4;
  --ink: #1f2937;
  --ink-2: #374151;
  --muted: #6b7280;
  --muted-2: #9aa4af;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e7f4f1;
  --accent-line: #b9ded8;
  --ok: #15803d;
  --ok-soft: #e8f6ee;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #1d4ed8;
  --info-soft: #eaf0fd;
  --violet: #6d28d9;
  --violet-soft: #f1ebfd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .07);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, .18);
  --sidebar-w: 236px;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
}

/* ---------------- 软件风格（设置页可切换） ---------------- */
:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1e242c;
  --line: #262e37;
  --line-strong: #333d48;
  --ink: #e8eef4;
  --ink-2: #c9d3dc;
  --muted: #8a97a4;
  --muted-2: #66717c;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: #123330;
  --accent-line: #1e5751;
  --ok: #4ade80;
  --ok-soft: #143321;
  --warn: #fbbf24;
  --warn-soft: #3a2d12;
  --danger: #f87171;
  --danger-soft: #3d1a19;
  --info: #60a5fa;
  --info-soft: #17263d;
  --violet: #a78bfa;
  --violet-soft: #251c3d;
}
:root[data-theme="graphite"] {
  color-scheme: dark;
  --bg: #2b3035;
  --surface: #343a40;
  --surface-2: #3c434a;
  --line: #454d55;
  --line-strong: #525c65;
  --ink: #f1f3f5;
  --ink-2: #d7dce0;
  --muted: #adb5bd;
  --muted-2: #8b949c;
  --accent: #93c5fd;
  --accent-strong: #bfdbfe;
  --accent-soft: #3b4c60;
  --accent-line: #506a86;
  --ok: #86efac;
  --ok-soft: #2f4635;
  --warn: #fcd34d;
  --warn-soft: #4a3d1f;
  --danger: #fca5a5;
  --danger-soft: #4a2d2d;
  --info: #93c5fd;
  --info-soft: #33465c;
  --violet: #c4b5fd;
  --violet-soft: #40345c;
}
:root[data-theme="ocean"] {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --line: #dde6ef;
  --line-strong: #cbd8e4;
  --ink: #1b2a3a;
  --ink-2: #33475b;
  --muted: #64788c;
  --muted-2: #93a5b6;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #e6efff;
  --accent-line: #bfd3f7;
  --ok: #15803d;
  --ok-soft: #e8f6ee;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #1d4ed8;
  --info-soft: #eaf0fd;
  --violet: #6d28d9;
  --violet-soft: #f1ebfd;
}
:root[data-theme="sand"] {
  --bg: #f6f1e8;
  --surface: #fffdf8;
  --surface-2: #faf5ec;
  --line: #e9e0d2;
  --line-strong: #d9cdb9;
  --ink: #2f2a22;
  --ink-2: #4a4236;
  --muted: #7d7263;
  --muted-2: #a2988a;
  --accent: #a15c2b;
  --accent-strong: #7c451f;
  --accent-soft: #f6ead9;
  --accent-line: #e5cdb1;
  --ok: #15803d;
  --ok-soft: #e8f6ee;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --info: #1d4ed8;
  --info-soft: #eaf0fd;
  --violet: #6d28d9;
  --violet-soft: #f1ebfd;
}
/* 深色风格下把固定白色背景改为主题色 */
:root[data-theme="midnight"] .input,
:root[data-theme="graphite"] .input,
:root[data-theme="midnight"] .select,
:root[data-theme="graphite"] .select,
:root[data-theme="midnight"] .textarea,
:root[data-theme="graphite"] .textarea,
:root[data-theme="midnight"] .lang-seg button,
:root[data-theme="graphite"] .lang-seg button,
:root[data-theme="midnight"] .btn.danger,
:root[data-theme="graphite"] .btn.danger {
  background: var(--surface);
}
:root[data-theme="midnight"] .btn:hover,
:root[data-theme="graphite"] .btn:hover { border-color: var(--line-strong); }
:root[data-theme="midnight"] .btn.soft:hover,
:root[data-theme="graphite"] .btn.soft:hover { background: var(--surface-2); }
:root[data-theme="midnight"] .btn.danger,
:root[data-theme="graphite"] .btn.danger { border-color: var(--line-strong); }
:root[data-theme="midnight"] ::selection,
:root[data-theme="graphite"] ::selection { background: rgba(148, 163, 184, .35); }
:root[data-theme="midnight"] ::-webkit-scrollbar-thumb,
:root[data-theme="graphite"] ::-webkit-scrollbar-thumb { background: var(--line-strong); }
:root[data-theme="midnight"] ::-webkit-scrollbar-thumb:hover,
:root[data-theme="graphite"] ::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* 主题选择卡片 */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.theme-card {
  display: flex; flex-direction: column; gap: 7px; align-items: stretch;
  padding: 7px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--ink-2); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.theme-card:hover { border-color: var(--line-strong); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-swatch {
  display: block; height: 46px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .08);
  position: relative; overflow: hidden;
}
.theme-swatch::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: 8px; height: 8px;
  border-radius: 4px; background: var(--swatch-accent, transparent);
}
.theme-card .theme-name { font-size: 11.5px; text-align: center; padding-bottom: 2px; }


* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: #cdeae5; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d2dae1; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b9c4cd; }

/* ---------------- Layout ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(145deg, #0f766e, #0b5c56);
  color: #fff;
  box-shadow: 0 6px 14px rgba(15, 118, 110, .24);
  flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; border-radius: 12px; }
.brand-fallback { width: 38px; height: 38px; display: grid; place-items: center; }
.brand-mark svg { width: 23px; height: 23px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 15.5px; letter-spacing: .02em; color: var(--ink); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 11px; color: var(--muted); margin-top: 3px; letter-spacing: .02em; }

.nav { flex: 1; overflow-y: auto; padding-bottom: 8px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .12em;
  color: var(--muted-2); text-transform: uppercase;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; margin: 1px 0;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 13px;
  position: relative;
  transition: background .15s, color .15s;
}
.nav-item .ico { width: 20px; height: 20px; display: grid; place-items: center; color: var(--muted); transition: color .15s; }
.nav-item .ico svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item:hover .ico { color: var(--ink-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-item.active .ico { color: var(--accent); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}

.sidebar-foot { padding: 10px 6px 4px; border-top: 1px solid var(--line); margin-top: 6px; }
.storage-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: 999px;
}
.storage-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: #16a34a; }
.build-label { font-size: 10.5px; color: var(--muted-2); margin-top: 8px; padding-left: 2px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 76px; flex: 0 0 76px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  background: rgba(244, 246, 248, .86);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.page-heading h1 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.page-heading p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.today { font-size: 12px; color: var(--muted); }
.lang-btn { min-width: 48px; }

.view {
  flex: 1; overflow-y: auto;
  padding: 22px 28px 40px;
  animation: fadeUp .28s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- Boot ---------------- */
.boot {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); color: var(--muted); font-size: 12px;
  transition: opacity .3s, visibility .3s;
}
.boot.hide { opacity: 0; visibility: hidden; }
.boot-mark { width: 52px; height: 52px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; animation: pulse 1.2s ease-in-out infinite; }
.boot-mark svg { width: 30px; height: 30px; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.94); opacity: .75; } }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: #c7d1d9; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(15, 118, 110, .18); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.soft { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-strong); }
.btn.soft:hover { background: #dcf0ec; }
.btn.danger { color: var(--danger); border-color: #efc9c5; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 11.5px; border-radius: 6px; gap: 4px; }
.btn.icon { width: 30px; padding: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.link-btn { background: none; border: none; padding: 0; color: var(--accent); font-size: 12.5px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------------- Page head ---------------- */
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-actions .left, .page-actions .right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 14px; font-weight: 600; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(4, 1fr); }
.dash-grid { grid-template-columns: 1.55fr 1fr; margin-top: 16px; }

.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 7px; line-height: 1.15; }
.kpi .hint { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }
.kpi .hint b { color: var(--ink-2); font-weight: 600; }
.kpi .kpi-ico {
  width: 40px; height: 40px; border-radius: 11px; flex: 0 0 40px;
  display: grid; place-items: center;
}
.kpi .kpi-ico svg { width: 20px; height: 20px; }
.kpi .kpi-ico.teal { background: var(--accent-soft); color: var(--accent); }
.kpi .kpi-ico.blue { background: var(--info-soft); color: var(--info); }
.kpi .kpi-ico.amber { background: var(--warn-soft); color: var(--warn); }
.kpi .kpi-ico.violet { background: var(--violet-soft); color: var(--violet); }
.kpi .kpi-ico.green { background: var(--ok-soft); color: var(--ok); }

/* quick actions */
.quick-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 16px; }
.quick-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; text-align: left;
  transition: border-color .15s, background .15s, transform .1s;
}
.quick-card:hover { border-color: var(--accent-line); background: #fcfffe; transform: translateY(-1px); }
.quick-card .q-ico { width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: 0 0 32px; }
.quick-card:hover .q-ico { background: var(--accent-soft); color: var(--accent); }
.quick-card .q-ico svg { width: 16px; height: 16px; }
.quick-card b { font-size: 12.5px; font-weight: 600; display: block; }
.quick-card span { font-size: 11px; color: var(--muted); }

/* low stock */
.low-list { display: flex; flex-direction: column; }
.low-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--line);
}
.low-row:last-child { border-bottom: none; }
.low-row .tool-ident { flex: 1; min-width: 0; }
.low-row .tool-ident b { font-size: 12.5px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.low-row .tool-ident span { font-size: 11px; color: var(--muted); }
.low-row .stock-num { font-size: 13px; font-weight: 650; }
.low-row .stock-num small { font-size: 10.5px; color: var(--muted); font-weight: 400; }
.low-row .bar { width: 80px; height: 5px; border-radius: 3px; background: #eef2f5; overflow: hidden; }
.low-row .bar i { display: block; height: 100%; border-radius: 3px; }

/* category bars */
.cat-list { padding: 6px 18px 16px; }
.cat-row { padding: 9px 0; }
.cat-row .cat-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cat-row .cat-name { font-size: 12.5px; color: var(--ink-2); }
.cat-row .cat-val { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-row .cat-track { height: 7px; border-radius: 5px; background: #eef2f5; overflow: hidden; }
.cat-row .cat-track i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #2aa79b, #0f766e); }

/* ---------------- Table ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
/* 长表格：表头随内容滚动保持冻结 */
.table-sticky { max-height: 60vh; overflow: auto; }
.table-sticky thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2);
  box-shadow: inset 0 -1px 0 var(--line);
}
.table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.table th {
  text-align: left; font-size: 10.8px; letter-spacing: .05em; text-transform: uppercase;
  font-weight: 600; color: var(--muted);
  background: var(--surface-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-2);
}
.table tbody tr:hover { background: #fbfdfd; }
.table tbody tr.muted-row td { opacity: .55; }
.table tbody tr.cancelled td:not(:last-child) { text-decoration: line-through; color: var(--muted); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .center { text-align: center; }
.table .strong { font-weight: 600; color: var(--ink); }
.table .muted { color: var(--muted); }
.table .nowrap { white-space: nowrap; }
.table .row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
.table-empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.table-empty svg { width: 34px; height: 34px; color: var(--muted-2); margin-bottom: 8px; }
.table-empty p { font-size: 12.5px; }

.clickable { cursor: pointer; }
/* 收款管理：客户配色圆点 */
.cust-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.doc-no { font-weight: 600; color: var(--accent-strong); }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.muted { background: #f0f3f5; color: var(--muted); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 6px;
  font-size: 11px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 76px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .12); }
.input:disabled, .select:disabled, .textarea:disabled { background: #f5f7f8; color: var(--muted); }
.input.sm, .select.sm { height: 32px; font-size: 12.5px; padding: 0 8px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.form-grid .col-2 { grid-column: span 2; }
.form-grid .col-3 { grid-column: span 3; }
.form-hint { font-size: 11px; color: var(--muted-2); }

.field-inline { display: flex; gap: 8px; align-items: center; }
.field-inline .select { flex: 1; }

.cat-add-row { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.cat-add-row .input { flex: 1; }
.cat-list { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; }
.cat-row:hover { background: var(--surface-2); }
.cat-row.active { background: var(--accent-soft); }
.cat-name { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 13px; color: var(--ink); min-width: 0; }
.cat-name svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.cat-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-name small { font-size: 11px; }
.cat-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.cat-row:hover .cat-actions { opacity: 1; }
.cat-empty { padding: 24px 12px; text-align: center; color: var(--muted-2); }
.cat-empty svg { width: 28px; height: 28px; margin-bottom: 6px; color: var(--muted); }
.cat-empty p { font-size: 12.5px; }

.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-bar .search {
  position: relative; flex: 1; min-width: 220px; max-width: 360px;
}
.filter-bar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); }
.filter-bar .search .input { padding-left: 33px; }
.filter-bar .select { width: auto; min-width: 130px; }
.filter-bar .spacer { flex: 1; }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(20, 30, 40, .42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 20px 20px;
  animation: fadeIn .18s ease;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .22s cubic-bezier(.2, .8, .3, 1);
  overflow: hidden;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal.md { max-width: 720px; }
.modal.lg { max-width: 900px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 15px; font-weight: 650; }
.modal-head p { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.modal-close { background: none; border: none; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.modal.danger .modal-head h2 { color: var(--danger); }

/* ---------------- Toast ---------------- */
.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  min-width: 200px; max-width: 380px;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px;
  border-radius: 9px;
  background: #1f2937; color: #fff;
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
  animation: toastIn .22s ease;
}
.toast.ok { background: #14532d; }
.toast.error { background: #7f1d1d; }
.toast.warn { background: #78350f; }
.toast.hide { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------------- Empty ---------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 52px 20px; text-align: center;
  color: var(--muted);
}
.empty .empty-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; margin-bottom: 12px; color: var(--muted-2); }
.empty .empty-ico svg { width: 24px; height: 24px; }
.empty h3 { font-size: 13.5px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.empty p { font-size: 12px; margin-bottom: 14px; }

/* ---------------- Dashboard ---------------- */
.dash-section { margin-top: 16px; }
.card-foot { display: flex; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--line); }
.mini-stats { display: flex; gap: 22px; padding: 0 18px 14px; }
.mini-stat { display: flex; flex-direction: column; gap: 2px; }
.mini-stat b { font-size: 15px; font-weight: 650; }
.mini-stat span { font-size: 11px; color: var(--muted); }

/* ---------------- Tool stock cells ---------------- */
.stock-cell { display: flex; align-items: center; gap: 8px; }
.stock-cell b { font-weight: 650; font-size: 13px; }
.stock-cell small { color: var(--muted); font-size: 11px; }
.dot-ind { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.dot-ind.ok { background: #16a34a; }
.dot-ind.low { background: #d97706; }
.dot-ind.out { background: #dc2626; }

/* ---------------- Doc editor ---------------- */
.doc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.doc-head-title { display: flex; align-items: center; gap: 12px; }
.doc-head-title .doc-mark { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.doc-head-title .doc-mark svg { width: 21px; height: 21px; }
.doc-head-title h2 { font-size: 17px; font-weight: 650; }
.doc-head-title p { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.doc-head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.form-card { padding: 18px; }
.form-section-title { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 13px; display: flex; align-items: center; gap: 8px; }
.form-section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.items-card { margin-top: 16px; }
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600;
  text-align: left; padding: 10px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.items-table td { padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.items-table tbody tr:last-child td { border-bottom: none; }
.items-table .idx { color: var(--muted-2); font-size: 11.5px; text-align: center; width: 34px; }
.items-table .input, .items-table .select { height: 32px; font-size: 12.5px; }
.items-table .input.tool-input { min-width: 260px; }
.items-table .select.tool-select { min-width: 230px; }
.items-table .amount-cell { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.8px; padding-right: 12px; white-space: nowrap; }
.items-table .row-del { color: var(--muted-2); background: none; border: none; cursor: pointer; padding: 4px; border-radius: 6px; display: grid; place-items: center; }
.items-table .row-del:hover { color: var(--danger); background: var(--danger-soft); }
.items-table .row-del svg { width: 15px; height: 15px; }
.item-stock-hint { font-size: 10.5px; margin-top: 3px; color: var(--muted-2); }
.item-stock-hint.bad { color: var(--danger); }

/* 刀具输入 + 下拉选择按钮 */
.tool-pick { display: flex; align-items: center; gap: 4px; }
.tool-pick .tool-input { flex: 1; min-width: 0; }
.tool-pick-btn {
  width: 24px; height: 28px; flex: 0 0 24px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 7px;
  background: var(--surface-2); color: var(--ink);
  font-size: 12px; line-height: 1; cursor: pointer;
}
.tool-pick-btn:hover { border-color: var(--accent); color: var(--accent); }

/* 刀具下拉面板 */
.tool-pick-pop {
  position: fixed; z-index: 2000; max-height: 320px; overflow-y: auto;
  padding: 5px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); box-shadow: 0 12px 32px rgba(15, 23, 42, .22);
}
.tp-item { padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.tp-item:hover { background: var(--accent-soft); }
.tp-main { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.tp-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tp-empty { padding: 14px; text-align: center; font-size: 12px; color: var(--muted); }

/* 服务类（text）明细：多行文字输入 */
.tool-text-input {
  width: 100%; min-height: 64px; resize: vertical;
  font-family: inherit; font-size: 12.5px; line-height: 1.5;
  white-space: pre-wrap;
}
.items-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 10px; flex-wrap: wrap; }

.totals-wrap { display: flex; justify-content: flex-end; padding: 4px 18px 18px; }
.totals { width: 320px; display: flex; flex-direction: column; gap: 7px; }
.totals .t-row { display: flex; justify-content: space-between; font-size: 12.8px; color: var(--ink-2); }
.totals .t-row span:last-child { font-variant-numeric: tabular-nums; }
.totals .t-row.grand { border-top: 1px solid var(--line); padding-top: 9px; margin-top: 2px; font-size: 15px; font-weight: 700; color: var(--ink); }
.totals .t-row .muted { color: var(--muted); font-weight: 400; }
.totals .t-row.grand span:last-child { color: var(--accent-strong); }
.totals .discount-input { width: 110px; height: 30px; padding: 0 8px; text-align: right; font-size: 12.8px; }

.doc-info-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 16px; }
.doc-info-grid .span-2 { grid-column: span 2; }

.subline { font-size: 11px; color: var(--muted); margin-top: 2px; }
.amount-strong { font-weight: 650; color: var(--ink); }

/* ---------------- Settings ---------------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settings-card { padding: 20px; }
.settings-card h3 { font-size: 14px; font-weight: 650; margin-bottom: 4px; }
.settings-card .desc { font-size: 11.5px; color: var(--muted); margin-bottom: 16px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: none; }
.settings-row .txt b { font-size: 12.8px; font-weight: 600; display: block; }
.settings-row .txt span { font-size: 11px; color: var(--muted); }
.logo-preview { width: 90px; height: 56px; border: 1px dashed var(--line-strong); border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted-2); font-size: 10.5px; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.backup-note { font-size: 11px; color: var(--muted); line-height: 1.6; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 12px; word-break: break-all; }
.lang-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.lang-seg button { height: 32px; padding: 0 14px; border: none; background: #fff; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.lang-seg button + button { border-left: 1px solid var(--line-strong); }
.lang-seg button.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

/* ---------------- Print ---------------- */
.print-root { display: none; }

@media print {
  @page { size: A4; margin: 12mm 13mm; }
  html, body { height: auto; background: #fff; }
  body > *:not(.print-root) { display: none !important; }
  .print-root { display: block !important; }
  .print-doc { color: #111; font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif; font-size: 10.5pt; }
  .print-doc .p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid #0f766e; padding-bottom: 12px; }
  .print-doc .p-company { display: flex; gap: 12px; align-items: flex-start; }
  .print-doc .p-logo { width: 62px; height: 62px; object-fit: contain; }
  .print-doc .p-co-name { font-size: 15pt; font-weight: 700; letter-spacing: .02em; }
  .print-doc .p-co-meta { font-size: 8.6pt; color: #444; line-height: 1.55; margin-top: 4px; white-space: pre-line; }
  .print-doc .p-title-box { text-align: right; }
  .print-doc .p-title { font-size: 21pt; font-weight: 750; letter-spacing: .12em; color: #0f766e; line-height: 1.1; }
  .print-doc .p-title-cn { font-size: 11pt; letter-spacing: .3em; color: #333; margin-top: 2px; }
  .print-doc .p-doc-meta { margin-top: 10px; font-size: 9pt; color: #333; line-height: 1.65; }
  .print-doc .p-doc-meta b { display: inline-block; min-width: 62px; color: #111; }
  .print-doc .p-parties { display: flex; gap: 18px; margin-top: 14px; }
  .print-doc .p-party { flex: 1.15; border: 1px solid #d8dee3; border-radius: 4px; padding: 9px 11px; min-height: 84px; }
  .print-doc .p-party .p-label { font-size: 7.6pt; letter-spacing: .16em; color: #6b7280; text-transform: uppercase; }
  .print-doc .p-party .p-name { font-size: 11pt; font-weight: 700; margin-top: 3px; }
  .print-doc .p-party .p-lines { font-size: 8.8pt; color: #333; line-height: 1.5; margin-top: 3px; white-space: pre-line; }
  .print-doc table.p-items { width: 100%; border-collapse: collapse; margin-top: 14px; }
  .print-doc table.p-items th { background: #eef4f3; border: 1px solid #c9d3d9; padding: 6px 7px; font-size: 8.4pt; text-align: left; letter-spacing: .04em; text-transform: uppercase; }
  .print-doc table.p-items td { border: 1px solid #d8dee3; padding: 6px 7px; font-size: 9pt; vertical-align: top; }
  .print-doc table.p-items .num { text-align: right; white-space: nowrap; }
  .print-doc table.p-items .center { text-align: center; }
  .print-doc table.p-items tbody tr:nth-child(even) td { background: #fafcfc; }
  .print-doc .p-summary { display: flex; justify-content: flex-end; margin-top: 12px; }
  .print-doc .p-sum-table { width: 250px; border-collapse: collapse; }
  .print-doc .p-sum-table td { padding: 5px 8px; font-size: 9pt; border-bottom: 1px solid #e4e9ee; }
  .print-doc .p-sum-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
  .print-doc .p-sum-table tr.total td { font-size: 11.5pt; font-weight: 700; border-top: 2px solid #0f766e; border-bottom: none; padding-top: 7px; color: #0f766e; }
  .print-doc .p-notes { margin-top: 14px; font-size: 8.8pt; color: #333; }
  .print-doc .p-notes .p-label { font-size: 7.6pt; letter-spacing: .14em; color: #6b7280; text-transform: uppercase; }
  .print-doc .p-signs { display: flex; gap: 40px; margin-top: 38px; }
  .print-doc .p-sign { flex: 1; border-top: 1px solid #777; padding-top: 5px; font-size: 8.6pt; color: #444; }
  .print-doc .p-foot { margin-top: 22px; border-top: 1px solid #d8dee3; padding-top: 6px; font-size: 7.8pt; color: #777; display: flex; justify-content: space-between; }
  .print-doc .p-stock-note { font-size: 8pt; color: #777; margin-top: 8px; }

  /* ============== Invoice / DO / Quotation 模板样式 ============== */
  .print-doc.tmpl-io { font-family: "Segoe UI", Arial, sans-serif; font-size: 10pt; color: #000; }
  .tmpl-io-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #000; padding-bottom: 10px; margin-bottom: 12px; }
  .tmpl-io-company { width: 52%; }
  .tmpl-io-logo { display: block; max-height: 64px; max-width: 220px; object-fit: contain; margin-bottom: 6px; }
  .tmpl-io-co-big { font-size: 14pt; font-weight: 700; letter-spacing: .02em; }
  .tmpl-io-co-sub { font-size: 9.5pt; font-weight: 500; }
  .tmpl-io-co-line { font-size: 8.2pt; line-height: 1.5; margin-top: 1px; }
  .tmpl-io-title-col { width: 44%; text-align: right; }
  .tmpl-io-big-title { font-size: 22pt; font-weight: 800; letter-spacing: .14em; line-height: 1.1; }
  .tmpl-io-meta-box { margin-top: 8px; display: inline-block; text-align: left; }
  .tmpl-io-meta-row { font-size: 9pt; line-height: 1.65; white-space: nowrap; }
  .tmpl-io-meta-lbl { display: inline-block; min-width: 110px; font-weight: 600; }
  .tmpl-io-meta-col { display: inline-block; width: 10px; text-align: center; }
  .tmpl-io-meta-val { font-weight: 400; }

  /* CUSTOMER bar */
  .tmpl-io-cust-bar { font-size: 9pt; font-weight: 700; letter-spacing: .08em; border: 1px solid #000; padding: 3px 8px; display: inline-block; margin-bottom: 6px; }
  .tmpl-io-cust-block { border: 1px solid #000; padding: 8px 10px 6px; margin-bottom: 12px; }
  .tmpl-io-cust-name { font-size: 11pt; font-weight: 700; }
  .tmpl-io-cust-line { font-size: 9pt; line-height: 1.5; }

  /* 明细表 — Invoice (4 列块: DESC / UNIT PRICE / QTY / AMOUNT) */
  .tmpl-io-table { width: 100%; border-collapse: collapse; margin-top: 8px; table-layout: fixed; }
  .tmpl-io-table th, .tmpl-io-table td { border: 1px solid #000; padding: 5px 7px; font-size: 9pt; vertical-align: top; word-wrap: break-word; }
  .tmpl-io-th-desc { width: 58%; font-weight: 700; background: #e8e8e8; }
  .tmpl-io-th-price, .tmpl-io-th-amt { width: 17%; text-align: center; font-weight: 700; background: #e8e8e8; }
  .tmpl-io-th-qty { width: 8%; text-align: center; font-weight: 700; background: #e8e8e8; }
  .tmpl-io-td-desc { white-space: pre-line; line-height: 1.5; }
  .tmpl-io-td-num, .tmpl-io-td-qty { text-align: right; }
  .tmpl-io-td-qty { text-align: center; }

  /* 合计区 */
  .tmpl-io-sum-table { margin-left: auto; width: 280px; border-collapse: collapse; margin-top: 10px; }
  .tmpl-io-sum-table td { padding: 3px 10px; font-size: 9pt; }
  .tmpl-io-sum-row td { border: none; border-bottom: 1px solid #000; }
  .tmpl-io-sum-total td { border-top: 2px solid #000; border-bottom: 2px double #000; font-size: 11pt; font-weight: 700; padding-top: 6px; }
  .tmpl-io-sum-lbl { text-align: right; }
  .tmpl-io-sum-val { text-align: right; font-variant-numeric: tabular-nums; }

  /* BANK DETAILS */
  .tmpl-io-bank { margin-top: 16px; border: 1px solid #000; padding: 8px 10px; }
  .tmpl-io-bank-title { font-size: 9pt; font-weight: 700; letter-spacing: .08em; margin-bottom: 4px; border-bottom: 1px solid #000; padding-bottom: 2px; display: inline-block; }
  .tmpl-io-bank-row { font-size: 8.5pt; line-height: 1.5; }
  .tmpl-io-bank-lbl { display: inline-block; min-width: 150px; font-weight: 600; }
  .tmpl-io-bank-val { font-weight: 400; }

  /* 感谢语 */
  .tmpl-io-thank { margin-top: 18px; text-align: center; font-size: 9pt; font-weight: 700; letter-spacing: .06em; }

  /* ============== Invoice 模板（严格对齐 INV00538.xlsx 的 7 列网格） ============== */
  .tmpl-inv-grid { width: 100%; border-collapse: collapse; table-layout: fixed; font-family: Arial, Helvetica, sans-serif; color: #000; }
  .tmpl-inv-grid td { padding: 1px 5px; font-size: 10pt; line-height: 1.35; vertical-align: middle; overflow: hidden; }
  .tmpl-inv-grid .tmpl-inv-logo { vertical-align: top; padding-top: 2px !important; }
  .tmpl-inv-grid .tmpl-inv-logo img { display: block; max-height: 30mm; max-width: 100%; object-fit: contain; }
  .tmpl-inv-grid .tmpl-inv-co { font-size: 12pt; font-weight: 700; }
  .tmpl-inv-grid .tmpl-inv-co-line { font-size: 10pt; font-weight: 700; line-height: 1.3; }
  .tmpl-inv-grid .tmpl-inv-title { font-size: 26pt; font-weight: 700; text-align: center; letter-spacing: .06em; line-height: 1.05; }
  .tmpl-inv-grid .tmpl-inv-meta-lbl { font-size: 10pt; white-space: nowrap; }
  .tmpl-inv-grid .tmpl-inv-meta-val { font-size: 11pt; border: 1px solid #000; padding: 0 4px !important; }
  .tmpl-inv-grid .tmpl-inv-custbar { background: #7030A0; color: #fff; font-size: 11pt; font-weight: 700; padding: 2px 6px !important; }
  .tmpl-inv-grid .tmpl-inv-cust-name { font-size: 11pt; line-height: 1.35; }
  .tmpl-inv-grid .tmpl-inv-th { background: #7030A0; color: #fff; font-size: 11pt; font-weight: 700; padding: 3px 6px !important; border: 1px solid #000; }
  .tmpl-inv-grid .tmpl-inv-item { font-size: 11pt; border-left: 1px solid #000; border-right: 1px solid #000; line-height: 1.35; }
  .tmpl-inv-grid .tmpl-inv-item.r { text-align: right; }
  .tmpl-inv-grid .tmpl-inv-item.c { text-align: center; }
  .tmpl-inv-grid .tmpl-inv-sum-lbl { font-size: 10pt; }
  .tmpl-inv-grid .tmpl-inv-sum-val { font-size: 11pt; text-align: right; border-bottom: 1px solid #000; padding-right: 6px !important; }
  .tmpl-inv-grid .tmpl-inv-sum-lbl.strong { font-weight: 700; font-size: 11pt; }
  .tmpl-inv-grid .tmpl-inv-sum-val.strong { font-weight: 700; font-size: 11pt; }
  .tmpl-inv-grid .tmpl-inv-bankbar { background: #7030A0; color: #fff; font-size: 11pt; font-weight: 700; padding: 2px 6px !important; }
  .tmpl-inv-grid .tmpl-inv-bank-lbl { font-size: 11pt; white-space: nowrap; }
  .tmpl-inv-grid .tmpl-inv-bank-val { font-size: 10pt; line-height: 1.3; }
  .tmpl-inv-grid .tmpl-inv-thank { text-align: center; font-size: 11pt; font-weight: 700; padding-top: 6px !important; }

  /* ============== DO 模板 ============== */
  .tmpl-do-meta-row { display: flex; gap: 20px; }
  .tmpl-do-meta-row .tmpl-io-cust-block { flex: 1; margin-bottom: 12px; }
  .tmpl-do-right-meta { width: 320px; padding-top: 6px; }
  .tmpl-do-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
  .tmpl-do-table th, .tmpl-do-table td { border: 1px solid #000; padding: 5px 7px; font-size: 9pt; vertical-align: top; }
  .tmpl-do-th-qty { width: 12%; text-align: center; font-weight: 700; background: #e8e8e8; }
  .tmpl-do-sign { margin-top: 28px; border: 1px solid #000; padding: 14px 20px; text-align: center; }
  .tmpl-do-sign-line { font-size: 9pt; font-weight: 600; text-decoration: underline; margin-bottom: 18px; }
  .tmpl-do-sign-name { font-size: 11pt; font-weight: 700; letter-spacing: .15em; }

  /* ============== Quotation 模板 (9 列展示) ============== */
  .tmpl-q .tmpl-io-header { border-bottom: 2px solid #000; }
  .tmpl-q-cust { border: none; padding: 4px 0; }
  .tmpl-q-table { width: 100%; border-collapse: collapse; margin-top: 8px; table-layout: fixed; }
  .tmpl-q-table th, .tmpl-q-table td { border: 1px solid #000; padding: 4px 6px; font-size: 8.5pt; vertical-align: top; }
  .tmpl-q-table .no { width: 30px; text-align: center; font-weight: 700; background: #e8e8e8; }
  .tmpl-q-table .part { width: 90px; font-weight: 700; background: #e8e8e8; }
  .tmpl-q-table .desc { font-weight: 700; background: #e8e8e8; text-align: left; }
  .tmpl-q-table .qty { width: 45px; text-align: center; font-weight: 700; background: #e8e8e8; }
  .tmpl-q-table .up { width: 72px; text-align: right; font-weight: 700; background: #e8e8e8; }
  .tmpl-q-table .amt { width: 78px; text-align: right; font-weight: 700; background: #e8e8e8; }
  .tmpl-q-td.no { text-align: center; }
  .tmpl-q-td.desc { white-space: pre-line; line-height: 1.4; }
  .tmpl-q-td.qty, .tmpl-q-td.part { text-align: center; }
  .tmpl-q-td.up, .tmpl-q-td.amt { text-align: right; font-variant-numeric: tabular-nums; }
  .tmpl-q-sum-table { margin-left: auto; width: 200px; border-collapse: collapse; margin-top: 8px; }
  .tmpl-q-sum-table td { padding: 3px 8px; font-size: 9pt; }
  .tmpl-q-sum-row td { border-bottom: 1px solid #000; }
  .tmpl-q-sum-total td { border-top: 2px solid #000; border-bottom: 2px double #000; font-size: 11pt; font-weight: 700; padding-top: 5px; }
  .tmpl-q-sum-lbl { text-align: right; font-weight: 500; }
  .tmpl-q-sum-val { text-align: right; font-variant-numeric: tabular-nums; }
  .tmpl-q-contact { margin-top: 16px; font-size: 8.5pt; line-height: 1.5; }
  .tmpl-q-thank { margin-top: 22px; }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-grid { grid-template-columns: repeat(3, 1fr); }
  .doc-info-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1080px) {
  .dash-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   K&Q 单据版式 — Invoice / DO / Quotation
   尺寸严格对齐 INV00537.pdf (Letter) / DO00537.pdf (A4) / Q2600071.pdf (Letter)
   ============================================================ */
@media print {
  @page kqletter { size: Letter; margin: 0; }
  @page kqa4 { size: A4; margin: 0; }

  .print-doc.kq {
    /* 原 PDF 由 Word/Excel 导出，正文与标题均为 Calibri；用错字体会导致标题变宽、位置整体偏移 */
    font-family: Calibri, "Segoe UI", Arial, sans-serif;
    font-size: 10pt;
    color: #000;
    background: #fff;
    line-height: 1.2;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-doc.kq a { color: #0000ff; text-decoration: underline; }

  /* Invoice 固定 A4 单页：内容宽度保持与原版一致，纸张改为 A4 */
  .kq-inv { width: 595pt; padding: 58pt 16pt 0 36.5pt; page: kqa4; }
  .kq-do { width: 595pt; padding: 58pt 27pt 0 36.5pt; page: kqa4; }
  .kq-q { width: 612pt; padding: 58pt 45.5pt 0 36.5pt; page: kqletter; }

  /* ---- 抬头 ---- */
  /* 原模板的表格起始位置是固定的（不随客户地址行数浮动），因此给抬头区固定高度 */
  .kq-head { display: flex; align-items: flex-start; position: relative; }
  .kq-inv .kq-head { height: 207.8pt; }
  .kq-do .kq-head { height: 203pt; }
  .kq-q .kq-head { height: 214pt; }
  .kq-inv .kq-left, .kq-q .kq-left { width: 400.5pt; }
  .kq-do .kq-left { width: 404.5pt; }

  .kq-brand { display: flex; }
  .kq-logo { flex: 0 0 136.5pt; width: 136.5pt; }
  .kq-logo img { display: block; max-width: 132pt; max-height: 78pt; object-fit: contain; }
  .kq-co { flex: 1; min-width: 0; }
  .kq-co-name { font-size: 12pt; font-weight: 700; line-height: 14.3pt; }
  .kq-co-line { font-size: 10pt; font-weight: 700; line-height: 14.3pt; }

  .kq-meta { flex: 0 0 auto; position: relative; }
  .kq-inv .kq-meta { width: 142pt; }
  .kq-do .kq-meta { width: 127pt; }
  .kq-q .kq-meta { width: 129.5pt; }

  .kq-title {
    position: absolute; right: 0; top: 0;
    text-align: right; font-weight: 700; color: #7030A0;
    line-height: 1; white-space: nowrap;
  }
  /* 标题右边缘相对内容区右边缘的内缩量，取自原 PDF 文本末端坐标 */
  .kq-inv .kq-title { font-size: 29pt; right: 15pt; top: -2pt; }
  .kq-do .kq-title { font-size: 23.5pt; right: 12.8pt; top: -1pt; }
  .kq-q .kq-title { font-size: 26pt; right: 5pt; top: -2pt; }

  .kq-meta-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .kq-inv .kq-meta-tbl { margin-top: 54pt; }
  .kq-do .kq-meta-tbl { margin-top: 52.8pt; }
  .kq-q .kq-meta-tbl { margin-top: 56pt; }
  /* 方框内文字贴底：底线对齐，文字压到框的下框线上 */
  .kq-meta-tbl td { padding: 0; font-size: 11pt; line-height: 11.6pt; height: 14.6pt; vertical-align: bottom; }
  .kq-ml { text-align: left; white-space: nowrap; }
  .kq-inv .kq-ml { width: 68pt; padding-left: 12pt !important; }
  .kq-do .kq-ml { width: 62pt; }
  .kq-q .kq-ml { width: 60.5pt; }
  .kq-mv { white-space: nowrap; }
  /* Partial Shipment 等长标签行：整行合并，标签与输入值同行不重叠 */
  .kq-mfull {
    font-size: 8.5pt !important; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  /* 单号较长时（旧格式 DO-2026-0001）自动缩字号，避免顶出方框 */
  .kq-meta-tbl td.kq-mv-sm { font-size: 9pt; }
  .kq-box { border: .75pt solid #000; padding: 0 2pt !important; }
  .kq-gap td { height: 5pt; line-height: 5pt; }

  /* ---- 紫色条 ---- */
  .kq-bar {
    background: #7030A0; color: #fff;
    font-size: 11pt; font-weight: 700;
    height: 15pt; line-height: 15pt;
  }
  .kq-custbar { margin-top: 13pt; }
  .kq-inv .kq-custbar { width: 134.5pt; padding-left: 14.5pt; }
  .kq-do .kq-custbar { width: 131pt; padding-left: 14.5pt; }
  .kq-q .kq-custbar { width: 128.5pt; padding-left: 14.5pt; }

  /* ---- 客户 ---- */
  .kq-cust { margin-top: 6pt; }
  .kq-cust-name { font-size: 11pt; font-weight: 700; line-height: 14.5pt; }
  .kq-cust-line { font-size: 10pt; line-height: 14.5pt; }
  .kq-do .kq-cust { margin-bottom: 12pt; }
  .kq-q .kq-cust { margin-top: 8pt; margin-bottom: 8pt; }

  /* ---- 表格 ---- */
  .kq-tbl {
    width: 100%; border-collapse: collapse; table-layout: fixed;
    border: .75pt solid #000;
  }
  .kq-tbl th {
    background: #7030A0; color: #fff;
    font-size: 11pt; font-weight: 700;
    height: 15.5pt; line-height: 15.5pt;
    padding: 0 2pt; text-align: center; white-space: nowrap;
    border-left: .75pt solid #000; border-right: .75pt solid #000;
  }
  .kq-tbl td {
    height: 14.5pt; font-size: 9pt;
    padding: 0 3pt; text-align: center; vertical-align: bottom;
    border-left: .75pt solid #000; border-right: .75pt solid #000;
  }
  /* 原 PDF 的斑马纹从表头下第一行开始是浅灰（#F2F2F2），且行间没有横线 */
  .kq-tbl tbody tr:nth-child(odd) td { background: #F2F2F2; }
  /* Invoice：整条明细（两个半行 + PART NO 跨行格）同色，逐条交替，避免一条明细被切成灰白两半 */
  .kq-tbl-inv tbody tr.kq-shade td { background: #F2F2F2; }
  .kq-tbl-inv tbody tr.kq-clear td { background: #ffffff; }
  .kq-tbl tbody tr { page-break-inside: avoid; }
  .kq-tbl td.kq-desc { text-align: left; font-weight: 400; padding-bottom: 2pt; }
  /* Invoice：明细各列（描述/单价/数量/金额）与表头一样居中 */
  .kq-tbl-inv td.kq-desc { text-align: center; padding-left: 3pt; padding-bottom: 0; }
  .kq-tbl-inv tr.kq-item td { text-align: center; }
  .kq-do .kq-tbl td { height: 14.25pt; }
  .kq-th-desc { text-align: left !important; padding-left: 8pt !important; }
  /* Invoice / DO 的 DESCRIPTION 表头居中（Quotation 保持原缩进） */
  .kq-inv .kq-th-desc, .kq-do .kq-th-desc { text-align: center !important; padding-left: 0 !important; }
  .kq-th-pn { text-align: center !important; padding-left: 0 !important; padding-right: 0 !important; }
  .kq-tbl td.kq-pn { text-align: center; padding-left: 0; font-weight: 400; }
  /* Invoice：单行明细，PART NO 与其它列同一行垂直居中 */
  .kq-tbl-inv td.kq-pn { vertical-align: middle; }
  .kq-q .kq-th-desc { text-align: center !important; padding-left: 0 !important; }

  /* Quotation 长描述 */
  .kq-tbl-q tr.kq-q-pad td { height: 15pt; }
  .kq-tbl-q td.kq-q-desc { text-align: center; vertical-align: top; padding: 4pt 3pt 2pt; }
  .kq-q-name { font-size: 12pt; font-weight: 400; line-height: 15pt; }
  .kq-q-line { font-size: 9pt; line-height: 13pt; }
  .kq-tbl-q td.kq-q-num { text-align: center; vertical-align: top; padding-top: 6pt; }
  .kq-tbl-q td.kq-q-amt { text-align: center; vertical-align: top; padding-top: 6pt; }
  .kq-tbl-q td.kq-pn { text-align: center; vertical-align: top; padding: 6pt 0 0; font-size: 9pt; font-weight: 400; }

  /* ---- 底部（银行 + 合计） ---- */
  .kq-foot { display: flex; align-items: flex-start; position: relative; }
  .kq-inv .kq-foot { margin-top: -3pt; }
  .kq-q .kq-foot { margin-top: 21.6pt; }
  /* 报价单合计行距为 15pt（与原报价单一致） */
  .kq-q .kq-tot-tbl td { height: 14.25pt; line-height: 14.25pt; }

  .kq-bank { width: 345pt; }
  .kq-inv .kq-bank { margin-top: 14.5pt; }
  .kq-bankbar { width: 345pt; padding-left: 14.5pt; }
  .kq-bank-tbl { width: 345pt; border-collapse: collapse; margin-top: 7.4pt; }
  .kq-bank-tbl td { padding: 0; font-size: 11pt; line-height: 14.5pt; height: 14.5pt; vertical-align: top; }
  .kq-bl { width: 110.5pt; padding-left: 2.5pt !important; white-space: nowrap; }
  .kq-bv-sm { font-size: 10pt !important; }

  .kq-tot { width: 142pt; margin-left: auto; }
  /* Invoice：合计区整体下移两个正文行高（2 × 14.5pt），与表格底部空出两行 */
  .kq-inv .kq-tot { margin-top: 29pt; }
  .kq-q .kq-tot { width: 141.3pt; }
  .kq-tot-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .kq-tot-tbl td {
    padding: 0; font-size: 10pt; line-height: 14.25pt; height: 14.25pt;
    vertical-align: middle;
    border-bottom: .75pt solid #0070C0;
  }
  .kq-tl { width: 62%; padding-left: 12pt !important; white-space: nowrap; }
  .kq-tv { width: 38%; text-align: right; padding-right: 6pt !important; font-size: 11pt; line-height: 14.25pt; white-space: nowrap; }
  /* Invoice 合计四行文字下沉，贴近各行下方的蓝线 */
  .kq-inv .kq-tot-tbl td { vertical-align: bottom; line-height: 11.6pt; }
  .kq-inv .kq-tot-tbl .kq-tv { line-height: 11.6pt; }
  .kq-inv .kq-total td { vertical-align: top; line-height: 6.8pt; }
  .kq-total td {
    background: #F2F2F2; font-weight: 700; font-size: 11pt;
    border-top: 3pt double #0070C0; border-bottom: none;
    height: 12pt; line-height: 6.8pt; vertical-align: top;
  }
  .kq-cur { padding-right: 10pt; }

  .kq-qcontact { flex: 0 0 330pt; width: 330pt; font-size: 10.5pt; line-height: 14.5pt; }
  .kq-tot { flex: 0 0 auto; }

  /* ---- DO 签收栏 ---- */
  .kq-signs { display: flex; justify-content: space-between; margin-top: 10pt; }
  .kq-sign-l { width: 139.5pt; }
  .kq-sign-r { width: 127pt; }
  .kq-sign-label { font-size: 10.8pt; line-height: 14pt; white-space: nowrap; }
  .kq-sign-space { height: 40pt; }
  .kq-sign-space img { max-height: 26pt; max-width: 120pt; }
  .kq-sign-rule { border-top: .75pt solid #000; margin-top: 2pt; }

  /* ---- 页脚 ---- */
  .kq-thanks { text-align: center; color: #0070C0; font-style: italic; font-weight: 700; font-size: 11pt; }
  .kq-inv .kq-thanks { margin-top: 8pt; }
  .kq-do .kq-thanks { margin-top: 16pt; font-size: 10.8pt; }
  .kq-q .kq-thanks { margin-top: 10pt; font-size: 10.8pt; }
  .kq-thanks-q { position: absolute; left: 44.7pt; bottom: 0; width: 330pt; text-align: center; margin: 0; font-size: 11pt; }
}
