/* Portaly appearance tokens are opt-in. Tenant pages and website previews keep
   each component's original fallback colours and their own site design. */
html[data-portal-theme="light"] { color-scheme: light; }
html[data-portal-theme="dark"] {
    color-scheme: dark;
    --portal-canvas: #121c17;
    --portal-surface: #1b2821;
    --portal-panel: #26382c;
    --portal-strong: #243c2c;
    --portal-text: #eef2e7;
    --portal-muted: #bdc9b5;
    --portal-subtle: #a9b99d;
    --portal-on-strong: #f3f6eb;
    --portal-accent-ink: #17211b;
    --portal-line: #4a604f;
    --portal-line-soft: #374d3e;
    --portal-danger: #ffb7a7;
    --portal-danger-surface: #472c27;
    --portal-warning: #f1cd83;
    --portal-warning-surface: #403622;
    --portal-link: #a7cdf8;
    --portal-link-surface: #26384b;
    --portal-logo-surface: #f6f5f0;
    background: var(--portal-canvas);
    color: var(--portal-text);
}
html[data-portal-theme="dark"] body { color: var(--portal-text); }
html[data-portal-theme="dark"] :is(input,textarea,select) { accent-color: #c7dc79; }
html[data-portal-theme="dark"] :focus-visible { outline-color: #b3cd75; }
html[data-portal-theme="dark"] * { scrollbar-color: #a6bc8c #1b2821; }
html[data-portal-appearance="true"]:has(.builder-shell) { --portal-appearance-bottom: 88px; }

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select:none;
}

html {background-color:var(--portal-canvas,#f6f5f0);
}

body {
    width: 100%;
    max-width: 1920px;
    margin-inline: auto;
}

h1:focus {outline:none;
}

/* Shared scrollbar styling for the page and nested scroll areas. */
* {
    scrollbar-width: thin;
    scrollbar-color: #17211b #ecefe5;
}

/* Use the richer styling where scrollbar pseudo-elements are supported. */
@supports selector(::-webkit-scrollbar) {
    * {
        scrollbar-width: auto;
        scrollbar-color: auto;
    }
}

::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {border:3px solid var(--portal-line,#f6f5f0);border-radius:999px;background:var(--portal-panel,#ecefe5);background-clip:padding-box;
    box-shadow: inset 0 0 0 1px #dce1d5;
}

::-webkit-scrollbar-thumb {
    min-height: 48px;
    min-width: 48px;border:3px solid var(--portal-line,#f6f5f0);border-radius:999px;background:linear-gradient(135deg, var(--portal-strong,#526058), var(--portal-strong,#17211b));background-clip:padding-box;
}

::-webkit-scrollbar-thumb:hover {background:#e2f06f;background-clip:padding-box;
}

::-webkit-scrollbar-thumb:active {background:var(--portal-panel,#b9c74d);background-clip:padding-box;
}

::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

::-webkit-scrollbar-corner {background:var(--portal-canvas,#f6f5f0);
}

@media (forced-colors: active) {
    * {
        scrollbar-width: auto;
        scrollbar-color: auto;
    }
}

.valid.modified:not([type=checkbox]) {outline:1px solid var(--portal-line,#26b050);
}

.invalid {outline:1px solid var(--portal-line,#e50000);
}

.validation-message {color:var(--portal-danger,#e50000);
}

.blazor-error-boundary {background:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MS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ding: 1rem 1rem 1rem 3.7rem;color:var(--portal-on-strong,white);
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {border-color:var(--portal-line,#929292);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {color:var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Keep wide records within a keyboard-accessible scroll panel. */
.admin-workspace .content .sheet { max-width: 100%; min-width: 0; overscroll-behavior-x: contain; }
.admin-workspace .content .sheet:focus-visible {outline:2px solid var(--portal-line,#849735);outline-offset:3px; }
.admin-workspace .content .table-hint { display: none; }
.admin-workspace .content .editor, .admin-workspace .content .members, .admin-workspace .content .group-list { min-width: 0; }
.admin-workspace .content .editor h2, .admin-workspace .content .editor p, .admin-workspace .content .notice { overflow-wrap: anywhere; }
.admin-workspace .content .editor-heading > div, .admin-workspace .content .member-heading > div { min-width: 0; }
.admin-workspace .content .editor-heading > a { flex-shrink: 0; white-space: nowrap; }
.admin-workspace .content input:not([type=checkbox]), .admin-workspace .content select, .admin-workspace .content textarea { min-width: 0; max-width: 100%; }
.admin-workspace .content input[type=checkbox] { flex-shrink: 0; }
.admin-workspace .content .pagination { flex-wrap: wrap; gap: 12px; }
@media (max-width: 820px) {
    .admin-workspace .content .table-hint { display: block; margin: 12px 0 8px; font-size: 12px;color:var(--portal-muted,#647068); }
    .admin-workspace .content button, .admin-workspace .content .create-link { min-height: 44px; }
    .admin-workspace .content input:not([type=checkbox]), .admin-workspace .content select, .admin-workspace .content textarea { font-size: 16px; }
    .admin-workspace .content .search > a, .admin-workspace .content .filters > a, .admin-workspace .content .pagination a, .admin-workspace .content .editor-heading > a, .admin-workspace .content td a { display: inline-flex; align-items: center; min-height: 44px; }
    .admin-workspace .content .check, .admin-workspace .content .permission { min-height: 44px; }
}
@media (max-width: 600px) {
    .admin-workspace .content .title-row { align-items: flex-start; flex-direction: column; }
    .admin-workspace .content .title-actions { flex-wrap: wrap; width: 100%; }
    .admin-workspace .content .create-link { white-space: nowrap; display: inline-flex; align-items: center; }
    .admin-workspace .content .editor-heading { flex-wrap: wrap; gap: 8px 16px; }
    .admin-workspace .content .editor-heading > div { flex: 1 1 180px; }
    .admin-workspace .content .search input, .admin-workspace .content .filters input { flex: 1 0 100%; width: 100%; min-width: 0; }
    .admin-workspace .content .filters select { width: 100%; min-width: 0; }
}

/* Mobile workspace: desktop rules remain unchanged. */
@media (max-width: 640px) {

html { scroll-padding-top: 76px; }
input:not([type=checkbox]):not([type=radio]):not([type=color]),select,textarea { font-size:16px; }
input,textarea,[contenteditable=true] { user-select:text; -webkit-user-select:text; }
button,a,input,select,textarea,summary { touch-action:manipulation; }
* { scrollbar-width:thin; }
dialog { max-width:calc(100vw - 24px); max-height:calc(100dvh - 24px); }
.admin-workspace .content .table-hint { display:none; }

}
