:root {
    color-scheme: dark;
    --bg: #0a0e0c;
    --surface: #101512;
    --surface-raised: #141b17;
    --border: #202b25;
    --text: #dce7e0;
    --text-muted: #7d9188;
    --accent: #5be8a3;
    --accent-soft: rgba(91, 232, 163, 0.1);
    --font-sans: -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--text);
    background: var(--surface-raised);
    padding: 0.1em 0.4em;
    border-radius: 4px;
}

.shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */

.sidebar {
    width: 220px;
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
}

.mark {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    padding: 0.4rem 0.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.mark__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    flex: none;
}

.mark__text {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--text);
}

.mark__text small {
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-size: 0.7rem;
}

.sidenav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidenav a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.55rem 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.sidenav a:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.sidenav a.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

.sidenav__hint {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
}

.sidebar__foot {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.sidebar__foot a {
    text-decoration: none;
    color: var(--text-muted);
}

.sidebar__foot a:hover {
    color: var(--accent);
}

/* Main */

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.topbar__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.status__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.content {
    padding: 2rem;
    max-width: 880px;
}

.lede {
    color: var(--text-muted);
    max-width: 60ch;
    line-height: 1.6;
    margin-top: 0;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
}

.card--accent {
    border-color: var(--accent);
    background: linear-gradient(180deg, var(--accent-soft), var(--surface) 60%);
}

.card h2 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

.card--accent h2 {
    color: var(--text);
}

.card__value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0 0 0.4rem;
}

.card__value--muted {
    color: var(--text-muted);
    font-size: 1rem;
}

.card__hint {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.card__action {
    display: inline-block;
    margin-top: 0.9rem;
    text-decoration: none;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
}

.card__action:hover {
    text-decoration: underline;
}

.endpoints > h2 {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.endpoint-group {
    margin-bottom: 1.25rem;
}

.endpoint-group h3 {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 0.4rem;
}

.endpoint-group dl {
    margin: 0;
}

.endpoint {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.endpoint dt {
    flex: none;
    width: 320px;
    display: flex;
    gap: 0.4rem;
}

.endpoint dt code:first-child {
    color: var(--accent);
}

.endpoint__link {
    text-decoration: none;
}

.endpoint__link code {
    color: var(--text);
}

.endpoint__link:hover code {
    color: var(--accent);
    text-decoration: underline;
}

.endpoint dd {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.error-panel {
    max-width: 420px;
    padding: 2rem 0;
}

.error-panel__dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff6b6b;
    box-shadow: 0 0 10px #ff6b6b;
    margin-bottom: 1rem;
}

.error-panel h2 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.error-panel p {
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0 0 1.25rem;
}

.sidebar__foot .logout-form {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar__user {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-button {
    font: inherit;
    font-size: 0.72rem;
    color: var(--text-muted);
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.55rem;
    cursor: pointer;
}

.logout-button:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

/* Login */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login {
    width: 100%;
    max-width: 340px;
    padding: 1rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
}

.login-card .mark {
    padding: 0 0 1.25rem;
    border-bottom: none;
    margin-bottom: 1.25rem;
}

.login-card__title {
    margin: 0 0 1.25rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.login-field input {
    font: inherit;
    color: var(--text);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.65rem;
}

.login-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-submit {
    width: 100%;
    font: inherit;
    font-weight: 600;
    color: var(--bg);
    background: var(--accent);
    border: none;
    border-radius: 6px;
    padding: 0.65rem;
    cursor: pointer;
    margin-top: 0.25rem;
}

.login-submit:hover {
    filter: brightness(1.05);
}

.login-error {
    color: #ff6b6b;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.login-error:empty {
    display: none;
}

@media (max-width: 640px) {
    .shell {
        flex-direction: column;
    }

    .sidebar {
        width: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .endpoint {
        flex-direction: column;
        gap: 0.2rem;
    }

    .endpoint dt {
        width: auto;
    }
}

/* Users and account */
.form-success {
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.85rem;
}

.field-error {
    color: #ff6b6b;
    font-size: 0.78rem;
}

.auth-switch {
    margin: 1rem 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

.auth-switch a {
    color: var(--accent);
}

.registration-card {
    width: min(520px, calc(100vw - 2rem));
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.profile-card,
.user-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
}

.profile-card h2 {
    margin-top: 0;
}

.profile-details {
    margin: 0;
}

.profile-details div {
    display: grid;
    grid-template-columns: 180px 1fr;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}

.profile-details dt,
.user-row__identity span {
    color: var(--text-muted);
}

.profile-details dd {
    margin: 0;
}

.user-list {
    display: grid;
    gap: 1rem;
}

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.user-row__identity {
    display: grid;
    gap: 0.25rem;
}

.roles-form {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.roles-form label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.secondary-button {
    font: inherit;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .user-row,
    .roles-form {
        align-items: stretch;
        flex-direction: column;
    }

    .profile-details div {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

.user-row--editable {
    align-items: stretch;
    flex-direction: column;
}

.admin-profile-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 0.75rem;
}

.admin-profile-form label {
    display: grid;
    gap: 0.3rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.admin-profile-form input {
    font: inherit;
    color: var(--text);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
}

.admin-profile-form .secondary-button {
    align-self: end;
}

.danger-button {
    font: inherit;
    color: #ff8f8f;
    background: rgba(255, 107, 107, 0.08);
    border: 1px solid rgba(255, 107, 107, 0.45);
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
}

.data-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.data-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.data-panel__head h2 {
    margin: 0;
    font-size: 1rem;
}

.data-panel__head span {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    font-size: 0.88rem;
}

.data-table th {
    color: var(--text-muted);
    background: var(--surface-raised);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.data-table td small,
.data-table td span {
    display: block;
}

.data-table td small {
    margin-top: 0.25rem;
    color: var(--text-muted);
}

.table-actions {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.table-actions form {
    margin: 0;
}

.empty-cell {
    color: var(--text-muted);
    text-align: center !important;
}

@media (max-width: 640px) {
    .admin-profile-form {
        grid-template-columns: 1fr;
    }
}
