:root {
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --bg: #ffffff;
    --header-bg: #f8fafc;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-light: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --status-bar-height: 36px;
    --first-col-width: 220px;
    --data-col-width: 200px;
}

/* 全屏布局基础 */
body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    overflow: hidden;
}

.app-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* === 顶部面板 === */
.top-panel {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand h1 {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
}

.meta-info {
    color: var(--text-light);
    font-size: 12px;
    margin-top: 2px;
}

/* 评定方式切换器样式 */
.mode-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    /* 间距稍大 */
    background: white;
    /* 纯白背景 */
    padding: 0 10px;
    /* 两侧内边距 */
    height: 32px;
    /* 固定高度，更有控件感 */
    border-radius: 6px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* 微弱阴影 */
    transition: all 0.2s;
}

.mode-switcher:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.input-label-inline {
    font-size: 12px;
    font-weight: 500;
    /*稍微降低字重 */
    color: #94a3b8;
    /* 更淡的灰色 */
    white-space: nowrap;
}

.mode-select {
    appearance: none;
    /* 去除默认样式 */
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    background: transparent;
    padding: 0 24px 0 4px;
    /* 右侧留出箭头位置 */
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    font-weight: 600;
    /* 字体加粗 */
    height: 100%;
    outline: none;

    /* 自定义下拉箭头 (灰色 Chevron) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 16px;

    transition: color 0.2s;
}

.mode-select:hover {
    color: var(--primary);
}

.mode-switcher:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* === 工具栏与校准点区域优化 === */
.control-bar {
    display: flex;
    align-items: center;
    /* 垂直居中 */
    padding: 10px 16px;
    background: var(--header-bg);
    gap: 16px;
    min-height: auto;
    flex-wrap: wrap;
    /* 允许换行，这是关键 */
}

/* 左侧按钮组 */
.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    /* 防止被挤压 */
}

.divider-v {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

/* 按钮样式 */
.btn {
    padding: 6px 14px;
    /* 稍微加大内边距 */
    border-radius: 6px;
    /* 更圆润一点 */
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    background: var(--primary);
    color: white;
    border: 1px solid transparent;
}

.btn.primary:hover {
    background: #1d4ed8;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn.ghost {
    background: white;
    color: var(--text-light);
    border: 1px solid var(--border);
}

.btn.ghost:hover {
    background: #f8fafc;
    color: var(--primary);
    border-color: #cbd5e1;
}

.btn.danger {
    background: #fff1f2;
    color: var(--danger);
    border-color: #fecaca;
}

.btn.danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.btn.small {
    padding: 4px 10px;
    font-size: 12px;
}

/* 输入框优化 */
.tag-input.compact {
    width: 280px;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
}

.tag-input.compact:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}

/* Tag 列表区域优化 */
.compact-tags {
    display: flex;
    gap: 8px;
    /* 增加间距 */
    align-items: center;
    flex-wrap: wrap;
    /* 允许换行 */
    flex: 1;
    /* 占据剩余空间 */
    min-width: 0;
    /* 防止溢出问题 */
}

/* 单个 Tag 样式优化 */
.tag-chip {
    height: 28px;
    /* 增加高度，不再拥挤 */
    font-size: 13px;
    padding: 0 4px 0 10px;
    /* 文字左侧留出空间，右侧按钮紧凑 */
    background: white;
    border: 1px solid #bfdbfe;
    color: var(--primary);
    border-radius: 14px;
    /* 更圆润 */
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(219, 234, 254, 0.5);
}

.tag-chip:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(219, 234, 254, 0.8);
}

.tag-text {
    font-weight: 500;
}

/* Tag 内部操作按钮组 */
.tag-actions {
    background: rgba(239, 246, 255, 0.5);
    /* 浅色背景区分 */
    border-radius: 12px;
    padding: 2px;
    display: flex;
    gap: 2px;
    margin-left: 4px;
}

.tag-btn {
    width: 20px;
    /* 固定宽度，防止挤压 */
    height: 20px;
    font-size: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
}

.tag-btn:hover {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.tag-btn.del:hover {
    color: var(--danger);
}

.tag-input-inline {
    width: 80px;
    height: 20px;
    font-size: 12px;
    border: 1px solid var(--primary);
    border-radius: 2px;
    padding: 0 4px;
}

/* === 表格区域 === */
.table-wrapper {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #f8fafc;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
}

/* 冻结首列 */
th:first-child,
tbody td:first-child,
tfoot td:first-child {
    position: sticky;
    left: 0;
    z-index: 20;
    background: white;
    width: var(--first-col-width);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
}

/* 冻结表头 */
thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f1f5f9;
    color: var(--text-main);
    font-weight: 600;
    font-size: 13px;
    height: 36px;
    border-bottom: 1px solid #cbd5e1;
    border-right: 1px solid var(--border);
    padding: 4px 8px;
}

thead th:first-child {
    z-index: 30;
    background: #f1f5f9;
}

/* 单元格 */
td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 6px 8px;
    vertical-align: top;
}

th.col-data,
td.col-data {
    width: var(--data-col-width);
    min-width: var(--data-col-width);
}

