:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #66717d;
    --line: #d8dee5;
    --line-strong: #b9c2cc;
    --surface: #ffffff;
    --surface-soft: #f4f6f8;
    --surface-raised: #fbfcfd;
    --nav: #15252a;
    --nav-soft: #20363b;
    --primary: #176b5b;
    --primary-dark: #0e5145;
    --positive: #147a50;
    --negative: #b73b3b;
    --warning: #a66b10;
    --info: #2e617e;
    --shadow: 0 10px 30px rgba(23, 32, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--surface-soft);
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--surface-soft);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

code,
pre,
.numeric,
.metric strong {
    font-variant-numeric: tabular-nums;
}

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    color: #f5f8f8;
    background: var(--nav);
    border-bottom: 1px solid #2c4247;
}

.topbar-inner {
    display: grid;
    grid-template-columns: 220px 1fr auto;
    align-items: center;
    width: min(1480px, calc(100% - 40px));
    min-height: 64px;
    margin: 0 auto;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    width: max-content;
}

.brand-mark {
    display: inline-grid;
    width: 32px;
    height: 32px;
    place-items: center;
    color: #082f29;
    background: #76d2b7;
    border-radius: 7px;
    font-size: 18px;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.08;
    letter-spacing: 0;
}

.brand strong {
    font-size: 13px;
}

.brand small {
    margin-top: 4px;
    color: #9eb2b3;
    font-size: 9px;
}

.main-nav {
    display: flex;
    height: 64px;
    gap: 4px;
}

.main-nav a {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 0 17px;
    color: #bfcaca;
    font-size: 13px;
    font-weight: 600;
}

.main-nav a:hover,
.main-nav a.active {
    color: #ffffff;
    background: var(--nav-soft);
}

.main-nav a.active::after {
    position: absolute;
    right: 17px;
    bottom: 0;
    left: 17px;
    height: 2px;
    background: #76d2b7;
    content: "";
}

.account {
    display: flex;
    align-items: center;
    color: #c5d0d0;
    gap: 12px;
}

.account form {
    margin: 0;
}

.page-shell {
    width: min(1480px, calc(100% - 40px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 24px;
}

.page-heading h1 {
    margin: 2px 0 0;
    font-size: clamp(25px, 2.5vw, 34px);
    line-height: 1.16;
    letter-spacing: 0;
}

.eyebrow,
.section-kicker {
    margin: 0;
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.heading-meta {
    display: flex;
    align-items: center;
    padding-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    gap: 8px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #24a171;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(36, 161, 113, 0.14);
}

.status-dot.is-warn {
    background: #d58a20;
    box-shadow: 0 0 0 3px rgba(213, 138, 32, 0.16);
}

.notice {
    display: flex;
    align-items: center;
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: 6px;
    font-size: 13px;
    gap: 9px;
}

.notice-success {
    color: #0f5f41;
    background: #eef9f4;
    border-color: #b9e1ce;
}

.notice-error {
    color: #8d2929;
    background: #fff1f1;
    border-color: #edc1c1;
}

.notice-info {
    color: #24566f;
    background: #edf7fb;
    border-color: #bedce9;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--info);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    50% {
        opacity: 0.3;
        transform: scale(0.8);
    }
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(330px, 0.72fr) minmax(620px, 1.8fr);
    align-items: start;
    gap: 20px;
}

.workspace-grid > *,
.detail-grid > * {
    min-width: 0;
}

.form-panel,
.table-panel,
.run-facts,
.log-panel,
.settings-section,
.progress-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-panel,
.table-panel,
.run-facts,
.log-panel {
    padding: 22px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.section-heading h2,
.settings-section-heading h2 {
    margin: 2px 0 0;
    font-size: 18px;
    line-height: 1.25;
}

.engine-chip,
.muted-count {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    color: var(--primary-dark);
    background: #eaf6f1;
    border: 1px solid #c9e7da;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 800;
}

.muted-count {
    color: var(--muted);
    background: var(--surface-soft);
    border-color: var(--line);
}

.field {
    display: grid;
    margin-bottom: 16px;
    gap: 7px;
}

.field > span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #3f4a55;
    font-size: 12px;
    font-weight: 700;
    gap: 8px;
}

.field > span small {
    color: var(--primary);
    font-size: 9px;
    font-weight: 800;
}

.field input,
.field select {
    width: 100%;
    height: 42px;
    padding: 0 11px;
    color: var(--ink);
    background: var(--surface-raised);
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    outline: none;
}

.field input:focus,
.field select:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.11);
}

