#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Luciferase A4 彩页 — 两个优化版本"""
import base64

def b64(p): return base64.b64encode(open(p,'rb').read()).decode()
LOGO=b64('/tmp/luc_logo.png'); REACT=b64('/tmp/luc_reaction.jpg'); QR=b64('/Users/liuxinyuan/work/公司资料/试用装申请.png')
BASE='/Users/liuxinyuan/Desktop/Hermes输出-工作类/对外物料/'

COMMON='''
@page{size:A4;margin:0}
*{box-sizing:border-box;margin:0;padding:0}
html,body{width:210mm;height:297mm;overflow:hidden}
body{font-family:"PingFang SC","Microsoft YaHei",-apple-system,sans-serif;color:#17324d;background:#fff;-webkit-print-color-adjust:exact;print-color-adjust:exact}
.page{width:210mm;height:297mm;padding:8mm 10mm 7mm;display:flex;flex-direction:column;position:relative;
background:radial-gradient(circle at 95% 4%,rgba(26,115,232,.10),transparent 20%),radial-gradient(circle at 4% 96%,rgba(30,142,90,.07),transparent 18%),#fff}
.top{display:flex;align-items:center;gap:3mm;border-bottom:.6pt solid #dbe6f0;padding-bottom:1.5mm}
.top img{height:8mm}.top .sl{margin-left:auto;font-size:6.8pt;color:#1565c0;letter-spacing:.9pt}
h1{font-size:22pt;line-height:1.1;letter-spacing:.2pt}
h2{font-size:10pt;color:#0b3f7a;margin:2.2mm 0 1.3mm;display:flex;align-items:center;gap:2mm}
h2:before{content:"";width:1.2mm;height:3.8mm;background:#1a73e8;border-radius:.6mm}
p{font-size:7.6pt;line-height:1.5}
.small{font-size:6.4pt;color:#5f7183;line-height:1.45}
.tag{display:inline-block;font-size:6.2pt;background:rgba(255,255,255,.16);border:1px solid rgba(255,255,255,.35);border-radius:1mm;padding:.4mm 1.4mm}
.footer{margin-top:auto;border-top:.6pt solid #dbe6f0;padding-top:1.4mm;display:flex;align-items:center;gap:3.5mm}
.footer .qr{width:12mm;height:12mm;flex:0 0 12mm}.footer .qr img{width:100%;height:100%;object-fit:contain;display:block}
.footer .info{font-size:6.3pt;line-height:1.55;color:#415a70}.footer .info b{color:#0b3f7a;font-size:7pt}
.footer .slogan{margin-left:auto;text-align:right;font-size:6.2pt;color:#1565c0;letter-spacing:.5pt}
'''

