:root {
    color-scheme: dark;
    --canvas: #131313;
    --panel: #191919;
    --raised: #222222;
    --hover: #292929;
    --selected: #313131;
    --line: #303030;
    --control-line: #575757;
    --text: #dfdfdf;
    --bright: #f5f5f5;
    --muted: #aaa;
    --link: #74bdff;
    --primary: #1964a6;
    --primary-hover: #2475b9;
    --error: #ffaaaa;
    --error-bg: #352022;
    --radius: 5px;
    --bar-height: 3rem;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background: var(--canvas);
    color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: .875rem; line-height: 1.5; }
h1, h2, h3, h4, p, ul, dl, pre { margin: 0; }
h1, h2, h3, h4, strong, th { color: var(--bright); font-weight: 600; }
h1 { margin-bottom: 1.25rem; font-size: 1.6rem; line-height: 1.25; letter-spacing: -.035em; }
h2 { font-size: 1rem; }
h3, h4 { font-size: .95rem; }
p + p { margin-top: .65rem; }
a { color: var(--link); text-underline-offset: .18em; }
a:hover { color: #aad7ff; }
button, input, select, textarea { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
:focus-visible, .profiles-upload:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
h1:focus { outline: none; }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.icon { width: 1.2rem; height: 1.2rem; flex: none; fill: currentColor; }

.portal-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--bar-height);
    padding-inline: 1.25rem;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.wordmark {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    color: var(--bright);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.04em;
    text-decoration: none;
}
.wordmark:hover { color: white; }
.cube {
    display: inline-block;
    flex: none;
    width: 1.35rem;
    aspect-ratio: .866;
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    background: conic-gradient(from 60deg, #a99864 0 120deg, #d5c58e 120deg 240deg, #f8e8ac 240deg);
}
.portal-context { padding-left: 1rem; border-left: 1px solid var(--control-line); color: var(--muted); }
.portal-account { margin-left: auto; min-width: 0; display: flex; align-items: center; gap: .55rem; color: var(--muted); }
.account-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-account form { flex: none; margin-left: .35rem; }
.portal-account .btn { min-height: 1.8rem; padding: .18rem .55rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel { margin-top: 1rem; }
.panel-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    min-height: 3.25rem;
    padding: .85rem 1.25rem;
    background: var(--raised);
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
}
.panel-heading p, .field-note, .empty-row { color: var(--muted); }
.panel-heading p { margin-top: .35rem; }
.panel-body, .empty-row { padding: 1.1rem 1.25rem; }

.btn, .live-card button, ::file-selector-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 2rem;
    padding: .32rem .8rem;
    background: var(--raised);
    border: 1px solid var(--control-line);
    border-radius: var(--radius);
    color: var(--text);
    font: inherit;
    font-size: .8125rem;
    font-weight: 550;
    line-height: 1.35;
    cursor: pointer;
}
.btn:hover, .live-card button:hover, ::file-selector-button:hover { background: var(--selected); color: var(--bright); }
.btn-primary, .live-card button[value=apply] { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, .live-card button[value=apply]:hover { background: var(--primary-hover); color: #fff; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: default; }
[hidden] { display: none !important; }
.form-control, .form-select {
    width: 100%;
    min-width: 0;
    min-height: 2.1rem;
    padding: .35rem .6rem;
    background: var(--canvas);
    border: 1px solid var(--control-line);
    border-radius: var(--radius);
}
.form-control::placeholder, textarea::placeholder { color: var(--muted); }
.form-control:disabled, .form-select:disabled { opacity: .55; }
.alert { padding: .7rem .9rem; border: 1px solid; border-radius: var(--radius); margin: .8rem 0; overflow-wrap: anywhere; }
.alert-danger, .blazor-error-boundary { background: var(--error-bg); color: var(--error); border-color: #714144; }
.alert-warning { background: #312b1d; color: #ebd39c; border-color: #655633; }
.alert-success { background: #1b3024; color: #a5dbb7; border-color: #375a43; }
.validation-message, .text-danger { color: var(--error); }
.blazor-error-boundary::after { content: "An error has occurred."; }

.service-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.25rem;
    text-decoration: none;
}
.service-row + .service-row { border-top: 1px solid var(--line); }
.service-row:hover { background: var(--hover); }
.service-row strong { color: var(--link); }
.service-row small { display: block; margin-top: .2rem; color: var(--muted); font-size: .8125rem; }
.service-icon { display: grid; place-items: center; width: 2.35rem; height: 2.35rem; border-radius: var(--radius); }
.profiles-icon { background: #342f21; color: #e1ca83; }
.assistant-icon { background: #282739; color: #baaade; }
.access-icon { background: #213038; color: #95c5d9; }
.row-arrow { color: var(--muted); }

.profiles-toolbar, .invite-form { display: flex; flex-wrap: wrap; align-items: end; gap: .9rem; }
.profiles-toolbar { padding: 1.1rem 1.25rem; }
.profiles-field { flex: 1 1 8rem; min-width: 0; }
.profiles-user { flex-grow: 3; }
.profiles-field label, .invite-form label { font-size: .8125rem; font-weight: 550; }
.profiles-field label { display: block; margin-bottom: .3rem; }
.profiles-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.profiles-upload { position: relative; }
.profiles-json-editor {
    height: clamp(20rem, 62dvh, 61rem);
    overflow: hidden;
    background: #1e1e1e;
    border-radius: 0 0 var(--radius) var(--radius);
}

.invite-form label { width: min(100%, 20rem); }
.invite-form input { display: block; margin-top: .3rem; }
.field-note { margin-top: .65rem; font-size: .8125rem; }
.invites { list-style: none; padding: 0; }
.invites li { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; justify-content: space-between; padding: .75rem 1.25rem; }
.invites li + li { border-top: 1px solid var(--line); }
.invites li span { overflow-wrap: anywhere; }
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .8125rem; }
th, td { padding: .85rem 1rem; text-align: start; vertical-align: top; }
thead th { background: var(--raised); color: var(--text); font-size: .75rem; }
tbody tr { border-top: 1px solid var(--line); }
tbody tr:hover { background: var(--hover); }
.admin-action { margin-top: .4rem; }
.invites .admin-action { margin: 0; }
.btn-sm { min-height: 1.65rem; padding: .18rem .5rem; font-size: .75rem; white-space: nowrap; }
.status-chip { padding: .1rem .45rem; border-radius: 1rem; color: var(--text); background: var(--selected); font-size: .75rem; }
.active-status { color: #a5dbb7; background: #21372a; }

@media (max-width: 760px) {
    .portal-bar { padding-inline: 1rem; gap: .6rem; }
    .portal-context { display: none; }
    .portal-account { font-size: .75rem; }
    .portal-account .icon { display: none; }
    h1 { font-size: 1.4rem; }
    .panel-heading, .panel-body, .profiles-toolbar, .empty-row, .service-row { padding-inline: 1rem; }
}
