:root {
    color-scheme: light;
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    font-synthesis: none;
    --page: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fafc;
    --text: #18202f;
    --muted: #687386;
    --line: #e4e9f1;
    --line-strong: #d6dde8;
    --accent: #315ee8;
    --accent-strong: #254cc4;
    --accent-soft: #edf2ff;
    --success: #237a57;
    --success-soft: #e9f7f0;
    --warning: #98610d;
    --warning-soft: #fff5df;
    --danger: #b13b46;
    --danger-soft: #fff0f1;
    --shadow: 0 18px 48px rgb(25 38 65 / 8%);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 82% 6%, rgb(49 94 232 / 9%), transparent 28rem),
        linear-gradient(180deg, #fafbfe 0, var(--page) 30rem);
}

button,
input {
    font: inherit;
}

button {
    touch-action: manipulation;
}

[hidden] {
    display: none !important;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 72px;
    padding: 0 4vw;
    border-bottom: 1px solid rgb(228 233 241 / 80%);
    background: rgb(255 255 255 / 78%);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text);
    font-size: 1rem;
    font-weight: 680;
    letter-spacing: -0.015em;
    text-decoration: none;
}

.brand-mark {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 0.32rem;
    object-fit: contain;
}

.page-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 0 0 3rem;
}

/* The generous air suit the marketing-style login screen; the logged-in
   dashboard wants a much tighter top gap. 3vw is ~37% of the old 8vw. */
#login-view {
    padding-top: clamp(3.5rem, 8vw, 7.5rem);
}

#app-view {
    padding-top: clamp(1.5rem, 3vw, 2.75rem);
}

.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(310px, 430px);
    align-items: center;
    gap: clamp(3rem, 8vw, 8rem);
    min-height: 58vh;
}

.intro-copy {
    max-width: 650px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 17ch;
    margin-bottom: 1.35rem;
    font-size: clamp(2.55rem, 6vw, 5.25rem);
    font-weight: 680;
    line-height: 1.02;
    letter-spacing: -0.055em;
}

