:root {
    --primary: #55a722;
    --primary-hover: #68b92e;
    --primary-active: #43851b;
    --page-bg: #f7f8fa;
    --card-bg: #ffffff;
    --text: #2e2e2e;
    --text-body: #535353;
    --text-secondary: #7e7e7e;
    --text-hint: #aaaaaa;
    --border: #dee0e3;
    --divider: #ebeef2;
    --warning: #fa8c16;
    --warning-bg: #fef3e7;
    --info: #5f96ea;
    --info-bg: #e7f0fc;
    --shadow: 0 0 16px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page-bg);
    color: var(--text-body);
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
}

button,
input,
select {
    font-family: inherit;
}

/* 顶部导航 */
.tool-header {
    height: 48px;
    background: #ffffff;
}

.tool-header-inner {
    width: 100%;
    max-width: 1440px;
    height: 48px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
}

.brand img {
    width: 28px;
    height: 28px;
    margin-right: 12px;
}

.help-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 190px;
    height: 32px;
    padding: 0 14px;
    border: none;
    border-radius: 16px;
    background: #f0f3f1;
    color: var(--text-body);
    font-size: 14px;
    line-height: 22px;
    cursor: pointer;
    text-align: left;
}

.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 10px;
    line-height: 12px;
    flex: none;
}

.help-btn:hover {
    color: var(--primary);
}

/* 主体 */
.tool-main {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 12px 24px 40px;
}

.page-title {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 20px;
    line-height: 28px;
    font-weight: 600;
}

.query-card {
    background: var(--card-bg);
    border-radius: 2px;
    box-shadow: var(--shadow);
    padding: 24px;
}

.form-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.field {
    min-width: 0;
}

.field.serial {
    position: relative;
    width: 416px;
}

.field.source {
    width: 416px;
    margin-left: 32px;
}

.field.target {
    width: 416px;
}

.field label {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 14px;
    line-height: 22px;
}

.field label .required {
    color: #ec4f4f;
    margin-right: 4px;
}

.field input,
.field select {
    width: 100%;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: #ffffff;
    color: var(--text-body);
    font-size: 14px;
    line-height: 22px;
    outline: none;
}

.field input::placeholder {
    color: var(--text-hint);
}

.field input:focus,
.field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(85, 167, 34, 0.12);
}

.field select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("../images/select-down.svg");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 12px;
    padding-right: 32px;
}

.field select:disabled {
    background-color: #f7f8fa;
    color: #b8b8b8;
    cursor: not-allowed;
}

.form-arrow {
    width: 16px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.form-arrow img {
    width: 16px;
    height: 16px;
    display: block;
}

.serial-status {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
}

.serial-status.ok {
    color: var(--primary);
}

.serial-status.error {
    color: #ec4f4f;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.btn {
    height: 32px;
    padding: 0 16px;
    border-radius: 2px;
    font-size: 14px;
    line-height: 22px;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-primary:active {
    background: var(--primary-active);
}

.btn-primary:disabled {
    background: #f0f3f1;
    border-color: #f0f3f1;
    color: var(--text-hint);
    cursor: not-allowed;
}

.btn-ghost {
    background: #ffffff;
    border-color: var(--border);
    color: var(--text-body);
}

.btn-ghost:hover {
    border-color: #bdbdbd;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-icon svg {
    width: 14px;
    height: 14px;
    flex: none;
}

.form-actions .btn-primary {
    width: 134px;
    padding: 0;
}

.form-actions .btn-ghost {
    width: 65px;
    padding: 0;
}

/* 结果 */
.result-card {
    margin-top: 12px;
    background: var(--card-bg);
    border-radius: 2px;
    box-shadow: var(--shadow);
    min-height: 200px;
    padding: 24px;
}

.empty-state {
    padding: 22px 20px 0;
    text-align: center;
}

.empty-state img {
    width: 200px;
    height: 85px;
    display: block;
    margin: 0 auto;
}

.empty-state p {
    margin: 0;
    color: var(--text-hint);
    font-size: 14px;
    line-height: 22px;
}

#warningArea .warning-bar {
    margin-top: 12px;
}

.warning-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    background: var(--warning-bg);
    border-radius: 2px;
    color: var(--text-body);
    font-size: 14px;
    line-height: 22px;
}

.warning-bar .warn-icon {
    width: 14px;
    height: 14px;
    flex: none;
    color: var(--warning);
}

.route-block {
    padding: 0;
}

.route-block + .route-block {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px dashed var(--divider);
}

.route-title {
    margin: 0;
    color: var(--text);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    text-align: center;
}

.route-preposition {
    color: var(--text-secondary);
    font-weight: 400;
}

.recommend-badge {
    display: inline;
    color: var(--text);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
}

.route-count {
    margin: 24px 0 8px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 22px;
    text-align: center;
}

.route-count strong {
    color: var(--primary);
    font-weight: 500;
}

.steps {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 12px 24px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-left: 4px solid #f1a45d;
    border-radius: 2px;
}

.step.is-target {
    border-left-color: #5f96ea;
}

