:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #eef2ec;
    background: #101211;
    --bg: #101211;
    --surface: #171b1a;
    --surface-strong: #1f2422;
    --surface-soft: #202722;
    --line: #333b37;
    --line-strong: #48524d;
    --text: #eef2ec;
    --muted: #aeb8af;
    --subtle: #7f8d84;
    --accent: #4fc389;
    --accent-strong: #7edba8;
    --cyan: #73c7d7;
    --amber: #f0b85a;
    --danger: #d96767;
    --danger-strong: #ef8585;
    --shadow: 0 22px 60px rgba(0, 0, 0, .34);
    --shadow-soft: 0 12px 34px rgba(0, 0, 0, .22);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(180deg, rgba(35, 42, 37, .9), rgba(16, 18, 17, 0) 360px),
        linear-gradient(120deg, rgba(115, 199, 215, .08), transparent 36%),
        linear-gradient(240deg, rgba(240, 184, 90, .08), transparent 42%),
        var(--bg);
    color: var(--text);
}

body.is-locked {
    overflow: hidden;
}

a {
    color: var(--cyan);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: #a6e3ec;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(16, 18, 17, .82);
    border-bottom: 1px solid rgba(72, 82, 77, .55);
    backdrop-filter: blur(18px);
}

nav,
.container,
footer {
    width: min(1160px, 100%);
    margin: 0 auto;
    padding-inline: 24px;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 74px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    color: #ffffff;
    font-weight: 800;
    text-decoration: none;
}

.brand-logo {
    display: block;
    flex: 0 0 auto;
    width: 62px;
    height: 46px;
    object-fit: contain;
    border: 1px solid rgba(126, 219, 168, .28);
    border-radius: 8px;
    background: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, .08), rgba(0, 0, 0, .18)), #0b0d0c;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}

.nav-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}

.nav-actions form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.nav-link,
.user-chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: .94rem;
}

.nav-link:hover {
    border-color: var(--line);
    background: rgba(255, 255, 255, .04);
    color: var(--text);
}

.user-chip {
    max-width: 240px;
    overflow: hidden;
    border-color: var(--line);
    background: rgba(255, 255, 255, .035);
    color: var(--text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.container {
    min-height: calc(100vh - 142px);
    padding-block: 34px 52px;
}

footer {
    padding-block: 22px;
    color: var(--subtle);
    font-size: .92rem;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.12;
}

h1 {
    font-size: 2.15rem;
}

h2 {
    font-size: 1.22rem;
}

p {
    margin: 0;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--accent-strong);
    font-size: .84rem;
    font-weight: 800;
    letter-spacing: 0;
}

.muted {
    color: var(--muted);
}

.page-header,
.server-card-main,
.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.page-header {
    margin-bottom: 22px;
}

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

.dashboard-metrics {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 1 1 auto;
    flex-wrap: wrap;
}

.metric {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .045);
    color: var(--muted);
    font-size: .86rem;
    font-weight: 800;
}

.metric strong {
    color: var(--text);
    font-size: 1.02rem;
}

.metric.running {
    border-color: rgba(79, 195, 137, .42);
    background: rgba(79, 195, 137, .13);
}

.metric.pending {
    border-color: rgba(240, 184, 90, .42);
    background: rgba(240, 184, 90, .12);
}

.metric.stopped {
    border-color: rgba(115, 199, 215, .24);
    background: rgba(115, 199, 215, .075);
}

.server-detail-header {
    align-items: center;
}

.server-identity {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.server-card,
.tool-panel,
.auth-card,
.empty-state {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .012)), var(--surface);
    box-shadow: var(--shadow);
}

.server-card {
    position: relative;
    display: grid;
    align-content: space-between;
    min-height: 196px;
    padding: 18px;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: border-color .16s ease, transform .16s ease, background .16s ease;
}

.server-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--cyan), var(--amber));
    opacity: .75;
}

.server-card:hover {
    border-color: rgba(126, 219, 168, .65);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    background: linear-gradient(180deg, rgba(79, 195, 137, .09), rgba(255, 255, 255, .012)), var(--surface);
}

.server-title {
    min-width: 0;
}

.server-title h2 {
    margin-bottom: 8px;
}

.server-title p,
.server-card > p {
    color: var(--muted);
}

