:root {
    /*color-scheme: light dark;*/
    /* slate (canonical neutral) */
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;

    /* blue (brand accent + focus) */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-brand-1: #009fd9;
    --blue-brand-2: #0069b1;
    --blue-brand-mid: #2374ab;
    --blue-dark: #231651;

    /* status / badge primitives (kept from prior palette) */
    --red-bg: #fee2e2;
    --red-fg: #b91c1c;
    --orange-bg: #fee5b4;
    --orange-fg: #b45309;
    --green-bg: #dcfce7;
    --green-fg: #15803d;
    --blue-bg: var(--blue-100);
    --blue-fg: var(--blue-800);
    --purple-bg: #e9d5ff;
    --purple-fg: #7c3aed;
    --gold-bg: #fef3c7;
    --gold-fg: #92400e;
    --grey-bg: var(--slate-100);
    --grey-fg: var(--slate-700);

    --logo-bar-1: #56d1d1;
    --logo-bar-2: #004aad;

    /* brand (tenant-overridable seam) */
    --brand-primary: var(--blue-600);
    --brand-primary-strong: var(--blue-700);
    --brand-accent: var(--blue-brand-1);

    /* surfaces */
    --surface-page: #fafafa;
    --surface-card: #fff;
    --surface-muted: var(--slate-50);
    --surface-header: var(--slate-100);
    --surface-icon-accent: var(--blue-50);
    --surface-dark: #171e26;

    /* borders */
    --border-subtle: var(--slate-200);
    --border-default: var(--slate-300);
    --border-input: var(--slate-300);
    --border-strong: var(--slate-400);
    --border-table-header: var(--slate-300);

    /* text */
    --text-strong: var(--slate-900);
    --text-default: var(--slate-700);
    --text-muted: var(--slate-500);
    --text-label: var(--slate-500);
    --text-on-dark: var(--surface-card);

    /* focus */
    --focus-ring: rgb(37 99 235 / 0.15);
    --focus-border: var(--brand-primary);

    /* elevation */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-inset-thin: inset 0 -1px 0 rgb(0 0 0 / 0.1);
    --shadow-modal: 0 10px 30px rgb(0 0 0 / 0.2);
    --shadow-popover: 0 0 10px rgb(0 0 0 / 0.4);
    --overlay-backdrop: rgb(0 0 0 / 0.35);

    /* overlays on dark surfaces (header, etc.) */
    --on-dark-border-subtle: rgb(255 255 255 / 0.1);
    --on-dark-border: rgb(255 255 255 / 0.2);
    --on-dark-surface: rgb(255 255 255 / 0.1);
    --on-dark-placeholder: rgb(255 255 255 / 0.5);

    /* misc */
    --search-icon: #9ca3af;
    --uploader-border: #666;
    --uploader-bg: #eee;
    

    --light: var(--surface-page);
    --primary: var(--surface-card);
    --primary-bg: var(--surface-dark);
    --ternary: var(--blue-brand-mid);
    --dark: var(--blue-dark);
    --gray: grey;
    --lightgray: var(--slate-300);
    --ultralightgray: var(--slate-100);

    --header-bg: var(--primary-bg);
    --main-menu-fg: var(--lightgray);
    --main-menu-bg: var(--primary-bg);
    --main-menu-selected-fg: var(--primary);
    --main-menu-hover-underline: var(--primary);
    --main-menu-selected-underline: var(--ternary);
    --sub-menu-fg: var(--slate-600);
    --sub-menu-bg: #e8eaed;
    --sub-menu-selected-fg: var(--dark);
    --sub-menu-hover-underline: var(--primary);
    --sub-menu-selected-underline: var(--primary);
    --action-bar-bg: var(--primary);
    --button-fg: var(--slate-700);
    --button-bg: var(--light);
    --button-border: var(--lightgray);
    --button-hover-bg: var(--ultralightgray);
    --button-primary-bg1: var(--blue-brand-1);
    --button-primary-bg2: var(--blue-brand-2);
    --button-secondary-fg: var(--slate-700);
    --button-secondary-border: var(--border-input);
    --search-input-focus: var(--lightgray);
    --search-input-top-bar-focus: var(--blue-brand-1);
    --inactive: var(--gray);

    /* spacing / radii kept here */
    --button-block-padding: .5rem;
    --button-inline-padding: .75rem;
    --button-border-radius: .5rem;
    --button-sm-block-padding: .125rem;
    --button-sm-inline-padding: .25rem;
    --badge-block-padding: .25rem;
    --badge-inline-padding: .75rem;
    --notification-badge: var(--red-fg);

    --table-content-min-height: 16rem;
}

*,
*:before,
*:after {
    box-sizing: border-box;
}

html {
    font-family: "Nunito", sans-serif;
    font-size: 18px;
    font-weight: 400;
    font-optical-sizing: auto;
    font-style: normal;
    line-height: 1.15;
    background-color: var(--light);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: var(--light);
    box-sizing: border-box;
}

input, type-ahead-wc::part(input), type-ahead-wc-2::part(input) {
    font-family: "Nunito", sans-serif;
}

a {
    text-decoration: none;
    color: var(--ternary);
    cursor: pointer;
}

body {
    margin: 0;
    line-height: 1;
    text-align: left;
}

html, body {
    @media (width < 600px) {
        overflow-x: hidden;
    }
}

header {
    display: flex;
    flex-flow: column nowrap;
    justify-content: space-between;
    padding-block-start: 15px;
    color: var(--primary);
    background-color: var(--header-bg);
}

footer {
    display: block;
    padding: 1rem;
    font-size: .8rem;
}

.sticky-header {
    padding: 0;
    margin: 0;
    position: sticky;
    top: 0;
    z-index: 9999;
}

svg {
    height: 24px;
    width: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- LAYOUTS --- */

.wrapper {
    /*max-inline-size: 1100px;*/
    margin-inline: auto;
    padding-inline: 21px;
    text-align: center;
}

.menu-container {
    position: relative;
    display: inline-block;
}


/* --- NAV AND MENUS --- */

.top-bar {
    display: flex;
    padding-inline: 15px;
    padding-block-start: 15px;
    padding-block-end: 10px;
    flex-flow: row wrap;
    justify-content: space-between;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--on-dark-border-subtle);
    .top-button-bar {
        display: flex;
        align-items: center;
        gap: .25rem;
        .search-wrapper {
            input[type="search"] {
                color: var(--text-on-dark);
                background-color: var(--on-dark-surface);
                border: 1px solid var(--on-dark-border);
                &::placeholder { color: var(--on-dark-placeholder); }
                &:focus { box-shadow: 0 0 0 2px var(--search-input-top-bar-focus); }
            }
        }
    }
}

.nav { 
    display: flex;
    flex-flow: row wrap;
    row-gap: .5rem;
    column-gap: .25rem;
    align-items: baseline; 
    font-size: .9rem;
    a {
        svg {
            height: .9rem;
            width: .9rem;
        }
        padding: .2rem;
        cursor: pointer;
        text-wrap: nowrap;
        border-bottom: .15rem solid transparent;
        transition: border-color ease-in-out 0.5s;
        &:hover, &:focus-visible {
            border-color: var(--lightgray);
        }
        &.selected {
            border-color: var(--ternary);
        }
        &.inactive {
            border-color: transparent;
            cursor: not-allowed;
            text-decoration: none;
            &:hover, &:focus-visible {
                text-decoration: none;
            }
        }
    }
}

.main-menu {
    color: var(--primary);
    background-color: var(--header-bg);
    padding-inline: 15px;
    padding-block: 5px;
    a { 
        color: var(--main-menu-fg);
        &:hover, &:focus-visible {
            color: var(--main-menu-selected-fg);
        } 
        &.selected { 
            color: var(--main-menu-selected-fg);
            border-color: var(--ternary);
        }
        &.inactive { color: var(--inactive); }
    }
}

.sub-menu {
    color: var(--sub-menu-fg);
    background: var(--sub-menu-bg);
    padding-inline: 15px;
    padding-block-start: 10px;
    padding-block-end: 5px;
    a { 
        color: var(--sub-menu-fg);
        &:hover, &:focus-visible {
            color: var(--sub-menu-selected-fg);
            border-color: var(--sub-menu-selected-fg);
        }
        &.selected {
            color: var(--sub-menu-selected-fg);
            border-color: var(--ternary);
        }
        &.inactive { color: var(--inactive); }
    }
}


