.cert-container {
    background: #fff;
    border: 1px solid #ddd;
    padding: 40px;
    margin: 30px auto;
    max-width: 800px;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden; /* Prevent watermark overflow */
}
.cert-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 8rem;
    color: rgba(0,0,0,0.03);
    pointer-events: none;
    z-index: 0;
    white-space: nowrap; /* Prevent line break */
}
/* ... existing styles ... */

@media (max-width: 768px) {
    .cert-container {
        padding: 20px;
        margin: 15px;
    }
    .cert-watermark {
        font-size: 4rem;
    }
    .cert-title {
        font-size: 1.5rem;
    }
    .cert-info-row {
        display: flex;
        flex-direction: column;
    }
    .cert-label {
        width: 100%;
        margin-bottom: 5px;
    }
}

.cert-title {
    text-align: center;
    margin-bottom: 40px;
    font-family: "SimSun", serif;
    font-weight: bold;
    color: #333;
}
.cert-info-row {
    margin-bottom: 15px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 10px;
}
.cert-label {
    font-weight: bold;
    color: #666;
    width: 120px;
    display: inline-block;
}
.cert-value {
    font-weight: 500;
    color: #000;
}
.status-valid {
    color: #198754;
    font-weight: bold;
}
.status-expired {
    color: #dc3545;
    font-weight: bold;
}

@media print {
    body { 
        background: white !important; 
        -webkit-print-color-adjust: exact;
    }
    .navbar, .d-print-none { 
        display: none !important; 
    }
    .cert-container {
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
    .cert-title {
        margin-top: 0;
        margin-bottom: 20px;
        font-size: 24px;
    }
    .cert-info-row {
        margin-bottom: 8px;
        padding-bottom: 5px;
    }
    /* 强制在一页内 */
    html, body {
        height: 100%;
        overflow: visible;
    }
    
    /* 强制布局为一行 */
    .row {
        display: flex !important;
        flex-wrap: nowrap !important;
    }
    
    /* 强制左侧栏宽度 */
    .col-md-8 {
        width: 66.666667% !important;
        flex: 0 0 66.666667% !important;
        max-width: 66.666667% !important;
    }
    
    /* 强制右侧栏宽度 */
    .col-md-4 {
        width: 33.333333% !important;
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
    }

    /* 底部二维码行恢复全宽 */
    .row.mt-4 {
        margin-top: 20px !important;
        page-break-inside: avoid;
        flex-wrap: wrap !important; /* 允许换行 */
    }
    .row.mt-4 .col-12 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* 缩小图片和二维码以适应 */
    .img-thumbnail {
        max-height: 150px !important;
    }
    #cert_qrcode img {
        width: 200px !important;
        height: 200px !important;
    }
}