.server-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 58px;
    height: 58px;
    overflow: hidden;
    border: 1px solid rgba(126, 219, 168, .35);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(79, 195, 137, .28), rgba(115, 199, 215, .18)),
        #1f2a25;
    color: #eafff1;
    font-size: 1rem;
    font-weight: 900;
}

.server-icon.large {
    width: 76px;
    height: 76px;
    font-size: 1.15rem;
}

.server-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.status-pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    width: fit-content;
    max-width: 100%;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #242b28;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill.running,
.status-badge.running {
    border-color: rgba(79, 195, 137, .45);
    background: rgba(79, 195, 137, .16);
    color: #adf0c9;
}

.status-pill.pending,
.status-badge.warning {
    border-color: rgba(240, 184, 90, .5);
    background: rgba(240, 184, 90, .14);
    color: #ffd997;
}

.status-pill.stopped,
.status-badge.stopped {
    border-color: rgba(174, 184, 175, .25);
    background: rgba(255, 255, 255, .045);
    color: #c8d0ca;
}

.connection {
    align-self: end;
    margin-top: 18px;
    color: #b8edf4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92rem;
}

.join-code {
    margin-top: 10px;
    color: #ffd997;
    font-weight: 700;
}

.join-code strong {
    color: #fff1c9;
}

.notice {
    margin: 16px 0;
    padding: 13px 14px;
    border: 1px solid rgba(115, 199, 215, .36);
    border-radius: 8px;
    background: rgba(115, 199, 215, .11);
    color: #dffaff;
}

.notice.warning,
.alert-warning {
    border-color: rgba(240, 184, 90, .45);
    background: rgba(240, 184, 90, .12);
    color: #ffe5af;
}

.notice.error,
.alert-danger,
.validation-summary-errors {
    border-color: rgba(217, 103, 103, .48);
    background: rgba(217, 103, 103, .12);
    color: #ffd1d1;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.info-grid > div {
    min-height: 86px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.info-grid span {
    display: block;
    margin-bottom: 6px;
    color: var(--subtle);
    font-size: .84rem;
}

.info-grid strong {
    overflow-wrap: anywhere;
}

.info-grid .join {
    border-color: rgba(240, 184, 90, .48);
}

.tool-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr);
    gap: 16px;
    margin: 18px 0 24px;
}

.tool-panel,
.auth-card,
.empty-state {
    padding: 18px;
}

.tool-panel {
    box-shadow: var(--shadow-soft);
}

.tool-panel.wide {
    margin: 18px 0;
}

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

.actions,
.table-actions,
.upload-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.table-actions form,
.inline-form {
    margin: 0;
}

button,
.button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    max-width: 100%;
    border: 1px solid rgba(126, 219, 168, .3);
    border-radius: 8px;
    padding: 10px 14px;
    background: #297a52;
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    transition: transform .16s ease, filter .16s ease, background .16s ease, border-color .16s ease;
}

button:hover,
.button:hover,
.btn:hover {
    color: #ffffff;
    filter: brightness(1.08);
    transform: translateY(-1px);
}

button:disabled,
.button[aria-disabled="true"],
.btn:disabled {
    cursor: wait;
    opacity: .62;
    transform: none;
}

.secondary,
.btn-secondary {
    border-color: var(--line-strong);
    background: #303a35;
}

.danger,
.btn-danger {
    border-color: rgba(239, 133, 133, .4);
    background: #8d3d3d;
}

.compact {
    min-height: 34px;
    padding: 7px 10px;
    font-size: .9rem;
}

.link-button {
    min-height: auto;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--cyan);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.link-button:hover {
    color: #a6e3ec;
    filter: none;
    transform: none;
}

.button-symbol {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 1.1em;
    height: 1.1em;
    line-height: 1;
}

.back-link {
    display: inline-flex;
    margin-bottom: 16px;
    color: var(--muted);
    text-decoration: none;
}

.back-link:hover {
    color: var(--text);
}

.logs-heading {
    margin-top: 10px;
}

.logs {
    width: 100%;
    max-height: 600px;
    overflow: auto;
    margin: 0;
    padding: 15px;
    border: 1px solid #28322e;
    border-radius: 8px;
    background: #0a0d0c;
    color: #d6efe1;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92rem;
    line-height: 1.55;
    white-space: pre-wrap;
}