.field input[readonly] {
    color: #56616c;
    background: #f1f3f5;
}

.field-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.advanced-fields {
    margin: 0 0 16px;
    padding: 12px;
    background: #f8faf9;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.advanced-fields summary {
    color: #3f4a55;
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.advanced-fields[open] summary {
    margin-bottom: 14px;
}

.advanced-fields .field:last-child,
.advanced-fields .field-pair:last-child {
    margin-bottom: 0;
}

.advanced-fields .field-pair:last-child .field {
    margin-bottom: 0;
}

.check-field {
    display: flex;
    align-items: flex-start;
    margin-bottom: 14px;
    padding: 11px;
    color: #3f4a55;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 5px;
    cursor: pointer;
    gap: 10px;
}

.check-field input {
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.check-field span {
    display: grid;
    gap: 3px;
}

.check-field strong {
    font-size: 12px;
}

.check-field small {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.form-note {
    margin: 2px 0 18px;
    padding: 10px 11px;
    color: #52616a;
    background: #f5f8f7;
    border-left: 3px solid #7bb6a6;
    font-size: 11px;
    line-height: 1.65;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

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

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

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

.button-quiet {
    color: #d4dddd;
    background: transparent;
    border-color: #53666a;
}

.button-small {
    min-height: 30px;
    padding: 0 10px;
    font-size: 11px;
}

.button-wide {
    width: 100%;
}

.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.data-table th {
    padding: 9px 10px;
    color: #77818b;
    background: #f6f8f9;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: 10px;
    text-align: left;
    text-transform: uppercase;
}

.data-table td {
    padding: 13px 10px;
    border-bottom: 1px solid #e7ebef;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f9fbfb;
}

.data-table td small {
    display: block;
    max-width: 260px;
    margin-top: 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-overflow: ellipsis;
}

.row-link {
    color: var(--primary);
    font-weight: 800;
}

.empty-cell {
    padding: 42px !important;
    color: var(--muted);
    text-align: center;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    color: #47525d;
    background: #edf0f2;
    border: 1px solid #d7dce1;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.status-running {
    color: #265c74;
    background: #eaf5fa;
    border-color: #bfdce8;
}

.status-starting {
    color: #78530f;
    background: #fff8e8;
    border-color: #ead7a8;
}

.status-completed {
    color: #11633f;
    background: #eaf7f0;
    border-color: #b8e1ca;
}

.status-failed,
.status-cancelled {
    color: #8f2f2f;
    background: #fff0f0;
    border-color: #ecc1c1;
}

.status-queued {
    color: #78530f;
    background: #fff8e8;
    border-color: #ead7a8;
}

.back-link {
    display: inline-block;
    margin-bottom: 13px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
}

.run-heading {
    align-items: center;
}

.progress-panel {
    padding: 18px 20px;
}

.progress-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 20px;
}

.progress-header strong {
    display: block;
    margin-top: 3px;
    font-size: 18px;
}

#progress-percent {
    color: var(--primary);
    font-size: 22px;
    font-weight: 800;
}

.progress-track {
    height: 9px;
    overflow: hidden;
    background: #e7ebee;
    border-radius: 999px;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--primary);
    border-radius: inherit;
    transition: width 350ms ease;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    margin: 16px 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric {
    padding: 15px 17px;
    border-right: 1px solid var(--line);
}

.metric:last-child {
    border-right: 0;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 10px;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 23px;
    line-height: 1;
}

.metric-positive strong {
    color: var(--positive);
}

.metric-negative strong {
    color: var(--negative);
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(300px, 0.7fr) minmax(520px, 1.6fr);
    gap: 18px;
}

.fact-list {
    margin: 0;
}

.fact-list > div {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    padding: 10px 0;
    border-bottom: 1px solid #e8ecef;
    gap: 14px;
}

.fact-list > div:last-child {
    border-bottom: 0;
}

.fact-list dt {
    color: var(--muted);
    font-size: 11px;
}

.fact-list dd {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 12px;
    font-weight: 700;
}

.inline-error {
    margin-top: 14px;
    padding: 10px;
    color: #8f2f2f;
    background: #fff0f0;
    border: 1px solid #ecc1c1;
    border-radius: 5px;
    font-size: 11px;
}

.is-hidden {
    display: none;
}

.log-panel {
    min-width: 0;
}

.stream-state {
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 10px;
    gap: 7px;
}

.log-output {
    min-height: 330px;
    max-height: 540px;
    margin: 0;
    padding: 15px;
    overflow: auto;
    color: #d7e3df;
    background: #122025;
    border: 1px solid #2c4147;
    border-radius: 6px;
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    line-height: 1.7;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.settings-form {
    display: grid;
    gap: 18px;
}

.settings-section {
    padding: 22px;
}

.settings-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.settings-section-heading > span {
    color: var(--muted);
    font-size: 11px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(190px, 1fr));
    gap: 4px 16px;
}

.field-important input,
.field-important select {
    border-color: #9ec8bb;
}

.field-key {
    overflow: hidden;
    color: #89939d;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field-error {
    color: var(--negative);
    font-size: 10px;
    font-style: normal;
}

.settings-actions {
    position: sticky;
    z-index: 10;
    bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    box-shadow: 0 12px 32px rgba(23, 32, 42, 0.16);
    gap: 16px;
}

.settings-actions > div {
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 11px;
    gap: 8px;
}

.settings-actions code {
    padding: 3px 6px;
    color: var(--primary-dark);
    background: #eaf6f1;
    border-radius: 4px;
}

.auth-page {
    min-height: 100vh;
    background: #edf1f2;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(380px, 1.15fr) minmax(380px, 0.85fr);
    width: min(1100px, calc(100% - 40px));
    min-height: 620px;
    margin: 0 auto;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 24px 80px rgba(20, 38, 43, 0.16);
    transform: translateY(7vh);
}

.auth-intro {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 46px;
    color: #ffffff;
    background: var(--nav);
}

.auth-wordmark {
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 800;
    gap: 11px;
}

.auth-intro h1 {
    max-width: 460px;
    margin: 8px 0 0;
    font-size: clamp(38px, 5vw, 64px);
    line-height: 1.04;
    letter-spacing: 0;
}

.auth-intro .eyebrow {
    color: #76d2b7;
}

.auth-signal {
    display: flex;
    align-items: flex-end;
    height: 80px;
    gap: 7px;
}

.auth-signal span {
    width: 8px;
    background: #76d2b7;
}

.auth-signal span:nth-child(1) { height: 18%; }
.auth-signal span:nth-child(2) { height: 45%; }
.auth-signal span:nth-child(3) { height: 100%; }
.auth-signal span:nth-child(4) { height: 66%; }
.auth-signal span:nth-child(5) { height: 28%; }

.auth-form-panel {
    display: grid;
    place-items: center;
    padding: 42px;
}

.auth-form {
    display: grid;
    width: min(340px, 100%);
    gap: 15px;
}

.auth-form h2 {
    margin: 3px 0 13px;
    font-size: 28px;
}

.check-row {
    display: flex;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    gap: 8px;
}

.check-row input {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
}

@media (max-width: 1180px) {
    .workspace-grid {
        grid-template-columns: 340px minmax(0, 1fr);
    }

    .settings-grid {
        grid-template-columns: repeat(3, minmax(180px, 1fr));
    }

    .metric-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .metric:nth-child(3) {
        border-right: 0;
    }

    .metric:nth-child(-n+3) {
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 900px) {
    .topbar-inner {
        grid-template-columns: 1fr auto;
        width: min(100% - 28px, 1480px);
        gap: 10px 18px;
        padding: 10px 0;
    }

    .main-nav {
        grid-row: 2;
        grid-column: 1 / -1;
        height: 40px;
    }

    .main-nav a {
        padding: 0 12px;
    }

    .account > span {
        display: none;
    }

    .page-shell {
        width: min(100% - 28px, 1480px);
        padding-top: 24px;
    }

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

    .settings-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .auth-shell {
        grid-template-columns: 1fr;
        min-height: 0;
        transform: translateY(4vh);
    }

    .auth-intro {
        min-height: 300px;
        padding: 32px;
    }

    .auth-form-panel {
        padding: 38px 28px 48px;
    }
}

@media (max-width: 620px) {
    .page-heading,
    .progress-header,
    .settings-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-heading h1 {
        font-size: 24px;
        overflow-wrap: anywhere;
    }

    .field-pair,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .form-panel,
    .table-panel,
    .run-facts,
    .log-panel,
    .settings-section {
        padding: 17px;
    }

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

    .metric,
    .metric:nth-child(3) {
        border-right: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
    }

    .metric:nth-child(even) {
        border-right: 0;
    }

    .metric:nth-last-child(-n+2) {
        border-bottom: 0;
    }

    .settings-actions > div {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .auth-intro {
        min-height: 260px;
        padding: 25px;
    }

    .auth-intro h1 {
        font-size: 39px;
    }
}
