* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #667eea;
}

.login-info {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    font-size: 14px;
}

.login-info p {
    margin: 5px 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header h1 {
    color: #667eea;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-info {
    background: #06b6d4;
    color: white;
}

.btn-info:hover {
    background: #0891b2;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-block {
    width: 100%;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 工序表单卡片间距更紧凑 */
.tab-content .card {
    margin-bottom: 12px;
}

.card-title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.alert {
    padding: 12px 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.alert-error {
    background: #fee;
    color: #c33;
    border-left: 4px solid #c33;
}

.alert-success {
    background: #efe;
    color: #3c7;
    border-left: 4px solid #3c7;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

table tr:hover {
    background: #f9fafb;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-created {
    background: #dbeafe;
    color: #1e40af;
}

.status-material_issued {
    background: #fef3c7;
    color: #92400e;
}

.status-printing,
.status-laser,
.status-cutting {
    background: #d1fae5;
    color: #065f46;
}

.status-completed {
    background: #ecfdf5;
    color: #047857;
}

.status-closed {
    background: #f3f4f6;
    color: #374151;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tabs-container {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* 表单单行布局强制不换行 */
.form-row-single {
    display: grid !important;
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 1fr !important;
    gap: 10px;
    margin-bottom: 10px;
    overflow-x: auto;
    min-width: 800px;
}

/* 表单标题行 */
.form-row-title {
    white-space: nowrap;
}

.process-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.process-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.process-card.active {
    border-color: #667eea;
    background: #eef2ff;
}

.process-card h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #667eea;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #999;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 10px;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
}

.modal-header h2 {
    margin: 0;
    color: #667eea;
}

.close {
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
    position: relative;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background: #e5e7eb;
    z-index: 1;
}

.progress-step {
    flex: 1;
    text-align: center;
    position: relative;
    z-index: 2;
}

.progress-step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e5e7eb;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #999;
    border: 3px solid white;
}

.progress-step.active .progress-step-circle {
    background: #667eea;
    color: white;
}

.progress-step.completed .progress-step-circle {
    background: #10b981;
    color: white;
}

/* 工序表单卡片样式 */
.process-form-card {
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    padding: 15px !important;
}

.process-form-card:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    border-left-color: #5568d3;
}

.process-form-title {
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.process-form {
    margin-top: 8px;
}

/* 紧凑式表单布局 */
.form-row-compact {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

/* 工单和作业时间占更大列宽 */
.form-row-compact .form-group-compact:nth-child(1),
.form-row-compact .form-group-compact:nth-child(2) {
    grid-column: span 2;
}

/* 其他字段默认宽度 */
.form-group-compact {
    margin-bottom: 0;
    grid-column: span 1;
}

.form-group-compact label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.form-group-compact input,
.form-group-compact select {
    width: 100%;
    font-size: 14px;
}

/* 标签必填标识 */
label span {
    margin-left: 3px;
}

/* 表单占位符样式 */
input::placeholder,
textarea::placeholder {
    color: #9ca3af;
    font-size: 14px;
}

/* 紧凑表单按钮 */
.process-form .btn {
    width: auto;
    min-width: 100px;
}

/* 响应式 - 中等屏幕 */
@media (max-width: 1400px) {
    .form-row-compact {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .form-row-compact .form-group-compact:nth-child(1),
    .form-row-compact .form-group-compact:nth-child(2) {
        grid-column: span 2;
    }
    
    .form-row-compact .form-group-compact:nth-child(3),
    .form-row-compact .form-group-compact:nth-child(4),
    .form-row-compact .form-group-compact:nth-child(5),
    .form-row-compact .form-group-compact:nth-child(6) {
        grid-column: span 1;
    }
}

/* 响应式 - 平板 */
@media (max-width: 1200px) {
    .form-row-compact {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .form-row-compact .form-group-compact:nth-child(1),
    .form-row-compact .form-group-compact:nth-child(2),
    .form-row-compact .form-group-compact:nth-child(3) {
        grid-column: span 1;
    }
    
    .form-row-compact .form-group-compact:nth-child(4),
    .form-row-compact .form-group-compact:nth-child(5),
    .form-row-compact .form-group-compact:nth-child(6) {
        grid-column: span 1;
    }
}

/* 响应式 - 中等屏幕 */
@media (max-width: 1400px) {
    .form-row-single {
        grid-template-columns: 1.8fr 1.2fr 0.8fr 0.8fr 0.8fr 0.8fr !important;
        min-width: 700px;
    }
}

/* 响应式 - 小屏幕 */
@media (max-width: 1200px) {
    .form-row-single {
        grid-template-columns: 1.5fr 1fr 0.8fr 0.8fr 0.8fr 0.8fr !important;
        min-width: 600px;
    }
}

/* 不良明细样式 */
.defect-detail-container {
    transition: all 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

.defect-detail-container:hover {
    border-color: #667eea !important;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

/* 不良明细显示/隐藏动画 */
.defect-detail-container.fade-in {
    animation: fadeInUp 0.3s ease-out;
}

.defect-detail-container.fade-out {
    animation: fadeOutUp 0.3s ease-in;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.defect-categories {
    transition: all 0.2s ease;
}

.defect-category {
    transition: all 0.2s ease;
}

.defect-category:hover {
    transform: translateY(-1px);
}

.defect-category input {
    transition: all 0.2s ease;
}

.defect-category input:focus {
    border-color: #667eea !important;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
    outline: none;
}

.defect-category input:not(:placeholder-shown) {
    background-color: #fef2f2;
    border-color: #fca5a5;
}

.defect-summary {
    transition: all 0.2s ease;
}

.defect-summary:hover {
    background-color: #d1d5db !important;
}

/* 输入验证样式 */
.input-error {
    border: 2px solid #ef4444 !important;
    background-color: #fef2f2 !important;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 响应式 - 移动端 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header {
        flex-direction: column;
        gap: 10px;
    }
    
    table {
        font-size: 12px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-row-compact {
        grid-template-columns: 1fr;
    }
    
    .form-row-title {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .form-row-title > div:first-child {
        min-width: 100% !important;
        margin-bottom: 10px;
    }
    
    .form-row-single {
        grid-template-columns: 1fr !important;
        min-width: auto !important;
    }
    
    .form-group-compact {
        grid-column: span 1 !important;
    }
    
    .process-form-card {
        padding: 12px !important;
    }
    
    .process-form .btn {
        width: 100%;
    }
    
    /* 移动端不良明细优化 */
    .defect-categories {
        flex-direction: column !important;
        align-items: flex-end !important;
        gap: 6px !important;
    }
    
    .defect-category {
        width: 100% !important;
        justify-content: flex-end !important;
    }
    
    .defect-category label {
        font-size: 10px !important;
        min-width: 60px !important;
    }
    
    .defect-category input {
        padding: 3px 4px !important;
        font-size: 11px !important;
        width: 40px !important;
    }
    
    .defect-summary {
        margin-left: 0 !important;
        margin-top: 4px !important;
    }
}