/* --- TAG CLASSES --- */

.visibility-hidden { visibility: hidden; }
.display-none { display: none; }
.block-display-card {
    /*transition: all 0.25s;*/
    /*transition-behavior: allow-discrete;*/
}
.text-align-center { text-align: center; }
.text-align-right { text-align: right; }
.padding-block-025 { padding-block: .25rem; }


/* --- BUTTONS AND BUTTON BARS --- */

button {
    font-family: Nunito, sans-serif;
    font-size: .85rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    list-style: none;
    white-space: nowrap;
    color: var(--button-fg);
    background-color: var(--button-bg);
    border: 1px solid var(--button-border);
    border-radius: var(--button-border-radius);
    padding: var(--button-block-padding) var(--button-inline-padding);
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
    &:hover, &:focus-visible  {
        background-color: var(--button-hover-bg);
        border-color: var(--button-border);
    }
}

.link-button {
    font-size: .85rem;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: var(--button-fg);
    background-color: var(--button-bg);
    border: 1px solid var(--button-border);
    border-radius: var(--button-border-radius);
    padding: var(--button-block-padding) var(--button-inline-padding);
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
    text-decoration: none;
    &:hover, &:focus-visible {
        background-color: var(--button-hover-bg);
        text-decoration: none;
    }
}

.link-utility {
    font-size: .85rem;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--button-block-padding) var(--button-inline-padding);
    transition: all ease-in-out 0.8s;
    text-decoration: underline;
    text-underline-offset: .15rem;
    &:hover, &:focus-visible {
        filter: brightness(50%);
    }
}

.btn-primary {
    background: linear-gradient(to top left, var(--button-primary-bg1), var(--button-primary-bg2));
    color: var(--primary);
    border: none;
    transition: filter .15s ease;
    &:hover, &:focus-visible {
        background: linear-gradient(to top left, var(--button-primary-bg1), var(--button-primary-bg2));
        filter: brightness(110%);
    }
}

.ico-button {
    svg {
        height: 24px;
        width: 24px;
    }
}

.ico-button-small {
    cursor: pointer;
    svg {
        height: 12px;
        width: 12px;
    }
}

.ico-button-disabled {
    cursor: default;
    pointer-events: none;
    svg {
        stroke: var(--lightgray);
    }
}

.small-button {
    cursor: pointer;
    font-size: .3rem;
    border: 0;
}

.x-button {
    position: absolute;
    top: -10px;
    right: -10px;
    border: 1px solid var(--gray) !important;
    border-radius: 50%;
}

.disabled-button {
    outline: none;
    user-select: none;
    pointer-events: none;
    color: var(--lightgray) !important;
    background: transparent none !important;
    border: 1px solid var(--lightgray) !important;
    cursor: not-allowed;
}

.inactive-button {
    outline: none;
    user-select: none;
    pointer-events: none;
    cursor: not-allowed;
}

.inactive-link {
    outline: none;
    user-select: none;
    color: var(--inactive);
    cursor: not-allowed;
    text-decoration: none;
}

.action-bar {
    background-color: var(--action-bar-bg);
    margin: 0;
    margin-block-start: .5rem;
    padding: 0;
    padding-inline: .5rem;
    border-radius: .5rem;
    box-shadow: var(--shadow-sm);
    h3 { margin: 0; }
}

.button-bar {
    display: flex;
    flex-flow: row wrap;
    justify-content: flex-start;
    align-items: center;
    gap: .5rem;
    padding-block: .25rem;
    &.flex-end { justify-content: flex-end; }
    &.space-between { justify-content: space-between; }
    &.center { justify-content: center; }
    &.small-buttons {
        button {
            font-size: .65rem;
            border-radius: .25rem;
            padding: .125rem .25rem;
            svg {
                height: 16px;
                width: 16px;
            }
        }
    }
}

.sticky-button-bar {
    position: sticky;
    top: 8.75rem;
    z-index: 9999;
    background-color: var(--light);
    @media (width < 600px) {
        top: 6.7rem;
    }
}


/* --- LOGO --- */

.logo {
    font-family: Montserrat, sans-serif;
    font-size: 1.8rem;
    color: var(--primary);
    display: grid;
    grid-template-columns: 4ch 7ch;
    grid-template-rows: 1fr 0fr;
    grid-column-gap: .1rem;
    grid-row-gap: .2rem;
    padding-right: .5rem;
    user-select: none;
    strong { font-weight: 700; }
    .logo-bar {
        display: inline-block;
        height: .1rem;
        background-image: linear-gradient(to right, var(--logo-bar-1), var(--logo-bar-2) 60%);
        filter: blur(.3px);
    }
}


/* --- SEARCH BAR --- */


.search-wrapper {
    position: relative;
    svg {
        position: absolute;
        left: .75rem;
        top: 50%;
        transform: translateY(-50%);
        width: 1rem;
        height: 1rem;
        color: var(--search-icon);
    }
    input[type="search"] {
        border-radius: .5rem;
        padding: .5rem 1rem .5rem 2.5rem;
        width: 16rem;
        border: 1px solid var(--gray);
        &::placeholder { color: var(--gray); }
        color: var(--gray);
        &:focus {
            outline: none;
            box-shadow: 0 0 0 2px var(--search-input-focus);
        }
    }
}

.app-search-result {
    padding-block-start: .5rem;
    p {
        padding: .25rem .5rem;
        text-align: left;    
    }
}

/* --- FORMS --- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-gap: 1rem;
    align-items: start;
    @media (width < 900px) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    @media (width < 600px) {
        grid-template-columns: 1fr;
    }
}

.details-form-action-bar {
    background-color: var(--action-bar-bg);
    margin: 0;
    padding-inline: 1rem;
    border-radius: .5rem;
    box-shadow: var(--shadow-sm);
    h3 { margin: 0; }
}

.details-form {
    label { display: block; padding-bottom: .25rem; font-size: .8rem; font-weight: bold; white-space: nowrap; }
    input, type-ahead-wc::part(input) { width: 100%; padding: .25rem; }
    type-ahead-wc-2::part(input) { width: 100%; padding: .25rem; }
    type-ahead-wc::part(list), type-ahead-wc-2::part(list) {
        font-size: .8rem;
        margin-block-start: .25rem;
        padding-block: .15rem;
        padding-inline: .25rem;
        border: 1px solid var(--gray); border-radius: .5rem; 
    }
    select { width: 100%; padding: .25rem; -webkit-appearance: none; }
    input[type=checkbox] { width: auto; padding: .25rem; }
    textarea { width: 100%; height: 4rem; padding: .25rem; }
    .table-container { padding-top: 1rem; }
    details { 
        width: 100%;
        background-color: var(--primary);
        margin-block: 1rem;
        padding-inline: 1rem;
        padding-block: .5rem;
        border-radius: .5rem;
        box-shadow: var(--shadow-sm);
        summary {
            cursor: pointer;
            text-align: start;
            padding-block-start: 1.5rem;
            padding-block-end: 1rem;
            margin-block-end: .2rem;
        }
        section {
            border-top: 1px dotted var(--lightgray);
            padding-block: 1rem;
        }
        &::details-content {
            display: block;
            block-size: 0;
            overflow: hidden;
            transition-property: block-size, content-visibility;
            transition-duration: 0.3s;
            transition-behavior: allow-discrete;
        }
        &[open]::details-content {
            block-size: auto; /* fallback */
            block-size: calc-size(auto, size);
        }
    }

}

.form-general-error { font-size: 0.8rem; }

.form-field {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    label {
        font-size: .8rem;
        color: var(--slate-700);
        display: block;
    }
    span {
        padding-block: .25rem;
        padding-inline-start: .3rem;
        text-align: left;
    }
    .textarea { text-align: left; }
    input, select, textarea, type-ahead-wc::part(input), type-ahead-wc-2::part(input) {
        background-color: var(--surface-card);
        border: 1px solid var(--border-input);
        border-radius: .5rem;
        width: 100%;
        padding: .3rem .5rem;
    }
    input[type=checkbox] { width: auto; padding: .25rem; }
    input:focus, select:focus, textarea:focus {
        outline: none;
        box-shadow: 0 0 0 2px var(--blue-brand-1);
    }
    &.required {
        label::after { content: "*"; color: var(--red-fg); }
    }
    textarea { resize: none; }
    .form-field-error {
        padding-top: .1rem;
        font-size: .6rem;
        font-weight: bold;
        color: var(--red-fg);
    }
}