# ---------- Version A ----------
A = f'''<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><style>{COMMON}
.hero{{margin-top:2.2mm;background:linear-gradient(120deg,#0b3f7a,#1264b8 55%,#1a73e8);border-radius:2.4mm;color:#fff;padding:4mm 5mm;display:flex;align-items:center;gap:5mm}}
.hero .l{{flex:1}}
.hero .sub{{font-size:8pt;opacity:.94;margin-top:1.2mm}}
.hero .code{{font-size:6.8pt;opacity:.85;margin-top:1mm}}
.hero .stamp{{text-align:right;font-size:6.4pt;line-height:1.6;opacity:.92;border-left:1px solid rgba(255,255,255,.28);padding-left:4mm}}
.hero .stamp b{{display:block;font-size:16pt;line-height:1.1}}
.adv{{display:grid;grid-template-columns:repeat(3,1fr);gap:3mm;margin-top:1mm}}
.card{{border:.7pt solid #dbe6f0;border-radius:2mm;padding:2.6mm 3mm;background:#fff;position:relative;overflow:hidden}}
.card:before{{content:"";position:absolute;left:0;top:0;width:100%;height:1.2mm;background:linear-gradient(90deg,#1a73e8,#7fb3f5)}}
.card h3{{font-size:8.6pt;color:#0b3f7a;margin:.8mm 0 1.2mm}}
.card .big{{font-size:20pt;color:#1a73e8;font-weight:700;line-height:1.05}}
.card .big small{{font-size:7pt;color:#5f7183;font-weight:400}}
.card .cap{{font-size:6.5pt;color:#5f7183;line-height:1.4;margin-top:1mm}}
.chart{{margin-top:1.2mm}}
.chart svg{{width:100%;height:auto;display:block}}
.two{{display:grid;grid-template-columns:1.15fr .85fr;gap:3.2mm;margin-top:1mm}}
.panel{{border:.6pt solid #dbe6f0;border-radius:2mm;padding:2.4mm 3mm;background:#fbfdff}}
.reaction img{{width:100%;height:auto;display:block;margin-top:1mm}}
.apps{{display:grid;grid-template-columns:repeat(2,1fr);gap:1.6mm;margin-top:1mm}}
.app{{border:.5pt solid #dbe6f0;border-radius:1.3mm;padding:1.4mm 1.8mm;background:#fff;font-size:6.8pt;color:#17456e;display:flex;align-items:center;gap:1.4mm}}
.app i{{width:1.6mm;height:1.6mm;border-radius:50%;background:#1a73e8;flex:0 0 1.6mm}}
table{{width:100%;border-collapse:collapse;font-size:6.9pt}}
th{{background:#eaf3fd;color:#17456e;text-align:left;padding:1.2mm 1.8mm;border:.5pt solid #cfe0ef;font-weight:600}}
td{{padding:1.2mm 1.8mm;border:.5pt solid #dbe6f0}}
.order{{display:grid;grid-template-columns:1.25fr .75fr;gap:3mm;margin-top:1mm}}
</style></head><body><div class="page">
<div class="top"><img src="data:image/png;base64,{LOGO}"><span class="sl">守护生命健康，缔造美好生活</span></div>

<div class="hero"><div class="l"><span class="tag">分子诊断原料 · 报告基因</span>
<h1>Luciferase <span style="font-size:11pt;font-weight:400">萤火虫荧光素酶</span></h1>
<div class="sub">基因工程改造 · 高信号 · 耐温稳 · 可冻干</div>
<div class="code">E800系列 ｜ 1 mg/mL ｜ 甘油液体 / 冻干粉</div></div>
<div class="stamp"><b>3×</b>相同酶量<br>荧光信号</div></div>

<h2>产品优势：三个可直接比较的指标</h2>
<div class="adv">
  <div class="card"><h3>信号更强 · 用量更省</h3><div class="big">≈3×<small> 信号</small></div>
    <div class="chart"><svg viewBox="0 0 260 90">
      <text x="0" y="14" font-size="9" fill="#5f7183">相对信号（同酶量）</text>
      <rect x="0" y="26" width="200" height="18" rx="3" fill="#1a73e8"/><text x="208" y="39" font-size="10" fill="#1a73e8" font-weight="700">100</text>
      <rect x="0" y="56" width="66" height="18" rx="3" fill="#c7d3df"/><text x="74" y="69" font-size="10" fill="#7b8ea2">33</text>
      <text x="0" y="88" font-size="8" fill="#415a70">Luciferase</text><text x="120" y="88" font-size="8" fill="#7b8ea2">Supplier N</text>
    </svg></div>
    <div class="cap">相同酶量下，信号值约为竞品 3 倍；同等信号要求下可减少酶用量。</div></div>

  <div class="card"><h3>耐温更稳 · 运输更宽容</h3><div class="big">74% <small>/ 77%</small></div>
    <div class="chart"><svg viewBox="0 0 260 105">
      <text x="0" y="12" font-size="8" fill="#5f7183">7 天活力保留（%）</text>
      <line x1="24" y1="88" x2="250" y2="88" stroke="#dbe6f0"/>
      <rect x="45" y="27" width="26" height="61" rx="2" fill="#1a73e8"/><text x="48" y="22" font-size="9" fill="#1a73e8" font-weight="700">74</text>
      <rect x="78" y="55" width="26" height="33" rx="2" fill="#c7d3df"/><text x="81" y="50" font-size="9" fill="#7b8ea2">40</text>
      <rect x="150" y="24" width="26" height="64" rx="2" fill="#1a73e8"/><text x="153" y="19" font-size="9" fill="#1a73e8" font-weight="700">77</text>
      <rect x="183" y="43" width="26" height="45" rx="2" fill="#c7d3df"/><text x="186" y="38" font-size="9" fill="#7b8ea2">55</text>
      <text x="55" y="101" font-size="8" fill="#415a70">37℃</text><text x="160" y="101" font-size="8" fill="#415a70">25℃</text>
      <text x="108" y="101" font-size="7" fill="#7b8ea2">本品</text><text x="215" y="101" font-size="7" fill="#7b8ea2">竞品</text>
    </svg></div>
    <div class="cap">37℃ 7 天保留 74%（竞品 40%）；25℃ 7 天保留 77%（竞品 55%）。</div></div>

  <div class="card"><h3>形式灵活 · 按需定制</h3><div class="big">2<small> 种形式</small></div>
    <div class="chart"><svg viewBox="0 0 260 90">
      <rect x="18" y="18" width="38" height="52" rx="8" fill="#e8f1fd" stroke="#1a73e8" stroke-width="2"/>
      <path d="M18 45 h38" stroke="#1a73e8" stroke-width="2"/><text x="14" y="86" font-size="8" fill="#415a70">甘油液体</text>
      <rect x="110" y="18" width="38" height="52" rx="5" fill="#e8f1fd" stroke="#1a73e8" stroke-width="2"/>
      <path d="M120 30 h18 M120 40 h18 M120 50 h18" stroke="#1a73e8" stroke-width="2"/><text x="104" y="86" font-size="8" fill="#415a70">冻干粉</text>
      <text x="180" y="42" font-size="10" fill="#1a73e8" font-weight="700">定制</text><text x="180" y="56" font-size="7.5" fill="#5f7183">浓度 / 缓冲 / 规格</text>
    </svg></div>
    <div class="cap">甘油液体与冻干粉两种形式；冻干后性能稳定，支持按应用定制。</div></div>
</div>

<div class="two">
  <div class="panel"><h2 style="margin-top:0">反应原理</h2>
    <div class="reaction"><img src="data:image/jpeg;base64,{REACT}"></div>
    <p class="small" style="margin-top:1mm">D-Luciferin + ATP + O₂ → Oxyluciferin + AMP + CO₂ + PPi + 光（Mg²⁺ 参与）</p>
  </div>
  <div class="panel"><h2 style="margin-top:0">应用方向</h2>
    <div class="apps">
      <div class="app"><i></i>ATP 检测与定量</div><div class="app"><i></i>报告基因检测</div>
      <div class="app"><i></i>细胞活力/代谢</div><div class="app"><i></i>ATP 试剂盒开发</div>
      <div class="app"><i></i>体外诊断原料</div><div class="app"><i></i>分子生物学研究</div>
    </div>
    <p class="small" style="margin-top:2mm">适用于细胞、微生物、环境样本及体外诊断发光体系。</p>
  </div>
</div>

<h2>货号与规格</h2>
<div class="order">
<table><tr><th>产品名称</th><th>货号</th><th>规格</th><th>形式</th></tr>
<tr><td>Luciferase</td><td><b>E800系列</b></td><td>1 mg/mL</td><td>甘油液体 / 冻干粉</td></tr></table>
<div class="panel" style="padding:1.6mm 2.4mm"><p class="small">保存：−20℃ 长期保存，避免反复冻融；冻干粉按说明书复溶。<br>数据：加速稳定性 4℃/25℃/37℃、0/2/4/7 天；竞品为 Supplier N。</p></div>
</div>

<div class="footer"><div class="qr"><img src="data:image/png;base64,{QR}"></div>
<div class="info"><b>珠海宝锐生物科技有限公司</b><br>0756-8699969 ｜ marketing@biori.com ｜ www.biori.com<br>广东省珠海市香洲区水岸一路 88 号</div>
<div class="slogan">BIORI BIOTECH<br>守护生命健康，缔造美好生活</div></div>
</div></body></html>'''

