* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.upload-section {
    padding: 40px;
    border-bottom: 1px solid #eee;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-area.dragover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: scale(1.02);
}

.upload-icon {
    width: 60px;
    height: 60px;
    color: #667eea;
    margin-bottom: 20px;
}

.upload-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.upload-content p {
    color: #666;
    font-size: 1rem;
}

.file-info {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.file-details {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.file-details span {
    font-weight: 500;
}

.preview-section {
    padding: 40px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.section-header h2 {
    font-size: 1.8rem;
    color: #333;
}

.actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.preview-controls {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.preview-controls label {
    font-weight: 500;
    color: #555;
}

.preview-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    font-size: 14px;
}

.labels-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.label {
    width: 200px;
    height: 100px;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    font-size: 11px;
    line-height: 1.2;
    overflow: hidden;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.label .text-section {
    height: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
}

.label .brand {
    font-weight: bold;
    color: #333;
    font-size: 8px;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.label .product-name {
    color: #555;
    font-size: 7px;
    margin: 1px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.label .emg-section {
    height: 30px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
}

.label .barcode-container {
    height: 20px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 2px 0;
    position: relative;
    overflow: hidden;
}

.label .barcode {
    max-width: 100%;
    max-height: 100%;
    transform: scale(0.9);
    margin-left: 0;
}

.label .code69-container {
    height: 50px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 2px 0;
    position: relative;
    overflow: hidden;
}

.label .code69-barcode {
    max-width: 100%;
    max-height: 100%;
    transform: scale(0.8);
    margin-left: 0;
}

.label .emg-code {
    font-family: 'Courier New', monospace;
    font-size: 8px;
    color: #333;
    text-align: center;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.data-section {
    padding: 40px;
    border-top: 1px solid #eee;
}

.data-section h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 20px;
}

.table-container {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
}

tr:hover {
    background: #f8f9ff;
}

.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

/* 模板页面样式 */
.template-section {
    padding: 40px;
}

.template-info {
    margin-bottom: 40px;
}

.template-info h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 15px;
}

.template-info p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.template-requirements {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    border-left: 4px solid #667eea;
}

.template-requirements h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.template-requirements ul {
    list-style: none;
    padding: 0;
}

.template-requirements li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    color: #555;
}

.template-requirements li:last-child {
    border-bottom: none;
}

.template-requirements strong {
    color: #333;
    font-weight: 600;
}

.barcode-info {
    margin-top: 20px;
    padding: 15px;
    background: #e8f4fd;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.barcode-info h4 {
    color: #007bff;
    margin-bottom: 10px;
    font-size: 1rem;
}

.barcode-info p {
    color: #555;
    line-height: 1.5;
    margin: 0;
    font-size: 0.9rem;
}

.template-example {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.template-example h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.example-table {
    overflow-x: auto;
}

.example-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.example-table th,
.example-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.example-table th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.example-table tr:hover {
    background: #f8f9ff;
}

.download-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 40px;
    text-align: center;
}

.download-section h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 25px;
}

.download-options {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.download-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
}

.instructions {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.instructions h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 25px;
    text-align: center;
}

.instruction-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.step-number {
    width: 40px;
    height: 40px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.step-content h4 {
    color: #333;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.step-content p {
    color: #666;
    line-height: 1.5;
    margin: 0;
}

.back-to-main {
    text-align: center;
    padding: 20px 0;
}

/* 主页面模板下载链接 */
.template-link {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: #667eea;
    color: white;
    padding: 15px 20px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 500;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
}

.template-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(102, 126, 234, 0.4);
    color: white;
    text-decoration: none;
}

.template-link svg {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    vertical-align: middle;
}

@media print {
    @page {
        size: 40mm 20mm;
        margin: 0;
    }
    
    body {
        background: white;
        width: 40mm;
        height: 20mm;
        margin: 0;
        padding: 0;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    header, .upload-section, .preview-controls, .actions, .data-section {
        display: none !important;
    }
    
    .preview-section {
        padding: 0;
    }
    
    .labels-container {
        display: block;
        page-break-inside: avoid;
    }
    
    .label {
        width: 38mm;
        height: 18mm;
        margin: 0 auto;
        page-break-after: always;
        break-after: page;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        font-size: 2mm;
        padding: 1mm;
        background: white;
        box-shadow: none;
    }
    
    .label .brand {
        font-weight: bold;
        font-size: 2.2mm;
        margin-bottom: 0.3mm;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #333;
    }
    
    .label .product-name {
        font-size: 1.8mm;
        margin: 0.3mm 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #555;
    }
    
    .label .text-section {
        height: 3.5mm;
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
    }
    
    .label .barcode-container {
        height: 3mm;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        overflow: hidden;
        margin: 0.3mm 0;
    }
    
    .label .barcode {
        max-width: 100%;
        max-height: 100%;
        transform: scale(0.9);
        margin-left: 0;
    }
    
    .label .code69-container {
        height: 9mm;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        overflow: hidden;
        margin: 0.3mm 0;
    }
    
    .label .code69-barcode {
        max-width: 100%;
        max-height: 100%;
        transform: scale(0.8);
        margin-left: 0;
    }
    
    .label .emg-section {
        height: 5.5mm;
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
    }
    
    .label .emg-code {
        font-family: 'Courier New', monospace;
        font-size: 2.2mm;
        text-align: center;
        font-weight: bold;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #333;
    }
    
    .label:last-child {
        page-break-after: avoid;
        break-after: avoid;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .upload-section, .preview-section, .data-section {
        padding: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .actions {
        width: 100%;
        justify-content: stretch;
    }
    
    .btn-primary, .btn-secondary {
        flex: 1;
        text-align: center;
    }
    
    .labels-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .label {
        width: 100%;
        height: 80px;
    }
}
