* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", SimSun, Arial, sans-serif;
}
body {
    background-color: #f2f5f9;
    padding: 24px;
    font-size: 14px;
    color: #222;
    line-height: 1.7;
}
.main-wrap {
    max-width: 210mm;
    margin: 0 auto;
}
/* A4纸张页面容器（210mm × 297mm），纵向弹性布局让表格填满整页 */
.a4-page {
    width: 210mm;
    min-height: 297mm;
    padding: 12mm;
    margin: 0 auto 24px;
    background: #ffffff;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.12);
    box-sizing: border-box;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
}
/* 主表格自动拉伸填满剩余高度 */
#planTable, .record-table {
    flex: 1 1 auto;
}
/* 其余块不被压缩 */
.a4-page > h1,
.a4-page > h2,
.a4-page > .record-info-table,
.a4-page > .record-sign-table,
.a4-page > .rule-panel {
    flex: 0 0 auto;
}
/* 页脚页码 */
.page-foot {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 6mm;
    text-align: center;
    font-size: 12px;
    color: #6b7280;
}
/* 每页右上角打印按钮 */
.page-print-btn {
    position: absolute;
    top: 8mm;
    right: 8mm;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.page-print-btn:hover {
    background: #e8f3ff;
}
.page-print-btn svg {
    width: 26px;
    height: 26px;
}
/* 每页右上角删除按钮（在打印图标左侧相邻） */
.page-del-btn {
    position: absolute;
    top: 8mm;
    right: calc(8mm + 44px);
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 默认灰色，悬停/聚焦时变红 */
    color: #9ca3af;
}
.page-del-btn:hover,
.page-del-btn:focus {
    background: #ffece8;
    color: #f53f3f;
}
.page-del-btn svg {
    width: 24px;
    height: 24px;
}
h1 {
    text-align: center;
    font-size: 18px;
    margin-bottom: 10px;
    color: #1f2937;
    letter-spacing: 1px;
}
h2 {
    font-size: 16px;
    margin: 0 0 10px;
    border-left: 5px solid #1677ff;
    padding-left: 12px;
    color: #263859;
}
h2.title-center {
    text-align: center;
    border-left: none;
    padding-left: 0;
}
h3 {
    font-size: 14px;
    margin-bottom: 6px;
    color: #1d4ed8;
}
/* 工具栏：左侧系统标题，右侧操作按钮 */
.tool-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}
.tool-bar-title {
    font-size: 20px;
    font-weight: 600;
    color: #263859;
    letter-spacing: 1px;
}
.tool-bar-btns {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
/* 记录表门店筛选 */
.filter-box {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
}
.filter-box select {
    height: 36px;
    min-width: 190px;
    padding: 0 8px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}
.filter-box select:focus {
    outline: none;
    border-color: #1677ff;
}
/* 筛选结果提示 */
.search-tip {
    grid-column: 1 / -1;
    padding: 8px 12px;
    background: #fff7e6;
    border: 1px solid #ffd591;
    border-radius: 5px;
    font-size: 13px;
    color: #874d00;
}
.search-tip.hide {
    display: none;
}
/* 被筛选掉的页 */
.a4-page.search-hidden {
    display: none !important;
}
button {
    padding: 9px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}
button:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}
.btn-print { background: #1677ff; color: #fff; }
.btn-export { background: #00b42a; color: #fff; }
.btn-config { background: #8b5cf6; color: #fff; }
.btn-reset { background: #6b7280; color: #fff; }
/* 右下角悬浮的「新增巡检记录表」圆形按钮 */
.btn-add-float {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 900;
    width: 56px;
    height: 56px;
    padding: 0;
    /* 默认灰色，悬停时变橙 */
    background: #9ca3af;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-add-float:hover {
    background: #ff7d00;
    box-shadow: 0 4px 14px rgba(255, 125, 0, 0.4);
}
/* 巡查规范面板（字号与打印保持一致，确保一页装满不溢出） */
.rule-panel {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 22px;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.5;
}
.rule-content {
    padding-top: 6px;
}
.rule-content p {
    margin: 3px 0;
    text-indent: 16px;
}
.rule-item {
    margin-bottom: 6px;
}
.rule-title {
    font-weight: 600;
    color: #1d4ed8;
    text-indent: 0 !important;
}
/* 表格通用样式（字号/内边距与打印一致） */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    table-layout: fixed;
}
table th, table td {
    border: 1px solid #c4c8cf;
    padding: 5px 4px;
    font-size: 11.5px;
    line-height: 1.4;
    vertical-align: middle;
    text-align: center;
    word-break: break-all;
    overflow-wrap: anywhere;
}
table th {
    background-color: #e8f3ff;
    font-weight: 600;
}
/* 表头信息行（日期/门店）：与下方记录表无缝拼接 */
.record-info-table {
    margin-bottom: -1px;
}
/* 底部签字行：与上方记录表无缝拼接 */
.record-sign-table {
    margin-top: -1px;
}
.info-label {
    background-color: #e8f3ff;
    font-weight: 600;
    white-space: nowrap;
    word-break: keep-all;
}
.info-input-cell {
    text-align: left;
}
.info-input-cell input,
.info-input-cell select {
    width: 100%;
    border: 1px solid #ddd;
    padding: 3px 5px;
    border-radius: 4px;
    font-size: 11.5px;
    background: #fff;
}
/* 打印用纯文本（屏幕上隐藏） */
.print-text {
    display: none;
}
/* 可输入单元格控件 */
td input[type="date"],
td input[type="time"],
td input[type="text"] {
    width: 100%;
    border: 1px solid #ddd;
    padding: 3px 5px;
    border-radius: 4px;
    font-size: 11.5px;
}
/* 日期/时间控件需容纳文字与日历图标，去掉内边距挤压 */
td input[type="date"],
td input[type="time"],
.info-input-cell input[type="date"] {
    padding: 3px 2px;
    min-width: 0;
}
td input[type="date"]::-webkit-calendar-picker-indicator,
.info-input-cell input[type="date"]::-webkit-calendar-picker-indicator {
    margin-left: 2px;
    padding: 0;
}
td textarea {
    width: 100%;
    border: 1px solid #ddd;
    padding: 3px 5px;
    border-radius: 4px;
    resize: vertical;
    font-size: 11.5px;
}
/* 记录表20行：单元格随内容自适应高度 */
.record-tbody textarea,
.record-tbody input {
    min-height: 24px;
    height: 24px;
    overflow: hidden;
    line-height: 1.4;
}
.record-tbody td {
    padding: 3px 4px;
}
/* 计划表行高适中，方便填写；日期/时间列字号略小以完整显示 */
#planTbody input {
    height: 26px;
}
#planTbody input[type="date"],
#planTbody input[type="time"] {
    font-size: 11px;
}
/* 持续时长：由起止时间自动计算，只读 */
#planTbody .duration-cell {
    background: #f3f4f6;
    color: #374151;
    text-align: center;
    cursor: default;
}
/* 签字空白单元格 加大行高方便手写；签名内容居中且字号更大 */
.sign-cell {
    height: 50px;
    text-align: center;
    font-size: 16px;
    vertical-align: middle;
}
/* ============ 统一弹窗样式（居中） ============ */
.modal-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
    align-items: center;
    justify-content: center;
}
.modal-mask.show {
    display: flex;
}
.modal-box {
    width: 520px;
    max-width: 92vw;
    max-height: 88vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    padding: 20px 22px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}
