/* Client Builder - Global Design System & Stylesheet */

:root {
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /* Theme Palette */
    --accent: #2453c8;
    --accent-hover: #1a42a8;
    --accent-subtle: #edf3fd;
    --text-main: #132238;
    --muted: #53647a;
    --surface: #ffffff;
    --soft-surface: #f8fafc;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;

    /* Elevation / Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);

    color: var(--text-main);
    background: #f4f6fa;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }

/* Header & Navigation */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 0;
    z-index: 20;
}
.header-inner, .management-main {
    width: min(100%, 1344px);
    margin: 0 auto;
    padding-inline: 28px;
}
.header-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    min-height: 64px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.brand:focus-visible { outline: 3px solid #245dd8; outline-offset: 6px; border-radius: 6px; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #3667e6 0%, var(--accent) 100%);
    color: #fff;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 4px rgba(36, 83, 200, 0.25);
}

.management-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}
.management-nav a {
    padding: 7px 14px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.management-nav a:hover {
    background: #f1f5fa;
    color: var(--accent);
}
.management-nav a[aria-current="page"] {
    background: #eaf1fc;
    color: var(--accent);
}

.account {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    min-width: 0;
    font-size: 13px;
    color: var(--muted);
}
.username {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-main);
}
.account form { margin: 0; }