h2 {
    margin-bottom: 0;
    font-size: 1.35rem;
    font-weight: 680;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.eyebrow {
    margin-bottom: 0.75rem;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 760;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.lead {
    max-width: 55ch;
    margin-bottom: 0;
    color: var(--muted);
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    line-height: 1.7;
}

.lead.compact {
    font-size: 1.05rem;
}

.card {
    border: 1px solid rgb(228 233 241 / 88%);
    border-radius: var(--radius);
    background: rgb(255 255 255 / 94%);
    box-shadow: var(--shadow);
}

.login-card {
    padding: clamp(1.6rem, 4vw, 2.5rem);
}

.card-heading {
    margin-bottom: 1.7rem;
}

/* The upload card's heading is the eyebrow alone now, so the space the h2
   used to sit in is dropped. Scoped to the upload card: the login card still
   pairs an eyebrow with an h2 and needs the original gap. */
.upload-card .card-heading .eyebrow {
    margin-bottom: 0;
}

.stack {
    display: grid;
    gap: 1rem;
}

label:not(.file-picker) {
    display: grid;
    gap: 0.5rem;
    color: #394456;
    font-size: 0.88rem;
    font-weight: 650;
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: var(--surface);
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgb(49 94 232 / 12%);
}

textarea {
    /* A browser defaults a text area to monospace; this note is prose. */
    font: inherit;
    min-height: 7rem;
    line-height: 1.55;
    resize: vertical;
}

/* The model and workflow selects, first styling pass: the native arrow is
   dropped and a plain "▾" glyph is positioned over the control's right edge by
   the wrapper's ::after — no image, so nothing can fail to load. The glyph is
   decorative and ignores the pointer, so clicks land on the select.
   Everything else — height, radius, border, focus ring — is inherited from the
   shared input rule above, so the closed control matches the other fields.
   The model picker carries both this class and .model-picker, so it is styled
   identically by construction: one picker, one look, and the class is the hook
   a future divergence would hang from. */
.workflow-picker select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.75rem;
    cursor: pointer;
    transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.workflow-picker .select-wrap {
    position: relative;
    display: block;
}

.workflow-picker .select-wrap::after {
    content: "▾";
    position: absolute;
    top: 50%;
    right: 1rem;
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    transform: translateY(-50%);
    transition: transform 140ms ease;
}

/* While the list is open (Chrome/Edge report focus-within for it), tip the
   glyph to point up, the way modern pickers do. */
.workflow-picker .select-wrap:focus-within::after {
    transform: translateY(-50%) rotate(180deg);
}

.workflow-picker select:hover:not(:disabled) {
    border-color: var(--accent);
    background-color: var(--surface-soft);
}

.workflow-picker select:disabled {
    cursor: wait;
    color: var(--muted);
}

/* The selected workflow's description, sitting directly under the select as
   part of the picker's block in the form stack: quiet helper text, the same
   voice as the file picker's detail lines. Hidden whenever the selection
   declares none, so the stack never gains an empty gap. */
.workflow-description {
    margin: -0.35rem 0 0;
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.45;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0.65rem 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 680;
    line-height: 1;
    transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

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

.button:focus-visible,
.file-picker:focus-visible {
    outline: 3px solid rgb(49 94 232 / 26%);
    outline-offset: 2px;
}

.button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.button.primary {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 8px 20px rgb(49 94 232 / 18%);
}

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

.button.secondary {
    border-color: var(--line-strong);
    color: #344054;
    background: var(--surface);
}

.button.secondary:hover:not(:disabled) {
    border-color: #bbc5d5;
    background: var(--surface-soft);
}

.button.danger {
    border-color: #e4b8bd;
    color: var(--danger);
    background: var(--danger-soft);
}

.button.danger:hover:not(:disabled) {
    border-color: #d89ba2;
    background: #ffe5e7;
}

.form-status {
    min-height: 1.35rem;
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.account-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.customer-badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0.45rem 0.75rem;
    border: 1px solid #dbe3f4;
    border-radius: 999px;
    color: #36508c;
    background: var(--accent-soft);
    font-size: 0.84rem;
    font-weight: 700;
}

/* Per-account credit status, shown next to the customer badge once signed
   in. Same pill shape as .customer-badge, neutral colours so "Unlimited" and
   a low remaining count read as information, not as an alert. */
.credits-badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0.45rem 0.75rem;
    border: 1px solid #dbe3f4;
    border-radius: 999px;
    color: #3d4657;
    background: #f2f4fa;
    font-size: 0.84rem;
    font-weight: 700;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.6fr);
    align-items: start;
    gap: 1.5rem;
}

.upload-card,
.jobs-card {
    padding: clamp(1.35rem, 3vw, 2rem);
}

.file-picker {
    display: grid;
    gap: 0.4rem;
    min-height: 128px;
    padding: 1.25rem;
    border: 1px dashed #b9c6df;
    border-radius: 13px;
    cursor: pointer;
    place-content: center;
    text-align: center;
    background: var(--surface-soft);
    transition: border-color 140ms ease, background 140ms ease;
}

.file-picker:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.file-picker-title {
    color: #2a426f;
    font-weight: 700;
}

.file-picker-detail {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.55;
}

/* A background note is optional and secondary to the archive itself, so the form
   keeps it folded until the analyst asks for it. A closed <details> still submits its
   field, and app.js reads the value directly rather than depending on that. */
.background-details {
    padding: 0.2rem 0;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface-soft);
}

.background-details > summary {
    padding: 0.6rem 0.9rem;
    color: #334873;
    font-weight: 700;
    cursor: pointer;
}

/* label:not(.file-picker) already lays this out and out-specifies this rule, so
   only the inset and the weight of the question are added here. */
.background-field {
    padding: 0.4rem 0.9rem 0;
}

.background-field span {
    color: var(--muted);
    font-weight: 400;
}

code,
pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

code {
    padding: 0.12rem 0.32rem;
    border-radius: 5px;
    color: #334873;
    background: var(--accent-soft);
    font-size: 0.88em;
}

/*
   One card per job. The list is a plain <ul> and each card is a grid, so the
   width of a job ID, a failure reason, or the presence of output links never
   pushes the other jobs around the way table columns did.
*/
.job-list {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* The welcome panel is the card's content while there are no jobs, so it sits
   in the middle of the card. Error text in #jobs-status below the list is
   short and reads fine centered too. */
.jobs-welcome {
    max-width: 46rem;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
    text-align: left;
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.jobs-welcome-title {
    margin: 0 0 0.75rem;
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 680;
    letter-spacing: -0.015em;
    text-align: center;
}

.jobs-welcome p {
    margin: 0 0 0.85rem;
}

.jobs-welcome p:last-child {
    margin-bottom: 0;
}

.jobs-welcome code {
    padding: 0.05em 0.35em;
    border-radius: 5px;
    background: var(--accent-soft);
    font-size: 0.88em;
}

.jobs-welcome a {
    color: var(--accent);
    text-decoration: none;
}

.jobs-welcome a:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}

.jobs-card #jobs-status {
    margin-top: 0;
    text-align: center;
}

.job-card {
    display: grid;
    gap: 0.7rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface-soft);
}

