:root {
    color-scheme: dark;
    --bg: #1a1b1d;
    --panel: #1d1e20;
    --panel-2: #18191b;
    --line: #2d2e31;
    --line-soft: #252629;
    --text: #f6f8ff;
    --muted: #b9bbc2;
    --dim: #7d8088;
    --blue: #d7d9df;
    --cyan: #f6f8ff;
    --green: #30d39a;
    --yellow: #e3a008;
    --red: #ef4444;
    --purple: #56595f;
    --button-bg: #18191b;
    --button-grad: linear-gradient(135deg, #34363a, #56595f);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #1a1b1d 0%, #111214 100%);
    color: var(--text);
    font-family: Inter, Segoe UI, Arial, sans-serif;
}

.backend-topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 20;
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    padding: 0 20px;
    background: rgba(24, 25, 27, .92);
    backdrop-filter: blur(12px);
}

.backend-logo,
.top-actions,
.top-actions a {
    display: flex;
    align-items: center;
}

.backend-logo {
    gap: 10px;
    color: white;
    text-decoration: none;
    font-size: 17px;
}

.backend-logo img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.top-actions {
    gap: 10px;
}

.top-actions a {
    gap: 8px;
}

.top-actions a,
button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0 16px;
    background:
        linear-gradient(var(--button-bg), var(--button-bg)) padding-box,
        var(--button-grad) border-box;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: filter .18s ease, color .18s ease, transform .18s ease;
}

button:hover,
.top-actions a:hover,
.button-link:hover {
    color: white;
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.heroicon {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.backend-sidebar {
    position: fixed;
    top: 82px;
    bottom: 0;
    left: 0;
    width: 300px;
    overflow: auto;
    border-right: 1px solid var(--line);
    background: rgba(8, 10, 16, .72);
    backdrop-filter: blur(10px);
    padding: 34px 0 24px;
}

.backend-sidebar nav {
    display: grid;
    gap: 4px;
}

.backend-sidebar a {
    min-height: 38px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    color: #c6c7ce;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.backend-sidebar a:hover {
    border-left-color: var(--cyan);
    background: rgba(255, 255, 255, .06);
    color: white;
}

.backend-main {
    width: min(1180px, calc(100vw - 340px));
    margin-left: 300px;
    padding: 110px 24px 64px;
}

.breadcrumbs {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 14px;
}

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

h1 {
    margin-bottom: 16px;
    font-size: 44px;
    font-weight: 600;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 8px;
    font-size: 28px;
    font-weight: 600;
}

p,
small,
span {
    color: var(--muted);
}

.doc-hero {
    padding-bottom: 28px;
    animation: fade-up .28s ease both;
}

.doc-hero p {
    max-width: 760px;
    font-size: 18px;
    line-height: 1.55;
}

.hero-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.hero-cards a {
    min-height: 96px;
    display: flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 24px;
    background: linear-gradient(135deg, #202123, #18191b);
    color: white;
    font-size: 22px;
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease;
}

.hero-cards a:hover {
    transform: translateY(-2px);
    outline: 1px solid rgba(246, 248, 255, .24);
}

.doc-section {
    margin: 28px 0 42px;
    animation: fade-up .34s ease both;
}

.section-heading {
    margin-bottom: 16px;
}

.section-heading p {
    max-width: 820px;
    line-height: 1.55;
}

.doc-card,
.profile-panel,
.api-token-card,
.release-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}

.doc-card,
.api-token-card {
    padding: 18px;
}

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

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

.span-2 {
    grid-column: span 2;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 650;
}

input,
textarea,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    background: #0d111a;
    color: var(--text);
    outline: none;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(246, 248, 255, .10);
}

.primary {
    border-color: transparent;
    background:
        linear-gradient(var(--button-bg), var(--button-bg)) padding-box,
        var(--button-grad) border-box;
    color: white;
}

.danger {
    border-color: rgba(239, 68, 68, .45);
    color: #ffb4b4;
}

.alert {
    border: 1px solid rgba(227, 160, 8, .35);
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: rgba(227, 160, 8, .08);
}

.api-token-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

code,
pre {
    border-radius: 10px;
    background: #0d111a;
    color: #d4e7ff;
    font-family: JetBrains Mono, Consolas, monospace;
}

code {
    overflow: hidden;
    padding: 4px 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.endpoint-card {
    display: grid;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    background: #101520;
    color: var(--text);
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease;
}

.endpoint-card:hover {
    transform: translateY(-2px);
    border-color: rgba(246, 248, 255, .24);
}

.endpoint-card span {
    width: fit-content;
    border-radius: 999px;
    padding: 3px 9px;
    color: white;
    font-size: 12px;
    font-weight: 900;
}

.endpoint-card.get span { background: var(--green); }
.endpoint-card.post span { background: var(--blue); }
.endpoint-card.put span { background: var(--yellow); }
.endpoint-card.delete span { background: var(--red); }

.profile-list {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.profile-panel {
    overflow: hidden;
}

.profile-panel summary,
.file-manager summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    min-height: 58px;
    padding: 0 16px;
    cursor: pointer;
}

.profile-panel summary span,
.file-manager summary {
    color: white;
    font-weight: 800;
}

mark {
    border-radius: 999px;
    padding: 4px 9px;
    background: rgba(246, 248, 255, .10);
    color: #f6f8ff;
}

.profile-panel form,
.file-manager form {
    border-top: 1px solid var(--line-soft);
    padding: 16px;
}

.profile-icon-form {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.profile-icon-form img {
    width: 52px;
    height: 52px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    object-fit: cover;
}

.profile-icon-placeholder {
    width: 52px;
    height: 52px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}

.danger-row {
    display: flex;
    justify-content: flex-end;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.check-line input {
    width: auto;
    min-height: auto;
}

.file-manager {
    margin-bottom: 14px;
}

.file-table {
    display: grid;
    gap: 8px;
    padding: 0 16px 16px;
}

.file-row,
.release-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(160px, .5fr) auto;
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    padding: 10px;
    background: #0d111a;
}

.file-row span,
.release-card strong {
    color: white;
}

.release-layout {
    display: grid;
    gap: 16px;
}

.release-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 14px;
    align-items: end;
}

.build-log {
    min-height: 210px;
    max-height: 340px;
    overflow: auto;
    margin: 0;
    padding: 14px;
    white-space: pre-wrap;
}

.release-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.release-card {
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.release-card div {
    display: grid;
    gap: 5px;
}

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

.metric-card {
    display: grid;
    gap: 8px;
}

.metric-card strong {
    color: white;
    font-size: 34px;
    font-weight: 700;
}

.inline-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    border-top: 1px solid var(--line-soft);
    padding: 16px;
}

.file-picker {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: rgba(255, 255, 255, .025);
}

.file-picker span {
    color: var(--muted);
    min-width: 220px;
}

.eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--dim);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.muted-empty {
    display: grid;
    gap: 12px;
}

.muted-empty strong {
    color: white;
    font-size: 20px;
}

.muted-empty .button-link {
    width: fit-content;
}

.sftp-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.sftp-sidebar,
.sftp-main {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(16, 21, 32, .76);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .24);
}