/* Main Layout & Typography */
main { max-width: 1168px; margin: 0 auto; padding: 48px 24px; flex: 1; }
.management-main { max-width: none; min-height: calc(100vh - 120px); padding-block: 28px 48px; flex: 1; }
.eyebrow { color: #245dd8; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 10px; }
h1 { font-size: clamp(24px, 3.5vw, 32px); line-height: 1.3; font-weight: 700; letter-spacing: -.02em; margin: 0 0 16px; color: var(--text-main); }
h2 { font-size: 18px; font-weight: 650; margin: 0 0 16px; color: var(--text-main); }
h3 { font-size: 15px; font-weight: 600; margin: 16px 0 10px; color: var(--text-main); }
.description { color: var(--muted); font-size: 15px; line-height: 1.8; margin: 0; }

/* Alerts, Notices & Status Messages */
.notice {
    display: block;
    margin: 18px 0 0;
    padding: 12px 16px;
    border: 1px solid #d4e3fa;
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: #f0f6ff;
    color: #274872;
    font-size: 13.5px;
    line-height: 1.7;
    box-shadow: var(--shadow-xs);
}

.notice-warning {
    background: #fffbeb;
    border-color: #fde68a;
    border-left-color: #b45309;
    color: #78350f;
}

.form-error, .project-config-saved {
    position: relative;
    padding: 12px 16px 12px 46px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.6;
    margin-block: 16px;
    overflow-wrap: anywhere;
    box-shadow: var(--shadow-sm);
    animation: alertSlideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes alertSlideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-error {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    border-left: 4px solid #e11d48;
    color: #9f1239;
}
.form-error::before, .project-config-saved::before {
    position: absolute;
    inset-block-start: 13px;
    inset-inline-start: 13px;
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    color: #ffffff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
}
.form-error::before { content: "!" / ""; background: #be123c; }

.project-config-saved {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-left: 4px solid #10b981;
    color: #065f46;
}
.project-config-saved::before { content: "✓" / ""; background: #087554; }
.project-config-saved p { margin: 2px 0 0; font-weight: 400; }

/* Floating Toast Notification */
.toast {
    position: fixed;
    inset-block-end: max(16px, env(safe-area-inset-bottom));
    inset-inline-end: 16px;
    z-index: 30;
    max-inline-size: min(420px, calc(100vw - 32px));
    overflow-wrap: anywhere;
    padding: 12px 18px;
    border-radius: 10px;
    background: #065f46;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.toast.toast-fadeout {
    opacity: 0;
    transform: translateY(8px);
}
.toast-error {
    background: #9f1239;
}
@media (prefers-reduced-motion: reduce) {
    .form-error, .project-config-saved, .toast { animation: none; transition: none; }
}

/* Modules & Cards on Dashboard */
.modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.module {
    display: grid;
    gap: 8px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
    box-shadow: var(--shadow-xs);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.module:hover {
    border-color: #b2ccf4;
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.module strong {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    color: var(--text-main);
    font-size: 17px;
    font-weight: 650;
}
.module strong span {
    color: var(--accent);
    font-size: 18px;
    transition: transform 0.18s ease;
}
.module:hover strong span {
    transform: translateX(3px);
}

/* Panels and Editors */
.section { margin-top: 26px; }
.panel, .editor {
    border: 1px solid var(--border);
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
}
.editor { display: grid; gap: 20px; margin-top: 20px; }
.editor > button { justify-self: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-grid-wide { grid-column: 1 / -1; }

/* Reuse History Card */
.reuse-card {
    display: grid;
    padding: 16px 20px;
    gap: 10px;
    background: #fafcff;
    border: 1px solid #dbe6f5;
}
.reuse-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}
.reuse-select {
    flex: 1 1 360px;
    min-width: 0;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
}
.reuse-grid button { min-height: 42px; }
.reuse-card p.muted { margin: 0; font-size: 12.5px; }

/* Buttons & Interactive Controls */
button, input { font: inherit; }
button { cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.actions form { margin: 0; }
.button { display: inline-block; text-decoration: none; text-align: center; }

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.primary-button:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.primary-button:active {
    transform: translateY(0);
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: var(--surface);
    color: #274872;
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}
.secondary-button:hover {
    border-color: #94a3b8;
    background: #f8fafc;
    color: var(--accent);
    transform: translateY(-1px);
}
.secondary-button:active {
    transform: translateY(0);
}

.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #fecdd3;
    color: #be123c;
    background: #fff;
    padding: 8px 15px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.danger-button:hover {
    background: #fff1f2;
    border-color: #fda4af;
}

.compact-button { padding: 4px 10px; border-radius: 6px; font-size: 13px; }

.text-button {
    border: 0;
    padding: 6px 4px;
    color: var(--accent);
    background: transparent;
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.15s ease;
}
.text-button:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

:is(a, button, summary, .table-wrap, .login-form input):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a { color: var(--accent); text-underline-offset: 3px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font-size: 13px; font-weight: 500; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.page-heading, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.page-heading { margin-bottom: 20px; }
.page-heading h1 { margin: 0; font-size: 26px; overflow-wrap: anywhere; }
.page-heading :is(.muted, .eyebrow) { margin: 4px 0 0; }
.page-heading .eyebrow { margin: 0 0 6px; }
.section-heading { flex-wrap: wrap; margin-bottom: 14px; }
.section-heading h2 { margin: 0; }

/* Form Fields & Controls */
label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 500; color: #20314a; }
input:where(:not([type="checkbox"], [type="radio"], [type="hidden"])), select, textarea {
    width: 100%;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: var(--text-main);
    background: #fff;
    font: inherit;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.management-main :where(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"]), select, textarea) {
    min-height: 42px;
    border-color: #cbd5e1;
    font-size: 14.5px;
    line-height: 1.45;
}
.management-main :where(input:not([type="checkbox"], [type="radio"]), select, textarea):focus-visible {
    border-color: var(--accent);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(36, 83, 200, 0.18);
}
.management-main :where(input, select, textarea):where(:disabled, [readonly]) {
    background-color: #f8fafc;
    color: var(--muted);
    border-color: #e2e8f0;
}
.management-main :where(input, textarea)::placeholder { color: #94a3b8; opacity: 1; }
.management-main select { appearance: none; }
.management-main :is(select, .repository-select input) {
    padding-right: 36px;
    background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position: right 16px center, right 11px center;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}
.management-main :is(select, .repository-select input:not(:focus)) { text-overflow: ellipsis; }
.management-main select:enabled { cursor: pointer; }

@media (forced-colors: active) {
    .management-main select { appearance: auto; }
    .management-main :is(select, .repository-select input) { padding-right: 12px; background-image: none; }
    .repository-select-options button.active { outline: 1px solid Highlight; outline-offset: -1px; }
}

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-weight: normal; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; border-radius: 4px; accent-color: var(--accent); }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: 10px; padding: 20px; background: #fafcff; }
legend { padding: 0 8px; font-weight: 600; font-size: 13.5px; color: #20314a; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.6; }

/* Filter Bar */
.filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 240px)) auto;
    align-items: end;
    gap: 12px;
    margin-bottom: 18px;
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
.filters label { min-width: 0; }
.filters .actions :is(a, button) { min-height: 42px; }

/* Tables & Lists */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
th {
    color: #475569;
    font-size: 12.5px;
    font-weight: 600;
    background: #f8fafc;
    letter-spacing: 0.02em;
}
th, td { padding: 14px 18px; border-bottom: 1px solid #f1f5f9; vertical-align: top; line-height: 1.6; }
tbody tr:last-child > :is(th, td) { border-bottom: 0; }
.empty { padding: 40px; color: #64748b; text-align: center; }

.list-table :is(th, td) { padding: 12px 16px; line-height: 1.5; }
.list-table thead th { padding-block: 10px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.list-table th[scope="row"] { background: transparent; color: inherit; font-size: inherit; font-weight: 400; }
.list-table tbody tr { transition: background-color 0.12s ease; }
.list-table tbody tr:focus-within { background: #f8fafc; }
@media (hover: hover) { .list-table tbody tr:hover { background: #f8fafc; } }
.list-table .empty { padding: 36px 16px; }

.project-table { min-width: 660px; }
.build-table { min-width: 850px; }
.build-table th[scope="row"], .build-table td:nth-child(5) { max-width: 230px; overflow-wrap: anywhere; }
.project-table th[scope="row"] { max-width: 350px; overflow-wrap: anywhere; }
.machine-table { table-layout: fixed; min-width: 870px; }
.machine-table thead th:nth-child(1) { width: 22%; }
.machine-table thead th:nth-child(2) { width: 15%; }
.machine-table thead th:nth-child(3) { width: 20%; }
.machine-table thead th:nth-child(4) { width: 18%; }
.machine-table thead th:nth-child(5) { width: 15%; }
.machine-table thead th:nth-child(6) { width: 10%; }
.machine-name { overflow-wrap: anywhere; }
.machine-field-label, .project-field-label { display: none; }

.cell-stack { display: grid; justify-items: start; gap: 4px; min-width: 0; }
.cell-title { color: #1e3a8a; font-weight: 650; text-decoration: none; }
.cell-title:hover, .row-link:hover, .row-actions a:hover { text-decoration: underline; }
.table-time { color: #64748b; font-size: 13px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.inline-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.inline-group form, .row-actions form { margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.row-link, .row-actions :is(a, button) { padding-block: 2px; font-size: 13px; text-decoration: none; white-space: nowrap; }
.row-actions button:hover { text-decoration: underline; }
.version-number { max-width: 100%; color: #1e293b; font-size: 13.5px; font-weight: 650; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.version-target { color: var(--accent); }
.agent-state-link { display: inline-block; border-radius: 6px; text-decoration: none; }
.agent-state-link:hover { text-decoration: underline; color: #be123c; }

/* Badges & Status Pills */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.state {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}
.state-succeeded { color: #047857; background: #ecfdf5; border-color: #d1fae5; }
.state-failed, .state-interrupted { color: #be123c; background: #fff1f2; border-color: #ffe4e6; }
.state-running, .state-uploading { color: #1d4ed8; background: #eff6ff; border-color: #dbeafe; }
.state-available { color: #b45309; background: #fffbeb; border-color: #fef3c7; }
.connection-state::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Key-Value Details Grid */
.details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
}
dl.details + dl.details { margin-top: 12px; }
.details-domains {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.details > div {
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-xs);
    min-width: 0;
}
dt { color: #64748b; font-size: 12.5px; font-weight: 500; margin-bottom: 5px; }
dd { margin: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 500; color: var(--text-main); line-height: 1.6; }
.agent-details { margin: 0 0 14px; }
.machine-details { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
#agent-version { scroll-margin-top: 112px; }
#build-artifact {
    background: #fafcff;
    border-color: #d8e5f8;
}
#build-artifact a.primary-button {
    font-size: 14.5px;
    padding: 10px 20px;
}
#build-artifact p { margin: 10px 0 0; }

/* Console Grid & Two-Column Layout */
.console-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    align-items: start;
    gap: 24px;
    margin-top: 20px;
}
.console-layout > * { min-width: 0; }
form.console-layout {
    margin-top: 18px;
}
.console-main, .console-aside {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}
.console-main { gap: 20px; }
.console-aside { gap: 16px; }
.console-form-actions {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.console-form-actions button { min-height: 44px; }
@media (max-width: 1040px) {
    .console-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Status Banner */
.status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 18px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
}
.status-banner-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    min-width: 0;
    overflow-wrap: anywhere;
}
.status-banner-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    font-size: 13px;
    color: var(--muted);
}
.status-banner-meta strong {
    color: var(--text-main);
    font-weight: 600;
}
.status-banner-note { flex-basis: 100%; margin: 0; }
#build-error { margin: 0; }

/* Aside Card for Metadata */
.aside-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
}
.aside-card h2 {
    font-size: 16px;
    font-weight: 650;
    color: var(--text-main);
    margin: 0 0 14px;
}
.aside-card > :last-child:is(p, pre) { margin-bottom: 0; }
.aside-card dl {
    display: grid;
    gap: 9px;
    margin: 0;
}
.aside-card dl > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding-bottom: 7px;
    border-bottom: 1px solid #f1f5f9;
}
.aside-card dl > div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}
.aside-card dt {
    font-size: 12.5px;
    color: var(--muted);
    margin: 0;
    white-space: nowrap;
}
.aside-card dd {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-main);
    text-align: right;
    overflow-wrap: anywhere;
}
.aside-card dd > .muted { display: block; }
.aside-card details, .aside-card summary + dl { margin-top: 12px; }
.build-rules ul { margin: 0; padding-inline-start: 18px; }
.build-rules li + li { margin-top: 8px; }

/* Log Viewer & Monospace Pre */
pre {
    padding: 12px;
    border-radius: 8px;
    background: var(--soft-surface);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: 13px/1.6 ui-monospace, Consolas, monospace;
}
.build-log-scroll {
    max-height: min(520px, 65vh);
    overflow: auto;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #1e293b;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    scrollbar-width: thin;
    scrollbar-color: #334155 #0f172a;
}
.build-log-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.build-log-scroll::-webkit-scrollbar-track { background: #0f172a; border-radius: 4px; }
.build-log-scroll::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
.build-log-scroll::-webkit-scrollbar-thumb:hover { background: #475569; }
.build-log-scroll table { table-layout: fixed; min-width: 800px; }
.build-log-scroll th:nth-child(1) { width: 20%; }
.build-log-scroll th:nth-child(2) { width: 8%; }
.build-log-scroll th:nth-child(3) { width: 14%; }
.build-log-scroll th:nth-child(4) { width: 58%; }
.build-log-scroll thead th {
    background: #1e293b;
    color: #94a3b8;
    border-bottom: 1px solid #334155;
    font-size: 11.5px;
    font-weight: 600;
    padding: 10px 14px;
    letter-spacing: 0.03em;
}
.build-log-scroll tbody td {
    padding: 8px 14px;
    border-bottom: 1px solid #1e293b;
    font-size: 12.5px;
    line-height: 1.5;
    vertical-align: top;
    overflow-wrap: anywhere;
}
.build-log-scroll tbody tr:hover {
    background: #1e293b80;
}
.build-log-scroll td:nth-child(1) { color: #94a3b8; font-size: 12px; font-variant-numeric: tabular-nums; }
.build-log-scroll td:nth-child(2) { font-weight: 700; font-size: 11px; color: #38bdf8; white-space: nowrap; }
.build-log-scroll td:nth-child(3) { color: #cbd5e1; font-weight: 600; font-size: 12px; }
.build-log-scroll .log-message {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    color: #f1f5f9;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12.5px;
    line-height: 1.6;
}

/* Pagination */
.build-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 16px;
}
.build-pagination p { margin: 0; }
.build-pagination .actions a {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

/* Environment & Project Configs */
.project-config-nav { display: flex; flex-wrap: wrap; gap: 4px 12px; border-bottom: 1px solid var(--border); }
.project-config-nav a {
    margin-bottom: -1px;
    padding: 10px 16px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.project-config-nav a:hover { color: var(--accent); }
.project-config-nav a[aria-current="page"] {
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.project-config-form { margin-top: 16px; }
.project-config-form > .actions { padding-top: 16px; border-top: 1px solid var(--border); }
.project-environments { display: grid; gap: 16px; min-width: 0; }
.project-environments h2, .project-environments h3, .project-environments p { margin: 0; }

.environment-tabs:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f1f5f9;
}
.environment-tabs button {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #475569;
    text-align: left;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.environment-tabs button span { font-size: 13.5px; font-weight: 600; }
.environment-tabs code { font-size: 12px; overflow-wrap: anywhere; }
.environment-tabs button:hover { background: #e2e8f0; color: var(--accent); }
.environment-tabs button[aria-selected="true"] {
    color: var(--accent);
    border-color: transparent;
    background: #fff;
    box-shadow: var(--shadow-sm);
}
.environment-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.environment-panel {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-xs);
}
.environment-panel[hidden], .environment-enhanced .environment-panel > summary { display: none; }
.environment-panel[open] > summary { margin-bottom: 20px; }
.environment-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.environment-domains, .environment-security { display: grid; align-content: start; gap: 16px; min-width: 0; }
.environment-fields h3 { margin-bottom: 6px; font-size: 15px; }
.environment-fields textarea { resize: vertical; line-height: 1.6; }
.environment-security textarea {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 12px;
    background: #f8fafc;
}
.environment-note { padding: 12px 14px; border-radius: 8px; background: #f8fafc; border: 1px solid #e2e8f0; }

.project-repository, .project-source, .project-credential-clear { grid-column: 1 / -1; }
.project-config-section { display: grid; gap: 20px; min-width: 0; }
.project-config-section h2, .project-config-section > p, .project-config-section > div > p, .project-build-defaults { margin: 0; }
.project-platforms { display: grid; gap: 16px; min-width: 0; }
.project-desktop-platforms { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.project-platforms fieldset {
    margin: 0;
    padding: 20px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.project-platforms fieldset:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-sm);
}
.project-package { display: grid; gap: 12px; min-width: 0; }
.project-package p { margin: 0; }
.project-package [data-asset-download] { overflow-wrap: anywhere; }
.windows-signing-placeholder { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.project-macos-signing { display: grid; gap: 16px; min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: #fafcff; }
.project-macos-signing :is(h3, h4, p) { margin: 0; }
.macos-signing-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; }
.macos-signing-header p { grid-column: 1; }
.macos-signing-toggle {
    grid-column: 2;
    grid-row: 1 / 3;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--soft-surface);
    font-weight: 600;
    white-space: nowrap;
}
.macos-signing-toggle input { margin: 0; }
.macos-signing-toggle:has(input:disabled) { color: var(--muted); }
.macos-signing-fields:not([hidden]) { display: grid; gap: 12px; }
.macos-signing-fields .notice { display: block; padding: 10px 12px; }
.macos-signing-group { display: grid; align-content: start; gap: 12px; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--soft-surface); }
.macos-signing-group label { min-width: 0; }
.macos-signing-group small { white-space: nowrap; }
[data-assets-clear-native][hidden] { display: none; }

.project-source, .project-ref-tools:not([hidden]) { display: grid; gap: 12px; }
.project-source-controls { display: flex; align-items: center; gap: 12px; }
.project-source-controls > .repository-select { flex: 1; }
.repository-select { position: relative; min-width: 0; }
.repository-select-options:not([hidden]) {
    position: absolute;
    z-index: 10;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: min(300px, 45vh);
    overflow: auto;
    padding: 6px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.repository-select-options button {
    display: block;
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    text-align: left;
    overflow-wrap: anywhere;
    transition: background-color 0.12s ease;
}
.repository-select-options button[aria-selected="true"] { background: #eaf1fc; color: var(--accent); font-weight: 600; }
.repository-select-options button:hover, .repository-select-options button.active { background: #f1f5fa; }
.repository-select-heading, .repository-select-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.project-source-controls > button { flex-shrink: 0; }
.project-ref-tools p { margin: 0; }

.repository-refs:not([hidden]), .build-assets:not([hidden]) { display: grid; gap: 16px; grid-column: 1 / -1; }
[data-asset-kind][hidden] { display: none; }
.asset-field { display: grid; gap: 10px; align-content: start; min-width: 0; }
.asset-image {
    width: 160px;
    min-height: 100px;
    display: grid;
    place-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
}
[data-asset-kind="dark_tray_icon"] .asset-image { background: #1e293b; }
.asset-image img { width: 128px; height: 128px; object-fit: contain; }
.asset-image[hidden], .asset-image img[hidden], .asset-image span[hidden], [data-asset-download][hidden], [data-asset-retry][hidden], [data-assets-clear][hidden] { display: none; }
.asset-thumbnail { width: 56px; min-height: 48px; padding: 4px; }
.asset-thumbnail img { width: 40px; height: 40px; }
.asset-thumbnail span {
    padding: 2px;
    border-radius: 4px;
    color: var(--text-main);
    background: var(--surface);
    font-size: 11px;
}
.build-detail-assets .asset-thumbnail { margin: 0 0 6px auto; }
.asset-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.asset-list { display: grid; gap: 12px; }
.build-form .asset-field {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--soft-surface);
}
.build-form input[type="file"] { padding: 6px 8px; }
.asset-preview-row { display: flex; align-items: center; gap: 10px; }
.asset-feedback { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.asset-feedback p, .build-form fieldset > p { margin: 0; }
.source-ref { grid-column: 1 / -1; }
button:disabled { cursor: default; opacity: .55; }

/* Releases */
.release-table { table-layout: fixed; }
.release-table th:nth-child(-n+2) { width: 18%; }
.release-table :is(th, td) { overflow-wrap: anywhere; padding-inline: 12px; }
.release-table thead th { white-space: normal; }
.release-hash {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}
.release-upload { display: grid; gap: 10px; }
.release-upload p { margin: 0; }
.release-upload button { justify-self: start; }
.release-upload input[type="file"] {
    padding: 8px 10px;
    font-size: 13.5px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #fafcff;
}
.release-upload ::file-selector-button {
    margin-inline-end: 10px;
    padding: 5px 10px;
    border: 0;
    border-radius: 6px;
    background: #eaf1fc;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
/* Machine settings and access credentials */
.machine-platforms { display: flex; flex-wrap: wrap; gap: 8px; }
.machine-platforms label {
    min-height: 38px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--soft-surface);
}
.machine-platforms label:has(input:disabled) { color: var(--muted); cursor: default; }
.machine-platforms + p { margin-bottom: 0; }
.token-controls { display: grid; gap: 6px; margin: 18px 0; }
.token-controls p { margin: 0; }
.token-input { display: flex; flex-wrap: wrap; gap: 8px; }
.copy-token[hidden] { display: none; }
.secret-value {
    flex: 1 1 240px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 14px;
    font-weight: 600;
    color: #1e3a8a;
    background: #f0f6ff;
    border-color: #bfdbfe;
    letter-spacing: 0.03em;
}
.aside-card ol {
    padding-left: 20px;
    margin: 12px 0 16px;
    line-height: 1.8;
    color: #334155;
    font-size: 13.5px;
}
.aside-card ol li { margin-bottom: 6px; }
.break-all { overflow-wrap: anywhere; }
summary { cursor: pointer; font-weight: 600; color: #1e293b; }

/* Login */
body.login-page {
    background: linear-gradient(180deg, #edf3fa 0%, #f4f6fa 100%);
    min-height: 100vh;
}
.login-main { display: flex; justify-content: center; align-items: center; min-height: 82vh; padding: 24px; }
.login-card {
    width: min(100%, 420px);
    padding: 38px;
    border: 1px solid #dce5f1;
    border-top: 4px solid var(--accent);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow-lg);
}
.login-card .brand { margin-bottom: 24px; }
.login-card .brand-mark { width: 38px; height: 38px; font-size: 14px; border-radius: 10px; }
.login-card h1 { font-size: 24px; margin-bottom: 8px; }
.login-card .description { font-size: 13.5px; color: var(--muted); }
.login-form { display: grid; gap: 14px; margin-top: 22px; }
.login-form label { font-size: 13.5px; font-weight: 600; color: #1e293b; }
.login-form input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 11px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-bottom: 4px;
    color: inherit;
    background: #fff;
    font-size: 14.5px;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-form input:focus-visible {
    border-color: var(--accent);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(36, 83, 200, 0.18);
}
.login-form .primary-button {
    width: 100%;
    min-height: 44px;
    font-size: 15px;
    margin-top: 8px;
}

/* Footer */
footer {
    padding: 24px 16px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
    background: var(--surface);
}

/* Responsive Media Queries */
@media (max-width: 800px) {
    .details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-heading { align-items: flex-start; }
}
@media (max-width: 900px) {
    .project-desktop-platforms { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
    .environment-fields { grid-template-columns: 1fr; gap: 24px; }
    .macos-signing-header p { grid-column: 1 / -1; }
    .macos-signing-toggle { grid-row: 1; }
    .macos-signing-groups { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 520px) {
    .environment-tabs:not([hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .environment-tabs button { padding: 10px; }
    .environment-panel { padding: 16px; }
}
@media (max-width: 760px) {
    .header-inner { grid-template-columns: 1fr auto; gap: 6px 12px; padding-block: 12px 8px; }
    .management-nav { grid-column: 1 / -1; grid-row: 2; }
    .account { grid-column: 2; grid-row: 1; }
    .username { max-width: 120px; }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 930px) {
    :is(.machine-table-wrap, .project-table-wrap) { border: 0; border-radius: 0; background: transparent; }
    :is(.machine-table, .project-table), :is(.machine-table, .project-table) tbody { display: block; min-width: 0; }
    :is(.machine-table, .project-table) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    :is(.machine-table, .project-table) tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-xs); }
    :is(.machine-table, .project-table) tr:last-child { margin-bottom: 0; }
    :is(.machine-table, .project-table) tbody tr > :is(th, td) { min-width: 0; padding: 0; border: 0; }
    :is(.machine-table, .project-table) :is(.machine-version, .machine-actions, .project-actions, .empty) { grid-column: 1 / -1; }
    :is(.machine-table, .project-table) tbody tr > :is(.machine-version, .machine-actions, .project-actions) { padding-top: 10px; border-top: 1px solid #e8edf4; }
    :is(.machine-table, .project-table) tbody tr > .empty { padding: 10px 0; }
    .machine-field-label, .project-field-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
    .project-state { text-align: right; }
    .agent-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
}
@media (max-width: 520px) {
    .form-grid, .details, .modules { grid-template-columns: 1fr; }
    .reuse-select { grid-template-columns: minmax(0, 1fr); }
    .build-log-scroll table { min-width: 600px; }
    .build-log-scroll :is(thead th, tbody td) { padding-inline: 8px; }
    .project-config-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .header-inner, .management-main { padding-inline: 16px; }
    .management-main { padding-top: 22px; }
    main { padding-top: 36px; }
    .page-heading { flex-direction: column; gap: 12px; }
    .page-heading h1 { font-size: 24px; }
    .editor, .panel { padding: 16px; }
    .brand { font-size: 16px; }
    .username { max-width: 64px; }
    .management-nav { gap: 2px; }
    .management-nav a { padding-inline: 8px; }
    .filters { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) { .project-source-controls { flex-direction: column; align-items: stretch; } }
