:root {
  --navy: #1a3a6b; --navy-dark: #122a4f; --accent: #2b6cb0;
  --bg: #eef1f6; --card: #ffffff; --border: #d8dee9;
  --text: #24292f; --muted: #6b7280; --danger: #c0392b; --ok: #1a7f37;
  --paper-line: #555;
}
[v-cloak] { display: none; }
* { box-sizing: border-box; }
body { margin: 0; font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); cursor: pointer; text-decoration: none; margin-right: 8px; }
a.danger { color: var(--danger); }
code { background: #eef2f7; border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; margin: 2px; display: inline-block; font-size: 12px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); }
input:focus, textarea:focus, select:focus { outline: 2px solid #b8cdea; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; }

/* ================= 登录 ================= */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1100px 620px at 18% 22%, #2c5794 0%, transparent 62%),
              linear-gradient(135deg, #16305c 0%, #0c1c37 100%);
}
.login-panel {
  display: grid; grid-template-columns: 1fr 1fr; width: 880px; max-width: 100%;
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.login-brand {
  background: linear-gradient(158deg, #1e4179 0%, #12294c 100%);
  color: #fff; padding: 52px 44px; display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.login-brand::after {
  content: ""; position: absolute; width: 320px; height: 320px; right: -130px; bottom: -130px;
  border-radius: 50%; background: rgba(255,255,255,.06);
}
.brand-mark { font-size: 40px; margin-bottom: 16px; }
.login-brand h1 { margin: 0; font-size: 27px; letter-spacing: 1px; font-weight: 600; color: #ffffff; }
.brand-sub { margin: 8px 0 30px; color: #9fbde6; letter-spacing: 3px; font-size: 11.5px; text-transform: uppercase; }
.brand-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; position: relative; z-index: 1; }
.brand-points li { color: #e3ebf7; font-size: 13.5px; padding-left: 24px; position: relative; }
.brand-points li::before { content: "✓"; position: absolute; left: 0; color: #8ec1ff; font-weight: bold; }

.login-form { padding: 54px 48px; display: flex; flex-direction: column; }
.login-form h2 { margin: 0; font-size: 24px; color: var(--navy); font-weight: 600; }
.form-sub { margin: 7px 0 28px; color: var(--muted); font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field > span { font-size: 13px; color: #4b5563; font-weight: 500; }
.field input { width: 100%; padding: 11px 12px; border-radius: 8px; font-size: 15px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.field input::placeholder { color: #9aa3af; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(43,108,176,.15); }
.field input:disabled { background: #f6f7f9; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: transparent; cursor: pointer; font-size: 15px; padding: 4px 6px; line-height: 1; }
.login-err { margin: -6px 0 14px; padding: 9px 12px; border-radius: 7px; font-size: 13px; background: #fdecea; color: #a02b1c; border: 1px solid #f5c6c0; }
.btn.lg { padding: 12px 16px; font-size: 15px; letter-spacing: 3px; border-radius: 8px; }
.login-tip { margin: 18px -10px 0; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.9; }
.login-tip code { background: #eef2f7; padding: 1px 6px; font-size: 12px; color: var(--navy); }

/* ================= 布局 ================= */
header { display: flex; align-items: center; background: var(--navy); color: #fff; padding: 0 20px; height: 52px; position: sticky; top: 0; z-index: 10; }
.logo { font-weight: bold; margin-right: 28px; }
nav { display: flex; gap: 4px; flex: 1; }
nav a { color: #c7d4e8; padding: 15px 14px; margin: 0; border-bottom: 3px solid transparent; }
nav a.active { color: #fff; border-bottom-color: #7fb3ff; }
nav a:hover { color: #fff; }
header .user { color: #c7d4e8; }
header .user a { color: #fff; margin-left: 8px; }
main { max-width: 1240px; margin: 20px auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.card h2 { margin: 0 0 12px; font-size: 16px; color: var(--navy); }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 10px; }
.hint { color: var(--muted); font-size: 13px; }
.hint.ok, .ok { color: var(--ok); }
.err { color: var(--danger); font-size: 13px; }
.r { text-align: right; } .c { text-align: center; }
.money { font-variant-numeric: tabular-nums; }

.btn { display: inline-block; padding: 7px 16px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font: inherit; color: var(--text); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); color: #fff; }
.btn.primary:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.sm { padding: 4px 10px; font-size: 13px; }

.field-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.field-row label { width: 110px; padding-top: 7px; color: var(--muted); flex-shrink: 0; }
.field-row input, .field-row textarea { flex: 1; max-width: 480px; }

.match-block { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; background: #fafbfd; }
.match-head { margin-bottom: 8px; }
.match-head a { float: right; }
.match-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.match-option { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; background: #fff; }
.match-option.selected { border-color: var(--accent); background: #eef4fc; }
.m-name { font-weight: 600; }
.m-model { color: var(--muted); flex: 1; }
.m-price { color: var(--navy); font-weight: 600; }

/* ================= 工具栏 ================= */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: sticky; top: 52px; z-index: 6; }
.tb-label { color: var(--muted); font-size: 12.5px; }
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

.fmt-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; position: sticky; top: 118px; z-index: 5; padding: 10px 14px; }
.fmt-bar.disabled { opacity: .75; }
.fmt-target { color: var(--navy); font-size: 12.5px; font-weight: 600; min-width: 200px; }
.fmt-btn { width: 30px; height: 28px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: pointer; font-size: 13px; color: var(--text); }
.fmt-btn:hover { border-color: var(--accent); }
.fmt-btn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.fmt-btn[disabled] { opacity: .4; cursor: not-allowed; }
.fmt-bar .fmt-btn:last-of-type { width: auto; padding: 0 10px; }
.color-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.color-dot.on { box-shadow: 0 0 0 2px var(--accent); }
.color-pick { width: 30px; height: 28px; padding: 2px; cursor: pointer; }
.over-page { color: var(--danger); font-weight: 600; }

/* ================= A4 纸面 ================= */
.paper-scroll { overflow-x: auto; padding-bottom: 30px; display: flex; justify-content: center; }
.paper.a4 {
  background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.16);
  padding: 15mm; flex-shrink: 0;
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif; color: #000;
  font-size: 10.5pt; line-height: 1.45;
}
.paper.a4.portrait { width: 210mm; min-height: 297mm; }
.paper.a4.landscape { width: 297mm; min-height: 210mm; }
.paper.a4.compact { font-size: 8.5pt; line-height: 1.25; }
.paper.a4.compact .p-table th, .paper.a4.compact .p-table td { padding: 2px 4px; }

.p-company { text-align: center; font-size: 15pt; font-weight: bold; color: #000; margin-bottom: 2mm; }
.p-title { text-align: center; font-size: 19pt; font-weight: bold; letter-spacing: 6px; margin: 0 0 3mm; color: #000; }
.paper.a4.landscape .p-title { font-size: 13pt; letter-spacing: 3px; }
.p-meta { display: flex; justify-content: flex-end; gap: 20px; font-size: 9.5pt; margin-bottom: 3mm; }
.inline-date { border: none; background: transparent; font: inherit; color: inherit; padding: 0 2px; width: 125px; }
.inline-date:hover { background: #f2f6fc; }

.p-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1px 12mm; margin-bottom: 3mm; font-size: 9.5pt; }
.party-row { display: flex; align-items: baseline; min-height: 5.2mm; }
.party-row > span:first-child { flex-shrink: 0; min-width: 20mm; }
.paper.a4.landscape .party-row > span:first-child { min-width: 24mm; }
.ed.grow { flex: 1; }

/* 可编辑元素 */
.ed { display: inline-block; min-width: 8px; min-height: 1em; outline: none; border-radius: 2px; padding: 0 2px; }
.ed:hover { background: #f0f5fd; box-shadow: inset 0 0 0 1px #c9dcf5; }
.ed:focus { background: #fff; box-shadow: inset 0 0 0 2px var(--accent); }
.ed.num { text-align: right; min-width: 40px; font-variant-numeric: tabular-nums; }
.ed.spec { white-space: pre-wrap; }

/* 明细表 */
.p-table { width: 100%; border-collapse: collapse; margin-bottom: 2mm; table-layout: fixed; }
.p-table th, .p-table td { border: 1px solid var(--paper-line); padding: 4px 5px; vertical-align: middle; word-break: break-word; }
.p-table th { background: #eef2f8; font-weight: bold; text-align: center; font-size: 9.5pt; color: #000; }
.p-table th small { display: block; font-weight: normal; font-size: 7.5pt; color: #444; }
.p-table.eng th, .p-table.eng td { font-size: 8.5pt; padding: 3px 4px; }
.p-table tfoot td { background: #f7f9fc; font-weight: bold; }
.p-table tfoot .cn { font-weight: normal; font-size: 9pt; }
.group-row td { background: #e9eff8; font-weight: bold; text-align: left; }
.row-del { border: none !important; background: transparent; width: 22px; text-align: center; }
.row-del a, .row-del-inline { font-size: 12px; opacity: 0; transition: opacity .12s; }
.p-table tbody tr:hover .row-del a, .group-row:hover .row-del-inline { opacity: 1; }
.row-del-inline { float: right; margin-right: 2px; }
.p-table tfoot .cn { font-size: 8.5pt; white-space: nowrap; }

.row-tools { display: flex; gap: 8px; align-items: center; margin: 2mm 0 3mm; }
.row-tools input { width: 240px; }

.p-terms { margin-top: 2mm; font-size: 9pt; }
.terms-title { font-weight: bold; margin-bottom: 1mm; }
.p-terms ol { margin: 0; padding-left: 20px; }
.p-terms li { margin-bottom: 0.6mm; display: flex; gap: 6px; align-items: baseline; }
.p-sign { display: flex; gap: 40px; margin-top: 5mm; font-size: 9.5pt; }

/* 列表 */
.list-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.list-table th, .list-table td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.list-table th { color: var(--muted); font-weight: 600; background: #f7f9fc; }
.list-table th.r, .list-table td.r { text-align: right; }
.list-table tr:hover td { background: #f6f9fe; }
.tag { background: #eef2f7; border-radius: 10px; padding: 2px 10px; font-size: 12px; }
.ph-list code { margin: 2px 4px 2px 0; }
.ai-answer { margin-top: 12px; background: #f0f6ff; border: 1px solid #c3d9f5; border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; }

.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 12px; padding: 24px 28px; width: 560px; max-height: 84vh; overflow: auto; }
.modal h2 { margin-top: 0; color: var(--navy); }
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: var(--navy-dark); color: #fff; padding: 10px 22px; border-radius: 8px; z-index: 99; box-shadow: 0 4px 16px rgba(0,0,0,.25); }

@media (max-width: 760px) {
  .login-panel { grid-template-columns: 1fr; width: 420px; }
  .login-brand { padding: 32px; }
  .brand-points { display: none; }
  .login-form { padding: 32px 28px; }
}

/* ================= 打印 ================= */
@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: #fff; }
  header, .toolbar, .fmt-bar, .no-print, .row-del, .row-del-inline,
  section:not(:has(.paper)), .card:not(.paper) { display: none !important; }
  main { max-width: none; margin: 0; padding: 0; }
  .paper-scroll { overflow: visible; padding: 0; display: block; }
  .paper.a4 { box-shadow: none; width: auto; min-height: auto; padding: 12mm; }
  .ed:hover, .ed:focus { background: transparent !important; box-shadow: none !important; }
  .inline-date { border: none; }
}
@media print { .paper.a4.landscape { page: landscape; } }
@page landscape { size: A4 landscape; margin: 0; }

/* ================= V2 平台化 ================= */
main.wide { max-width: none; margin: 20px 18px; }
.nowrap { white-space: nowrap; }
.role-badge { background: rgba(255,255,255,.15); border-radius: 10px; padding: 2px 10px; font-size: 12px; margin-right: 8px; }
.tag.role-admin { background: #fde8e8; color: #a02b1c; }
.tag.role-supervisor { background: #e8f0fd; color: #1a3a6b; }
.tag.role-employee { background: #eef2f7; }

/* 产品库 */
.products-table .thumb { width: 46px; height: 46px; object-fit: contain; border: 1px solid var(--border); border-radius: 4px; cursor: zoom-in; background: #fff; }
.thumb.lg { width: 90px; height: 90px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; }
.spec-col { min-width: 260px; }
.spec-text { max-height: 3.2em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12.5px; color: #444; }
.lightbox { position: fixed; inset: 0; margin: auto; max-width: 80vw; max-height: 80vh; z-index: 200; background: #fff; padding: 12px; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); cursor: zoom-out; }

/* 纸面头部:编号左上 */
.p-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 9.5pt; margin-bottom: 1mm; }
.p-no { font-weight: bold; font-size: 10.5pt; }

/* 图片单元格 */
.img-cell { display: flex; align-items: center; justify-content: center; gap: 3px; min-height: 10mm; }
.img-cell img { max-width: 100%; max-height: 18mm; object-fit: contain; cursor: pointer; }
.img-add { border: 1px dashed var(--border); background: #fafbfd; border-radius: 4px; padding: 3px 8px; cursor: pointer; color: var(--muted); font-size: 11px; }
.img-add:hover { border-color: var(--accent); color: var(--accent); }
.img-del { font-size: 11px; }
.p-table td .img-cell img { display: block; }
.p-table tfoot td.l { text-align: left; }

/* 弹窗尺寸 */
.modal.lg { width: 680px; }
.modal.xl { width: 1080px; max-width: 96vw; }
.modal h3 { color: var(--navy); font-size: 14px; margin: 14px 0 8px; }

/* 模板设计器 */
.tpl-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 24px; }
.col-config { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.col-item { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 5px; background: #f7f9fc; }
.col-item.off { opacity: .5; background: transparent; }
.col-item .col-name { flex: 1; }
.col-ops a { font-size: 14px; padding: 0 4px; }
.col-ops a.dis { opacity: .25; pointer-events: none; }
.term-pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.term-pick { display: flex; align-items: baseline; gap: 6px; font-size: 12.5px; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.term-pick:hover { background: #f0f5fd; }

/* 模板缩放预览:A4 横向按容器宽度缩放 */
.tpl-preview-box { border: 1px solid var(--border); border-radius: 8px; background: #e8ebf0; padding: 12px; overflow: hidden; }
.tpl-preview-box .paper.mini { transform: scale(0.42); transform-origin: top left; width: 297mm; min-height: 210mm; padding: 10mm; box-shadow: 0 2px 10px rgba(0,0,0,.2); margin-bottom: calc(-210mm * 0.58); margin-right: calc(-297mm * 0.58); }
.tpl-preview-box.big { display: flex; justify-content: center; }
.tpl-preview-box.big .paper.mini { transform: scale(0.62); margin-bottom: calc(-210mm * 0.38); margin-right: 0; }
.fmt-btn.wide { width: auto; padding: 0 10px; }

/* ================= 产品库重设计 ================= */
.prod-card { padding: 0; overflow: hidden; }
.prod-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fbfcfe, #f4f6fa);
  flex-wrap: wrap;
}
.prod-toolbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.prod-toolbar-right { display: flex; align-items: center; gap: 8px; }

.search-box { position: relative; display: flex; align-items: center; }
.search-box input { width: 320px; padding: 8px 30px 8px 32px; border-radius: 20px; }
.search-ico { position: absolute; left: 10px; font-size: 13px; opacity: .55; pointer-events: none; }
.search-clear { position: absolute; right: 10px; color: var(--muted); margin: 0; font-size: 12px; }

.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: 6px 14px; margin: 0; color: var(--muted); font-size: 13px; border-right: 1px solid var(--border); }
.seg a:last-child { border-right: none; }
.seg a.on { background: var(--navy); color: #fff; }

.prod-scroll { overflow: auto; max-height: calc(100vh - 210px); }
.prod-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.prod-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--navy); color: #fff; font-weight: 600; font-size: 13px;
  padding: 10px 10px; text-align: left; white-space: nowrap;
}
.prod-table td { padding: 6px 10px; border-bottom: 1px solid #edf0f5; vertical-align: middle; }
.prod-table tbody tr:hover td { background: #f2f7ff; }
.prod-table tbody tr.disabled-row td { opacity: .55; background: #fafafa; }

/* 列宽 */
.col-seq   { width: 48px; text-align: center; color: var(--muted); }
.col-img   { width: 68px; }
.col-name  { width: 24%; }
.col-model { width: 15%; }
.col-spec  { width: auto; }
.col-unit  { width: 52px; text-align: center; }
.col-price { width: 110px; text-align: right; }
.col-tax   { width: 56px; text-align: center; }
.col-ops   { width: 142px; text-align: center; white-space: nowrap; }
.prod-table th.col-price { text-align: right; }
.prod-table th.col-seq, .prod-table th.col-unit, .prod-table th.col-tax, .prod-table th.col-ops { text-align: center; }

/* 等高缩略图 + 悬停大图 */
.thumb-wrap { position: relative; display: inline-block; }
.thumb-sm {
  height: 40px; width: 52px; object-fit: contain; display: block;
  border: 1px solid var(--border); border-radius: 5px; background: #fff; cursor: zoom-in;
}
.thumb-pop {
  display: none; position: absolute; left: 60px; top: 50%; transform: translateY(-50%);
  z-index: 30; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px; box-shadow: 0 10px 34px rgba(0,0,0,.25);
}
.thumb-pop img { max-width: 260px; max-height: 220px; display: block; }
.thumb-wrap:hover .thumb-pop { display: block; }
.no-img { color: #c3c9d4; font-size: 12px; }

/* 单行省略 + 悬停浮层显示全文 */
.cell-clip {
  display: block; position: relative; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%; cursor: default;
}
.cell-clip.name-text { font-weight: 600; color: #1d2b45; }
.cell-clip:hover::after {
  content: attr(data-full);
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 40;
  background: #202a3c; color: #fff; font-size: 12.5px; line-height: 1.7; font-weight: normal;
  padding: 9px 12px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.3);
  white-space: pre-wrap; width: max-content; max-width: 460px;
}
.cell-clip[data-full=""]:hover::after { display: none; }

/* 操作按钮 */
.op-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 5px;
  padding: 3px 10px; font-size: 12.5px; cursor: pointer; color: var(--accent); margin: 0 2px;
}
.op-btn:hover { border-color: var(--accent); background: #eef4fc; }
.op-btn.danger { color: var(--danger); }
.op-btn.danger:hover { border-color: var(--danger); background: #fdf0ee; }
.op-btn.ok { color: var(--ok); }
.op-btn.ok:hover { border-color: var(--ok); background: #edf8f0; }
.tag.warn { background: #fdf3e0; color: #9a6b12; }


/* ================= 页码页脚 / 多页打印 ================= */
.paper.a4 { position: relative; }
.p-pagefoot { position: absolute; bottom: 6mm; left: 0; right: 0; text-align: center; font-size: 8pt; color: #333; }
.cn-line { font-weight: normal; }
@media print {
  .p-table thead { display: table-header-group; }   /* 跨页每页重复表头 */
  .p-table tfoot { display: table-row-group; }      /* 合计只出现一次(随内容流) */
  .p-table tr { page-break-inside: avoid; }
}

/* AI 提示词编辑 */
.prompt-ta { font-size: 12.5px; line-height: 1.7; font-family: inherit; max-width: 720px !important; }
.sm-link { font-size: 12px; display: inline-block; margin-top: 4px; }
