/* ============================================================
   票管大师官网 · 在线工具页
   ============================================================ */

.site-nav > a.is-current {
    color: var(--brand);
    background: rgba(37, 99, 235, .08);
    font-weight: 600;
}

.tool-page { padding-top: 72px; }

/* ---------- 工具页头部 ---------- */
.tool-hero {
    padding: 64px 0 0;
    background:
        radial-gradient(900px 420px at 82% -20%, rgba(96, 165, 250, .2), transparent 62%),
        radial-gradient(700px 360px at 6% 0%, rgba(79, 70, 229, .12), transparent 58%),
        #fff;
}
.tool-hero h1 {
    font-size: clamp(28px, 3.6vw, 42px);
    margin: 20px 0 14px;
    letter-spacing: -.03em;
}
.tool-hero > .container > p {
    /* 这句话约 43 个汉字，16px 下需要 690px 左右；620px 会硬折行，宽屏下给足一行 */
    max-width: 780px;
    font-size: 16px;
    color: var(--ink-3);
    line-height: 1.75;
}

/* ---------- 切换标签 ---------- */
.tool-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 30px;
    padding: 5px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
}
.tool-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-2);
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .2s, color .2s, box-shadow .2s;
}
.tool-tab svg { width: 17px; height: 17px; }
.tool-tab:hover { color: var(--brand); background: rgba(37, 99, 235, .07); }
.tool-tab.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    box-shadow: 0 8px 18px -10px rgba(37, 99, 235, .9);
}
.tool-tab.is-active:hover { color: #fff; }

/* ---------- 工具主体 ---------- */
.tool-body {
    padding: 36px 0 96px;
    background: var(--bg-soft);
    border-top: 1px solid var(--line);
    margin-top: 36px;
}
.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
    animation: panelIn .32s var(--ease);
}
.panel[hidden] { display: none; }
@keyframes panelIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.tool-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 36px;
    align-items: start;
}
.tool-controls { display: flex; flex-direction: column; gap: 20px; }

