:root {
    color-scheme: light;
    font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
    --page-bg: #f3f5f3;
    --surface: #ffffff;
    --surface-muted: #f7f8f7;
    --surface-strong: #eef1ef;
    --border: #d9dfdc;
    --border-strong: #bcc7c2;
    --text: #202622;
    --text-muted: #66706b;
    --text-faint: #89918d;
    --accent: #176b5b;
    --accent-hover: #115547;
    --accent-soft: #e7f3ef;
    --success: #28734e;
    --success-soft: #e7f4ec;
    --warning: #9a5a08;
    --warning-soft: #fff3dc;
    --danger: #a43f3f;
    --danger-soft: #fcebea;
    --neutral-soft: #edf0ee;
    --focus: #0a7c69;
    --shadow-dialog: 0 18px 50px rgb(20 30 25 / 20%);
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html {
    min-width: 320px;
    background: var(--page-bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--page-bg);
    font-size: 14px;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

button:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex="0"]:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 8px;
    left: 8px;
    padding: 8px 12px;
    color: #ffffff;
    background: var(--accent);
    border-radius: 4px;
    transform: translateY(-150%);
}

.skip-link:focus {
    transform: translateY(0);
}

/* 顶栏维持紧凑高度，避免占用历史数据的浏览空间。 */
.app-header {
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 10px clamp(16px, 3vw, 36px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header h1 {
    margin: 1px 0 0;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 650;
}

.app-kicker,
.section-kicker {
    margin: 0;
    color: var(--text-faint);
    font-size: 10px;
    line-height: 1.2;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.record-summary {
    margin: 0;
    color: var(--text-muted);
    white-space: nowrap;
}

.workspace {
    width: 100%;
    min-height: calc(100vh - 66px);
    margin: 0;
    display: grid;
    grid-template-columns: clamp(420px, 28vw, 560px) minmax(0, 1fr);
    background: var(--surface);
}

.history-pane,
.detail-pane {
    min-width: 0;
}

.history-pane {
    padding: 20px;
    border-right: 1px solid var(--border);
}

.detail-pane {
    padding: 20px clamp(20px, 2.5vw, 34px) 44px;
}

.pane-heading,
.detail-heading,
.section-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.pane-heading h2,
.detail-heading h2,
.section-heading-row h3 {
    margin: 0;
    font-weight: 650;
}

.pane-heading h2,
.detail-heading h2 {
    font-size: 18px;
}

.section-heading-row h3 {
    font-size: 15px;
}

.pane-heading p,
.detail-heading p,
.section-heading-row p {
    margin: 3px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.detail-heading {
    min-height: 52px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.section-kicker + h2 {
    margin-top: 2px;
}

/* 表单控件使用固定高度，筛选状态变化时不会造成布局跳动。 */
.filter-toolbar {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 128px auto;
    gap: 10px;
    align-items: end;
    margin: 16px 0;
    padding: 13px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.field,
.compact-field {
    display: grid;
    gap: 5px;
    min-width: 0;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
}

.field input,
.field select,
.compact-field select,
.page-size-field select {
    width: 100%;
    height: 34px;
    min-width: 0;
    padding: 0 9px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
}

.field input::placeholder {
    color: var(--text-faint);
}

.filter-actions {
    display: flex;
    gap: 6px;
}

.button,
.icon-button {
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-weight: 600;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    white-space: nowrap;
}

.button-primary {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

.button-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.button-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-strong);
}

.button-secondary:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
    background: var(--surface-strong);
}

.button-quiet {
    color: var(--text-muted);
    background: transparent;
}

.button-quiet:hover:not(:disabled) {
    color: var(--text);
    background: var(--surface-strong);
}

.icon-button {
    width: 34px;
    padding: 0;
    color: var(--text);
    background: var(--surface);
    border-color: var(--border-strong);
    font-size: 20px;
    line-height: 1;
}

.state-panel {
    min-height: 126px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 5px;
    padding: 22px;
    color: var(--text-muted);
    text-align: center;
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
}

.state-panel strong {
    color: var(--text);
    font-size: 14px;
}

.state-panel .button {
    margin-top: 8px;
}

.state-indicator {
    width: 18px;
    height: 18px;
    display: none;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
}

.state-panel.is-loading .state-indicator {
    display: block;
    animation: spin 0.8s linear infinite;
}

.state-panel.is-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #dfb4b1;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.table-shell {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 5px;
}

.history-pane .table-shell {
    overflow-x: hidden;
}

.history-table,
.repair-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table {
    table-layout: fixed;
}

.history-table th,
.history-table td,
.repair-table th,
.repair-table td {
    padding: 9px 10px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.history-table th,
.repair-table th {
    color: var(--text-muted);
    background: var(--surface-muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.history-table tbody tr {
    cursor: pointer;
}

.history-table tbody tr:last-child td,
.repair-table tbody tr:last-child td {
    border-bottom: 0;
}

.history-table th:nth-child(1),
.history-table td:nth-child(1) {
    width: 36%;
}

.history-table th:nth-child(2),
.history-table td:nth-child(2) {
    width: 18%;
}

.history-table th:nth-child(3),
.history-table td:nth-child(3) {
    width: 23%;
}

.history-table th:nth-child(4),
.history-table td:nth-child(4) {
    width: 15%;
}

.history-table th:nth-child(5),
.history-table td:nth-child(5) {
    width: 8%;
}

.history-table td {
    overflow-wrap: break-word;
}

.history-table tbody tr:hover {
    background: #f4f8f6;
}

.history-table tbody tr.is-selected {
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
}

.file-cell {
    min-width: 0;
}

.file-cell strong,
.file-cell span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-cell strong {
    color: var(--text);
    font-size: 13px;
}

.file-cell span,
.cell-muted {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}

.status-badge {
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 7px;
    color: #46504b;
    background: var(--neutral-soft);
    border: 1px solid #d6ddda;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.status-badge.is-succeeded {
    color: var(--success);
    background: var(--success-soft);
    border-color: #b9dcc8;
}

.status-badge.is-running {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: #b6d9cf;
}

.status-badge.is-failed {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #e2b7b4;
}

.status-badge.is-canceled,
.status-badge.is-review {
    color: var(--warning);
    background: var(--warning-soft);
    border-color: #e6cb98;
}

.pagination {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
}

.page-info {
    min-width: 86px;
    color: var(--text-muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.page-size-field {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 6px;
    color: var(--text-muted);
    font-size: 11px;
}

.page-size-field select {
    width: 58px;
}

.detail-state {
    min-height: 240px;
    margin-top: 18px;
}

.detail-content {
    min-width: 0;
}

.run-metadata {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.metadata-item {
    min-width: 0;
    padding: 14px 12px 14px 0;
}

.metadata-item dt {
    color: var(--text-muted);
    font-size: 11px;
}

.metadata-item dd {
    margin: 3px 0 0;
    color: var(--text);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.error-banner {
    margin-top: 14px;
    padding: 9px 11px;
    color: var(--danger);
    background: var(--danger-soft);
    border-left: 3px solid var(--danger);
    overflow-wrap: anywhere;
}

.detail-section {
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}

.detail-section:last-child {
    border-bottom: 0;
}

.inline-state {
    min-height: 72px;
    display: grid;
    place-items: center;
    margin-top: 12px;
    padding: 14px;
    color: var(--text-muted);
    text-align: center;
    background: var(--surface-muted);
    border: 1px dashed var(--border);
    border-radius: 5px;
}

.inline-state.is-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #dfb4b1;
}

/* 所有时间条共享同一横轴，父子缩进和时间重叠可以同时辨识。 */
.timeline-scroll {
    width: 100%;
    margin-top: 12px;
    overflow-x: auto;
}

.timeline-board {
    min-width: 700px;
}

.timeline-axis,
.timeline-row {
    display: grid;
    grid-template-columns: minmax(190px, 31%) minmax(430px, 1fr) 74px;
    align-items: center;
    gap: 10px;
}

.timeline-axis {
    min-height: 28px;
    color: var(--text-faint);
    font-size: 10px;
}

.timeline-axis-track {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    font-variant-numeric: tabular-nums;
}

.timeline-axis-track span {
    text-align: center;
}

.timeline-axis-track span:first-child {
    text-align: left;
}

.timeline-axis-track span:last-child {
    text-align: right;
}

.timeline-row {
    min-height: 48px;
    border-top: 1px solid var(--border);
}

.timeline-label {
    min-width: 0;
    padding: 7px 0 7px calc(var(--depth, 0) * 14px);
}

.timeline-label strong,
.timeline-label span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-label strong {
    font-size: 12px;
}

.timeline-label span {
    margin-top: 1px;
    color: var(--text-muted);
    font-family: Consolas, "Courier New", monospace;
    font-size: 10px;
}

.timeline-label.is-child {
    position: relative;
}

.timeline-label.is-child::before {
    position: absolute;
    top: 50%;
    left: calc((var(--depth, 1) * 14px) - 10px);
    width: 7px;
    height: 8px;
    content: "";
    border-left: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
    transform: translateY(-70%);
}

.timeline-track {
    position: relative;
    height: 24px;
    overflow: hidden;
    background-color: var(--surface-muted);
    background-image: linear-gradient(to right, transparent calc(25% - 1px), var(--border) 25%, transparent calc(25% + 1px), transparent calc(50% - 1px), var(--border) 50%, transparent calc(50% + 1px), transparent calc(75% - 1px), var(--border) 75%, transparent calc(75% + 1px));
    border: 1px solid var(--border);
    border-radius: 3px;
}

.timeline-bar {
    position: absolute;
    top: 4px;
    bottom: 4px;
    min-width: 4px;
    background: #6f7b75;
    border-radius: 2px;
}

.timeline-bar.is-succeeded {
    background: var(--success);
}

.timeline-bar.is-running {
    background: var(--accent);
    animation: pulse 1.5s ease-in-out infinite;
}

.timeline-bar.is-failed {
    background: var(--danger);
}

.timeline-bar.is-canceled {
    background: var(--warning);
}

@keyframes pulse {
    50% {
        opacity: 0.58;
    }
}

.timeline-duration {
    color: var(--text-muted);
    font-size: 11px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.segmented-control {
    width: fit-content;
    max-width: 100%;
    display: flex;
    margin-top: 12px;
    overflow-x: auto;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
}

.segmented-control button {
    min-height: 32px;
    padding: 0 12px;
    color: var(--text-muted);
    white-space: nowrap;
    background: var(--surface);
    border: 0;
    border-right: 1px solid var(--border-strong);
}

.segmented-control button:last-child {
    border-right: 0;
}

.segmented-control button[aria-selected="true"] {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 700;
}

.artifact-gallery {
    min-height: 150px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.artifact-item {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 5px;
}

.artifact-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    padding: 0;
    overflow: hidden;
    background: var(--surface-strong);
    border: 0;
    border-bottom: 1px solid var(--border);
}

.artifact-preview img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.artifact-preview:hover img {
    filter: contrast(1.03);
}

.artifact-preview.is-error img {
    display: none;
}

.artifact-preview .image-error {
    padding: 12px;
    color: var(--danger);
    font-size: 12px;
}

.artifact-item figcaption {
    padding: 8px 9px 9px;
}

.artifact-name,
.artifact-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.artifact-name {
    font-size: 12px;
    font-weight: 650;
}

.artifact-meta {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10px;
}

.artifact-gallery > .inline-state {
    grid-column: 1 / -1;
    margin-top: 0;
}

.ocr-content,
.final-json-content {
    max-height: 430px;
    min-height: 140px;
    margin: 12px 0 0;
    padding: 14px;
    overflow: auto;
    color: #29302c;
    background: #f6f7f5;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-family: Consolas, "Microsoft YaHei", monospace;
    font-size: 12px;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.final-json-content {
    max-height: 640px;
}

/* 修复区先给出业务结论，再展开第三阶段真正处理过的字段。 */
.repair-overview {
    margin-top: 12px;
}

.repair-outcome {
    padding: 12px 14px;
    color: var(--success);
    background: var(--success-soft);
    border-left: 3px solid var(--success);
}

.repair-outcome.is-review {
    color: var(--warning);
    background: var(--warning-soft);
    border-left-color: var(--warning);
}

.repair-outcome-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
}

.repair-outcome p {
    margin: 4px 0 0;
    color: var(--text);
    line-height: 1.65;
}

.repair-metrics {
    display: grid;
    grid-template-columns: repeat(6, minmax(92px, 1fr));
    margin: 0;
    border: 1px solid var(--border);
    border-top: 0;
}

.repair-metrics > div {
    min-width: 0;
    padding: 9px 11px;
    border-right: 1px solid var(--border);
}

.repair-metrics > div:last-child {
    border-right: 0;
}

.repair-metrics dt {
    color: var(--text-muted);
    font-size: 11px;
}

.repair-metrics dd {
    margin: 2px 0 0;
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* 待处理明细把系统条件翻译为用户可执行的复核步骤。 */
.repair-issues {
    margin-top: 18px;
}

.repair-subheading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.repair-subheading h4,
.repair-subheading p {
    margin: 0;
}

.repair-subheading h4 {
    color: var(--text);
    font-size: 14px;
}

.repair-subheading p {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
}

.repair-policy {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 12px;
    margin-top: 10px;
    padding: 11px 13px;
    background: #eef4f7;
    border-left: 3px solid #55758a;
}

.repair-policy strong {
    color: #324e60;
    font-size: 12px;
}

.repair-policy p {
    margin: 0;
    color: var(--text);
    font-size: 12px;
    line-height: 1.65;
}

.repair-issue-list {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.repair-issue-item {
    min-width: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid #e3c58f;
    border-radius: 5px;
}

.repair-issue-heading {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 12px;
    background: var(--warning-soft);
    border-bottom: 1px solid #ead8b8;
}

.repair-issue-heading h5 {
    margin: 1px 0 0;
    color: var(--text);
    font-size: 14px;
}

.repair-issue-sequence {
    color: var(--warning);
    font-size: 10px;
    font-weight: 700;
}

.repair-issue-scope {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-bottom: 1px solid var(--border);
}

.repair-issue-scope > div {
    min-width: 0;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 9px;
    padding: 8px 12px;
}

.repair-issue-scope > div + div {
    border-left: 1px solid var(--border);
}

.repair-issue-scope span {
    color: var(--text-faint);
    font-size: 11px;
}

.repair-issue-scope strong {
    color: var(--text);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.repair-issue-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.repair-issue-statement {
    min-width: 0;
    padding: 11px 12px;
}

.repair-issue-statement + .repair-issue-statement {
    border-left: 1px solid var(--border);
}

.repair-issue-statement > strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 11px;
}

.repair-issue-statement.is-failure > strong {
    color: var(--danger);
}

.repair-issue-statement.is-requirement > strong {
    color: #496d80;
}

.repair-issue-statement.is-action > strong {
    color: var(--success);
}

.repair-issue-statement p {
    margin: 0;
    color: var(--text);
    font-size: 12px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.repair-issue-image {
    width: min(360px, 100%);
    margin: 0;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--border);
}

.repair-issue-image-button {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    padding: 0;
    overflow: hidden;
    background: var(--surface-strong);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    cursor: zoom-in;
}

.repair-issue-image-button img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.repair-issue-image figcaption {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 10px;
}

.repair-issue-item > .repair-issue-statement,
.repair-issue-ocr {
    border-top: 1px solid var(--border);
}

.repair-issue-ocr summary {
    padding: 9px 12px;
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    font-weight: 650;
}

.repair-issue-ocr pre {
    max-height: 260px;
    margin: 0;
    padding: 10px 12px;
    overflow: auto;
    color: var(--text);
    background: var(--surface-muted);
    border-top: 1px solid var(--border);
    font-family: Consolas, "Microsoft YaHei", monospace;
    font-size: 11px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.repair-table-shell {
    margin-top: 14px;
}

.repair-evidence-row td {
    padding: 0;
    background: var(--surface-muted);
}

.repair-evidence {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr);
    gap: 12px;
    padding: 12px;
}

.repair-evidence-panel {
    min-width: 0;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.repair-evidence-panel > strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 12px;
}

.repair-evidence-panel > p {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
}

.repair-evidence-ocr pre {
    max-height: 240px;
    margin: 0;
    overflow: auto;
    color: var(--text);
    background: var(--surface-strong);
    font-family: Consolas, "Microsoft YaHei", monospace;
    font-size: 11px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.repair-evidence-image {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
}

.repair-evidence-image .repair-issue-image-button {
    max-height: 240px;
}

.repair-table {
    min-width: 860px;
    table-layout: fixed;
}

.repair-table th:nth-child(1),
.repair-table td:nth-child(1) {
    width: 15%;
}

.repair-table th:nth-child(2),
.repair-table td:nth-child(2),
.repair-table th:nth-child(3),
.repair-table td:nth-child(3) {
    width: 20%;
}

.repair-table th:nth-child(4),
.repair-table td:nth-child(4) {
    width: 13%;
}

.repair-table th:nth-child(5),
.repair-table td:nth-child(5) {
    width: 32%;
}

.repair-table td {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.repair-table tr.is-replaced td {
    background: #edf7f1;
}

.repair-table tr.is-review td {
    background: #fff8e9;
}

.repair-field strong,
.repair-field span,
.repair-confidence,
.repair-value > span {
    display: block;
}

.repair-field strong {
    color: var(--text);
    font-size: 13px;
}

.repair-field span,
.repair-confidence,
.repair-value > span {
    margin-top: 3px;
    color: var(--text-faint);
    font-size: 10px;
}

.repair-value > div {
    color: var(--text);
    white-space: pre-wrap;
}

.repair-value .empty-value {
    color: var(--text-faint);
    font-style: italic;
}

.repair-status {
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    color: var(--text-muted);
    background: var(--neutral-soft);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.repair-status.is-replaced,
.repair-status.is-kept {
    color: var(--success);
    background: var(--success-soft);
    border-color: #b9dcc8;
}

.repair-status.is-review {
    color: var(--warning);
    background: var(--warning-soft);
    border-color: #e6cb98;
}

.repair-reason {
    color: var(--text) !important;
}

.image-dialog {
    width: min(1100px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    padding: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    box-shadow: var(--shadow-dialog);
}

.image-dialog::backdrop {
    background: rgb(22 28 24 / 64%);
}

.image-dialog.is-fullscreen {
    inset: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
}

.dialog-toolbar {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 10px 7px 14px;
    border-bottom: 1px solid var(--border);
}

.image-zoom-tools {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
}

.zoom-reset-button {
    min-height: 30px;
    padding: 0 8px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    font-size: 11px;
}

.image-zoom-label {
    min-width: 42px;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dialog-toolbar p {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
}

.image-dialog[open] {
    height: min(900px, calc(100vh - 28px));
    display: flex;
    flex-direction: column;
}

.image-dialog-viewport {
    min-height: 0;
    flex: 1;
    display: grid;
    place-items: center;
    overflow: auto;
    background: var(--surface-strong);
}

.image-dialog img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
}

.image-dialog img.is-zoomed {
    max-width: none;
    max-height: none;
    object-fit: initial;
}

.image-dialog img.is-error {
    /* 原图加载失败时不再占满视口，避免空白大框。 */
    display: none;
}

.image-dialog-error {
    margin: 0;
    padding: 14px 18px;
    max-width: min(420px, 80%);
    text-align: center;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
}

.image-dialog-loading {
    margin: 0;
    padding: 14px 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.toast {
    position: fixed;
    z-index: 120;
    right: 18px;
    bottom: 18px;
    max-width: min(340px, calc(100vw - 36px));
    padding: 9px 12px;
    color: #ffffff;
    background: #29332e;
    border-radius: 4px;
    box-shadow: 0 6px 18px rgb(20 30 25 / 18%);
}

[hidden] {
    display: none !important;
}

/* 双栏桌面在左栏较窄时让筛选按钮换行，避免覆盖右侧详情。 */
@media (min-width: 1101px) and (max-width: 1650px) {
    .filter-toolbar {
        grid-template-columns: minmax(0, 1fr) 120px;
    }

    .filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1100px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .history-pane {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .artifact-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .app-header {
        align-items: flex-start;
        padding: 11px 14px;
    }

    .app-header h1 {
        font-size: 19px;
    }

    .record-summary {
        display: none;
    }

    .history-pane,
    .detail-pane {
        padding: 16px 14px 30px;
    }

    .filter-toolbar {
        grid-template-columns: minmax(0, 1fr) 120px;
    }

    .field-keyword,
    .filter-actions {
        grid-column: 1 / -1;
    }

    .filter-actions .button {
        flex: 1;
    }

    /* 手机历史记录改为两行摘要，避免五列内容被强行压缩。 */
    .history-table,
    .history-table tbody {
        display: block;
    }

    .history-table thead {
        display: none;
    }

    .history-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 5px 12px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }

    .history-table tbody tr:last-child {
        border-bottom: 0;
    }

    .history-table td,
    .history-table th:nth-child(n),
    .history-table td:nth-child(n) {
        width: auto;
        padding: 0;
        border-bottom: 0;
    }

    .history-table td:nth-child(2),
    .history-table td:nth-child(4) {
        text-align: right;
    }

    .history-table td:nth-child(3),
    .history-table td:nth-child(4),
    .history-table .issue-cell.has-issues {
        color: var(--text-muted);
        font-size: 11px;
    }

    .history-table td:nth-child(3)::before {
        content: "开始 ";
        color: var(--text-faint);
    }

    .history-table td:nth-child(4)::before {
        content: "耗时 ";
        color: var(--text-faint);
    }

    .history-table .issue-cell {
        display: none;
        grid-column: 1 / -1;
    }

    .history-table .issue-cell.has-issues {
        display: block;
    }

    .history-table .issue-cell.has-issues::before {
        content: "待处理问题 ";
        color: var(--warning);
    }

    .repair-policy {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .repair-issue-heading {
        align-items: flex-start;
    }

    .repair-issue-scope,
    .repair-issue-details {
        grid-template-columns: 1fr;
    }

    .repair-issue-scope > div {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .repair-issue-scope > div + div,
    .repair-issue-statement + .repair-issue-statement {
        border-left: 0;
        border-top: 1px solid var(--border);
    }

    .repair-issue-ocr pre {
        max-height: none;
        overflow: visible;
    }

    .final-json-content {
        max-height: none;
        overflow: visible;
    }

    .run-metadata {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metadata-item:nth-last-child(-n + 3) {
        border-bottom: 1px solid var(--border);
    }

    .metadata-item:nth-last-child(-n + 2) {
        border-bottom: 0;
    }

    .artifact-gallery {
        grid-template-columns: 1fr;
    }

    /* 手机时间线保留步骤、耗时和进度条，不再要求横向拖动。 */
    .timeline-scroll {
        overflow-x: visible;
    }

    .timeline-board {
        min-width: 0;
    }

    .timeline-axis {
        display: none;
    }

    .timeline-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 5px 10px;
        padding: 8px 0;
    }

    .timeline-label {
        grid-column: 1;
        grid-row: 1;
    }

    .timeline-track {
        grid-column: 1 / -1;
        grid-row: 2;
        height: 20px;
    }

    .timeline-duration {
        grid-column: 2;
        grid-row: 1;
    }

    /* 手机修复明细改为逐条纵向记录，处理结果和依据无需横向滚动。 */
    .repair-table-shell {
        overflow: visible;
        border: 0;
    }

    .repair-table,
    .repair-table tbody {
        min-width: 0;
        display: block;
    }

    .repair-table thead {
        display: none;
    }

    .repair-table tbody {
        display: grid;
        gap: 10px;
    }

    .repair-table tbody tr {
        display: grid;
        overflow: hidden;
        border: 1px solid var(--border);
        border-radius: 5px;
    }

    .repair-table td,
    .repair-table th:nth-child(n),
    .repair-table td:nth-child(n) {
        width: auto;
    }

    .repair-table td {
        display: grid;
        grid-template-columns: 82px minmax(0, 1fr);
        gap: 3px 10px;
        padding: 9px 10px;
    }

    .repair-table tbody tr:last-child td {
        border-bottom: 1px solid var(--border);
    }

    .repair-table td::before {
        grid-column: 1;
        grid-row: 1 / span 10;
        color: var(--text-faint);
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
    }

    .repair-table td > * {
        grid-column: 2;
    }

    .repair-table td:nth-child(1) {
        order: 1;
    }

    .repair-table td:nth-child(4) {
        order: 2;
    }

    .repair-table td:nth-child(2) {
        order: 3;
    }

    .repair-table td:nth-child(3) {
        order: 4;
    }

    .repair-table td:nth-child(5) {
        order: 5;
        border-bottom: 0;
    }

    .ocr-content {
        max-height: none;
        overflow: visible;
    }

    .repair-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .repair-metrics > div:nth-child(3n) {
        border-right: 0;
    }

    .repair-metrics > div:nth-child(-n + 3) {
        border-bottom: 1px solid var(--border);
    }
}

@media (max-width: 440px) {
    .app-kicker {
        display: none;
    }

    .header-actions .button {
        min-width: 38px;
        padding: 0 10px;
    }

    .filter-toolbar {
        grid-template-columns: 1fr;
    }

    .field-keyword,
    .filter-actions {
        grid-column: auto;
    }

    .pagination {
        justify-content: space-between;
    }

    .page-size-field {
        margin-left: 0;
    }

    .run-metadata {
        grid-template-columns: 1fr;
    }

    .metadata-item,
    .metadata-item:nth-last-child(-n + 2),
    .metadata-item:nth-last-child(-n + 3) {
        border-bottom: 1px solid var(--border);
    }

    .metadata-item:last-child {
        border-bottom: 0;
    }

    .segmented-control {
        width: 100%;
    }

    .segmented-control button {
        flex: 1 0 auto;
    }

    .repair-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .repair-metrics > div,
    .repair-metrics > div:nth-child(3n),
    .repair-metrics > div:nth-child(-n + 3) {
        border-right: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
    }

    .repair-metrics > div:nth-child(2n) {
        border-right: 0;
    }

    .repair-metrics > div:nth-last-child(-n + 2) {
        border-bottom: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
