/* ============ 全局 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ 导航 ============ */
.navbar {
    background: #1e3a5f;
    color: #fff;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.navbar .logo { font-size: 18px; font-weight: bold; }
.navbar .logo small { font-size: 12px; opacity: 0.7; margin-left: 8px; }
.navbar .nav-links { display: flex; gap: 24px; }
.navbar .nav-links a { color: #cbd5e1; font-size: 14px; }
.navbar .nav-links a:hover, .navbar .nav-links a.active { color: #fff; text-decoration: none; }

/* ============ 容器 ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.container-narrow { max-width: 800px; margin: 0 auto; padding: 24px; }

/* ============ 卡片 ============ */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 24px;
    margin-bottom: 20px;
}

/* ============ 统计卡片 ============ */
.stats-row { display: flex; gap: 16px; margin-bottom: 24px; }
.stat-card {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-align: center;
}
.stat-card .num { font-size: 32px; font-weight: bold; }
.stat-card .label { font-size: 14px; color: #64748b; margin-top: 4px; }
.stat-card.total .num { color: #1e3a5f; }
.stat-card.qualified .num { color: #5cb85c; }
.stat-card.unqualified .num { color: #d9534f; }
.stat-card.pending .num { color: #f0ad4e; }

/* ============ 表格 ============ */
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data-table th {
    background: #f1f5f9;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}
table.data-table tr:hover { background: #f8fafc; }

/* ============ 状态标签 ============ */
.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}
.badge-pending { background: #f0ad4e; }
.badge-qualified { background: #5cb85c; }
.badge-unqualified { background: #d9534f; }

/* ============ 按钮 ============ */
.btn {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    transition: opacity 0.2s;
}
.btn:hover { text-decoration: none; opacity: 0.9; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-success { background: #5cb85c; color: #fff; }
.btn-danger { background: #d9534f; color: #fff; }
.btn-warning { background: #f0ad4e; color: #fff; }
.btn-default { background: #e2e8f0; color: #475569; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ============ 角色标签 ============ */
.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.role-admin { background: #dbeafe; color: #1d4ed8; }
.role-user { background: #f1f5f9; color: #475569; }

/* ============ 表单 ============ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
}
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ============ 检验项目表格 ============ */
.inspect-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inspect-table th {
    background: #1e3a5f; color: #fff; padding: 8px 10px; text-align: center;
}
.inspect-table td {
    padding: 8px 10px; border: 1px solid #e2e8f0; text-align: center;
}
.inspect-table td.col-item, .inspect-table td.col-standard { text-align: left; }
.result-pass { background: #d4edda; }
.result-fail { background: #f8d7da; }
.result-pending { background: #fff3cd; }

.radio-group { display: flex; gap: 12px; justify-content: center; }
.radio-group label { cursor: pointer; padding: 2px 8px; border-radius: 4px; }
.radio-group input[type="radio"] { margin-right: 3px; }

/* ============ 扫码状态页 ============ */
.check-page { max-width: 500px; margin: 0 auto; padding: 16px; }
.status-hero {
    text-align: center;
    padding: 40px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    color: #fff;
}
.status-hero .status-text { font-size: 48px; font-weight: bold; }
.status-hero .status-sub { font-size: 16px; margin-top: 8px; opacity: 0.9; }

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}
.info-row .label { color: #64748b; font-size: 14px; }
.info-row .value { font-weight: 600; font-size: 14px; }

.stage-list { margin-top: 16px; }
.stage-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}
.stage-item .stage-name { flex: 1; font-size: 14px; }
.stage-item .stage-result {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

/* ============ 二维码打印 ============ */
.print-controls { margin-bottom: 20px; display: flex; gap: 12px; align-items: center; }
.qr-grid { display: flex; flex-wrap: wrap; gap: 16px; }

/* ===== 屏幕显示：横向卡片 ===== */
.qr-card {
    width: 260px;
    height: 180px;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
    background: #fff;
    page-break-inside: avoid;
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}
.qr-card .qr-company {
    font-size: 11px;
    font-weight: bold;
    color: #000;
    padding-bottom: 4px;
    margin-bottom: 6px;
    border-bottom: 1px solid #333;
    line-height: 1.2;
}
.qr-card .qr-body {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-height: 0;
}
.qr-card .qr-left {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qr-card .qr-left img { width: 120px; height: 120px; display: block; }
.qr-card .qr-right {
    flex: 1;
    text-align: left;
    overflow: hidden;
}
.qr-card .qr-title { font-size: 13px; font-weight: bold; color: #000; line-height: 1.25; }
.qr-card .qr-model { font-size: 12px; color: #000; margin-top: 4px; font-weight: bold; }
.qr-card .qr-code { font-size: 12px; color: #000; margin-top: 4px; font-weight: bold; }
.qr-card .qr-project { font-size: 10px; color: #000; margin-top: 6px; font-weight: bold; padding-top: 4px; border-top: 0.5pt solid #999; }
.qr-checkbox { position: absolute; top: 4px; right: 4px; cursor: pointer; z-index: 10; }
.qr-checkbox input { width: 18px; height: 18px; cursor: pointer; }

/* 取消勾选的卡片变灰，但不消失 */
.qr-unselected { opacity: 0.4; }

/* 打印区域：屏幕上移出视口但不隐藏(display:none会导致图片不加载) */
.print-only { position: absolute; left: -99999px; top: 0; width: 210mm; }

/* ===== A4标签打印：全内联样式，CSS只负责显隐和页面设置 ===== */
@media print {
    @page {
        size: A4;
        margin: 0;
    }
    html, body { background: #fff !important; width: 210mm; }
    .navbar, .no-print, .qr-checkbox, .screen-only { display: none !important; }
    .container { max-width: none !important; width: 210mm !important; padding: 0 !important; margin: 0 !important; }
    .print-only { position: static !important; left: 0 !important; top: 0 !important; }
    /* 所有尺寸由JS内联样式控制 */
}

/* ============ 阶段进度 ============ */
.stage-progress { display: flex; gap: 4px; margin: 16px 0; }
.stage-step {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    border-radius: 6px;
    font-size: 12px;
    background: #f1f5f9;
    color: #64748b;
}
.stage-step.pass { background: #d4edda; color: #155724; }
.stage-step.fail { background: #f8d7da; color: #721c24; }
.stage-step.pending { background: #fff3cd; color: #856404; }

/* ============ 提示 ============ */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-info { background: #d1ecf1; color: #0c5460; }
.alert-success { background: #d4edda; color: #155724; }
.alert-warning { background: #fff3cd; color: #856404; }
.alert-danger { background: #f8d7da; color: #721c24; }

/* ============ 搜索栏 ============ */
.search-bar { display: flex; gap: 12px; margin-bottom: 20px; }
.search-bar input, .search-bar select {
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
}
.search-bar input { flex: 1; }

/* ============ 导航用户 ============ */
.navbar .nav-user {
    color: #fbbf24;
    font-size: 14px;
    font-weight: 600;
    margin-right: 8px;
}
.navbar .nav-user {
    color: #fbbf24;
    font-size: 14px;
    font-weight: 600;
    margin-right: 8px;
}
.navbar .nav-logout {
    color: #fff;
    font-size: 13px;
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    text-decoration: none;
}
.navbar .nav-logout:hover { background: rgba(255,255,255,0.3); color: #fff; text-decoration: none; }

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .navbar { flex-direction: column; height: auto; padding: 12px 16px; gap: 8px; }
    .navbar .nav-links { flex-wrap: wrap; justify-content: center; }
    .container { padding: 12px; }
    .container-narrow { padding: 12px; }
    .form-row { flex-direction: column; gap: 12px; }
    .stats-row { flex-direction: column; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 6px; }
    .qr-grid { justify-content: center; }
}

