:root {
    --bg: #0b1020;
    --bg-accent: #121934;
    --panel: rgba(10, 14, 30, 0.92);
    --panel-soft: rgba(15, 21, 41, 0.92);
    --line: #25304a;
    --line-soft: #1c2438;
    --text: #e6edf9;
    --muted: #8794aa;
    --cyan: #6be7ff;
    --green: #6fe38f;
    --yellow: #ffd76b;
    --red: #ff8f8f;
    --purple: #c1a7ff;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background:
        radial-gradient(circle at top left, rgba(52, 91, 165, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(0, 212, 255, 0.1), transparent 24%),
        linear-gradient(180deg, #09101f 0%, #090d18 100%);
    min-height: 100%;
}

body {
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    padding: clamp(12px, 1.2vw, 18px);
    max-width: 1720px;
    margin: 0 auto;
    opacity: 0;
    transition: opacity .15s;
}

body.ready {
    opacity: 1;
}

a {
    color: var(--cyan);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input[type=text],
select {
    font: inherit;
}

input[type=text],
select {
    width: 100%;
    min-width: 0;
    background: #0d1325;
    border: 1px solid #36415d;
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
}

input[type=text]:focus,
select:focus {
    outline: none;
    border-color: rgba(107, 231, 255, 0.75);
    box-shadow: 0 0 0 3px rgba(107, 231, 255, 0.14);
}

button {
    background: var(--cyan);
    color: #07101b;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    transition: transform .12s, background .12s, opacity .12s;
}

button:hover {
    background: #55daf7;
    transform: translateY(-1px);
}

button:disabled {
    opacity: .48;
    cursor: not-allowed;
    transform: none;
}

button.secondary,
.commit-btn {
    background: #1a2338;
    color: #eef4ff;
    border: 1px solid #36415d;
}

button.secondary:hover,
.commit-btn:hover {
    background: #242f48;
}

button.danger {
    background: #ef6a6a;
    color: #fff;
}

button.danger:hover {
    background: #df5555;
}

.app-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.page-title {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.eyebrow {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 12px;
}

h1 {
    font-size: clamp(22px, 2.8vw, 30px);
    line-height: 1.05;
    color: #f4fbff;
}

.subtitle {
    color: #9ba8be;
    max-width: 920px;
    font-size: 12px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.surface {
    background: linear-gradient(180deg, rgba(14, 18, 34, 0.96) 0%, rgba(10, 14, 28, 0.96) 100%);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.surface-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 0;
}

.surface-head h2,
.surface-head h3 {
    font-size: 15px;
    color: #f5f8ff;
}

.surface-kicker {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.surface-body {
    padding: 12px 14px 14px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.summary-grid-inline {
    grid-template-columns: repeat(3, minmax(92px, 120px));
    align-items: stretch;
}

.stat-card {
    padding: 12px 14px;
    background: linear-gradient(180deg, rgba(18, 25, 52, 0.92) 0%, rgba(10, 14, 30, 0.92) 100%);
    border: 1px solid var(--line);
    border-radius: 14px;
    min-height: 84px;
}

.stat-card .stat-value {
    font-size: clamp(22px, 2.3vw, 28px);
    font-weight: 800;
    color: var(--cyan);
}

.stat-card .stat-label {
    margin-top: 3px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}

.main-grid {
    display: grid;
    grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.sidebar-stack,
.content-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-stack .surface-head {
    padding: 10px 12px 0;
}

.sidebar-stack .surface-head h2 {
    font-size: 15px;
}

.sidebar-stack .surface-body {
    padding: 10px 12px 12px;
}

.sidebar-stack .surface-kicker {
    font-size: 12px;
}

.launch-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.launch-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 260px);
    gap: 10px;
    align-items: stretch;
}

.launch-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.commit-picker {
    position: relative;
}

.commit-btn {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
}

.commit-btn-icon {
    color: #91a0ba;
    font-size: 12px;
    flex: 0 0 auto;
    margin-left: 10px;
}

.launch-hint {
    color: #74839a;
    font-size: 12px;
    white-space: nowrap;
}

.sidebar-stack .notice {
    margin-top: 8px;
}

.commit-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: min(860px, calc(100vw - 48px));
    max-height: min(70vh, 560px);
    z-index: 120;
    background: #0c1224;
    border: 1px solid #36415d;
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.commit-dropdown.open {
    display: flex;
    flex-direction: column;
}

.commit-dropdown .loading {
    padding: 20px;
    text-align: center;
    color: #738099;
}

.commit-filter {
    padding: 10px;
    border-bottom: 1px solid var(--line-soft);
}

.commit-list {
    overflow-y: auto;
    flex: 1;
    max-height: min(60vh, 500px);
}

.commit-hint {
    padding: 12px 16px;
    color: #66748b;
    font-size: 12px;
    text-align: center;
}

.commit-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--line-soft);
    display: grid;
    grid-template-columns: 62px minmax(72px, auto) minmax(220px, 1fr) minmax(120px, 180px) 120px auto;
    gap: 10px;
    align-items: center;
    font-size: 13px;
}

.commit-item:hover {
    background: #151d33;
}

.commit-built {
    border-left: 3px solid var(--green);
}

.commit-item.is-building {
    border-left-color: var(--yellow);
}

.commit-item.is-failed {
    border-left-color: var(--red);
}

.c-hash,
.hash {
    font-family: Consolas, Monaco, monospace;
    color: var(--yellow);
}

.c-msg {
    color: #dce4f2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.c-branch {
    color: var(--purple);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.c-date {
    color: #647188;
    font-size: 11px;
}

.c-built {
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
}

.c-built-running,
.status-running,
.mode-badge.app {
    background: rgba(111, 227, 143, 0.12);
    color: var(--green);
}

.c-built-building,
.status-building {
    background: rgba(255, 215, 107, 0.14);
    color: var(--yellow);
}

.c-built-stopped,
.status-stopped {
    background: rgba(124, 136, 156, 0.16);
    color: #b4bfd0;
}

.c-built-failed,
.status-failed {
    background: rgba(255, 143, 143, 0.12);
    color: var(--red);
}

.c-actions,
.actions,
.quick-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.c-actions {
    grid-column: auto;
    margin-left: 0;
    justify-content: flex-end;
    justify-self: end;
    white-space: nowrap;
}

.quick-actions {
    gap: 6px;
}

.quick-actions button {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 8px;
    min-height: 28px;
    font-weight: 700;
}

.c-action {
    background: transparent;
    border: 1px solid #3b4453;
    color: #c7d0e0;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 11px;
    cursor: pointer;
}

.actions {
    gap: 6px;
}

.actions button {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 8px;
    min-height: 28px;
    font-weight: 700;
}

.actions .danger {
    padding-inline: 9px;
}

.c-action:hover {
    background: #202534;
    color: #fff;
}

.c-action.primary {
    border-color: rgba(107, 231, 255, 0.34);
    color: #9aefff;
}

.c-action.open {
    border-color: rgba(111, 227, 143, 0.34);
    color: #9ef0b3;
}

.c-action.warn {
    border-color: rgba(255, 215, 107, 0.34);
    color: #ffe9a4;
}

.notice {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #2a3140;
    background: #101522;
    color: #d5def0;
    font-size: 13px;
    display: none;
}

.notice.open {
    display: block;
}

.notice.error {
    border-color: #5b2b2b;
    background: #211212;
    color: #ffb4b4;
}

.notice.success {
    border-color: #21452a;
    background: #102014;
    color: #a8efb7;
}

.resource-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(11, 16, 29, 0.9);
}

.resource-row {
    display: grid;
    grid-template-columns: minmax(132px, 156px) minmax(0, 1fr);
    gap: 0;
    padding: 10px 12px;
    background: transparent;
    border-bottom: 1px solid var(--line-soft);
}

.resource-row:last-child {
    border-bottom: 0;
}

.resource-side {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding-right: 12px;
}

.resource-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-left: 1px solid rgba(37, 48, 74, 0.55);
}

.resource-heading {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.resource-label {
    font-size: 14px;
    color: #f3f7ff;
    font-weight: 700;
    min-width: 0;
}

.resource-caption {
    color: #7f8da5;
    font-size: 11px;
}

.mode-badge {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    white-space: normal;
    line-height: 1.2;
    max-width: 100%;
    align-self: flex-start;
}

.mode-badge.db {
    background: rgba(107, 197, 247, 0.12);
    color: #6bc5f7;
}

.resource-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
    padding: 7px 10px;
    border-bottom: 1px solid rgba(37, 48, 74, 0.45);
    background: transparent;
    gap: 12px;
}

.resource-metric-row:last-child {
    border-bottom: 0;
}

.resource-key {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .95;
    color: #8d9ab0;
    flex: 0 0 52px;
}

.resource-value {
    color: #eef3fb;
    font-size: 12px;
    font-weight: 600;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    text-align: right;
    line-height: 1.35;
    word-break: break-word;
    flex: 1 1 auto;
    min-width: 0;
}

.resource-value-cpu {
    align-items: center;
}

.cpu-track {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: 0;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
}

.cpu-bar {
    display: inline-block;
    width: 66px;
    height: 10px;
    background: #11182a;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}

.cpu-bar-fill {
    height: 100%;
    transition: width .5s, background .5s;
}

.cpu-val {
    font-size: 11px;
    font-family: Consolas, Monaco, monospace;
    min-width: 50px;
    display: inline-block;
}

.quick-sections {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.quick-card {
    padding: 12px 14px 14px;
}

.quick-card h3 {
    font-size: 13px;
    color: #9aa4b2;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 12px;
}

.quick-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    background: #121625;
    border: 1px solid #1d2538;
}

.quick-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.quick-meta {
    color: #6f7a8c;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-empty {
    color: #5f6675;
    font-size: 13px;
    padding: 8px 2px;
}

.table-panel {
    overflow: hidden;
}

.table-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1.2fr) repeat(2, minmax(180px, 220px));
    gap: 8px;
    padding: 0 14px 8px;
}

.table-scroll {
    overflow-x: auto;
    border-top: 1px solid var(--line-soft);
}

table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 9px 12px;
    color: #75839a;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .07em;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(12, 18, 34, 0.96);
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 14px;
    vertical-align: top;
}

tbody tr:hover td {
    background: rgba(18, 24, 39, 0.78);
}

tbody tr.row-building td {
    background: rgba(255, 215, 0, .035);
}

tbody tr.row-failed td {
    background: rgba(255, 107, 107, .04);
}

tbody tr.row-running td {
    background: rgba(81, 207, 102, .03);
}

.status {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.branch {
    color: var(--purple);
}

.resource-cell {
    display: inline-flex;
    gap: 10px;
    flex-wrap: wrap;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
}

.resource-cell .mem {
    color: #6bc5f7;
}

.resource-cell .cpu {
    color: var(--green);
}

.empty {
    text-align: center;
    padding: 56px 24px;
    color: #677389;
}

.muted-action {
    color: #697386;
    font-size: 12px;
}

.quick-actions button {
    padding: 5px 10px;
    font-size: 12px;
}

.actions {
    gap: 4px;
}

.actions button {
    background: transparent;
    border: 0;
    color: #afbdd3;
    padding: 3px 5px;
    min-height: 0;
    font-size: 12px;
    border-radius: 6px;
    font-weight: 600;
}

.actions button.secondary {
    background: transparent;
    color: #afbdd3;
    border: 0;
}

.actions button:hover {
    background: rgba(33, 41, 61, 0.72);
    color: #f2f6fd;
    transform: none;
}

.actions .danger {
    color: #ff9d9d;
}

.actions .danger:hover {
    background: rgba(80, 26, 26, 0.55);
    color: #ffd0d0;
}

.actions button:disabled {
    background: transparent;
    opacity: .35;
}

.actions-cell {
    min-width: 180px;
}

.log-modal {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 18, .78);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}

.log-modal.open {
    display: flex;
}

.log-panel {
    width: min(1100px, 100%);
    height: min(84vh, 860px);
    background: #0d0d1a;
    border: 1px solid #333;
    border-radius: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid #222;
    background: #111122;
}

.log-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.log-title h2 {
    font-size: 18px;
    color: #f5f7fb;
}

.log-subtitle {
    font-size: 12px;
    color: #7f8798;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.log-status {
    font-size: 12px;
    color: #7f8798;
}

.log-body {
    flex: 1;
    overflow: auto;
    padding: 14px 18px;
    background: #090912;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 1.6;
}

.log-line {
    color: #a9b3c7;
    white-space: pre-wrap;
    word-break: break-word;
}

.log-line.err {
    color: var(--red);
}

.log-line.warn {
    color: var(--yellow);
}

.log-line.ok {
    color: var(--green);
}

.log-empty {
    color: #5f6675;
    padding: 18px 0;
}

.close-btn {
    background: transparent;
    color: #9aa4b2;
    border: 1px solid #394150;
}

.close-btn:hover {
    background: #202534;
    color: #fff;
}

@media (max-width: 1480px) {
    .main-grid {
        grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    }

    .launch-fields {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1280px) {
    body {
        padding: 16px;
    }

    .summary-grid,
    .main-grid,
    .quick-sections,
    .table-toolbar,
    .resource-list {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .launch-fields {
        grid-template-columns: 1fr;
    }

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

    .launch-actions .actions {
        justify-content: flex-start;
    }

    .launch-hint {
        white-space: normal;
    }

    .summary-grid-inline {
        width: 100%;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .quick-item,
    .resource-row {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        justify-content: flex-start;
    }

    .resource-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .resource-side {
        padding-right: 0;
    }

    .resource-main {
        border-left: 0;
        border-top: 1px solid rgba(37, 48, 74, 0.55);
    }

    table,
    thead,
    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    table {
        min-width: 0;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 12px;
        padding: 16px;
    }

    tbody tr {
        border: 1px solid var(--line);
        border-radius: 16px;
        overflow: hidden;
        background: rgba(12, 18, 34, 0.96);
    }

    td {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 12px 14px;
        border-bottom: 1px solid rgba(37, 48, 74, 0.65);
    }

    td::before {
        content: attr(data-label);
        color: #7f8da5;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .06em;
        flex: 0 0 110px;
    }

    td:last-child {
        border-bottom: none;
    }

    td.actions-cell {
        align-items: flex-start;
    }

    td.actions-cell .actions {
        justify-content: flex-end;
    }
}

@media (min-width: 1281px) {
    html,
    body {
        height: 100%;
    }

    .page-header {
        align-items: center;
    }

    .subtitle {
        display: none;
    }

    .summary-grid-inline {
        grid-template-columns: repeat(3, minmax(86px, 108px));
        gap: 8px;
    }

    .main-grid {
        grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    }

    .resource-row {
        grid-template-columns: 132px minmax(0, 1fr);
    }

    .summary-grid-inline .stat-card {
        min-height: 0;
        padding: 8px 10px;
    }

    .summary-grid-inline .stat-value {
        font-size: 20px;
        line-height: 1;
    }

    .summary-grid-inline .stat-label {
        margin-top: 2px;
        font-size: 10px;
    }

    .quick-list {
        max-height: 180px;
        overflow: auto;
    }

    .table-panel .surface-body {
        padding-bottom: 8px;
    }
}

@media (max-width: 780px) {
    .commit-dropdown {
        left: 50%;
        transform: translateX(-50%);
        width: calc(100vw - 32px);
    }

    .commit-item {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .c-actions {
        margin-left: 0;
    }

    td {
        flex-direction: column;
        align-items: flex-start;
    }

    td::before {
        flex: 0 0 auto;
    }

    td.actions-cell .actions {
        justify-content: flex-start;
    }

    .log-modal {
        padding: 12px;
    }

    .log-header {
        flex-direction: column;
        align-items: stretch;
    }

    .log-toolbar {
        justify-content: flex-start;
    }
}