.live-logs {
    max-height: 72vh;
}

.form-stack,
.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
}

.form-stack label,
.form-grid label:not(.checkbox-row),
label,
.form-label {
    display: block;
    margin-bottom: 6px;
    color: #d7ded7;
    font-weight: 700;
}

input:not([type="checkbox"]),
select,
textarea,
.form-control {
    width: 100%;
    min-height: 42px;
    padding: 10px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #0f1311;
    color: #ffffff;
    font: inherit;
    outline: none;
}

input[type="file"] {
    padding: 8px;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus {
    border-color: rgba(126, 219, 168, .75);
    box-shadow: 0 0 0 3px rgba(79, 195, 137, .16);
}

.checkbox-row,
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}

.form-check-input {
    width: 18px;
    height: 18px;
}

.validation,
.text-danger,
.field-validation-error {
    display: block;
    margin-top: 5px;
    color: #ffb7b7;
    font-size: .9rem;
}

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

.user-table,
.table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.user-table th,
.user-table td,
.table th,
.table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.user-table th,
.table th {
    color: var(--muted);
    font-size: .86rem;
    font-weight: 800;
}

.user-table tbody tr,
.table tbody tr {
    transition: background .16s ease;
}

.user-table tbody tr:hover,
.table tbody tr:hover {
    background: rgba(255, 255, 255, .035);
}

.auth-card {
    width: min(540px, 100%);
    margin: 42px auto;
}

.auth-card h1 {
    margin-bottom: 18px;
}

.login-card {
    text-align: center;
}

.login-card .form-stack {
    text-align: left;
}

.login-logo {
    display: block;
    width: min(260px, 82%);
    height: auto;
    margin: 0 auto 16px;
    object-fit: contain;
}

.empty-state {
    display: grid;
    justify-items: start;
    gap: 12px;
    margin-block: 24px;
}

hr {
    height: 1px;
    border: 0;
    background: var(--line);
}

.row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.col-md-3,
.col-md-4,
.col-md-6,
.col-md-8,
.col-md-9,
.col-md-12 {
    min-width: 0;
}

.form-floating {
    position: relative;
    margin-bottom: 14px;
}

.form-floating > label {
    margin-top: 6px;
    color: var(--muted);
}

.btn-primary {
    background: #297a52;
}

.w-100 {
    width: 100%;
}

.nav-pills {
    display: flex;
    gap: 8px;
    padding: 0;
    margin: 0 0 18px;
    list-style: none;
    flex-wrap: wrap;
}

.nav-pills .nav-link {
    border-color: var(--line);
}

.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    border-color: rgba(126, 219, 168, .42);
    background: rgba(79, 195, 137, .14);
    color: #d8ffe8;
}

.validation-summary-errors,
.alert {
    margin: 16px 0;
    padding: 13px 14px;
    border-radius: 8px;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

.ui-lock {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(8, 10, 9, .72);
    backdrop-filter: blur(8px);
}

.ui-lock[hidden] {
    display: none;
}

.ui-lock-panel {
    display: grid;
    justify-items: center;
    gap: 10px;
    width: min(360px, 100%);
    padding: 22px;
    border: 1px solid rgba(126, 219, 168, .38);
    border-radius: 8px;
    background: #171b1a;
    box-shadow: var(--shadow);
    text-align: center;
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(126, 219, 168, .22);
    border-top-color: var(--accent-strong);
    border-radius: 50%;
    animation: spin .85s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 760px) {
    nav,
    .container,
    footer {
        padding-inline: 14px;
    }

    nav {
        align-items: flex-start;
        flex-direction: column;
        padding-block: 14px;
    }

    .nav-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .dashboard-metrics {
        justify-content: flex-start;
        width: 100%;
    }

    h1 {
        font-size: 1.72rem;
    }

    .page-header,
    .dashboard-header,
    .server-detail-header,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .server-identity {
        align-items: flex-start;
    }

    .tool-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .server-card {
        min-height: 180px;
    }

    .actions,
    .upload-form {
        align-items: stretch;
        flex-direction: column;
    }

    .actions > *,
    .upload-form > * {
        width: 100%;
    }

    .user-chip {
        max-width: 100%;
    }
}