.job-card-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.job-title {
    margin: 0;
    color: #27344a;
    font-size: 1rem;
    font-weight: 680;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.job-card .status-pill {
    flex: none;
}

.job-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 1.6rem;
    margin: 0;
    font-size: 0.84rem;
}

.job-meta > div {
    display: flex;
    gap: 0.4rem;
}

.job-meta dt {
    color: var(--muted);
}

.job-meta dd {
    margin: 0;
    color: #465164;
    /* A customer-chosen archive name can be long; it must not widen the card. */
    overflow-wrap: anywhere;
}

/* Output and deletion actions share one row per job: the result action on the
   left, the delete action pushed to the far right. */
.job-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.9rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.job-actions .button {
    flex: none;
}

/* The destructive action belongs at the edge, away from reading order, and it
   stays there whether or not a result action sits on the left. */
.job-actions .button.danger {
    margin-left: auto;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.58rem;
    border-radius: 999px;
    color: var(--pill-fg, #4d586a);
    background: var(--pill-bg, #eff2f6);
    font-size: 0.76rem;
    font-weight: 720;
}

/*
   One rule per lifecycle state documented in gpu/README.md. Colours are set through
   --pill-fg and --pill-bg so a state never has to repeat the pill chrome.
   A state with no rule below keeps the neutral pill above, which is also the
   fallback for the "incomplete" and "unknown" states the API reports.
*/
.status-job-queued {
    --pill-fg: #3957a0;
    --pill-bg: var(--accent-soft);
}

.status-running {
    --pill-fg: var(--warning);
    --pill-bg: var(--warning-soft);
}

.status-completed {
    --pill-fg: var(--success);
    --pill-bg: var(--success-soft);
}

.status-failed {
    --pill-fg: var(--danger);
    --pill-bg: var(--danger-soft);
}

.status-deleting {
    --pill-fg: #8a4f17;
    --pill-bg: #fff0d8;
}

.failure-reason {
    margin: 0;
    padding: 0.55rem 0.75rem;
    border-left: 3px solid var(--danger);
    border-radius: 0 8px 8px 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    color: var(--danger);
    background: var(--danger-soft);
    font-size: 0.84rem;
    line-height: 1.5;
}

pre {
    max-height: 70vh;
    overflow: auto;
    margin: 0;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: #29364a;
    background: #f8fafc;
    font-size: 0.84rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/*
   The job's result, shown in place of a downloaded file. The dialog is sized off
   the viewport rather than the text so a 8k-word report scrolls inside it instead of
   pushing the page; the body is a <pre>, so line breaks and indentation in the
   report survive and nothing is re-wrapped into a shape the author did not write.
*/
.result-dialog {
    width: min(920px, calc(100vw - 2rem));
    max-height: calc(100vh - 4rem);
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.result-dialog::backdrop {
    background: rgb(15 24 41 / 46%);
}

.result-dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--line);
}

.result-title {
    /* Job IDs are 25 characters of timestamp and hex; they must not widen the
       dialog or crowd the close button out. */
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 1rem;
    font-weight: 700;
}

.result-body {
    max-height: calc(100vh - 12rem);
    border: 0;
    border-radius: 0;
    background: transparent;
}

/* The upload dialog: narrower than the result dialog — it holds one progress
   bar, a line of text and two buttons — and it shares the same chrome, backdrop
   and heading conventions so it reads as part of the same workspace. */
.upload-dialog {
    width: min(460px, calc(100vw - 2rem));
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.upload-dialog::backdrop {
    background: rgb(15 24 41 / 46%);
}

.upload-dialog-heading {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--line);
}

.upload-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.upload-dialog-body {
    display: grid;
    gap: 0.9rem;
    padding: 1.35rem;
}

.upload-progress {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--accent-soft);
}

.upload-progress-bar {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 120ms ease;
}

.upload-progress-text {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
}

.upload-status-text {
    min-height: 1.35rem;
    margin: 0;
    color: var(--danger);
    font-size: 0.9rem;
    line-height: 1.5;
}

.upload-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

footer {
    display: flex;
    justify-content: center;
    padding: 0 1rem 2rem;
    color: #929baa;
    font-size: 0.78rem;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 850px) {
    .login-layout,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .login-layout {
        gap: 3rem;
    }

    .login-card {
        max-width: 520px;
    }
}

@media (max-width: 580px) {
    .site-header {
        padding: 0 1rem;
    }

    .page-shell {
        width: min(100% - 1.25rem, 1180px);
    }

    #login-view {
        padding-top: 2.75rem;
    }

    h1 {
        font-size: 2.65rem;
    }

    .jobs-card {
        padding-inline: 1rem;
    }
}

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