:root {
    --page: #f4f7f6;
    --surface: #ffffff;
    --text: #17201e;
    --muted: #66736f;
    --line: #dce4e1;
    --primary: #147d70;
    --primary-dark: #0e665c;
    --primary-soft: #e9f6f3;
    --success: #138a5b;
    --success-soft: #eaf8f1;
    --danger: #d94848;
    --danger-soft: #fff0f0;
    --warning: #b36a13;
    --warning-soft: #fff7e6;
    --blue: #2673b8;
    --shadow: 0 8px 26px rgba(27, 48, 43, 0.07);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    color-scheme: light;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--text);
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

button,
textarea {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 76px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 21px;
    font-weight: 800;
}

.site-header h1,
.site-header p,
.section-heading h2,
.section-heading p,
.result-toolbar h2,
.result-toolbar p,
.notice p,
.empty-state p,
.result-card h3,
.result-card p {
    margin: 0;
}

.site-header h1 {
    font-size: 19px;
    line-height: 1.3;
}

.site-header p {
    color: var(--muted);
    font-size: 13px;
}

.page-main {
    display: grid;
    gap: 20px;
    padding: 24px 0 40px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.input-panel,
.result-panel {
    padding: 24px;
}

.section-heading,
.result-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.section-heading {
    margin-bottom: 14px;
}

.section-heading h2,
.result-toolbar h2 {
    font-size: 21px;
    line-height: 1.35;
}

.section-heading p,
.result-toolbar p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.line-count {
    flex: 0 0 auto;
    border: 1px solid #cce5df;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    padding: 3px 10px;
    font-size: 13px;
    font-weight: 700;
}

textarea {
    display: block;
    width: 100%;
    min-height: 190px;
    resize: vertical;
    border: 1px solid #cfd9d6;
    border-radius: 6px;
    outline: none;
    padding: 14px 16px;
    color: var(--text);
    background: #fff;
    line-height: 1.75;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea::placeholder {
    color: #98a5a1;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 125, 112, 0.12);
}

textarea:disabled {
    background: #f5f7f6;
    color: var(--muted);
}

.form-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 12px;
    margin-top: 14px;
}

.button {
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 9px 16px;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.08s ease;
}

.button:active:not(:disabled) {
    transform: translateY(1px);
}

.button:focus-visible,
.copy-field:focus-visible {
    outline: 3px solid rgba(20, 125, 112, 0.2);
    outline-offset: 2px;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.button-primary {
    background: var(--primary);
    color: #fff;
}

.button-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.button-secondary {
    border-color: #cfd9d6;
    background: #fff;
    color: #53605c;
}

.button-secondary:hover:not(:disabled) {
    border-color: #aebcb8;
    background: #f7f9f8;
}

.notice {
    margin-top: 16px;
    border: 1px solid #ecd496;
    border-left: 4px solid #d79a2b;
    border-radius: 6px;
    background: var(--warning-soft);
    padding: 12px 14px;
    color: #75490f;
    font-size: 13px;
}

.notice strong {
    display: block;
    margin-bottom: 2px;
    color: #5d390a;
}

.result-toolbar {
    align-items: center;
}

.button-copy-all {
    flex: 0 0 auto;
    border-color: #b9ddd5;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.button-copy-all:hover:not(:disabled) {
    border-color: var(--primary);
    background: #ddf1ec;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.stat-card {
    display: grid;
    place-items: center;
    min-height: 108px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fbfcfc;
    padding: 14px;
}

.stat-card strong {
    font-size: 32px;
    line-height: 1.2;
}

.stat-card span {
    color: var(--muted);
    font-weight: 700;
}

.stat-success strong {
    color: var(--success);
}

.stat-failed strong {
    color: var(--danger);
}

.result-list {
    min-height: 176px;
    border: 1px dashed #ccd7d4;
    border-radius: 6px;
    background: #fbfcfc;
    padding: 16px;
}

.empty-state {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: 142px;
    color: var(--muted);
    text-align: center;
}

.empty-icon {
    position: relative;
    width: 34px;
    height: 28px;
    margin-bottom: 8px;
    border: 3px solid #a9b3b0;
    border-radius: 5px;
}

.empty-icon::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 5px;
    width: 18px;
    height: 7px;
    border: 3px solid #a9b3b0;
    border-bottom: 0;
    border-radius: 5px 5px 0 0;
}

.empty-icon::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 7px;
    width: 14px;
    border-top: 3px solid #a9b3b0;
}

.empty-state strong {
    color: #394440;
}