/* 小尺寸弹窗：提示、确认、单项选择 */
.modal-box.modal-sm {
    width: 400px;
}
.modal-box h3 {
    font-size: 16px;
    margin-bottom: 14px;
    color: #263859;
    text-align: center;
}
/* 提示/确认正文 */
.modal-msg {
    font-size: 14px;
    line-height: 1.8;
    color: #374151;
    text-align: center;
    padding: 4px 0 6px;
}
.cfg-row {
    margin-bottom: 14px;
}
.cfg-row label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}
.cfg-row input[type="number"],
.cfg-row input[type="text"],
.cfg-row textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    padding: 7px 9px;
    font-size: 13px;
}
.cfg-row textarea {
    height: 150px;
    resize: vertical;
    line-height: 1.7;
}
.cfg-tip {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}
.cfg-inline {
    display: flex;
    gap: 12px;
}
.cfg-inline > div {
    flex: 1;
}
.cfg-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
}
.cfg-check input {
    width: 15px;
    height: 15px;
}
.modal-foot {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #e5e7eb;
}
.cfg-row select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    padding: 8px 9px;
    font-size: 13px;
    background: #fff;
}
.btn-cancel { background: #e5e7eb; color: #374151; }
.btn-save { background: #1677ff; color: #fff; }
.btn-danger { background: #f53f3f; color: #fff; }
/* ============ 屏幕布局：两页并排（打印不受影响） ============ */
@media screen {
    .main-wrap {
        max-width: none;
        width: calc(210mm * 2 + 24px);
        display: grid;
        grid-template-columns: repeat(2, 210mm);
        justify-content: center;
        align-items: start;
        gap: 24px;
    }
    /* 工具栏独占一整行 */
    .tool-bar {
        grid-column: 1 / -1;
        margin-bottom: 0;
    }
    /* 让记录表各页直接参与外层网格排列 */
    #recordPages {
        display: contents;
    }
    .a4-page {
        margin: 0;
    }
}
/* 窗口不够宽时整体缩放，保证两页仍能完整并排（并排总宽约 1660px） */
@media screen and (max-width: 1660px) {
    body { zoom: 0.82; }
}
@media screen and (max-width: 1410px) {
    body { zoom: 0.70; }
}
@media screen and (max-width: 1200px) {
    body { zoom: 1; }
    .main-wrap {
        width: 210mm;
        grid-template-columns: 210mm;
    }
}
/* 打印专属样式（A4 纵向） */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm;
    }
    html, body {
        width: 186mm;
        background: #fff;
        padding: 0;
        margin: 0;
        font-size: 12px;
        line-height: 1.5;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .main-wrap {
        max-width: none;
        width: 100%;
        margin: 0;
    }
    /* A4页容器：打印时尺寸交由@page控制，逐页分开并填满整页 */
    .a4-page {
        width: 100%;
        /* A4高297mm - 上下页边距24mm = 273mm */
        min-height: 273mm;
        height: 273mm;
        padding: 0 1px 0 0;
        margin: 0;
        box-shadow: none;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    /* 页脚固定在页面底部 */
    .page-foot {
        position: static;
        margin-top: auto;
        padding-top: 8px;
        font-size: 10.5px;
        page-break-inside: avoid;
    }
    /* 用 break-before 分页，避免末尾/中间产生空白页；
       单页打印的目标页必须排除，否则其前面会多出一张空白页 */
    .a4-page + .a4-page:not(.print-target),
    #recordPages .a4-page:not(.print-target) {
        page-break-before: always;
    }
    .tool-bar,
    .search-tip,
    .page-print-btn,
    .page-del-btn,
    .btn-add-float,
    .modal-mask {
        display: none !important;
    }
    /* 仅打印当前页：隐藏非目标页 */
    body.print-one .a4-page {
        display: none !important;
    }
    body.print-one #recordPages {
        display: contents;
    }
    body.print-one .a4-page.print-target {
        display: flex !important;
        page-break-before: auto;
        page-break-after: auto;
    }
    /* 规范面板：仅去掉屏幕装饰，字号排版与页面保持一致 */
    .rule-panel {
        border: none;
        background: #fff;
        margin-bottom: 0;
        padding: 0;
    }
    .rule-panel .rule-content {
        padding-top: 0;
    }
    .rule-panel .rule-content p {
        orphans: 3;
        widows: 3;
    }
    .rule-panel .rule-item {
        page-break-inside: avoid;
    }
    /* 表格：表头每页重复，行不跨页断开，边框完整（其余样式与页面一致） */
    table {
        page-break-inside: auto;
        width: 100% !important;
    }
    thead {
        display: table-header-group;
    }
    tbody {
        display: table-row-group;
    }
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    table th, table td {
        vertical-align: middle;
        white-space: pre-wrap;
    }
    table th, .info-label {
        background-color: #e8f3ff !important;
    }
    /* 兜底：补齐最右侧竖线（打印缩放取整易丢失） */
    table th:last-child,
    table td:last-child {
        border-right: 1px solid #c4c8cf !important;
    }
    /* 打印时隐藏表单控件，改用纯文本，保证内容完整换行显示 */
    table input,
    table select,
    table textarea {
        display: none !important;
    }
    /* 纯文本在单元格内水平垂直居中，长内容自动换行 */
    .print-text {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 18px;
        text-align: center;
        white-space: pre-wrap;
        word-break: break-all;
        overflow-wrap: anywhere;
    }
    .info-label {
        text-align: center;
    }
    .record-sign-table {
        page-break-inside: avoid;
    }
}