.sftp-sidebar {
    position: sticky;
    top: 102px;
    display: grid;
    gap: 10px;
    padding: 14px;
}

.sftp-sidebar-title,
.sftp-profile,
.sftp-toolbar,
.sftp-actions,
.sftp-row {
    display: grid;
    align-items: center;
}

.sftp-sidebar-title {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 6px 6px 10px;
}

.sftp-sidebar-title span {
    color: var(--muted);
    font-weight: 700;
}

.sftp-sidebar-title strong {
    color: white;
}

.sftp-profile {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    border: 1px solid transparent;
    border-radius: 16px;
    padding: 10px;
    color: var(--text);
    text-decoration: none;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.sftp-profile:hover,
.sftp-profile.active {
    border-color: rgba(246, 248, 255, .24);
    background:
        linear-gradient(rgba(16, 21, 32, .88), rgba(16, 21, 32, .88)) padding-box,
        var(--button-grad) border-box;
    transform: translateY(-1px);
}

.sftp-profile-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 14px;
    background: #0d111a;
    color: #f6f8ff;
}

.sftp-profile strong,
.sftp-name a,
.sftp-name > span:last-child {
    color: white;
    font-weight: 800;
}

.sftp-profile small {
    display: block;
    margin-top: 3px;
}

.sftp-profile em {
    min-width: 30px;
    border-radius: 999px;
    padding: 4px 8px;
    background: rgba(246, 248, 255, .10);
    color: #f6f8ff;
    font-style: normal;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.sftp-main {
    min-width: 0;
    overflow: hidden;
}

.sftp-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--line-soft);
}

.sftp-toolbar h2 {
    margin-bottom: 10px;
}

.sftp-toolbar code {
    display: inline-block;
    max-width: 100%;
}

.sftp-toolbar-actions,
.sftp-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.sftp-toolbar-actions form,
.sftp-delete {
    margin: 0;
}