.empty-state p {
    font-size: 13px;
}

.result-card + .result-card {
    margin-top: 12px;
}

.result-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 6px;
    background: #fff;
}

.result-card.is-running {
    border-left-color: var(--blue);
}

.result-card.is-success {
    border-left-color: var(--success);
}

.result-card.is-failed {
    border-left-color: var(--danger);
}

.result-card.is-pending {
    border-left-color: var(--warning);
}

.result-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 14px;
    background: #f8faf9;
    border-bottom: 1px solid var(--line);
}

.result-head h3 {
    overflow-wrap: anywhere;
    font-size: 15px;
}

.result-message {
    margin-top: 2px !important;
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.status-badge {
    flex: 0 0 auto;
    border-radius: 5px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 800;
}

.status-running {
    background: #eaf3fb;
    color: var(--blue);
}

.status-success {
    background: var(--success-soft);
    color: var(--success);
}

.status-failed {
    background: var(--danger-soft);
    color: var(--danger);
}

.status-pending {
    background: var(--warning-soft);
    color: var(--warning);
}

.result-body {
    padding: 14px;
}

.expiry-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    border: 1px solid #cde5df;
    border-radius: 6px;
    background: var(--primary-soft);
    padding: 8px 10px;
    color: var(--primary-dark);
    font-size: 13px;
}

.expiry-line strong {
    font-variant-numeric: tabular-nums;
}

.expiry-line.is-expired {
    border-color: #efc5c5;
    background: var(--danger-soft);
    color: var(--danger);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 18px;
}

.field-row {
    display: grid;
    grid-template-columns: 66px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    border-bottom: 1px solid #edf1f0;
}

.field-label {
    color: var(--muted);
    font-size: 13px;
}

.field-value {
    overflow-wrap: anywhere;
    font-family: Consolas, "Microsoft YaHei", monospace;
    font-size: 14px;
    font-weight: 700;
}

.copy-field {
    min-width: 38px;
    min-height: 30px;
    border: 1px solid #d4ddda;
    border-radius: 5px;
    background: #fff;
    color: #57635f;
    cursor: pointer;
    font-size: 12px;
}

.copy-field:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.result-card-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.copy-card-button {
    min-height: 38px;
    border-color: #bddbd5;
    background: #fff;
    color: var(--primary-dark);
}

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

.button-export {
    min-width: 116px;
    border-color: #bde6d4;
    background: #effaf5;
    color: var(--success);
}

.button-export-csv {
    border-color: #c7dfef;
    background: #f0f7fc;
    color: var(--blue);
}

.toast {
    position: fixed;
    z-index: 50;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    max-width: min(420px, calc(100% - 32px));
    transform: translate(-50%, 18px);
    border-radius: 6px;
    background: #1d2926;
    color: #fff;
    padding: 10px 16px;
    opacity: 0;
    pointer-events: none;
    text-align: center;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

@media (max-width: 700px) {
    .shell {
        width: min(100% - 24px, 1120px);
    }

    .header-inner {
        min-height: 66px;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
        font-size: 18px;
    }

    .site-header h1 {
        font-size: 17px;
    }

    .page-main {
        gap: 14px;
        padding: 14px 0 28px;
    }

    .input-panel,
    .result-panel {
        padding: 16px;
    }

    .section-heading h2,
    .result-toolbar h2 {
        font-size: 18px;
    }

    .section-heading p {
        max-width: 245px;
    }

    textarea {
        min-height: 176px;
        padding: 12px;
        font-size: 16px;
    }

    .form-actions {
        grid-template-columns: minmax(0, 1fr) 82px;
        gap: 8px;
    }

    .notice {
        padding: 10px 11px;
    }

    .result-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .button-copy-all {
        width: 100%;
    }

    .stats {
        gap: 8px;
        margin: 16px 0;
    }

    .stat-card {
        min-height: 88px;
        padding: 10px 6px;
    }

    .stat-card strong {
        font-size: 27px;
    }

    .result-list {
        padding: 8px;
    }

    .result-head {
        padding: 11px;
    }

    .result-body {
        padding: 11px;
    }

    .expiry-line {
        align-items: flex-start;
        flex-direction: column;
        gap: 2px;
    }

    .field-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .field-row {
        grid-template-columns: 58px minmax(0, 1fr) 38px;
    }

    .export-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .button-export {
        min-width: 0;
        padding-inline: 8px;
    }
}

@media (max-width: 390px) {
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .line-count {
        align-self: flex-start;
    }

    .result-head {
        flex-direction: column;
        gap: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