.form-field .phone-input {
    display: flex;
    gap: .4rem;
    width: 100%;
    .phone-country {
        flex: 0 0 6.5rem;
        width: auto;
        min-width: 0;
        text-overflow: ellipsis;
    }
    .phone-national {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }
}

.two-inputs {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: .5rem;
}

.range-bound-label {
    text-transform: uppercase;
    font-size: .65rem;
    letter-spacing: .03em;
    opacity: .7;
}

.error { color: var(--red-fg); }

.error-message-2 {
    padding: .5rem;
    color: var(--red-fg);
}

.error-message {
    padding: .5rem;
    background-color: var(--red-bg); color: var(--red-fg); 
    border: 1px solid var(--red-fg);
    border-radius: .5rem;
}

.info-message {
    padding: .5rem;
    background-color: var(--green-bg); color: var(--green-fg);
    border: 1px solid var(--green-fg);
    border-radius: .5rem;
}




.label-with-link {
    display: flex;
    justify-content: space-between;
    a {
        font-size: .5rem;
        margin-left: .25rem;    
    }
}

.multiselect-list { 
    padding: .5rem; 
    margin: 0;
    li { 
        list-style-type: circle; 
        text-align: left; 
    }
}

.multiselect-taglist {
    display: inline;
    list-style: none;
    margin: 0;
    padding-left: 0;
    padding-top: .25rem;
    li { display: inline; }
    li:after { content: ", "; }
    li:last-child:after { content: ""; }
}

.toggle-3 {
    border: 1px solid var(--lightgray);
    border-radius: .5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .25rem;
    max-width: max-content;
    input[type="radio"] {
        display: none;
        cursor: pointer;
        & + label {
            cursor: pointer;
            font-weight: unset;
            padding: .2rem;
            transition: all 0.3s ease;
            color: var(--ultralightgray);
        }
        .true&:is(:checked) + label {
            background-color: var(--green-bg);
            color: var(--green-fg);
        }
        .null&:is(:checked) + label {
            background-color: var(--grey-bg);
            color: var(--grey-fg);
        }
        .false&:is(:checked) + label {
            background-color: var(--red-bg);
            color: var(--red-fg);
        }
    }
    .false + label {
        border-top-left-radius: .25rem;
        border-bottom-left-radius: .25rem;
    }
    .true + label {
        border-top-right-radius: .25rem;
        border-bottom-right-radius: .25rem;
    }
}

.toggle-3.toggle-3-readonly {
    opacity: .7;
    background-color: var(--light);
    pointer-events: none;
    cursor: not-allowed;
}
.toggle-3.toggle-3-readonly input[type="radio"]:checked + label {
    background-color: var(--grey-bg);
    color: var(--grey-fg);
}

/* --- FILE UPLOAD --- */

.upload-form {
    /*display: flex;*/
    /*flex-direction: column;*/
    /*align-items: center;*/
}

input[type=file] { display: none; }

.uploader {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    border: 1px dashed var(--uploader-border);
    border-radius: .5rem;
    padding-inline: 1rem;
    padding-block: 3rem;
    cursor: pointer;
    background-color: var(--uploader-bg);
    text-align: center;
    p {
        max-width: 45ch;    
    }
    &:hover, &:focus-visible {
        filter: brightness(110%);
    }
}


/* --- TABLES --- */

.paging-bar {
    align-items: center;
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    font-size: .7rem;
    padding-block-end: .2rem;
}

.paging-bar #paging-position { white-space: nowrap; }

.segmented {
    display: flex;
    background: var(--surface-header);
    border: 1px solid var(--border-input);
    border-radius: .375rem;
    padding: .05rem;
    gap: .15rem;
    width: 100%;
    min-height: 2.25rem;
    box-sizing: border-box;
}
.segmented input { display: none; }
.segmented label {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .55rem .75rem;
    border-radius: .25rem;
    font-size: .8rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}
.form-field > .segmented {
    flex: 1;
    align-items: stretch;
}
.segmented input:checked + label {
    background: var(--brand-primary);
    color: var(--text-on-dark);
}
.segmented-readonly { font-weight: 600; }

.paging-size-select {
    font-size: .75rem;
    line-height: 1;
    padding: .3rem .35rem;
    border: 1px solid var(--button-border);
    border-radius: var(--button-border-radius);
    background: var(--button-bg);
    color: var(--button-fg);
    cursor: pointer;
    font-family: inherit;
}