/* 主导实验室行高亮 */
tr.pilot-row td {
    background-color: #f0f9ff !important;
}

tr.pilot-row td:first-child {
    border-right: 2px solid #3b82f6;
}

/* 数据输入布局 */
.data-cell-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 4px;
}

.input-wrapper {
    width: 100%;
}

.input-label {
    font-size: 9px;
    color: var(--text-light);
    display: block;
    margin-bottom: 2px;
    /* 强制不换行，解决对齐问题 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

input[type="text"] {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 2px;
    font-family: 'Consolas', monospace;
    font-size: 13px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

/* 虚体实验室名称输入框 */
input.lab-name-text {
    border: 1px dashed transparent;
    background: transparent;
    color: #64748b;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
}

input.lab-name-text:hover {
    border-color: #cbd5e1;
}

input.lab-name-text:focus {
    border: 1px solid var(--primary);
    background: white;
    color: var(--text-main);
}

/* 结果框 */
.result-box {
    min-height: 24px;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 3px;
    background: #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.en-val {
    font-family: 'Consolas', monospace;
    font-weight: 700;
    font-size: 12px;
}

.status-ok {
    color: var(--success);
    border: 1px solid #a7f3d0;
    background: #ecfdf5;
}

.status-crit {
    color: var(--warning);
    border: 1px solid #fde68a;
    background: #fffbeb;
}

.status-bad {
    color: var(--danger);
    border: 1px solid #fecaca;
    background: #fef2f2;
}

.status-out {
    opacity: 0.6;
    text-decoration: line-through;
    background: #e2e8f0;
    color: var(--text-light);
}

.status-ref {
    color: #0284c7;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    font-weight: bold;
}

.input-bad {
    border-color: var(--danger) !important;
    background-color: #fff0f0;
}

/* 实验室操作行 */
.lab-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: space-between;
    height: 100%;
}

.action-row {
    display: flex;
    gap: 4px;
    margin-top: 2px;
}

.mini-btn {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    border: 1px solid transparent;
}

.btn-fill-mini {
    background-color: #f1f5f9;
    color: var(--text-light);
    border-color: #e2e8f0;
}

.btn-del-mini {
    background-color: #fff1f2;
    color: var(--danger);
    border-color: #fecaca;
}

/* Pilot 选择器 */
.pilot-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.6);
    padding: 2px 4px;
    border-radius: 4px;
}

/* 底部统计报告 */
tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 10;
    /* 背景色改为与 Header 一致 */
    background: #f1f5f9;
    border-top: 2px solid #cbd5e1;
    height: 90px;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.02);
}

tfoot td:first-child {
    z-index: 30;
    background: #f1f5f9;
    border-right: 1px solid #cbd5e1;
}

.footer-cell-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    font-weight: 700;
    font-size: 14px;
}

/* 表格内小圆按钮 */
.precision-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.circle-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 1px solid #94a3b8;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    line-height: 1;
    transition: all 0.2s;
}

.circle-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed #cbd5e1;
    padding-bottom: 2px;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-light);
    font-size: 11px;
}

.stat-val {
    font-family: 'Consolas', monospace;
    font-weight: 700;
    color: var(--text-main);
    font-size: 13px;
}

.stat-main {
    font-size: 16px;
    color: var(--primary);
}

.val-sub {
    font-size: 10px;
    color: #94a3b8;
}

.val-err {
    color: var(--danger);
}

.val-ok {
    color: var(--success);
}

/* === 底部状态栏 (极简灰白风) === */
.status-bar {
    height: var(--status-bar-height);
    background: #fff;
    /* 纯白底 */
    border-top: 1px solid var(--border);
    color: var(--text-main);
    /* 深灰字 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    font-size: 12px;
    flex-shrink: 0;
}

.status-left {
    opacity: 1;
    width: 150px;
    color: var(--text-light);
}

.legend-inline {
    display: flex;
    gap: 16px;
}

.legend-inline .item {
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 1;
}

/* 图例样式微调：去除白色边框 */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.ok {
    background: #10b981;
    border: none;
}

.dot.crit {
    background: #f59e0b;
    border: none;
}

.dot.bad {
    background: #ef4444;
    border: none;
}

.tag-out {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: var(--text-light);
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 10px;
}

/* Resizer */
.resizer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    z-index: 50;
}

.resizer:hover,
.resizer.resizing {
    background: var(--primary);
}

/* 移动端优化 */
@media (max-width: 768px) {
    .control-bar {
        flex-wrap: wrap;
        height: auto;
        padding: 8px;
    }

    .tag-input.compact {
        width: 100%;
        min-width: 100%;
    }

    .status-bar {
        display: none;
    }

    th:first-child,
    tbody td:first-child,
    tfoot td:first-child {
        position: static !important;
        box-shadow: none !important;
        border-right: 1px solid var(--border);
        width: auto !important;
        min-width: 150px !important;
    }

    .resizer {
        display: none;
    }

    .table-wrapper {
        box-shadow: none;
        border-radius: 0;
    }
}