/* ---------- 表单控件 ---------- */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}
.field-label output {
    font-weight: 700;
    color: var(--brand);
    font-variant-numeric: tabular-nums;
}
.field textarea,
.field select,
.field input[type="text"],
.field input[type="number"] {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #dbe2ee;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    line-height: 1.6;
    transition: border-color .18s, box-shadow .18s;
}
.field textarea { resize: vertical; min-height: 92px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace; font-size: 13px; }
.field textarea:focus,
.field select:focus,
.field input:focus {
    outline: 0;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.field select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5l5-5' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 11px;
    padding-right: 34px;
}
.field input[type="color"] {
    width: 100%;
    height: 44px;
    padding: 3px;
    border: 1px solid #dbe2ee;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}
.field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 7px; }
.field input[type="color"]::-moz-color-swatch { border: 0; border-radius: 7px; }
.field input[type="range"] { width: 100%; margin: 12px 0 0; accent-color: var(--brand); }

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
}
.field-hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- 二维码预览 ---------- */
.tool-preview { display: flex; flex-direction: column; gap: 14px; }
.qr-stage {
    display: grid;
    place-items: center;
    padding: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background:
        linear-gradient(45deg, #f1f4f9 25%, transparent 25%, transparent 75%, #f1f4f9 75%) 0 0 / 18px 18px,
        linear-gradient(45deg, #f1f4f9 25%, transparent 25%, transparent 75%, #f1f4f9 75%) 9px 9px / 18px 18px,
        #fff;
}
/* 二维码中心 Logo 选择行 */
.qr-logo-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.qr-logo-row .btn {
    padding: 7px 14px;
    font-size: 13.5px;
}

/* .btn 自带 display，会盖掉 hidden 的浏览器默认样式，这里显式关掉 */
.qr-logo-row .btn[hidden] {
    display: none;
}

.qr-logo-name {
    font-size: 12.5px;
    color: var(--ink-3);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#qrCanvas {
    width: 100%;
    max-width: 340px;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 6px 20px -13px rgba(15, 23, 42, .5);
    image-rendering: pixelated;
}
.preview-note { font-size: 12.5px; color: var(--ink-3); text-align: center; }

/* ---------- 拖放区 ---------- */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 46px 24px;
    text-align: center;
    border: 1.5px dashed #cfd9ea;
    border-radius: var(--radius);
    background: #fbfcff;
    cursor: pointer;
    transition: border-color .2s, background-color .2s, transform .2s var(--ease);
}
.dropzone:hover,
.dropzone.is-over {
    border-color: var(--brand);
    background: #f2f7ff;
}
.dropzone.is-over { transform: scale(.995); }
.dropzone svg { width: 34px; height: 34px; color: var(--brand); }
.dropzone strong { font-size: 15.5px; }
.dropzone span { font-size: 13px; color: var(--ink-3); max-width: 44em; line-height: 1.7; }

.drop-status { margin-top: 14px; font-size: 13.5px; color: var(--ink-3); min-height: 0; }
.drop-status.is-error { color: #b42318; }
.drop-status.is-ok { color: #137a3f; }

/* ---------- 结果区 ---------- */
.result { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 24px; }
.result[hidden] { display: none; }
.result-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}
.result-title { font-size: 18px; }
.result-sub { margin-top: 5px; font-size: 13px; color: var(--ink-3); }
.result-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* 视图切换（原始版式 / 标准票面） */
.view-switch {
    display: inline-flex;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f1f5fb;
}
.view-switch[hidden] { display: none; }
.view-switch button {
    border: 0;
    background: transparent;
    border-radius: 999px;
    padding: 7px 15px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-3);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .18s, color .18s, box-shadow .18s;
}
.view-switch button:hover { color: var(--brand); }
.view-switch button.is-active {
    background: #fff;
    color: var(--brand);
    box-shadow: 0 2px 8px -4px rgba(15, 23, 42, .3);
}

.sheet-viewport {
    overflow: auto;
    padding: 20px;
    border-radius: 12px;
    background: #eef1f6;
    border: 1px solid #e3e9f3;
}
.sheet-box {
    position: relative;
    overflow: hidden;
    margin: 0 auto;
}
.sheet-scaler {
    position: absolute;
    top: 0;
    left: 0;
    width: max-content;
    transform-origin: top left;
}

/* ---------- 提示块 ---------- */
.notice {
    margin-top: 28px;
    padding: 18px 20px;
    border-left: 3px solid var(--brand-light);
    background: #f7faff;
    border-radius: 0 10px 10px 0;
}
.notice h3 { font-size: 14px; margin-bottom: 7px; color: var(--ink); }
.notice p { font-size: 13px; color: var(--ink-3); line-height: 1.85; }

/* ---------- XML 工具 ---------- */
.xml-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
/* .btn 的 display 会盖掉 [hidden] 的 UA 规则，这里显式隐藏 */
.xml-bar [hidden] { display: none !important; }

/* ---------- 二维码解码 ---------- */
.qr-decode-grid {
    display: grid;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    gap: 24px;
    align-items: start;
}
.qr-decode-stage {
    display: grid;
    place-items: center;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        linear-gradient(0deg, rgba(15, 23, 42, .03), rgba(15, 23, 42, .03)),
        repeating-conic-gradient(#f4f6fa 0% 25%, #fff 0% 50%) 0 0 / 16px 16px;
}
.qr-decode-stage canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 10px -4px rgba(15, 23, 42, .25);
}
.qr-decode-side { display: flex; flex-direction: column; gap: 14px; }
.qr-fields {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}
.qr-fields[hidden] { display: none; }
.qr-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.qr-table th,
.qr-table td {
    padding: 9px 14px;
    font-size: 13px;
    line-height: 1.6;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}
.qr-table tr:last-child th,
.qr-table tr:last-child td { border-bottom: 0; }
.qr-table th {
    width: 34%;
    font-weight: 500;
    color: var(--ink-3);
    background: #fafbfd;
    white-space: nowrap;
}
.qr-table td {
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

/* ============================================================
   票面（数电票版式）
   ============================================================ */
.invoice-sheet {
    position: relative;
    width: 210mm;
    min-height: 120mm;
    padding: 8mm 10mm 10mm;
    background: #fff;
    color: #16181d;
    box-sizing: border-box;
    font-family: "SimSun", "Songti SC", "STSong", "Noto Serif SC", serif;
    font-size: 9pt;
    line-height: 1.6;
}
.invoice-sheet * { box-sizing: border-box; }

.inv-head {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 12px;
    padding-bottom: 3mm;
    border-bottom: 1.2pt solid #16181d;
}
.inv-titles { text-align: center; }
.inv-kicker {
    display: inline-block;
    font-size: 7.5pt;
    letter-spacing: .28em;
    color: #4a5160;
    margin-bottom: 1.5mm;
}
.inv-title {
    font-size: 15pt;
    font-weight: 700;
    letter-spacing: .06em;
    line-height: 1.3;
}
.inv-meta {
    display: flex;
    flex-direction: column;
    gap: 1mm;
    font-size: 8.5pt;
    color: #2b3040;
    padding-top: 1mm;
    white-space: nowrap;
}
.inv-meta b { font-weight: 700; letter-spacing: .02em; }

.inv-parties { border: .6pt solid #555; border-top: 0; }
.inv-party { display: grid; grid-template-columns: 11mm 1fr; }
.inv-party + .inv-party { border-top: .6pt solid #555; }
.party-label {
    display: grid;
    place-items: center;
    padding: 2mm 1mm;
    font-size: 8pt;
    line-height: 1.15;
    text-align: center;
    color: #2b3040;
    border-right: .6pt solid #555;
    writing-mode: vertical-rl;
    letter-spacing: .12em;
}
.party-body { padding: 2mm 2.5mm; display: flex; flex-direction: column; gap: 1mm; }
.party-row { display: flex; gap: 2mm; font-size: 8.5pt; }
.party-row .k { flex: none; color: #2b3040; }
.party-row .v { word-break: break-all; }

.inv-table { width: 100%; border-collapse: collapse; border: .6pt solid #555; border-top: 0; }
.inv-table th,
.inv-table td {
    border-right: .6pt solid #555;
    border-bottom: .6pt solid #555;
    padding: 1.4mm 1.6mm;
    font-size: 8.5pt;
    vertical-align: middle;
    text-align: center;
}
.inv-table th {
    background: #f3f5f8;
    font-weight: 700;
    white-space: nowrap;
}
.inv-table th:last-child,
.inv-table td:last-child { border-right: 0; }
.inv-table tbody tr:last-child td { border-bottom: .6pt solid #555; }
.inv-table td.name { text-align: left; }
.inv-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-table tfoot td { background: #fafbfd; font-weight: 700; }
.inv-table tfoot .sum-label { text-align: right; }

.inv-total {
    display: flex;
    align-items: center;
    gap: 4mm;
    padding: 2mm 2.5mm;
    border: .6pt solid #555;
    border-top: 0;
    font-size: 8.5pt;
    background: #fafbfd;
}
.inv-total .cn { font-weight: 700; letter-spacing: .06em; }
.inv-total .num { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.inv-foot {
    display: flex;
    gap: 6mm;
    padding: 2.5mm 2.5mm 0;
    font-size: 8.5pt;
}
.inv-remark { flex: 1; }
.inv-remark .k { color: #2b3040; }
.inv-remark .v { white-space: pre-wrap; word-break: break-all; }
.inv-drawer { flex: none; white-space: nowrap; }

.inv-empty { color: #98a2b3; font-style: italic; }

/* ============================================================
   信息核对单（不还原发票版式，避免被截图冒用）
   ============================================================ */
.bill-sheet {
    padding: 10mm;
    font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 9pt;
}
.bill-head { padding-bottom: 3mm; }
.bill-title {
    font-size: 16pt;
    font-weight: 700;
    text-align: center;
    letter-spacing: .1em;
}
.bill-warn {
    margin: 4mm 0 5mm;
    padding: 2.5mm 3mm;
    border: .6pt dashed #d9a3a3;
    border-radius: 1.5mm;
    background: #fdf6f6;
    color: #96201f;
    font-size: 8pt;
    line-height: 1.75;
}
.bill-warn strong { font-weight: 700; }

.bill-table { width: 100%; border-collapse: collapse; margin-bottom: 5mm; }
.bill-table th,
.bill-table td {
    border: .5pt solid #9aa3b2;
    padding: 1.8mm 2mm;
    font-size: 8.5pt;
    text-align: left;
    vertical-align: top;
}
.bill-table th {
    background: #f4f6fa;
    font-weight: 600;
    color: #2b3040;
    white-space: nowrap;
}
.bill-table > tbody > tr > th { width: 24mm; }
.bill-items thead th { text-align: center; background: #f4f6fa; }
.bill-items tbody td { text-align: center; }
.bill-items tbody td.name { text-align: left; }
.bill-items td.num,
.bill-table tfoot td.num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.bill-table tfoot td { background: #f9fafc; font-weight: 600; }
.bill-table tfoot .sum-label { text-align: right; }
.bill-empty { color: #98a2b3; }
.bill-empty-cell { text-align: center; color: #98a2b3; }

.bill-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 2mm 8mm;
    font-size: 9pt;
    padding-top: 1mm;
}
.bill-foot .k { color: #4a5160; }
.bill-remark { flex-basis: 100%; word-break: break-all; }

/* ---------- OFD 文字层简化渲染 ---------- */
.ofd-sheet {
    position: relative;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 2px 10px -4px rgba(15, 23, 42, .3);
}
.ofd-graphic {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.ofd-text {
    position: absolute;
    white-space: pre;
    color: #111;
    font-family: "SimSun", "Songti SC", serif;
    line-height: 1;
    transform-origin: left top;
}
.ofd-sheet + .ofd-sheet { margin-top: 4mm; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .tool-page { padding-top: 64px; }
    .tool-hero { padding-top: 44px; }
    .tool-body { margin-top: 28px; padding-bottom: 72px; }
    .panel { padding: 22px; border-radius: var(--radius); }
    .tool-grid { grid-template-columns: 1fr; gap: 26px; }
    .qr-decode-grid { grid-template-columns: 1fr; gap: 18px; }
    .sheet-viewport { padding: 12px; }
}

@media (max-width: 640px) {
    .tool-tabs {
        display: flex;
        width: 100%;
        overflow-x: auto;
        border-radius: 14px;
        -webkit-overflow-scrolling: touch;
    }
    .tool-tab { padding: 9px 13px; font-size: 13.5px; }
    .tool-tab svg { width: 15px; height: 15px; }
    .result-head { align-items: flex-start; }
    .result-actions .btn { width: 100%; }
    .dropzone { padding: 34px 18px; }
    .qr-stage { padding: 18px; }
}

/* ---------- 打印兜底（正常情况下走隐藏 iframe 打印） ---------- */
@media print {
    .site-header, .site-footer, .tool-hero, .tool-tabs, .tool-controls, .dropzone,
    .notice, .result-actions, .xml-bar, .drop-status, .preview-note {
        display: none !important;
    }
    .tool-page, .tool-body { padding: 0 !important; background: #fff !important; border: 0 !important; margin: 0 !important; }
    .panel { padding: 0 !important; border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
    .result { margin: 0 !important; padding: 0 !important; border: 0 !important; }
    .result-head { display: none !important; }
    .sheet-viewport { overflow: visible !important; padding: 0 !important; background: #fff !important; border: 0 !important; border-radius: 0 !important; }
    .sheet-box { width: auto !important; height: auto !important; overflow: visible !important; margin: 0 !important; }
    .sheet-scaler { position: static !important; width: auto !important; transform: none !important; }
    .invoice-sheet { box-shadow: none; }
}