.table-container {
    border-radius: .5rem;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

/* --- PHONE-NUMBERS REGISTRY (sticky-table shell prototype) --- */

.registry-page .table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .35rem .25rem;
    font-size: .8rem;
    color: var(--text-default);
}
.registry-page .sticky-bottom-bar.table-toolbar { padding: .25rem .5rem; font-size: .7rem; }
.registry-page .sticky-bottom-bar.table-toolbar .paging-bar { font-size: inherit; }
.registry-page .table-toolbar-right { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.registry-page .paging-total-label,
.registry-page .paging-displayed-label { white-space: nowrap; }
@media (width < 600px) {
    .registry-page .paging-total-label,
    .registry-page .paging-displayed-label { display: none; }
}
.registry-page .table-wrap {
    width: max-content;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.registry-page .table-wrap > .table-container { flex: 1 1 auto; min-height: 0; }
.registry-page .sticky-bottom-bar {
    background: var(--surface-card);
    padding: .25rem .5rem;
    border-top: 1px solid var(--border-default);
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    z-index: 6;
}
@media (width >= 600px) {
    body:has(.registry-page) > footer { display: none; }
    .registry-page {
        height: calc(100vh - 8.75rem);
        display: flex;
        flex-direction: column;
    }
    .registry-page .table-wrap > form {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .registry-page .table-wrap { flex: 1 1 auto; min-height: 0; }
    .registry-page .table-container {
        overflow: auto;
        min-height: var(--table-content-min-height);
        border-top-left-radius: .5rem;
        border-top-right-radius: .5rem;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
    .registry-page .table-wrap { flex: 1 1 auto; min-height: 0; }
    .registry-page .table thead { position: static; }
    .registry-page .table thead th {
        position: sticky !important;
        top: -1px !important;
        z-index: 5;
        box-shadow: var(--shadow-inset-thin);
    }
    .registry-page .table thead th.sticky { left: -1px !important; z-index: 7; }
    .registry-page .table tbody td.sticky { position: sticky; left: -1px; z-index: 4; }
    .registry-page .table-wrap .table {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
}
@media (width < 600px) {
    html:has(.registry-page), body:has(.registry-page) {
        height: 100dvh;
        overflow: hidden;
    }
    body:has(.registry-page) { display: flex; flex-direction: column; }
    body:has(.registry-page) > header { flex: 0 0 auto; }
    body:has(.registry-page) > footer { display: none; }
    body:has(.registry-page) > #main-container {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .registry-page {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .registry-page .table-wrap > form {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .registry-page .table-wrap {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
    }
    .registry-page .table-container {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }
}

@media (width >= 600px) {

    .table {
        border-collapse: collapse;
        border-spacing: 0;
        empty-cells: show;
        border: 1px solid var(--lightgray);
        padding: .2rem;
        table-layout: fixed;
        border-radius: .5rem;
        /*width: 3000px;*/
        /*overflow-x:auto;*/
        thead {
            text-align: left;
            vertical-align: bottom;
            position: sticky;
            z-index: 2;
            top: 0;
        }
        tr {
            border: 1px solid var(--lightgray);
            padding: .35em;
            height: 2.3rem;
        }
        th,
        td {
            padding: .625em;
            text-align: center;
            vertical-align: middle;
            font-size: .7em;
            margin: 0;
        }
        th {
            font-size: .6em;
            letter-spacing: .1em;
            text-transform: uppercase;
            height: 2.5rem;
            font-weight: 700;
            color: var(--text-default);
            background-color: var(--surface-header);
            border-bottom: 2px solid var(--border-table-header);
            div { align-content: center; }
            &.sticky {
                z-index: 10;
                position: sticky;
                left: -1px;
            }
        }
        td {
            white-space: nowrap;
            &.text-align-right { text-align: right; }
            &.text-align-left { text-align: left; }
            &.sticky {
                z-index: 10;
                position: sticky;
                left: -1px;
            }
            &:last-child { width: 100%; }
        }
        tbody tr:nth-child(even) td { background-color: var(--ultralightgray); }
        tbody tr:nth-child(odd) td { background-color: var(--light); }
        tbody tr:hover {
            cursor: pointer;
            td {  background-color: var(--primary); }
            /*filter: drop-shadow(0px 2px var(--lightgray));            */
        }
    }

    .ellipsis {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sortable {
        cursor: pointer;
        user-select: none;
    }
    .sortable div {
        position: relative;
        display: inline-block;
        width: 100%;
        height: 1.75rem;
        padding-right: 1rem;
    }

    .sortable-arrow {
        position: absolute;
        left: 0;
        top: -.25rem;
        font-style: normal;
        font-size: 1em;
    }
    
    .no-changes-row td {
        color: rgb(from var(--grey-fg) r g b / 50%) !important;
    }

    .updated-cell {
        color: var(--gold-fg);
        background-color: rgb(from var(--gold-bg) r g b / 60%) !important;
        border: 1px solid rgb(from var(--gold-fg) r g b / 60%);
     }
    
    .error-cell {
        color: var(--red-fg);
        background-color: rgb(from var(--red-bg) r g b / 60%) !important;
        border: 1px solid rgb(from var(--red-fg) r g b / 60%);
        padding: .5rem;
        font-style: italic;
    }
    
}

@media (width < 600px) {
    
    .table { 
        border: 0; 
        width: 100%;
        caption { font-size: 1.3em; }
        thead { display: none; }
        tr {
            border-bottom: 3px solid var(--lightgray);
            display: block;
            margin-bottom: .625em;
            padding-block: 1rem;
            line-height: 1rem;
        }
        td {
            border-bottom: 1px solid var(--lightgray);
            display: block;
            font-size: .8em;
            text-align: right;
            padding-block: 0.1rem;
        }
        td::before {
            content: attr(data-label);
            float: left;
            /*font-size: 1rem;*/
            font-weight: 600;
            text-align: left;
            text-transform: uppercase;
        }
        td:last-child { border-bottom: 0; }
    }
}


/* --- NOTIFICATIONS --- */

.notification-btn {
    position: relative;
    padding: .5rem;
    border-color: var(--on-dark-border);
    border-radius: .5rem;
    box-shadow: unset;
    background-color: inherit;
    color: inherit;
    transition: background-color 0.2s;
    cursor: pointer;
    &> svg {
        width: 1.25rem;
        height: 1.25rem;
    }
    &:hover, &:focus-visible {
        background: unset;
        background-color: var(--on-dark-surface);
    }
    .notification-counter-badge {
        font-size: .6rem;
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: center;
        top: .15rem;
        right: .15rem;
        width: .8rem;
        height: .8rem;
        background-color: var(--notification-badge);
        border-radius: 9999px;
    }
    anchor-name: --notification-button;
}

.notification-list {
    cursor: default;
    width: 20ch;
    display: none;
    position: absolute;
    margin: 0;
    font-size: 1rem;
    margin-block-start: .25rem;
    margin-inline-start: .25rem;
    min-height: 2rem;
    inset: auto;
    top: anchor(bottom);
    right: anchor(right);
    position-anchor: --notification-button;
    height: auto;
    opacity: 0;
    transition: opacity .5s, display .5s, overlay .5s;
    transition-behavior: allow-discrete;
    position-try-fallbacks: --left;
    /*z-index: 3;*/
    background: var(--light);
    /*font-size: .75rem;*/
    border: 1px solid var(--gray);
    border-radius: .5rem;
    & > * {
        padding: .5rem;
    }
    &:popover-open {
        display: grid;
        opacity: 1;

        @starting-style {
            display: grid;
            opacity: 0;
        }
    }
    /*p {*/
    /*    margin: 0;*/
    /*    padding-block: .5rem;*/
    /*    text-align: left;*/
    /*}*/
    header {
        font-weight: 700;
        background-color: unset;
        color: unset;
        padding-block: .08rem;
        padding-inline: .5rem;
        font-size: .7em;
        border-radius: .5rem;
        margin-block-end: .5rem;
        text-align: left;
    }
    section {
        margin: 0;
        padding: 0;
    }
    .notification-cards {
        max-height: 20rem;
        overflow-y: scroll;
        scrollbar-width: thin;
    }
}

.notification-settings {
    font-size: .65rem;
    fieldset {
        margin-block-end: .25rem;
        border: 1px solid var(--lightgray);
        border-radius: .5rem;
        display: flex;
        justify-content: flex-end;
        select {
            font-size: .65rem;
            float: left;
        }
    }
    
}

/* --- USER AVATAR --- */

.avatar-signature { 
    color: var(--dark);
    .small { font-size: .5rem; }
    .ultrasmall { font-size: .45rem; }
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    color: var(--lightgray);
    background: linear-gradient(to bottom right, var(--button-primary-bg1), var(--button-primary-bg2));
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .5s ease-in-out;
    span { font-size: .8rem; }
    anchor-name: --avatar-button;
    &:hover, &:focus-visible {
        background: linear-gradient(to bottom right, var(--button-primary-bg1), var(--button-primary-bg2));
        filter: brightness(1.25);
    }
}

.avatar-menu {
    display: none;
    position: absolute;
    margin: 0;
    margin-block-start: .25rem;    
    margin-inline-start: .25rem;
    inset: auto;
    top: anchor(bottom);
    right: anchor(right);
    position-anchor: --avatar-button;
    height: auto;
    opacity: 0;
    transition: opacity .5s, display .5s, overlay .5s;
    transition-behavior: allow-discrete;
    /*position-try-fallbacks: --left;*/
    /*z-index: 3;*/
    background: var(--light);
    font-size: .75rem;
    border: 1px solid var(--gray);
    border-radius: .5rem;
    & > * {
        padding: .5rem;
    }
    &:popover-open {
        display: grid;
        opacity: 1;

        @starting-style {
            display: grid;
            opacity: 0;
        }
    }
    ul { padding: .5rem; margin: 0; }
    li { list-style-type: none; text-align: left; }
    li label { padding-inline-start: .25rem; }
}

/*@position-try --left {*/
/*    inset: auto;*/
/*    top: anchor(bottom);*/
/*    right: anchor(right);*/
/*}*/


/* --- COLUMN MENU --- */

.column-menu-trigger { gap: .5rem; anchor-name: --column-menu-anchor; }
.column-menu-trigger svg { width: 1rem; height: 1rem; stroke: currentColor; }

.column-menu {
    position: absolute;
    inset: auto;
    position-anchor: --column-menu-anchor;
    top: anchor(bottom);
    left: anchor(left);
    position-try-fallbacks: --column-menu-flip;
    margin: .25rem 0 0 0;
    width: min(360px, calc(100vw - 2rem));
    max-height: min(70vh, 30rem);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: .75rem;
    box-shadow: var(--shadow-popover);
    padding: 0;
    overflow: hidden;
    font-size: .85rem;
    color: var(--text-strong);
    opacity: 0;
    transition: opacity .2s, display .2s, overlay .2s;
    transition-behavior: allow-discrete;
}
.column-menu:popover-open {
    display: flex;
    flex-direction: column;
    opacity: 1;
    @starting-style {
        opacity: 0;
    }
}
.column-menu form {
    display: flex;
    flex-direction: column;
    max-height: inherit;
    min-height: 0;
    flex: 1 1 auto;
}
@position-try --column-menu-flip {
    left: auto;
    right: anchor(right);
}

.column-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
    flex: 0 0 auto;
}
.column-menu-header .button-bar { gap: .5rem; padding: 0; }
.column-menu-header .button-bar button,
.column-menu-header .button-bar .link-button {
    padding: .5rem 1rem;
    font-size: .875rem;
    border-radius: .375rem;
}

.column-menu-list {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .75rem 1.25rem 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
}

.column-menu-row {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .375rem .25rem;
    border-radius: .375rem;
    cursor: pointer;
    user-select: none;
}
.column-menu-row:hover { background: var(--surface-header); }
.column-menu-row input[type=checkbox] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--brand-primary);
    cursor: pointer;
}
.column-menu-row span { font-size: .9rem; }

.column-menu-toggle-all {
    border-bottom: 1px dashed var(--border-subtle);
    margin-bottom: .25rem;
    padding-bottom: .5rem;
    font-weight: 500;
    font-style: italic;
    color: var(--text-muted);
}


/* --- LOGIN --- */

.login-pane {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

.login {
    border: 1px solid var(--gray);
    border-radius: 10px;
    box-shadow: var(--shadow-popover);
}

.login-header {
    display: flex;
    justify-content: center;
    background-color: var(--header-bg);
    color: var(--primary);
    padding: 1.2rem;
    margin-bottom: .5rem;
    border-radius: 9px 9px 0 0;
}

.login-form {
    padding: 1.8rem;
    display: grid;
    grid-template-rows: 1fr;
    grid-gap: 1rem;
    align-items: start;
}


/* --- BADGES --- */

.customer-badge {
    border-radius: .25rem;
    border: 1px solid var(--lightgray);
    background-color: var(--light);
    padding: .3rem .3rem;
    margin-inline-end: .1rem;
    display: inline-block;
}

.sign-badge {
    border-radius: .25rem;
    border: 1px solid var(--lightgray);
    background-color: var(--light);
    width: 5ch;
    padding: .3rem .3rem;
    display: inline-block;
}

.status-badge {
    border-radius: 9999px;
    padding: var(--badge-block-padding) var(--badge-inline-padding);
    display: inline-block;
}

.with-marker {
    position: relative;
}

.row-badge {
    position: absolute;
    font-style: normal;
    top: -.25rem;
    left: -.05rem;
    border-radius: 9999px;
    margin: 0;
    padding: .05rem .3rem;
    border: 1px solid;
    z-index: 20;
}

.badge-green {
    background-color: var(--green-bg);
    color: var(--green-fg);
}

.border-green { border-color: var(--green-fg); }

.badge-orange {
    background-color: var(--orange-bg);
    color: var(--orange-fg);
}

.border-orange { border-color: var(--orange-fg); }

.badge-blue {
    background-color: var(--blue-bg);
    color: var(--blue-fg);
}

.border-blue { border-color: var(--orange-fg); }

.badge-red {
    background-color: var(--red-bg);
    color: var(--red-fg);
}

.border-red { border-color: var(--red-fg); }

.badge-purple {
    background-color: var(--purple-bg);
    color: var(--purple-fg);
}

.border-purple { border-color: var(--purple-fg); }

.badge-gold {
    background-color: var(--gold-bg);
    color: var(--gold-fg);
}

.border-gold { border-color: var(--gold-fg); }

.badge-grey {
    background-color: var(--grey-bg);
    color: var(--grey-fg);
}

.border-grey { border-color: var(--grey-fg); }


/* --- PROGRESS --- */

.progress {
    border-radius: 9999px;
    border: 1px solid var(--lightgray);
    background-color: var(--light);
    position: relative;
    overflow: hidden;
    height: .9rem;
    &.warning1 { color: var(--red-fg); }
    &.warning2 { color: var(--orange-fg); }
    &.warning3 { color: var(--light); }
    &:before {
        content: attr(data-label);
        position: absolute;
        text-align: center;
        left: 0;
        right: 0;
        top: .1rem;
    }
    
    .value {
        background-color: var(--lightgray);
        height: 100%;
        &.warning1 { background-color: var(--red-bg); }
        &.warning2 { background-color: var(--orange-bg); }
        &.warning3 { background-color: var(--gray); }
    }
}


/* --- INDICATOR --- */

.htmx-indicator {
    opacity: 0;
    visibility: hidden;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
    visibility: visible;
    transition: opacity 200ms ease-in;
}



/* --- CALENDAR --- */

.month-view-title {
    font-weight: 400;
}

.calendar {
    display: grid;
    margin-block: .5rem;
    grid-template-columns: repeat(7, 1fr);
    /*grid-template-columns: repeat(7, 13vw); !* slightly less than the 1/7 of the viewport *!*/
    /*grid-template-rows: 1.5rem repeat(6, 1fr);*/
    grid-template-rows: 1.5rem auto;
    border: 1px solid var(--lightgray);
    border-radius: .5rem;
    gap: 1px;
    .day-name {
        font-weight: 700;
        margin: 0;
        padding: .25rem;
        background-color: var(--blue-bg);
        border-top-radius: .5rem;
        @media (width < 600px) {
            font-size: .6rem;
        }
    }
    .day {
        /*max-width: 13vw; !* slightly less than the 1/7 of the viewport *!*/
        padding: .25rem;
        outline: 1px solid var(--lightgray);
        /*border: 1px solid var(--lightgray);*/
        /*border-radius: .5rem;*/
        &> p:first-of-type { 
            text-align: right;
            font-weight: 600;
            /*background-color: var(--ultralightgray);*/
            /*padding: .1rem;*/
            margin-block: 0;
            /*border-block-end: 1px solid var(--ultralightgray);*/
            margin-block-end: .5rem;
            &.other-month { color: var(--lightgray); }
        }
        &.today {
            background-color: var(--gold-bg);
            border: 1px solid var(--gold-fg);
            border-radius: .5rem;
        }
        &.weekend { background-color: var(--grey-bg); }
    }
    .events {
        margin: 0;
        padding: 0;
        min-height: 3rem;
        max-height: 7rem;
        overflow-y: auto;
        scrollbar-width: none;
    }
}

.calendar-event {
    padding-block: .08rem;
    padding-inline: .5rem;
    font-size: .7em;
    border-radius: .5rem;
    margin-block-end: 2px;
    text-align: left;

    summary {
        display: flex;
        justify-content: space-between;
        cursor: pointer;
        user-select: none;
        list-style: none;
        span {
            display: inline-block;
            max-width: 80%;
        }
        aside {
            display: inline-flex;
            align-items: flex-start;
            gap: .1rem;
            max-width: 20%;
            small {
                font-size: .6rem;
                height: 2.25ch;
                width: 2.25ch;
                display: flex;
                color: var(--dark);
                border: 1px solid var(--lightgray);
                border-radius: 50%;
                background-color: var(--light);
                align-items: center;
                justify-content: center;
            }
            svg {
                height: 14px;
                width: 14px;
                z-index: 20;
            }
        }
    }
    &::details-content {
        display: block;
        block-size: 0;
        overflow: hidden;
        transition-property: block-size, content-visibility;
        transition-duration: 0.3s;
        transition-behavior: allow-discrete;
    }
    &[open]::details-content {
        block-size: auto; /* fallback */
        block-size: calc-size(auto, size);
    }
    .links {
        padding-block: .2rem;
        font-style: italic;
        display: flex;
        flex-wrap: wrap;
        gap: 1px;
        a {
            display: inline;
            border: 1px solid var(--lightgray);
            border-radius: .25rem;
            padding-inline: .25rem;
            padding-block-start: .05rem;
            background-color: var(--light);
            text-align: left;
            vertical-align: center;
            text-wrap: nowrap;
        }
    }
    &.car-event {
        background-color: var(--blue-bg);
        color: var(--blue-fg);
        border: 1px solid rgb(from var(--blue-fg) r g b / 20%) ;
    }
    &.user-event {
        background-color: var(--green-bg);
        color: var(--green-fg);
        border: 1px solid rgb(from var(--green-fg) r g b / 20%) ;
    }
    &.misc-event {
        background-color: var(--orange-bg);
        color: var(--orange-fg);
        border: 1px solid rgb(from var(--orange-fg) r g b / 20%) ;
    }
    &.read-event {
        background-color: var(--grey-bg);
        color: var(--grey-fg);
        border: 1px solid rgb(from var(--grey-fg) r g b / 20%) ;
    }
    .date-label { font-style: italic; }
}

.calendar-event-responsive {
    @media (width < 600px) {
        padding-inline: .08rem;
        div:before {
            content: attr(title);
            display: inline;
            writing-mode: vertical-lr;
            text-orientation: mixed;
            max-width: 14ch;
        }
    }
    summary {
        @media (width < 600px) { overflow: hidden; }
        span {
            @media (width < 600px) { display: none; }
        }
        aside {
            @media (width < 600px) { max-width: 100%; }
        }
    }

    .links {
        a {
            @media (width < 600px) {
                writing-mode: vertical-lr;
                text-orientation: mixed;
            }
        }
    }
}

.phone-number-form {
    .details-form-action-bar {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: .75rem 1rem;
    }
    .phone-number-form-title {
        align-items: center;
        gap: .75rem;
        flex: 1 1 auto;
        min-width: 0;
        h3 {
            margin: 0;
            font-size: 1.125rem;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .phone-icon {
            width: 2rem;
            height: 2rem;
            padding: .375rem;
            background: var(--surface-icon-accent);
            border-radius: .5rem;
            stroke: var(--brand-primary);
            flex: 0 0 auto;
        }
    }
    details {
        padding: 0;
        margin-block: 1rem;
        overflow: hidden;
        border: 1px solid var(--border-subtle);
        summary {
            padding: .75rem 1.25rem;
            margin: 0;
            background: var(--surface-header);
            border-bottom: 1px solid var(--border-subtle);
            font-weight: 600;
            font-size: .95rem;
        }
        section.form-grid {
            border-top: none;
            padding: 1rem 1.25rem;
            align-items: stretch;
        }
    }
    .form-field {
        gap: .375rem;
        background: var(--surface-muted);
        border: 1px solid var(--border-subtle);
        border-radius: .5rem;
        padding: .625rem .75rem;
        label {
            font-size: .6875rem;
            font-weight: 500;
            letter-spacing: .04em;
            text-transform: uppercase;
            color: var(--text-label);
            padding: 0;
            white-space: normal;
        }
        span {
            font-weight: 600;
            color: var(--text-strong);
            padding: 0;
            min-height: 1.25rem;
        }
        input:not([type=checkbox]), select, textarea {
            background: var(--surface-card);
            border: 1px solid var(--border-input);
            border-radius: .375rem;
            padding: .375rem .5rem;
            width: 100%;
            font: inherit;
        }
        input:focus, select:focus, textarea:focus {
            outline: none;
            border-color: var(--focus-border);
            box-shadow: 0 0 0 3px var(--focus-ring);
        }
    }
}


/*
--------------
  Type-ahead 
--------------
*/

.custom-type-ahead-popover {
    position: absolute;
    margin: 0;
    inset: auto;
    top: anchor(bottom);
    left: anchor(left);
    margin-block-start: .25rem;
    padding-block: .15rem;
    padding-inline: .25rem;
    width: anchor-size(width);
    font-size: .8rem;
    max-height: 10rem;
    background: var(--light);
    border: 1px solid var(--gray);
    border-radius: .5rem;
    li {
        cursor: pointer;
        padding-block: .15rem;
        padding-inline: .25rem;
        text-align: left;
        &:hover, &:focus-visible, &:active {
            background: var(--green-bg);
            outline: 0;
        }
    }
}

.app-search-type-ahead-popover {
    svg {
        position: unset;
        transform: unset;
        margin-inline-end: .5rem;
    }
    .links {
        padding-block: .2rem;
        /*font-style: italic;*/
        display: flex;
        flex-wrap: wrap;
        gap: 1px;
        a {
            display: inline;
            border: 1px solid var(--lightgray);
            border-radius: .25rem;
            padding-inline: .25rem;
            padding-block-start: .05rem;
            background-color: var(--light);
            text-align: left;
            vertical-align: center;
            text-wrap: nowrap;
        }
    }
}


@layer type-ahead {
    :where(type-ahead-wc) {
        @supports not (position-anchor: --anchor) {
            & {
                display: block;
                position: relative;
                [popover]:popover-open {
                    inset: unset;
                    position: absolute;
                    width: auto;
                    z-index: 1;
                }
            }
        }
    }
}

/* --- FILTERS --- */

.advanced-filters-section {
    display: flex;
    padding-block-start: .25rem;
    gap: .25rem;
    details {
        width: 100%;
        font-size: .8rem;
        input,
        select {
            font-size: .8rem;
        }
        summary {
            cursor: pointer;
            user-select: none;
            text-align: start;
            font-size: .9rem;
            padding-block-start: .125rem;
            width: fit-content;
        }
        label {
            display: block;
            font-size: .8rem;
            font-weight: bold;
            padding-bottom: .25rem;
        }
        & > section {
            background-color: var(--primary);
            margin-block: .25rem;
            padding-inline: 1rem;
            padding-block: .25rem;
            border-radius: .5rem;
            box-shadow: var(--shadow-sm);
        }
        &::details-content {
            display: block;
            block-size: 0;
            overflow: hidden;
            transition-property: block-size, content-visibility;
            transition-duration: .3s;
            transition-behavior: allow-discrete;
        }
        &[open]::details-content {
            block-size: auto; /* fallback */
            block-size: calc-size(auto, size);
        }
    }
}

.filter-chip {
    border-radius: 9999px;
    align-items: center;
    gap: .5rem;
    padding: .275rem .75rem;
    font-size: .8rem;
    display: flex;
    background: var(--primary);
    border: 1px solid var(--border-strong);
    &:hover {
        background: var(--surface-muted, var(--light));
    }
    &.chip-selected {
        color: var(--brand-primary);
        background: var(--surface-muted, var(--light));
        border-color: var(--brand-primary);
    }
}

.chip-icon {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.filter-chip:not(.chip-selected) .chip-icon {
    color: var(--brand-primary);
}

.filter-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 .375rem;
    border-radius: 9999px;
    font-size: .7rem;
    font-weight: 600;
    background: linear-gradient(
        90deg,
        var(--button-primary-bg1),
        var(--button-primary-bg2)
    );
    color: var(--primary);
}

.multiselect-dropdown {
    position: relative;
    border: 1px solid var(--lightgray);
    border-radius: .25rem;
    background: var(--primary);
    width: 100%;
    box-sizing: border-box;
    > .multiselect-dropdown-summary {
        list-style: none;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .25rem;
        padding: .375rem .5rem;
        cursor: pointer;
        font-size: .85rem;
        min-height: 1.75rem;
        user-select: none;
        &::-webkit-details-marker {
            display: none;
        }
        &::marker {
            content: "";
            display: none;
        }
        &::before {
            display: none;
        }
    }
    .multiselect-dropdown-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1 1 auto;
        min-width: 0;
    }
    .multiselect-dropdown-caret {
        flex: 0 0 auto;
        transition: transform .15s ease;
    }
    &[open] > .multiselect-dropdown-summary .multiselect-dropdown-caret {
        transform: rotate(90deg);
    }
    .multiselect-dropdown-list {
        position: absolute;
        top: calc(100% + .125rem);
        left: 0;
        right: 0;
        margin: 0;
        padding: .25rem;
        list-style: none;
        background: var(--primary);
        border: 1px solid var(--lightgray);
        border-radius: .25rem;
        box-shadow: var(--shadow-sm);
        z-index: 30;
        max-height: 14rem;
        overflow-y: auto;
        li label {
            display: flex;
            align-items: center;
            gap: .375rem;
            padding: .25rem .375rem;
            cursor: pointer;
            border-radius: .25rem;
            font-size: .85rem;
            &:hover {
                background: var(--light);
            }
        }
        input[type="checkbox"] {
            width: auto;
            margin: 0;
        }
    }
}

.registry-filters {
    .filters-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 1fr;
        gap: .5rem;
        flex: 1 1 auto;
        min-height: 0;
        min-width: 0;
        position: relative;
    }
    &:has(.advanced-filters-details[open]) .filters-layout {
        grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    }
    .table-wrap > .table-toolbar {
        align-items: flex-start;
        padding: 0 0 .35rem;
    }
    .table-toolbar-right .column-menu-trigger {
        padding-block: .25rem;
        font-size: .75rem;
        line-height: 1;
    }
    .advanced-filters-section {
        display: block;
        padding: 0;
        min-height: 0;
        position: relative;
    }
    .advanced-filters-details:not([open]) {
        width: fit-content;
    }
    .advanced-filters-details[open] {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 16rem;
        background-color: var(--primary);
        border-radius: .5rem;
        box-shadow: var(--shadow-md);
        padding: .5rem .75rem;
        > summary {
            flex: 0 0 auto;
        }
        > .advanced-filter-container {
            flex: 1 1 auto;
            min-height: 0;
            background-color: transparent;
            box-shadow: none;
        }
        .filter-form-grid {
            display: flex;
            flex-direction: column;
            gap: .5rem;
            min-width: 0;
            flex: 1 1 0;
            min-height: 0;
            overflow-y: auto;
            padding: .1rem;
        }
    }
    .filter-form-grid > * {
        min-width: 0;
    }
    .two-inputs {
        display: flex;
        flex-direction: column;
        gap: .25rem;
        min-width: 0;
        width: 100%;
        > input,
        > span {
            flex: 0 0 auto;
            min-width: 0;
            width: 100%;
        }
    }
    .toggle-3 {
        gap: .25rem;
        label {
            white-space: nowrap;
        }
    }
    .qf-mobile-backdrop {
        display: none;
    }
    .action-bar {
        margin-block-end: 0;
    }
    .qf-toolbar {
        display: flex;
        align-items: center;
        gap: .5rem;
        padding: .5rem .75rem;
        background-color: var(--primary);
        border-radius: .5rem;
        box-shadow: var(--shadow-sm);
        margin-top: .5rem;
        margin-bottom: .5rem;
        min-width: 0;
    }
    .unified-toolbar {
        flex-wrap: nowrap;
    }
    .qf-kebab,
    .qf-star,
    .qf-active-quick {
        display: none;
    }
    .toolbar-actions {
        flex: 0 0 auto;
        gap: .375rem;
    }
    .toolbar-search {
        flex: 0 0 auto;
        margin: 0;
        .search-wrapper {
            margin: 0;
        }
        input[type="search"] {
            width: 14rem;
        }
    }
    .qf-quick-filter-settings-wrap {
        flex: 0 0 auto;
    }
    .qf-save-inline-wrapper > summary {
        list-style: none;
        cursor: pointer;
    }
    .qf-save-inline-wrapper > summary::-webkit-details-marker {
        display: none;
    }
    .qf-save-inline-wrapper > summary::marker {
        content: "";
    }
    .filter-footer-bar > .qf-save-inline-wrapper[open] > summary {
        display: none;
    }
    .active-pills-row {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-start;
        gap: .375rem;
        flex: 1 1 auto;
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: thin;
        padding: 0;
    }
    .filter-pill {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        gap: .375rem;
        padding: .25rem .5rem .25rem .625rem;
        background: var(--light);
        border: 1px solid var(--lightgray);
        border-radius: 1rem;
        font-size: .75rem;
        line-height: 1;
        .pill-label {
            color: var(--gray);
        }
        .pill-value {
            font-weight: 500;
            color: var(--text-default);
        }
    }
    .search-pill {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        gap: .375rem;
        padding: .25rem .5rem .25rem .625rem;
        background: var(--light);
        border: 1px solid var(--brand-primary);
        border-radius: 1rem;
        font-size: .75rem;
        line-height: 1;
        .chip-icon {
            color: var(--brand-primary);
        }
        .pill-label {
            color: var(--brand-primary);
        }
        .pill-value {
            font-weight: 500;
            color: var(--text-default);
        }
    }
    .pill-clear {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: 0;
        padding: 0;
        width: 1rem;
        height: 1rem;
        border-radius: 50%;
        cursor: pointer;
        color: var(--gray);
        &:hover {
            background: var(--lightgray);
            color: inherit;
        }
        .chip-icon {
            width: .75rem;
            height: .75rem;
        }
    }
    .advanced-filters-section:not(:has(.advanced-filters-details[open])) {
        display: none;
    }
    .sticky-bottom-bar {
        margin-top: auto;
    }
    .sticky-bottom-bar.table-toolbar {
        flex-wrap: wrap;
        row-gap: .25rem;
        min-width: 0;
    }
    .table-container {
        flex: 1 1 auto;
        min-height: 12rem;
    }
    .qf-mobile-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.75rem;
        height: 1.75rem;
        padding: 0;
        border: none;
        background: transparent;
        cursor: pointer;
        border-radius: .25rem;
        &:hover {
            background: var(--light);
        }
        .chip-icon {
            width: 1.1rem;
            height: 1.1rem;
        }
    }
    .filter-panel-header {
        display: flex;
        align-items: center;
        gap: .25rem;
        flex: 0 0 auto;
        margin-bottom: .75rem;
        .qf-mobile-close {
            margin-left: auto;
        }
    }
    .advanced-filters-details > summary {
        display: none;
        cursor: pointer;
    }
    .advanced-filters-details[open] > .advanced-filter-container {
        padding-inline: .25rem;
    }
    .advanced-filters-details[open]::details-content {
        display: flex;
        flex-direction: column;
        block-size: 100%;
        overflow: visible;
        transition: none;
    }
    .advanced-filters-details[open] > .advanced-filter-container {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
        padding-bottom: 0;
    }
    .advanced-filter-form {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        justify-content: flex-start;
        min-height: 0;
        input,
        select {
            min-width: 0;
            max-width: 100%;
            box-sizing: border-box;
        }
        input[type="date"] {
            width: 100%;
        }
    }
    .advanced-filter-form .filter-footer-bar {
        flex: 0 0 auto;
        flex-wrap: wrap;
        background: var(--primary);
        padding-block: .5rem;
        margin-block-start: .25rem;
    }
    .qf-save-summary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: .375rem;
        width: 1.75rem;
        height: 1.75rem;
        border-radius: .25rem;
        cursor: pointer;
        color: var(--brand-primary);
        list-style: none;
        &::-webkit-details-marker {
            display: none;
        }
        &::marker {
            content: "";
        }
        &:hover {
            background: var(--light);
        }
        .chip-icon {
            width: 1.1rem;
            height: 1.1rem;
        }
    }
    .qf-save-header {
        width: max-content;
        > .qf-save-summary {
            width: 1.75rem;
            height: 1.75rem;
            border: 1px solid var(--border-subtle, var(--lightgray));
            background: var(--surface-card, var(--primary));
        }
    }
    .qf-save-header[open] {
        background: var(--primary);
        border: 1px solid var(--border-subtle, var(--lightgray));
        border-radius: .375rem;
        padding: .125rem;
        display: flex;
        align-items: center;
        gap: .25rem;
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
    }
    .qf-quick-filter-settings-panel {
        width: max-content;
        > button {
            width: 1.75rem;
            height: 1.75rem;
            border: 1px solid var(--border-subtle, var(--lightgray));
            background: var(--surface-card, var(--primary));
            cursor: pointer;
        }
        > .qf-popover {
            width: 15rem;
            max-width: calc(100vw - 2rem);
        }
    }
    .qf-save-header[open] > .qf-save-summary {
        display: none;
    }
    .qf-save-header[open] .qf-save-inline {
        display: flex;
        align-items: center;
        gap: .25rem;
        flex: 1 1 auto;
        min-width: 0;
        input {
            flex: 1 1 auto;
            min-width: 0;
        }
    }
    .qf-pinned-chips {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: .375rem;
        flex: 1 1 auto;
        min-width: 0;
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    .toolbar-divider {
        flex: 0 0 auto;
        width: 1px;
        height: 1.5rem;
        align-self: center;
        background: var(--border-strong);
        margin-left: -.25rem;
        margin-right: .25rem;
    }
    .qf-btn {
        display: inline-flex;
        align-items: center;
        gap: .375rem;
        padding: .375rem .75rem;
        border: 1px solid var(--lightgray);
        border-radius: .5rem;
        background: var(--primary);
        font-size: .8rem;
        cursor: pointer;
        white-space: nowrap;
        &:hover {
            background: var(--light);
        }
        &.qf-active {
            background: var(--surface-muted, var(--light));
            color: var(--brand-primary);
            border-color: var(--brand-primary);
            .filter-count-badge {
                background: var(--brand-primary);
                color: var(--primary);
            }
        }
    }
    .qf-btn-filter .filter-count-badge {
        margin-left: .25rem;
        min-width: 1rem;
        height: 1rem;
        padding: 0 .3rem;
        font-size: .65rem;
        line-height: 1;
    }
    .qf-popover {
        position: absolute;
        inset: auto;
        margin: 0;
        width: 18rem;
        background: var(--primary);
        border: 1px solid var(--lightgray);
        border-radius: .5rem;
        box-shadow: var(--shadow-md, var(--shadow-sm));
        padding: .75rem;
        text-align: left;
    }
    .qf-kebab-summary { anchor-name: --qf-actions-anchor; }
    .qf-star-summary { anchor-name: --qf-quickfilter-anchor; }
    .qf-settings-trigger { anchor-name: --qf-settings-anchor; }
    .qf-popover-actions {
        position-anchor: --qf-actions-anchor;
        top: anchor(bottom);
        right: anchor(right);
        margin-top: .375rem;
    }
    .qf-popover-quickfilter {
        position-anchor: --qf-quickfilter-anchor;
        top: anchor(bottom);
        right: anchor(right);
        margin-top: .375rem;
    }
    .qf-popover-settings {
        position-anchor: --qf-settings-anchor;
        top: anchor(bottom);
        left: anchor(left);
        margin-top: .375rem;
    }
    .qf-popover-header {
        display: flex;
        flex-flow: row nowrap;
        align-items: center;
        justify-content: space-between;
        margin-bottom: .125rem;
        padding: 0;
        background: none;
        color: var(--text-default);
        h4 {
            margin: 0;
            font-size: .9rem;
            font-weight: 600;
        }
    }
    .qf-popover-hint {
        font-size: .7rem;
        color: var(--gray);
        margin: 0 0 .5rem;
    }
    .qf-popover-list {
        list-style: none;
        margin: 0;
        padding: 0;
        max-height: 16rem;
        overflow-y: auto;
    }
    .qf-popover-item {
        display: flex;
        align-items: center;
        gap: .25rem;
        padding: .25rem;
        border-radius: .25rem;
        &:hover {
            background: var(--light);
        }
        &.qf-active {
            background: var(--light);
        }
    }
    .qf-popover-empty {
        padding: .75rem;
        text-align: center;
        color: var(--gray);
        font-size: .8rem;
    }
    .qf-popover-label {
        flex: 1 1 auto;
        display: block;
        text-align: left;
        background: none;
        border: 0;
        padding: .25rem .375rem;
        font-size: .85rem;
        cursor: pointer;
        color: var(--text-default);
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .qf-icon-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: 0;
        padding: .25rem;
        border-radius: .25rem;
        cursor: pointer;
        color: var(--gray);
        &:hover {
            background: var(--lightgray);
            color: inherit;
        }
        &.qf-icon-danger:hover {
            color: var(--danger, #c0392b);
        }
    }
    .qf-locked-field .form-field {
        position: relative;
        opacity: .85;
        input,
        select {
            background-color: var(--light);
            color: var(--gray);
            cursor: not-allowed;
        }
        > span,
        .two-inputs > span {
            display: block;
            width: 100%;
            box-sizing: border-box;
            padding: .375rem .5rem;
            background-color: var(--light);
            color: var(--gray);
            border: 1px solid var(--lightgray);
            border-radius: .25rem;
            cursor: not-allowed;
        }
    }
    .qf-save-inline {
        display: none;
        align-items: center;
        gap: .25rem;
    }
    .qf-popover-rename form {
        display: flex;
        align-items: center;
        gap: .25rem;
        width: 100%;
        min-width: 0;
    }
    .qf-rename-input {
        flex: 1 1 auto;
        min-width: 0;
        padding: .25rem .375rem;
        border: 1px solid var(--lightgray);
        border-radius: .25rem;
        font-size: .8rem;
        &:focus {
            box-shadow: inset 0 0 0 2px var(--focus-ring);
        }
    }
    .filter-sections {
        display: flex;
        flex-direction: column;
        gap: .375rem;
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
    }
    .filter-section {
        flex: 0 0 auto;
        width: 100%;
        border: 1px solid var(--lightgray);
        border-radius: .375rem;
        background: var(--primary);
        overflow: hidden;
    }
    .filter-section > summary {
        width: 100%;
        list-style: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .5rem;
        padding: .5rem .875rem;
        background: var(--surface-header);
        font-size: .8rem;
        font-weight: 600;
        color: var(--text-default);
        user-select: none;
        box-sizing: border-box;
        &::-webkit-details-marker {
            display: none;
        }
        &::marker {
            content: "";
        }
        &:hover {
            background: var(--lightgray);
        }
    }
    .filter-section-label {
        display: inline-flex;
        align-items: center;
        gap: .375rem;
        min-width: 0;
    }
    .filter-section-chevron {
        transition: transform .15s ease;
        transform: rotate(90deg);
        width: .9rem;
        height: .9rem;
        color: var(--gray);
    }
    .filter-section[open] > summary .filter-section-chevron {
        transform: rotate(-90deg);
    }
    .filter-section-body.filter-form-grid {
        padding: .5rem .875rem .625rem !important;
        label {
            align-self: stretch;
            overflow-wrap: break-word;
            text-align: left;
        }
    }
}

@media (max-width: 800px) {
    body:has(.registry-filters) > #main-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .registry-filters.registry-page {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .registry-filters .unified-toolbar {
        width: 100%;
        min-width: 0;
    }
    .registry-filters {
        &:has(.advanced-filters-details[open]) .filters-layout {
            grid-template-columns: 1fr;
        }
        .advanced-filters-section {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: auto;
            width: 85vw;
            max-width: 360px;
            z-index: 10001;
            transform: translateX(-100%);
            transition: transform .25s ease;
            background: var(--primary);
            box-shadow: var(--shadow-modal);
            overflow: hidden;
        }
        &:has(.advanced-filters-details[open]) .advanced-filters-section {
            transform: translateX(0);
        }
        .advanced-filters-details[open] {
            height: 100%;
            border-radius: 0;
            box-shadow: none;
        }
        .qf-mobile-backdrop {
            display: block;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, .4);
            z-index: 10000;
            opacity: 0;
            pointer-events: none;
            transition: opacity .25s ease;
        }
        &:has(.advanced-filters-details[open]) .qf-mobile-backdrop {
            opacity: 1;
            pointer-events: auto;
        }
        .advanced-filter-form {
            position: static;
        }
        .unified-toolbar {
            display: grid;
            grid-template-columns: 1fr auto;
            gap: .5rem;
            align-items: center;
            padding: .5rem;
            .toolbar-actions {
                width: 100%;
                .link-button.btn-primary {
                    width: 100%;
                    min-height: 2.25rem;
                    box-sizing: border-box;
                }
                .link-button:not(.btn-primary) {
                    display: none;
                }
            }
            .qf-btn-filter {
                min-height: 2.25rem;
                box-sizing: border-box;
            }
            .toolbar-search,
            .toolbar-divider,
            .qf-pinned-chips {
                display: none;
            }
            .qf-btn-filter {
                width: 100%;
                justify-content: center;
            }
            .qf-kebab,
            .qf-star {
                display: block;
                position: relative;
            }
            .qf-kebab > button,
            .qf-star > button {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                box-sizing: border-box;
                width: 2.25rem;
                height: 2.25rem;
                border: 1px solid var(--border-subtle, var(--lightgray));
                border-radius: .5rem;
                background: var(--surface-card, var(--primary));
                color: var(--text-default);
                cursor: pointer;
            }
            .qf-star-summary.qf-star-active {
                color: var(--brand-primary);
                border-color: var(--brand-primary);
                .chip-icon {
                    color: var(--brand-primary);
                }
            }
            .qf-kebab > .qf-popover,
            .qf-star > .qf-popover {
                width: 16rem;
                max-width: calc(100vw - 1.5rem);
            }
            .qf-popover-action {
                display: block;
                padding: .5rem .625rem;
                border-radius: .375rem;
                text-align: left;
                cursor: pointer;
                &:hover {
                    background: var(--light);
                }
            }
            .qf-star-list {
                display: flex;
                flex-direction: column;
                gap: .25rem;
                align-items: stretch;
                .filter-chip {
                    width: 100%;
                    justify-content: flex-start;
                    border-radius: .375rem;
                }
                .filter-chip.visibility-hidden {
                    display: none;
                }
            }
            .qf-active-quick {
                grid-column: 1 / -1;
                display: flex;
                min-width: 0;
            }
            .qf-active-quick-pill {
                display: inline-flex;
                align-items: center;
                gap: .375rem;
                max-width: 100%;
                padding: .25rem .5rem .25rem .625rem;
                background: var(--surface-muted, var(--light));
                border: 1px solid var(--brand-primary);
                border-radius: 1rem;
                font-size: .8rem;
                color: var(--brand-primary);
            }
            .qf-active-quick-name {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }
        }
        .filter-footer-bar {
            flex-direction: column;
            align-items: stretch;
            gap: .5rem;
            button[type="submit"] {
                width: 100%;
                justify-content: center;
                padding-block: .625rem;
                font-size: .95rem;
            }
            button[type="reset"] {
                width: 100%;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                gap: .375rem;
                border: none;
                background: transparent;
                color: var(--text-muted);
                padding-block: .5rem;
                &::before {
                    content: "\2715";
                    font-size: .9em;
                }
            }
        }
    }
    body:has(.registry-filters .advanced-filters-details[open]) {
        overflow: hidden;
    }
}