.sftp-pathbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line-soft);
    padding: 12px 20px;
    background: rgba(13, 17, 26, .58);
}

.sftp-pathbar a {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    padding: 0 11px;
    color: #d4e7ff;
    text-decoration: none;
}

.sftp-pathbar a:hover {
    border-color: rgba(246, 248, 255, .24);
    color: white;
}

.sftp-actions {
    align-items: stretch;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.sftp-upload,
.sftp-create {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.sftp-upload > span {
    max-width: 280px;
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sftp-create label {
    min-width: 210px;
}

.sftp-create label span {
    color: var(--dim);
    font-size: 12px;
}

.sftp-create input {
    min-height: 38px;
    padding: 8px 12px;
}

.sftp-table {
    display: grid;
    padding: 12px;
}

.sftp-preserve-panel {
    display: grid;
    gap: 14px;
    border-bottom: 1px solid var(--line-soft);
    padding: 18px 20px;
    background: #111317;
}

.sftp-preserve-heading {
    display: grid;
    gap: 4px;
}

.sftp-preserve-heading strong {
    color: var(--text);
}

.sftp-preserve-heading span {
    color: var(--muted);
    font-size: 13px;
}

.sftp-preserve-add {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 10px;
}

.sftp-preserve-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sftp-preserve-list form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 6px 5px 10px;
    background: var(--panel-2);
}

.sftp-preserve-list code {
    background: transparent;
    padding: 0;
}

.sftp-preserve-list button {
    width: 28px;
    min-height: 28px;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--red);
    font-size: 20px;
}

.sftp-row {
    grid-template-columns: minmax(230px, 1.35fr) 100px 105px 138px minmax(190px, auto);
    gap: 12px;
    min-height: 54px;
    border-radius: 14px;
    padding: 8px 10px;
    text-decoration: none;
}

.sftp-row:not(.sftp-head):hover {
    background: rgba(255, 255, 255, .05);
}

.sftp-head {
    min-height: 38px;
    color: var(--dim);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

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

.sftp-name a,
.sftp-name > span:last-child {
    overflow: hidden;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sftp-icon {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 12px;
    background: #0d111a;
    color: #f6f8ff;
}

.sftp-badge {
    width: fit-content;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 800;
}

.sftp-badge.managed {
    background: rgba(48, 211, 154, .12);
    color: #8ef0c8;
}

.sftp-badge.local {
    background: rgba(227, 160, 8, .12);
    color: #ffd88b;
}

.sftp-badge.preserved {
    background: rgba(86, 89, 95, .24);
    color: #ffffff;
}

.sftp-row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
}

.sftp-row-actions form {
    margin: 0;
}

.sftp-row-actions button {
    min-height: 32px;
    padding: 0 10px;
}

.sftp-delete {
    justify-self: end;
}

.sftp-delete button {
    min-height: 32px;
    padding: 0 12px;
}

.sftp-up-row {
    color: var(--muted);
}

.sftp-empty {
    display: grid;
    gap: 8px;
    margin: 8px;
    border: 1px dashed var(--line);
    border-radius: 16px;
    padding: 24px;
    background: rgba(255, 255, 255, .025);
}

.sftp-empty strong {
    color: white;
    font-size: 18px;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, #1a1b1d 0%, #111214 100%);
}

.auth-shell {
    width: min(520px, calc(100vw - 32px));
}

.auth-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 28px;
    background: var(--panel);
}

.auth-logo {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 24px;
}

.auth-logo img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.wide {
    width: 100%;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .backend-sidebar {
        position: static;
        width: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding-top: 90px;
    }

    .backend-main {
        width: auto;
        margin-left: 0;
        padding-top: 28px;
    }

    .hero-cards,
    .endpoint-grid,
    .form-grid,
    .doc-grid,
    .release-form,
    .file-row,
    .release-card,
    .sftp-shell,
    .sftp-toolbar {
        grid-template-columns: 1fr;
    }

    .sftp-sidebar {
        position: static;
    }

    .sftp-toolbar-actions,
    .sftp-actions {
        justify-content: flex-start;
    }

    .sftp-row,
    .sftp-head {
        grid-template-columns: minmax(0, 1fr);
    }

    .sftp-preserve-add {
        grid-template-columns: 1fr;
    }

    .sftp-row-actions {
        justify-content: flex-start;
    }

    .sftp-head {
        display: none;
    }

    .sftp-delete {
        justify-self: start;
    }

    .span-2 {
        grid-column: span 1;
    }
}
