body {
    margin: 0;
    padding: 20px;
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
}

.main-container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.input-container {
    margin: 0;
    padding: 5px;
    background-color: #f9f9f9;
    border-bottom: 2px solid #ddd;
}

.input-field {
    margin: 5px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.input-field:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.subject-count-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e0e0e0;
}

.subject-count-row label {
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.subject-count-row select {
    width: auto;
    min-width: 80px;
}

.subject-inputs-container {
    margin-top: 10px;
}

.print-area {
    width: 210mm;
    min-height: 0;
    margin: 20px auto;
    position: relative;
    left: -7mm;
    padding: 20px;
}

.print-area:empty {
    height: 0;
    padding: 0;
    margin: 0;
}

.page {
    width: 210mm;
    height: 297mm;
    padding: 10mm 10mm 10mm;
    margin: 0 auto 20px;
    page-break-after: always;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20mm;
    border: 2px solid #007bff;
    border-radius: 8px;
    background-color: white;
    position: relative;
}

.page:last-child {
    page-break-after: auto;
    margin-bottom: 0;
}

.page::before {
    content: "第 " counter(page-counter) " 页";
    position: absolute;
    top: -10px;
    left: 20px;
    background-color: #007bff;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.page-counter {
    counter-reset: page-counter;
}

.page {
    counter-increment: page-counter;
}

.box {
    border: 2px solid black;
    border-radius: 80px;
    position: relative;
    padding: 20px;
    width: 90%;
    height: 120mm;
    margin: 0; /* 移除原有的 margin */
}

.region {
    position: absolute;
    top: 60px;
    left: 60px;
    border: 1px solid black;
    padding: 5px 10px;
    font-size: 35px;
    font-family: 方正小标宋简体, serif;
    font-weight: bold;
}

.box-number {
    position: absolute;
    top: 40px;
    right: 60px;
    border: 1px solid black;
    width: 240px;
    text-align: center;
    font-size: 40px;
    font-family: 方正小标宋简体, serif;
    font-weight: bold;
}

.box-number-row {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1px;
}

.box-label {
    font-size: 25px;
    font-weight: bold;
    font-family: 方正小标宋简体, serif;
    margin-right: 10px;
}

.box-number-content {
    padding: 1px;
}

.divider {
    border-top: 1px solid black;
}

.subject-type {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 80px;
    font-weight: bold;
    font-family: 方正小标宋简体, serif;
    white-space: normal; /* 允许文字换行 */
    width: 95%; /* 限制宽度，超出时换行 */
    max-width: 800px; /* 最大宽度限制 */
    text-align: center; /* 文字居中 */
    word-wrap: break-word; /* 长单词换行 */
    overflow-wrap: break-word; /* 现代浏览器支持 */
}

/* 添加新样式用于定位单个框 */
.box-container {
    width: 100%;
    flex: 0 0 120mm; /* 固定度 */
    display: flex;
    justify-content: center;
    align-items: center;
}

.box-container:first-child {
    margin-top: 8mm; /* 调整第一个框到顶部的距离 */
}

.page-title {
    text-align: center;
    font-size: 36px;
    font-family: 方正小标宋简体, serif;
    font-weight: bold;
    margin-bottom: 10mm;
}

@media print {
    body {
        background-color: white;
        padding: 0;
        margin: 0;
    }

    .main-container {
        box-shadow: none;
        border-radius: 0;
        display: none;
    }

    .input-container {
        display: none;
    }

    .separator, .print-section {
        display: none;
    }

    .page {
        border: none;
        margin: 0;
        padding: 10mm 10mm 10mm 15mm;
        page-break-after: always;
    }

    .page:last-child {
        page-break-after: auto;
    }

    .page::before {
        display: none;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }

    .print-area {
        left: 0;
        transform: translateX(-5mm);
        padding: 0;
        margin: 0;
        min-height: 0;
    }

    .print-area:empty {
        display: none;
    }
}

/* 添加页面标题样式 */
.html-title {
    text-align: center;
    font-size: 28px;
    font-family: 方正小标宋简体, serif;
    font-weight: bold;
    margin: 0 0 10px 0;
    color: #333;
    padding-bottom: 5px;
    border-bottom: 2px solid #007bff;
}

.subject-row {
    margin: 3px 0;
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
    display: none; /* 默认隐藏所有行 */
    background-color: white;
    border-radius: 4px;
}

.subject-row.visible {
    display: block; /* 显示选中的行 */
}

.subject-inputs {
    display: grid;
    grid-template-columns: 90px 230px 75px 80px 85px 80px 115px 80px;
    gap: 1px;
    align-items: center;
}

.input-field {
    width: 100%;
    margin: 0 0 0 -15px;
    box-sizing: border-box;
}

label {
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

.radio-group {
    margin: 12px 0;
    padding: 8px;
    background-color: white;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.radio-group label {
    margin-right: 20px;
    font-weight: normal;
}

.radio-group input[type="radio"] {
    margin-right: 5px;
}

.manual-input-area {
    display: none;
    margin: 12px 0;
    padding: 12px;
    background-color: white;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.manual-input-area.visible {
    display: block;
}

#subjectData {
    width: 100%;
    height: 150px;
    margin: 10px 0;
    font-family: monospace;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 10px;
    resize: vertical;
}

.button-group {
    margin: 12px 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.button-group button {
    margin-right: 10px;
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.button-group button:hover {
    background-color: #0056b3;
}

.button-group button:active {
    background-color: #004085;
}

.separator {
    height: 2px;
    background: linear-gradient(to right, transparent, #007bff, transparent);
    margin: 2px 0;
}

.print-section {
    padding: 2px;
    text-align: center;
}

.print-section button {
    padding: 5px 24px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.print-section button:hover {
    background-color: #218838;
}

.input-field-region {
    width: 200px;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.input-field-region:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}