# ---------- Version B ----------
B = f'''<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><style>{COMMON}
.hero{{margin-top:2mm;display:flex;align-items:flex-end;gap:4mm;border-bottom:2.5pt solid #1a73e8;padding-bottom:2mm}}
.hero .tag2{{font-size:6.4pt;color:#1a73e8;letter-spacing:.8pt;font-weight:600}}
.hero h1{{font-size:24pt;color:#0b3f7a;margin-top:.6mm}}
.hero .sub{{font-size:8pt;color:#5f7183;margin-top:.8mm}}
.hero .code{{margin-left:auto;text-align:right;font-size:6.8pt;color:#415a70;line-height:1.5}}
.main{{display:grid;grid-template-columns:1.05fr .95fr;gap:3.5mm;margin-top:3mm}}
.left{{display:flex;flex-direction:column;gap:3mm}}
.box{{border:.6pt solid #dbe6f0;border-radius:2mm;padding:2.4mm 3mm;background:#fff}}
.box h2{{margin-top:0}}
.reaction img{{width:100%;display:block}}
.apps{{display:grid;grid-template-columns:repeat(3,1fr);gap:1.5mm}}
.app{{background:#f3f8fe;border-radius:1.2mm;padding:1.6mm 1.2mm;text-align:center;font-size:6.6pt;color:#17456e;line-height:1.35}}
.app b{{display:block;color:#1a73e8;font-size:7pt;margin-bottom:.4mm}}
table{{width:100%;border-collapse:collapse;font-size:6.8pt}}
th{{background:#eaf3fd;color:#17456e;text-align:left;padding:1.1mm 1.6mm;border:.5pt solid #cfe0ef}}
td{{padding:1.1mm 1.6mm;border:.5pt solid #dbe6f0}}
.dash{{background:linear-gradient(160deg,#0b2f57,#0e4d8a 55%,#1264b8);border-radius:2.4mm;color:#fff;padding:3.4mm 3.6mm;display:flex;flex-direction:column;gap:2.6mm}}
.dash .ttl{{font-size:8.6pt;letter-spacing:.6pt;opacity:.95}}
.dash .row{{display:flex;gap:2.4mm}}
.metric{{flex:1;background:rgba(255,255,255,.10);border:1px solid rgba(255,255,255,.18);border-radius:1.6mm;padding:2mm 2.2mm}}
.metric b{{display:block;font-size:19pt;line-height:1.05}}
.metric span{{font-size:6.3pt;opacity:.88;line-height:1.35;display:block;margin-top:.4mm}}
.metric .cmp{{font-size:6pt;opacity:.75;margin-top:.8mm}}
.chartbox{{background:rgba(255,255,255,.96);border-radius:1.6mm;padding:2mm 2.4mm}}
.chartbox .ct{{font-size:6.8pt;color:#17456e;font-weight:600;margin-bottom:1mm}}
.chartbox svg{{width:100%;height:auto;display:block}}
.twoforms{{display:flex;gap:2mm;align-items:center;background:rgba(255,255,255,.10);border-radius:1.6mm;padding:2mm 2.4mm}}
.twoforms .f{{flex:1;font-size:6.4pt;opacity:.9;text-align:center}}
.twoforms .f b{{display:block;font-size:8pt;margin-top:.4mm}}
.note{{font-size:6.2pt;opacity:.8;line-height:1.5}}
</style></head><body><div class="page">
<div class="top"><img src="data:image/png;base64,{LOGO}"><span class="sl">守护生命健康，缔造美好生活</span></div>

<div class="hero"><div><div class="tag2">MOLECULAR DIAGNOSTICS RAW MATERIAL</div>
<h1>Luciferase <span style="font-size:12pt;font-weight:400;color:#415a70">萤火虫荧光素酶</span></h1>
<div class="sub">基因工程改造 · 高信号 · 耐温稳 · 可冻干</div></div>
<div class="code">E800系列<br>1 mg/mL<br>甘油液体 / 冻干粉</div></div>

<div class="main">
  <div class="left">
    <div class="box"><h2>反应原理</h2><div class="reaction"><img src="data:image/jpeg;base64,{REACT}"></div>
      <p class="small" style="margin-top:1mm">D-Luciferin + ATP + O₂ → Oxyluciferin + AMP + CO₂ + PPi + 光（Mg²⁺ 参与）</p></div>
    <div class="box"><h2>应用方向</h2><div class="apps">
      <div class="app"><b>ATP</b>检测与定量</div><div class="app"><b>REPORT</b>报告基因</div><div class="app"><b>CELL</b>活力/代谢</div>
      <div class="app"><b>KIT</b>试剂盒开发</div><div class="app"><b>IVD</b>体外诊断原料</div><div class="app"><b>RESEARCH</b>分子生物学</div>
    </div></div>
    <div class="box"><h2>货号与形式</h2><table>
      <tr><th>产品</th><th>货号</th><th>规格</th><th>形式</th></tr>
      <tr><td>Luciferase</td><td><b>E800系列</b></td><td>1 mg/mL</td><td>液体/冻干粉</td></tr>
    </table><p class="small" style="margin-top:1.2mm">保存：−20℃ 长期保存，避免反复冻融；冻干粉按说明书复溶。支持浓度/缓冲/规格定制。</p></div>
  </div>

  <div class="dash">
    <div class="ttl">核心性能 · 同酶量对比</div>
    <div class="row">
      <div class="metric"><b>3×</b><span>荧光信号</span><div class="cmp">Luciferase vs Supplier N</div></div>
      <div class="metric"><b>74%</b><span>37℃ 7 天活力</span><div class="cmp">竞品 40%</div></div>
      <div class="metric"><b>77%</b><span>25℃ 7 天活力</span><div class="cmp">竞品 55%</div></div>
    </div>
    <div class="chartbox"><div class="ct">相对信号（同酶量）</div>
      <svg viewBox="0 0 300 70">
        <rect x="0" y="12" width="230" height="18" rx="3" fill="#1a73e8"/><text x="238" y="26" font-size="12" fill="#0b3f7a" font-weight="700">100</text>
        <rect x="0" y="40" width="76" height="18" rx="3" fill="#c7d3df"/><text x="84" y="54" font-size="12" fill="#7b8ea2">33</text>
        <text x="0" y="68" font-size="8" fill="#415a70">Luciferase</text><text x="150" y="68" font-size="8" fill="#7b8ea2">Supplier N</text>
      </svg></div>
    <div class="chartbox"><div class="ct">7 天活力保留（%）</div>
      <svg viewBox="0 0 300 120">
        <line x1="24" y1="98" x2="292" y2="98" stroke="#dbe6f0"/>
        <rect x="48" y="25" width="28" height="73" rx="2" fill="#1a73e8"/><text x="51" y="20" font-size="11" fill="#0b3f7a" font-weight="700">74</text>
        <rect x="82" y="58" width="28" height="40" rx="2" fill="#c7d3df"/><text x="85" y="53" font-size="11" fill="#7b8ea2">40</text>
        <rect x="168" y="21" width="28" height="77" rx="2" fill="#1a73e8"/><text x="171" y="16" font-size="11" fill="#0b3f7a" font-weight="700">77</text>
        <rect x="202" y="43" width="28" height="55" rx="2" fill="#c7d3df"/><text x="205" y="38" font-size="11" fill="#7b8ea2">55</text>
        <text x="55" y="114" font-size="8" fill="#415a70">37℃</text><text x="175" y="114" font-size="8" fill="#415a70">25℃</text>
        <text x="118" y="114" font-size="7" fill="#7b8ea2">本品</text><text x="238" y="114" font-size="7" fill="#7b8ea2">竞品</text>
      </svg></div>
    <div class="twoforms"><div class="f">甘油液体<b>1 mg/mL</b></div><div class="f">冻干粉<b>定制</b></div></div>
    <div class="note">加速稳定性：4℃/25℃/37℃、0/2/4/7 天；信号为化学发光 RLU，活力以 0 天为 100%。竞品为 Supplier N。</div>
  </div>
</div>

<div class="footer"><div class="qr"><img src="data:image/png;base64,{QR}"></div>
<div class="info"><b>珠海宝锐生物科技有限公司</b><br>0756-8699969 ｜ marketing@biori.com ｜ www.biori.com<br>广东省珠海市香洲区水岸一路 88 号</div>
<div class="slogan">BIORI BIOTECH<br>守护生命健康，缔造美好生活</div></div>
</div></body></html>'''

for name,html in [('Luciferase_A4_优化版A_优势卡片_20261027.html',A),('Luciferase_A4_优化版B_数据看板_20261027.html',B)]:
    p=BASE+name; open(p,'w',encoding='utf-8').write(html); print('saved',p,len(html))