.step-main {
    min-width: 0;
}

.step-version {
    color: var(--text);
    font-size: 14px;
    line-height: 22px;
    font-weight: 500;
}

.step-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
    color: var(--text-hint);
    font-size: 12px;
    line-height: 20px;
}

.reboot-badge {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 6px;
    border-radius: 2px;
    font-size: 12px;
    line-height: 18px;
}

.reboot-badge.device,
.reboot-badge.engine {
    background: #fdf2e7;
    color: #d68438;
}

.reboot-badge.none {
    background: var(--info-bg);
    color: var(--info);
}

.step-detail {
    flex: none;
    width: 72px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: #ffffff;
    color: var(--text-body);
    font-size: 14px;
    line-height: 22px;
    cursor: pointer;
}

.step-detail:hover {
    color: var(--primary);
    border-color: #b9d9a7;
}

.step-arrow {
    height: 32px;
    color: var(--text-hint);
    font-size: 16px;
    line-height: 32px;
    text-align: center;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.result-actions .btn-primary {
    width: 134px;
    padding: 0;
    justify-content: center;
}

.result-actions .btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 204px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: #ffffff;
    color: var(--text-body);
    font-size: 14px;
    line-height: 22px;
    text-decoration: none;
}

.result-actions .btn-link:hover {
    color: var(--primary);
    border-color: #b9d9a7;
}

.result-actions .btn-link svg {
    width: 14px;
    height: 14px;
}

.error-state {
    padding: 40px 20px;
    text-align: center;
}

.error-state .error-title {
    color: var(--text);
    font-size: 14px;
    line-height: 22px;
}

.error-state .error-tip {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 22px;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-dialog {
    width: 800px;
    max-width: 100%;
    height: 724px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 2px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 24px;
    border-bottom: 1px solid var(--divider);
    flex: none;
}

.modal-title {
    margin: 0;
    color: var(--text);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
}

.modal-close {
    width: 56px;
    height: 56px;
    margin-right: -24px;
    border: none;
    background: transparent;
    color: #9a9a9a;
    font-size: 20px;
    line-height: 56px;
    cursor: pointer;
}

.modal-close:hover {
    color: #555555;
}

.modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    height: 78px;
    border: 1px solid var(--divider);
    border-radius: 2px;
    overflow: hidden;
}

.detail-cell {
    padding: 16px;
    border-right: 1px solid var(--divider);
}

.detail-cell:last-child {
    border-right: none;
}

.detail-cell .label {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 20px;
}

.detail-cell .value {
    margin-top: 4px;
    color: var(--text);
    font-size: 14px;
    line-height: 22px;
    font-weight: 500;
    word-break: break-all;
}

.detail-section {
    margin-top: 16px;
    padding-top: 16px;
    padding-left: 12px;
    border-left: 3px solid #8bc34a;
}

.detail-section h4 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
}

.detail-section .content {
    margin-left: 16px;
    color: var(--text-body);
    font-size: 14px;
    line-height: 22px;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-section + .detail-section {
    padding-top: 16px;
    border-top: 1px solid var(--divider);
}

.detail-section .muted {
    color: var(--text-hint);
    font-size: 14px;
    line-height: 22px;
}

.modal-footer {
    padding: 12px 24px 11px;
    text-align: right;
    border-top: 1px solid var(--divider);
    flex: none;
}

.modal-footer .btn {
    width: 65px;
    padding: 0;
}

.help-list {
    margin: 0;
    padding-left: 20px;
    color: var(--text-body);
    font-size: 14px;
    line-height: 22px;
}

.help-list li {
    margin-bottom: 8px;
}

.help-note {
    margin-top: 14px;
    padding: 10px 12px;
    background: var(--page-bg);
    border-radius: 2px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 22px;
}

@media (max-width: 1200px) {
    .field.serial,
    .field.source,
    .field.target {
        width: calc(50% - 40px);
        min-width: 260px;
        margin-left: 0;
    }

    .form-arrow {
        display: none;
    }

    .tool-main {
        padding: 12px 16px 40px;
    }

    .query-card,
    .result-card {
        padding: 16px;
    }

    .steps {
        max-width: 100%;
    }

    .detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .detail-cell:nth-child(2) {
        border-right: none;
    }

    .detail-cell:nth-child(1),
    .detail-cell:nth-child(2) {
        border-bottom: 1px solid var(--divider);
    }
}

@media (max-width: 700px) {
    .tool-header-inner {
        padding: 0 16px;
    }

    .brand {
        font-size: 15px;
    }

    .help-btn {
        padding: 0 10px;
        font-size: 12px;
    }

    .tool-main {
        padding: 12px 12px 32px;
    }

    .field.serial,
    .field.source,
    .field.target {
        width: 100%;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-cell {
        border-right: none;
        border-bottom: 1px solid var(--divider);
    }

    .detail-cell:last-child {
        border-bottom: none;
    }

    .result-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .result-actions .btn-primary,
    .result-actions .btn-link {
        width: 100%;
    }
}
