/* Portal shell chrome adapted from Aiden Integrator + design-system tokens. */
/* Product chrome. Semantic tokens live in aiden-tokens.css (--aiden-* / --int-* aliases). */
html { scrollbar-gutter: stable; }
html, body {
    margin: 0;
    background: var(--int-canvas);
    color: var(--int-ink);
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}
body {
    font-family: var(--aiden-font-body);
}

.page-shell {
    max-width: none;
    width: 100%;
    margin: 0;
    min-width: 0;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
}
.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--aiden-space-4, 1rem);
    margin: 0 0 var(--aiden-space-section-gap, 2rem);
}
.page-heading h1,
.page-heading .mud-typography-h4,
.page-heading .mud-typography-h5 {
    margin: 0;
    color: var(--int-ink-strong);
    font-family: var(--aiden-font-display) !important;
    letter-spacing: 0;
    line-height: 1.15 !important;
}
.page-heading p,
.page-heading .mud-typography-subtitle2 {
    margin: 0.3rem 0 0;
    color: var(--int-muted) !important;
}
.page-kicker {
    margin: 0 0 0.25rem !important;
    color: var(--aiden-royal, var(--int-primary)) !important;
    font-family: var(--aiden-font-body) !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.1em !important;
    text-transform: uppercase;
}
.surface,
.mud-paper.surface {
    min-width: 0;
    border: 1px solid var(--int-line) !important;
    border-radius: var(--int-surface-radius) !important;
    background: var(--int-surface) !important;
    box-shadow: var(--int-surface-shadow) !important;
}
.kpi-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.kpi-card:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--int-primary) 28%, var(--int-line)) !important;
    box-shadow: 0 14px 28px rgba(27, 43, 74, 0.08) !important;
}

.dashboard-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 0.65rem;
}

.dashboard-kpi-tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.35rem;
    min-height: 4.75rem;
    padding: 0.65rem 0.75rem !important;
}

.dashboard-kpi-label {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    color: var(--int-muted, #66748c) !important;
    min-height: 2.1em;
}

.dashboard-kpi-value {
    font-size: 1.15rem !important;
    font-weight: 760 !important;
    line-height: 1.15 !important;
    letter-spacing: -0.02em;
}

.dashboard-stack-primary {
    font-size: 0.85rem;
    font-weight: 650;
    line-height: 1.25;
    word-break: break-word;
}

.dashboard-stack-secondary {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
    line-height: 1.3;
    word-break: break-word;
}

.dashboard-status-clickable {
    cursor: pointer;
}

.dashboard-subtasks-table {
    border: 1px solid var(--int-line);
    border-radius: var(--int-surface-radius);
    overflow: hidden;
    background: var(--int-surface);
    box-shadow: none;
}

.dashboard-subtasks-table .mud-table-root {
    table-layout: fixed;
    width: 100%;
}

.status-soft-success.mud-chip {
    color: var(--int-success-fg) !important;
    background: var(--int-success-bg) !important;
    border: 1px solid var(--int-success-bd) !important;
}
.status-soft-error.mud-chip {
    color: var(--int-error-fg) !important;
    background: var(--int-error-bg) !important;
    border: 1px solid var(--int-error-bd) !important;
}
.status-soft-info.mud-chip {
    color: var(--int-info-fg) !important;
    background: var(--int-info-bg) !important;
    border: 1px solid var(--int-info-bd) !important;
}
.status-soft-warning.mud-chip {
    color: var(--int-warning-fg) !important;
    background: var(--int-warning-bg) !important;
    border: 1px solid var(--int-warning-bd) !important;
}
.status-soft-default.mud-chip {
    color: var(--int-muted) !important;
    background: color-mix(in srgb, var(--int-canvas) 70%, var(--int-surface)) !important;
    border: 1px solid var(--int-line) !important;
}
.status-soft-dark.mud-chip {
    color: var(--int-ink) !important;
    background: color-mix(in srgb, var(--int-primary) 10%, var(--int-surface)) !important;
    border: 1px solid var(--int-line-strong) !important;
}

/* Expression builder dictionary: avoid limelight-on-white; use light-blue text. */
.expression-dict-chip.mud-chip {
    color: var(--int-ink) !important;
    background: var(--int-surface) !important;
    border: 1px solid var(--int-line) !important;
}
.expression-dict-chip.mud-chip:hover {
    border-color: color-mix(in srgb, var(--code-accent, #9eb6d4) 55%, var(--int-line)) !important;
    background: color-mix(in srgb, var(--code-accent, #9eb6d4) 10%, var(--int-surface)) !important;
}
.expression-dict-chip__label {
    color: var(--int-ink-strong) !important;
}
.expression-dict-chip__template,
.expression-dict-chip__template code {
    font-size: 11px;
    line-height: 1.35;
    color: var(--code-accent, #9eb6d4) !important;
    opacity: 1 !important;
}

.mud-appbar.portal-appbar {
    height: var(--portal-topbar-height) !important;
    min-height: var(--portal-topbar-height) !important;
    background: var(--int-appbar-bg) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--int-line);
    color: var(--mud-palette-appbar-text) !important;
    box-shadow: none !important;
    z-index: calc(var(--mud-zindex-appbar, 1300) + 1) !important;
    overflow: visible !important;
}
.mud-appbar.portal-appbar .mud-toolbar,
.mud-appbar.portal-appbar .mud-toolbar-appbar,
.mud-appbar.portal-appbar .mud-toolbar-gutters {
    overflow: visible !important;
}

/* Full-height sidebar from the top of the viewport (covers AppBar on the left). */
.mud-drawer.portal-drawer {
    top: 0 !important;
    height: 100% !important;
    max-height: 100vh !important;
    z-index: calc(var(--mud-zindex-drawer, 1100) + 1) !important;
}

/* Desktop: AppBar only spans the content area next to the open sidebar. */
@media (min-width: 960px) {
    .portal-shell--drawer-open .mud-appbar.portal-appbar {
        left: 272px !important;
        width: calc(100% - 272px) !important;
        right: auto !important;
    }
}
.mud-appbar.portal-appbar .mud-icon-button {
    color: var(--mud-palette-appbar-text) !important;
}
.appbar-right-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    white-space: nowrap;
    overflow: visible;
    position: relative;
    z-index: calc(var(--mud-zindex-appbar, 1300) + 20);
}
.login-display--drawer {
    width: 100%;
    margin-bottom: 0.35rem;
}
.login-display--drawer .login-display-nav {
    width: 100%;
}
.login-display--drawer .mud-nav-link {
    color: rgba(217, 230, 246, 0.92) !important;
    min-height: 2.15rem;
    padding-inline: 0.85rem !important;
}
.login-display--drawer .mud-nav-link.mud-disabled {
    opacity: 1 !important;
    color: rgba(217, 230, 246, 0.82) !important;
}
.login-display--drawer .mud-nav-link .mud-nav-link-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.login-display--drawer .mud-nav-link .mud-icon-root {
    color: rgba(217, 230, 246, 0.88) !important;
}
.appbar-menu {
    position: relative;
    z-index: calc(var(--mud-zindex-appbar, 1300) + 15);
}
.appbar-menu-backdrop {
    position: fixed;
    inset: 0;
    /* Must stay below .portal-appbar stacking context (+1) so lang/user menu clicks reach the panel. */
    z-index: calc(var(--mud-zindex-appbar, 1300) - 1);
    background: transparent;
}
.appbar-menu-panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: calc(var(--mud-zindex-appbar, 1300) + 20);
    min-width: 13.5rem;
    padding: 0.35rem 0;
    border: 1px solid var(--int-line);
    border-radius: var(--aiden-radius-md, 0.5rem);
    background: var(--int-surface);
    box-shadow: var(--int-surface-shadow);
}
.appbar-menu-divider {
    height: 1px;
    margin: 0.25rem 0;
    background: var(--int-line);
}
.appbar-menu-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    min-height: 2.4rem;
    padding: 0.4rem 0.85rem;
    border: 0;
    background: transparent;
    color: var(--int-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.appbar-menu-item:hover,
.appbar-menu-item:focus-visible {
    background: color-mix(in srgb, var(--aiden-royal) 8%, var(--int-surface));
    outline: none;
}
.theme-dark-mode .appbar-menu-panel {
    background: color-mix(in srgb, #121a2b 90%, var(--aiden-royal));
    border-color: var(--int-line);
}
.theme-dark-mode .appbar-menu-item {
    color: #e7f0ff;
}
.theme-dark-mode .appbar-menu-item:hover,
.theme-dark-mode .appbar-menu-item:focus-visible {
    background: color-mix(in srgb, var(--aiden-royal) 22%, #121a2b);
}
button.lang-badge {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    padding: 0.15rem 0.25rem;
    border-radius: var(--aiden-radius-md, 0.5rem);
}
button.lang-badge:hover,
button.lang-badge:focus-visible {
    background: color-mix(in srgb, var(--aiden-royal) 8%, var(--aiden-off-white));
    outline: none;
}
.theme-dark-mode button.lang-badge:hover,
.theme-dark-mode button.lang-badge:focus-visible {
    background: color-mix(in srgb, var(--aiden-royal) 22%, #101625);
}
.lang-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 2.25rem;
    cursor: pointer;
}
button.user-widget {
    appearance: none;
    border: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    text-align: left;
}
.lang-badge__flag {
    width: 1.5rem;
    height: 1.5rem;
    object-fit: cover;
    border-radius: var(--aiden-radius-full, 9999px);
    flex: 0 0 auto;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--aiden-royal) 22%, transparent);
}
.lang-badge__code {
    letter-spacing: 0.04em;
    color: var(--int-ink-strong);
    font-size: 0.8rem;
    font-weight: 700;
}
    .lang-menu-item__flag {
        width: 1.35rem;
        height: 1rem;
        object-fit: cover;
        border-radius: 2px;
        margin: 0;
        flex: 0 0 1.35rem;
        display: block;
        align-self: center;
        box-shadow: 0 0 0 1px color-mix(in srgb, var(--aiden-royal) 18%, transparent);
    }
    .lang-menu-item__label {
        flex: 1 1 auto;
        text-align: left;
        line-height: 1.25;
    }
.lang-dropdown {
    position: relative;
    outline: none;
}
.lang-menu {
    position: absolute;
    top: calc(100% + 0.3rem);
    right: 0;
    left: auto;
    z-index: calc(var(--mud-zindex-appbar, 1300) + 5);
    min-width: 14rem;
    padding: 0.35rem 0;
    border: 1px solid var(--int-line);
    border-radius: var(--aiden-radius-md, 0.5rem);
    background: var(--int-surface);
    box-shadow: var(--int-surface-shadow);
}
    .lang-menu-item {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.65rem;
        flex-direction: row;
        width: 100%;
        min-height: 2.5rem;
        padding: 0.4rem 0.85rem;
        border: 0;
        background: transparent;
        color: var(--int-ink);
        font: inherit;
        text-align: left;
        cursor: pointer;
    }
.lang-menu-item:hover {
    background: color-mix(in srgb, var(--aiden-royal) 8%, var(--int-surface));
}
.dark-mode-toggle-button { flex: 0 0 auto; }

.mud-drawer.portal-drawer,
.mud-drawer.portal-drawer .mud-drawer-content {
    background: var(--int-sidebar-gradient) !important;
    color: #d9e6f6 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--aiden-font-body) !important;
}
.mud-drawer.portal-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0 !important;
}
.portal-drawer-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
}
.portal-drawer-brand {
    height: var(--portal-topbar-height);
    min-height: var(--portal-topbar-height);
    max-height: var(--portal-topbar-height);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 1rem;
    /* Match AppBar bottom border so the lines meet at the same Y. */
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    flex: 0 0 var(--portal-topbar-height);
}
.portal-brand-icon {
    flex: 0 0 auto;
    width: 2rem;
    height: 2.125rem;
    object-fit: contain;
    object-position: center;
}
.portal-brand-title {
    color: #fff !important;
    font-family: var(--aiden-font-body) !important;
    font-size: 1.0625rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.portal-drawer-nav {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem 0.2rem 1rem;
}
.portal-drawer-footer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    min-height: 3rem;
    padding: 0.55rem 0.35rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.11);
}
.portal-drawer-version {
    color: rgba(217, 230, 246, 0.72) !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em;
    user-select: text;
    white-space: nowrap;
    padding: 0 0.75rem;
}
.mud-drawer.portal-drawer .mud-nav-link {
    margin: 0.15rem 0.55rem;
    border-radius: var(--aiden-radius-md, 0.5rem) !important;
    color: #d9e6f6 !important;
    font-family: var(--aiden-font-body) !important;
    font-size: 0.88rem !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    min-height: 2.85rem;
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.mud-drawer.portal-drawer .mud-nav-link .mud-nav-link-icon,
.mud-drawer.portal-drawer .mud-nav-link .mud-nav-link-text {
    display: inline-flex !important;
    align-items: center !important;
    line-height: 1.2 !important;
}
.mud-drawer.portal-drawer .mud-nav-link .mud-nav-link-icon {
    flex: 0 0 auto;
    width: 1.35rem;
    height: 1.35rem;
    margin: 0 !important;
    justify-content: center;
}
.mud-drawer.portal-drawer .mud-nav-link .mud-nav-link-icon .mud-icon-root {
    margin: 0 !important;
    font-size: 1.25rem !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
}
.mud-drawer.portal-drawer .mud-nav-link .mud-nav-link-text,
.mud-drawer.portal-drawer .mud-nav-link .mud-nav-link-text *,
.mud-drawer.portal-drawer .mud-nav-link .mud-typography-body1,
.mud-drawer.portal-drawer .mud-nav-link .mud-typography-body2,
.mud-drawer.portal-drawer .mud-nav-link .mud-icon-root {
    color: inherit !important;
    font-family: inherit !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    letter-spacing: inherit !important;
}
.mud-drawer.portal-drawer .mud-nav-link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.18) !important;
}
.mud-drawer.portal-drawer .mud-nav-link.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.18) !important;
    box-shadow: inset 0.25rem 0 0 var(--aiden-limelight, #BFD730);
}
.mud-drawer.portal-drawer .mud-navmenu {
    padding: 0;
}

.mud-layout {
    background: var(--int-canvas);
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 0 !important;
    overflow: hidden !important;
}
.mud-main-content.portal-main,
.portal-main {
    display: flex !important;
    flex-direction: column !important;
    background: var(--int-canvas);
    /* Full viewport; pt-16 clears the fixed app bar inside the box */
    height: 100vh !important;
    max-height: 100vh !important;
    min-height: 0 !important;
    box-sizing: border-box !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
}
.portal-main > .page-shell {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding-bottom: 0.5rem;
}
.portal-app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex: 0 0 auto;
    margin-top: 0;
    min-height: var(--portal-footer-height, 3rem);
    padding: 0.55rem 1rem 0.75rem;
    border-top: 1px solid var(--int-line);
    color: var(--aiden-royal, var(--int-primary));
    font-size: 0.78rem;
    background: var(--int-canvas);
    position: relative;
    z-index: 5;
}
.portal-app-footer-logo {
    height: 1.5rem;
    width: auto;
}

.mud-paper:not(.mud-elevation-0):not(.mud-appbar) {
    border: 1px solid var(--int-line);
    border-radius: var(--int-surface-radius) !important;
    box-shadow: var(--int-surface-shadow) !important;
}
.mud-table {
    border: 1px solid var(--int-line);
    border-radius: var(--int-surface-radius);
    overflow: hidden;
    background: var(--int-surface);
    box-shadow: var(--int-surface-shadow);
}
.mud-table .mud-table-head .mud-table-cell {
    font-weight: 700 !important;
    color: var(--int-ink-strong) !important;
    background: color-mix(in srgb, var(--int-canvas) 65%, var(--int-surface));
}
/* Primary action = limelight; secondary = royal (Aiden DS action hierarchy). */
.mud-button-filled-primary {
    background: var(--aiden-color-action-primary, #BFD730) !important;
    color: var(--aiden-color-text-on-action, #32363D) !important;
    box-shadow: none !important;
}
.mud-button-filled-primary:hover {
    background: var(--aiden-color-action-primary-hover, #C9DD4F) !important;
}
.mud-button-filled-primary .mud-button-label,
.mud-button-filled-primary .mud-icon-root {
    color: inherit !important;
}
.mud-button-filled-secondary {
    background: var(--aiden-color-action-secondary, #3C5279) !important;
    color: var(--aiden-color-text-on-dark, #fff) !important;
    box-shadow: none !important;
}
.mud-button-filled-secondary:hover {
    filter: brightness(0.92);
}
.mud-button-outlined-secondary {
    border-color: var(--aiden-royal, var(--int-primary)) !important;
    color: var(--aiden-royal, var(--int-primary)) !important;
}
.theme-dark-mode .mud-button-outlined-secondary {
    border-color: var(--aiden-limelight) !important;
    color: var(--aiden-limelight) !important;
}
.theme-dark-mode .portal-app-footer {
    color: color-mix(in srgb, var(--aiden-royal, var(--int-primary)) 72%, var(--aiden-cool-grey, #d7d9dd));
}
.mud-input:focus-within .mud-input-outlined-border,
.mud-input-control:focus-within .mud-input-outlined-border {
    border-color: var(--aiden-color-border-focus, var(--int-primary)) !important;
}
.mud-input:focus-within {
    box-shadow: 0 0 0 3px var(--int-focus-ring);
    border-radius: var(--int-control-radius);
}
.mud-drawer-header { border-bottom: 1px solid var(--int-line); }
.mud-drawer:not(.portal-drawer) { background: var(--int-surface) !important; }
.listener-editor-panels .mud-expand-panel {
    border: 1px solid var(--int-line);
    border-radius: var(--int-control-radius) !important;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
/* ---- Operational shell + reusable component primitives (DS v0.2.0) ---- */
/* Links: royal on light surfaces; limelight only on inverse/dark. Never limelight body text on white. */
a.link,
.mud-link.link,
.page-shell a.link {
    color: var(--aiden-link-default-color, var(--aiden-royal));
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: var(--aiden-link-underline-thickness, 2px);
    text-underline-offset: 0.16em;
}
a.link:hover,
.mud-link.link:hover,
.page-shell a.link:hover {
    color: var(--aiden-link-default-color-hover, var(--aiden-sapphire-hover));
}
a.link:focus-visible,
.mud-link.link:focus-visible {
    outline: 3px solid var(--aiden-color-border-focus, var(--aiden-royal));
    outline-offset: 3px;
}
a.link.link--inverse,
.mud-link.link.link--inverse {
    color: var(--aiden-link-inverse-color, var(--aiden-limelight));
}
a.link.link--inverse:hover,
.mud-link.link.link--inverse:hover {
    color: var(--aiden-link-inverse-color-hover, var(--aiden-limelight-hover));
}
a.link.link--inverse:focus-visible,
.mud-link.link.link--inverse:focus-visible {
    outline-color: var(--aiden-link-inverse-color, var(--aiden-limelight));
}
/* Drawer/footer inverse surfaces may use limelight links without the class when intentional. */
.mud-drawer.portal-drawer a:not(.mud-nav-link):not(.link),
.portal-app-footer a:not(.link) {
    color: var(--aiden-link-inverse-color, var(--aiden-limelight));
}
.status-dot {
    flex: 0 0 auto;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: var(--aiden-radius-full, 9999px);
    background: var(--aiden-success);
}
.status-dot--error {
    background: var(--aiden-danger);
}
.nav-status-card .status-dot {
    border: 1px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12), 0 0 4px rgba(37, 211, 102, 0.55);
}
.env-pill {
    display: flex;
    align-items: center;
    gap: var(--aiden-space-2, 0.5rem);
    min-height: 2.5rem;
    border: 1px solid var(--aiden-cool-grey);
    border-radius: var(--aiden-radius-full, 9999px);
    padding: var(--aiden-space-2, 0.5rem) var(--aiden-space-3, 0.75rem);
    background: var(--aiden-off-white);
    color: var(--aiden-royal);
    font-size: 0.82rem;
    white-space: nowrap;
}
.env-pill .status-dot {
    background: var(--aiden-success);
}
.env-pill strong {
    color: var(--aiden-warm-black);
}
.env-pill span:not(.status-dot) {
    color: var(--aiden-royal);
}
.user-widget {
    display: flex;
    align-items: center;
    gap: var(--aiden-space-2, 0.5rem);
    min-height: 2.5rem;
    padding: var(--aiden-space-1, 0.25rem) var(--aiden-space-2, 0.5rem) var(--aiden-space-1, 0.25rem) var(--aiden-space-1, 0.25rem);
    border-radius: var(--aiden-radius-md, 0.5rem);
}
.user-widget--clickable {
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.user-widget--clickable:hover,
.user-widget--clickable:focus-visible {
    background: color-mix(in srgb, var(--aiden-royal) 8%, var(--aiden-off-white));
    outline: none;
}
.user-widget--clickable:focus-visible {
    box-shadow: 0 0 0 3px var(--int-focus-ring);
}
.user-menu-header {
    padding: 0.65rem 0.9rem 0.35rem;
    min-width: 12rem;
}
.user-menu-header__name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--int-ink-strong);
    line-height: 1.25;
}
.user-menu-header__meta {
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: var(--int-muted);
    line-height: 1.3;
}
.user-menu-popover.mud-popover,
.lang-menu-popover.mud-popover {
    border: 1px solid var(--int-line);
    border-radius: var(--aiden-radius-md, 0.5rem);
    box-shadow: var(--int-surface-shadow);
    overflow: hidden;
}
.lang-menu-item-content {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.theme-dark-mode .user-widget--clickable:hover,
.theme-dark-mode .user-widget--clickable:focus-visible {
    background: color-mix(in srgb, var(--aiden-royal) 22%, #101625);
}
.theme-dark-mode .user-menu-header__name {
    color: #fff;
}
.theme-dark-mode .user-menu-header__meta {
    color: color-mix(in srgb, #fff 70%, var(--aiden-cool-grey));
}
.user-widget .user-copy {
    display: grid;
    min-width: 0;
    line-height: 1.2;
    color: var(--aiden-warm-black);
}
.user-widget .user-copy strong {
    color: var(--aiden-warm-black);
    font-size: 0.82rem;
    white-space: nowrap;
}
.user-widget .user-copy small {
    margin-top: 0.1rem;
    color: var(--aiden-royal);
    font-size: 0.72rem;
    white-space: nowrap;
}
.avatar {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--aiden-radius-full, 9999px);
    background: color-mix(in srgb, var(--aiden-royal) 16%, var(--aiden-off-white));
    color: var(--aiden-royal);
    font-size: 0.72rem;
    font-weight: 700;
}
.nav-status-card {
    flex: 0 0 auto;
    margin: 0 0.55rem 0.55rem;
    padding: var(--aiden-space-3, 0.75rem);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--aiden-radius-md, 0.5rem);
    color: #fff;
    font-size: 0.72rem;
}
.nav-status-card span {
    display: flex;
    align-items: center;
    gap: var(--aiden-space-2, 0.5rem);
    font-weight: 700;
}
.nav-status-card small {
    display: block;
    margin-top: var(--aiden-space-2, 0.5rem);
    color: rgba(255, 255, 255, 0.55);
}

.metric-card {
    display: flex;
    align-items: center;
    gap: var(--aiden-space-4, 1rem);
    border: 1px solid var(--aiden-cool-grey);
    border-radius: var(--aiden-radius-md, 0.5rem);
    padding: var(--aiden-space-4, 1rem);
    background: var(--aiden-off-white);
}
.metric-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 2.8rem;
    height: 2.8rem;
    border-radius: var(--aiden-radius-md, 0.5rem);
    background: color-mix(in srgb, var(--aiden-royal) 12%, var(--aiden-off-white));
    color: var(--aiden-royal);
    font-size: 1.2rem;
}
.metric-icon--success {
    background: color-mix(in srgb, var(--aiden-success) 16%, var(--aiden-off-white));
    color: #087944;
}
.metric-icon--warning {
    background: color-mix(in srgb, var(--aiden-warning) 18%, var(--aiden-off-white));
    color: var(--aiden-warning);
}
.metric-icon--attention {
    background: color-mix(in srgb, var(--aiden-limelight) 22%, var(--aiden-off-white));
    color: var(--aiden-warm-black);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--aiden-space-4, 1rem);
    flex-wrap: wrap;
    min-height: 3.5rem;
    padding: var(--aiden-space-3, 0.75rem) var(--aiden-space-4, 1rem);
    border: 1px solid var(--aiden-cool-grey);
    border-radius: var(--aiden-radius-md, 0.5rem);
    background: var(--aiden-off-white);
    color: var(--aiden-royal);
    font-size: 0.85rem;
}
.toolbar-status {
    color: #087944;
    font-weight: 700;
}
.toolbar-error {
    color: var(--aiden-danger);
    font-weight: 700;
}

.mud-table.table--compact,
.table--compact {
    margin-top: 0;
    font-size: 0.82rem;
}
.mud-table.table--compact .mud-table-head .mud-table-cell,
.table--compact th {
    color: var(--int-muted) !important;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}
.mud-table.table--compact .mud-table-cell,
.table--compact th,
.table--compact td {
    padding: var(--aiden-space-2, 0.5rem) var(--aiden-space-3, 0.75rem);
    white-space: nowrap;
}
.mud-table.table--compact .mud-table-container .mud-table-root .mud-table-body tr:hover,
.table--compact tbody tr:hover {
    background: color-mix(in srgb, var(--aiden-royal) 4%, var(--aiden-off-white));
}

/* Listeners: trigger cell wraps long webhook URLs on max 3 lines (no horizontal scroll). */
.listeners-trigger-cell {
    white-space: normal !important;
}
.listeners-webhook-path {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    word-break: break-all;
    overflow-wrap: anywhere;
    line-height: 1.3;
}

.empty-state {
    display: grid;
    place-items: center;
    gap: var(--aiden-space-4, 1rem);
    padding: var(--aiden-space-7, 3rem);
    text-align: center;
}
.empty-icon {
    display: grid;
    place-items: center;
    width: 4rem;
    height: 4rem;
    border: 1px solid var(--aiden-cool-grey);
    border-radius: var(--aiden-radius-md, 0.5rem);
    background: color-mix(in srgb, var(--aiden-royal) 6%, var(--aiden-off-white));
    color: var(--aiden-royal);
    font-size: 1.45rem;
}

.notice {
    background: color-mix(in srgb, var(--aiden-royal) 7%, var(--aiden-off-white));
    border-left: 0.35rem solid var(--aiden-royal);
    padding: var(--aiden-space-3, 0.75rem) var(--aiden-space-4, 1rem);
}
.notice--success {
    border-left-color: var(--aiden-success);
    background: color-mix(in srgb, var(--aiden-success) 7%, var(--aiden-off-white));
}
.notice--attention {
    border-left-color: var(--aiden-limelight);
}
.notice--error {
    border-left-color: var(--aiden-danger);
    background: color-mix(in srgb, var(--aiden-danger) 7%, var(--aiden-off-white));
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: var(--aiden-status-pill-radius, var(--aiden-radius-full, 9999px));
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
}
.status-pill--neutral {
    background: color-mix(in srgb, var(--aiden-status-pill-neutral-background, var(--aiden-royal)) 12%, var(--aiden-off-white));
    color: var(--aiden-royal);
}
.status-pill--success {
    background: color-mix(in srgb, var(--aiden-status-pill-ok-background, var(--aiden-success)) 18%, var(--aiden-off-white));
    color: #087944;
}
/* DS attention = limelight primary + on-action text (always pair with a label). */
.status-pill--attention {
    background: color-mix(in srgb, var(--aiden-status-pill-attention-background, var(--aiden-limelight)) 38%, var(--aiden-off-white));
    color: var(--aiden-status-pill-attention-text, var(--aiden-warm-black));
}
.status-pill--error {
    background: color-mix(in srgb, var(--aiden-danger) 14%, var(--aiden-off-white));
    color: var(--aiden-danger);
}

.split-view {
    display: grid;
    grid-template-columns: minmax(15rem, 0.72fr) minmax(0, 1fr) minmax(20rem, 1.15fr);
    gap: var(--aiden-space-4, 1rem);
    min-height: 32rem;
}
.pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-y: auto;
    border: 1px solid var(--aiden-cool-grey);
    border-radius: var(--aiden-radius-md, 0.5rem);
    background: var(--aiden-off-white);
}
.pane-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--aiden-space-2, 0.5rem);
    min-height: 3.5rem;
    padding: var(--aiden-space-3, 0.75rem) var(--aiden-space-4, 1rem);
    border-bottom: 1px solid var(--aiden-cool-grey);
    background: color-mix(in srgb, var(--aiden-off-white) 96%, var(--aiden-royal));
}
.pane-list-item {
    padding: var(--aiden-space-3, 0.75rem) var(--aiden-space-4, 1rem);
    border-bottom: 1px solid var(--aiden-cool-grey);
    cursor: pointer;
    transition: background 0.2s ease;
}
.pane-list-item:hover {
    background: color-mix(in srgb, var(--aiden-royal) 4%, var(--aiden-off-white));
}
.pane-list-item[aria-current="true"] {
    background: color-mix(in srgb, var(--aiden-royal) 8%, var(--aiden-off-white));
    box-shadow: inset 0.25rem 0 0 var(--aiden-limelight);
}

.confirm-row {
    display: flex;
    align-items: flex-start;
    gap: var(--aiden-space-3, 0.75rem);
    flex-wrap: wrap;
    margin-top: var(--aiden-space-4, 1rem);
    padding: var(--aiden-space-3, 0.75rem) var(--aiden-space-4, 1rem);
    border: 1px solid color-mix(in srgb, var(--aiden-sapphire) 35%, var(--aiden-off-white));
    border-radius: var(--aiden-radius-md, 0.5rem);
    background: color-mix(in srgb, var(--aiden-sapphire) 8%, var(--aiden-off-white));
}

.tabs {
    display: flex;
    gap: var(--aiden-space-2, 0.5rem);
    overflow-x: auto;
    padding: var(--aiden-space-2, 0.5rem);
    margin-bottom: var(--aiden-space-4, 1rem);
    border: 1px solid var(--aiden-tabs-border, var(--aiden-cool-grey));
    border-radius: var(--aiden-tabs-radius, var(--aiden-radius-md, 0.5rem));
    background: var(--aiden-tabs-background, var(--aiden-off-white));
    scrollbar-width: thin;
}
.tabs button {
    flex: 0 0 auto;
    border: 0;
    border-radius: var(--aiden-radius-sm, 0.25rem);
    background: transparent;
    color: var(--aiden-tabs-text, var(--aiden-royal));
    font-weight: 700;
    min-height: 2.5rem;
    padding: var(--aiden-space-2, 0.5rem) var(--aiden-space-3, 0.75rem);
    cursor: pointer;
}
.tabs button:hover {
    background: color-mix(in srgb, var(--aiden-royal) 8%, var(--aiden-off-white));
}
.tabs button[aria-selected="true"] {
    background: var(--aiden-tabs-background-active, var(--aiden-limelight));
    color: var(--aiden-tabs-text-active, var(--aiden-warm-black));
}
/* MudTabs: selected tab uses limelight surface (DS filled tab), not underline-only. */
.mud-tabs.portal-tabs .mud-tab {
    color: var(--aiden-tabs-text, var(--aiden-royal)) !important;
    font-weight: 700;
    text-transform: none;
    min-height: 2.5rem;
}
.mud-tabs.portal-tabs .mud-tab.mud-tab-active,
.mud-tabs.portal-tabs .mud-tab[aria-selected="true"] {
    background: var(--aiden-tabs-background-active, var(--aiden-limelight)) !important;
    color: var(--aiden-tabs-text-active, var(--aiden-warm-black)) !important;
    border-radius: var(--aiden-radius-sm, 0.25rem);
}
.mud-tabs.portal-tabs .mud-tabs-toolbar,
.mud-tabs.portal-tabs .mud-tabs-tabbar {
    border: 1px solid var(--aiden-tabs-border, var(--aiden-cool-grey));
    border-radius: var(--aiden-tabs-radius, var(--aiden-radius-md, 0.5rem));
    background: var(--aiden-tabs-background, var(--aiden-off-white));
    min-height: auto;
    padding: var(--aiden-space-2, 0.5rem);
}
.mud-tabs.portal-tabs .mud-tab-slider,
.mud-tabs.portal-tabs .mud-tabs-tabbar-wrapper .mud-tab-slider {
    display: none;
}

.theme-dark-mode .env-pill {
    border-color: color-mix(in srgb, var(--int-line) 65%, var(--aiden-cool-grey));
    background: color-mix(in srgb, #101625 82%, var(--aiden-royal));
}
.theme-dark-mode .env-pill strong {
    color: #fff;
}
.theme-dark-mode .env-pill span:not(.status-dot) {
    color: color-mix(in srgb, #fff 78%, var(--aiden-cool-grey));
}
.theme-dark-mode .user-widget .user-copy strong {
    color: #fff;
}
.theme-dark-mode .user-widget .user-copy small {
    color: color-mix(in srgb, var(--aiden-cool-grey) 76%, #fff);
}
.theme-dark-mode .avatar {
    background: color-mix(in srgb, var(--aiden-royal) 36%, #101625);
    color: #e7f0ff;
}
.theme-dark-mode .status-dot {
    background: color-mix(in srgb, var(--aiden-success) 86%, #7ae6b0);
}
.theme-dark-mode .nav-status-card {
    border-color: rgba(255, 255, 255, 0.22);
    background: color-mix(in srgb, #121a2b 72%, var(--aiden-royal));
}
.theme-dark-mode .nav-status-card small {
    color: rgba(255, 255, 255, 0.68);
}
.theme-dark-mode .metric-card,
.theme-dark-mode .toolbar,
.theme-dark-mode .pane,
.theme-dark-mode .tabs,
.theme-dark-mode .mud-table.table--compact {
    border-color: var(--int-line);
    background: color-mix(in srgb, #121a2b 86%, var(--aiden-royal));
}
.theme-dark-mode .metric-icon {
    background: color-mix(in srgb, var(--aiden-royal) 28%, #101625);
    color: #d9e6f6;
}
.theme-dark-mode .metric-icon--success {
    background: color-mix(in srgb, var(--aiden-success) 26%, #101625);
    color: #7ae6b0;
}
.theme-dark-mode .metric-icon--warning {
    background: color-mix(in srgb, var(--aiden-warning) 26%, #101625);
    color: #ffb4ad;
}
.theme-dark-mode .metric-icon--attention {
    background: color-mix(in srgb, var(--aiden-limelight) 24%, #101625);
    color: #f3f9cd;
}
.theme-dark-mode .toolbar,
.theme-dark-mode .toolbar-status,
.theme-dark-mode .toolbar-error {
    color: #d9e6f6;
}
.theme-dark-mode .toolbar-status {
    color: #7ae6b0;
}
.theme-dark-mode .toolbar-error {
    color: #ffb4ad;
}
.theme-dark-mode .mud-table.table--compact .mud-table-head .mud-table-cell {
    color: color-mix(in srgb, #fff 70%, var(--aiden-cool-grey)) !important;
    background: color-mix(in srgb, #121a2b 88%, var(--aiden-royal));
}
.theme-dark-mode .mud-table.table--compact .mud-table-container .mud-table-root .mud-table-body tr:hover {
    background: color-mix(in srgb, var(--aiden-royal) 14%, #121a2b);
}
.theme-dark-mode .empty-icon {
    border-color: var(--int-line);
    background: color-mix(in srgb, var(--aiden-royal) 20%, #101625);
    color: #d9e6f6;
}
.theme-dark-mode .notice {
    background: color-mix(in srgb, var(--aiden-royal) 16%, #101625);
    color: #e7f0ff;
}
.theme-dark-mode .notice--success {
    background: color-mix(in srgb, var(--aiden-success) 16%, #101625);
}
.theme-dark-mode .notice--error {
    background: color-mix(in srgb, var(--aiden-danger) 14%, #101625);
}
.theme-dark-mode .status-pill--neutral {
    background: color-mix(in srgb, var(--aiden-royal) 28%, #101625);
    color: #d9e6f6;
}
.theme-dark-mode .status-pill--success {
    background: color-mix(in srgb, var(--aiden-success) 22%, #101625);
    color: #7ae6b0;
}
.theme-dark-mode .status-pill--attention {
    background: color-mix(in srgb, var(--aiden-limelight) 28%, #101625);
    color: #f3f9cd;
}
.theme-dark-mode .status-pill--error {
    background: color-mix(in srgb, var(--aiden-danger) 22%, #101625);
    color: #ffb4ad;
}
.theme-dark-mode .tabs button {
    color: #d9e6f6;
}
.theme-dark-mode .tabs button:hover {
    background: color-mix(in srgb, var(--aiden-royal) 18%, #121a2b);
}
.theme-dark-mode .tabs button[aria-selected="true"],
.theme-dark-mode .mud-tabs.portal-tabs .mud-tab.mud-tab-active,
.theme-dark-mode .mud-tabs.portal-tabs .mud-tab[aria-selected="true"] {
    background: var(--aiden-limelight) !important;
    color: var(--aiden-warm-black) !important;
}
.theme-dark-mode .split-view .pane-header {
    border-bottom-color: var(--int-line);
    background: color-mix(in srgb, #121a2b 84%, var(--aiden-royal));
}
.theme-dark-mode .pane-list-item {
    border-bottom-color: var(--int-line);
}
.theme-dark-mode .pane-list-item:hover {
    background: color-mix(in srgb, var(--aiden-royal) 16%, #121a2b);
}
.theme-dark-mode .pane-list-item[aria-current="true"] {
    background: color-mix(in srgb, var(--aiden-royal) 22%, #121a2b);
}
.theme-dark-mode .confirm-row {
    border-color: color-mix(in srgb, var(--aiden-sapphire) 48%, #101625);
    background: color-mix(in srgb, var(--aiden-sapphire) 16%, #101625);
    color: #e7f0ff;
}

/* ---- User guide (/help) ---- */
.help-layout {
    display: grid;
    grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
    gap: var(--aiden-space-4, 1rem);
    align-items: start;
}
.help-toc {
    position: sticky;
    top: calc(var(--portal-topbar-height, 4rem) + 0.75rem);
    padding: 0.85rem 0.75rem;
}
.help-toc__title {
    margin: 0 0 0.5rem !important;
    color: var(--int-ink-strong) !important;
}
.help-toc__nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.help-toc__link {
    display: block;
    border-radius: var(--aiden-radius-sm, 0.35rem);
    padding: 0.35rem 0.5rem;
    color: var(--int-muted);
    font-size: 0.82rem;
    line-height: 1.3;
    text-decoration: none;
}
.help-toc__link:hover,
.help-toc__link:focus-visible {
    color: var(--int-ink-strong);
    background: color-mix(in srgb, var(--int-primary) 8%, var(--int-surface));
    outline: none;
}
.help-content {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
}
.help-section {
    padding: 1rem 1.15rem 1.1rem;
    scroll-margin-top: calc(var(--portal-topbar-height, 4rem) + 0.75rem);
}
.help-section .mud-typography-h5 {
    margin: 0 0 0.55rem !important;
    color: var(--int-ink-strong) !important;
    font-family: var(--aiden-font-display) !important;
}
.help-section .mud-typography-body1 {
    margin: 0 0 0.55rem !important;
    color: var(--int-ink) !important;
    line-height: 1.5 !important;
}
.help-section__subtitle {
    margin: 0.75rem 0 0.35rem !important;
    color: var(--int-ink-strong) !important;
}
.help-list {
    margin: 0 0 0.65rem;
    padding-left: 1.2rem;
    color: var(--int-ink);
    line-height: 1.45;
}
.help-list li + li {
    margin-top: 0.35rem;
}
.help-list--ordered {
    padding-left: 1.35rem;
}
.help-code {
    font-family: var(--aiden-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 0.84em;
    padding: 0.1em 0.35em;
    border-radius: var(--aiden-radius-sm, 0.35rem);
    background: color-mix(in srgb, var(--int-primary) 8%, var(--int-surface));
    color: var(--int-ink-strong);
    word-break: break-word;
}
.help-pre {
    margin: 0.5rem 0 0.85rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--int-line);
    border-radius: var(--int-surface-radius);
    background: color-mix(in srgb, var(--int-canvas) 70%, var(--int-surface));
    overflow-x: auto;
}
.help-pre .help-code {
    padding: 0;
    background: transparent;
    white-space: pre;
    display: block;
    font-size: 0.8rem;
    line-height: 1.45;
}
.help-note {
    margin: 0.35rem 0 0 !important;
    color: var(--int-muted) !important;
}
.theme-dark-mode .help-code {
    background: color-mix(in srgb, var(--aiden-royal) 18%, #101625);
    color: #e7f0ff;
}
.theme-dark-mode .help-pre {
    background: color-mix(in srgb, #121a2b 88%, var(--aiden-royal));
    border-color: var(--int-line);
}
@media (max-width: 960px) {
    .help-layout {
        grid-template-columns: 1fr;
    }
    .help-toc {
        position: static;
    }
    .help-toc__nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
}

@media (max-width: 640px) {
    .page-heading { align-items: stretch; flex-direction: column; }
    .env-pill span:not(.status-dot),
    .user-widget .user-copy {
        display: none;
    }
    .user-widget {
        padding: 0;
    }
    .language-select-container {
        width: 18ch;
        min-width: 18ch;
        max-width: 18ch;
        flex-basis: 18ch;
    }
}

/* ---- New version banner (works without Blazor circuit) ---- */
.aiden-new-version-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: var(--int-primary-deeper, #243447);
    color: #f8fafc;
    box-shadow: 0 -8px 28px rgba(16, 29, 56, 0.28);
    border-top: 1px solid color-mix(in srgb, var(--int-secondary, #BED731) 55%, transparent);
}
.aiden-new-version-banner[hidden] {
    display: none !important;
}
.aiden-new-version-banner__inner {
    max-width: var(--aiden-layout-content-max-width, 1440px);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.aiden-new-version-banner__message {
    flex: 1 1 16rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
}
.aiden-new-version-banner__reload {
    appearance: none;
    border: none;
    cursor: pointer;
    border-radius: var(--aiden-radius-md, 0.5rem);
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--aiden-color-text-on-action, #32363D);
    background: var(--aiden-color-action-primary, var(--int-secondary, #BFD730));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.aiden-new-version-banner__reload:hover {
    filter: brightness(1.05);
}
.aiden-new-version-banner__reload:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}
.theme-dark-mode .aiden-new-version-banner {
    background: #0f121a;
    border-top-color: color-mix(in srgb, var(--int-secondary, #BED731) 40%, #33323e);
}

/* Nested MudNavGroup labels/icons on royal drawer */
.mud-drawer.portal-drawer .mud-nav-group,
.mud-drawer.portal-drawer .mud-nav-group .mud-nav-link {
    color: #d9e6f6 !important;
}
.mud-drawer.portal-drawer .mud-nav-group > .mud-nav-link {
    margin: 0.15rem 0.55rem;
    border-radius: var(--aiden-radius-md, 0.5rem) !important;
    min-height: 2.85rem;
}
.mud-drawer.portal-drawer .mud-nav-group .mud-nav-group {
    margin-left: 0.35rem;
}
.mud-drawer.portal-drawer .mud-expand-panel {
    background: transparent !important;
    color: inherit !important;
    box-shadow: none !important;
    border: 0 !important;
}
.mud-drawer.portal-drawer .mud-paper {
    background: transparent !important;
    color: inherit !important;
    box-shadow: none !important;
    border: 0 !important;
}
.portal-nav-menu {
    height: 100%;
}
@media (max-width: 959.95px) {
    .user-widget .user-copy {
        display: none;
    }
}


/* Viewport shell: footer always visible; home scrolls; grids scroll internally */
:root {
    --portal-footer-height: 3.25rem;
    /* Fallback when flex chain cannot resolve a concrete height */
    --portal-grid-height: calc(100vh - var(--portal-topbar-height, 64px) - var(--portal-footer-height) - 5.5rem);
}

html, body, #app {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}
body {
    overflow: hidden;
}

.portal-main > .page-shell > .mud-container {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Home / settings / forms: page-shell scrolls; content can exceed viewport */
.home-page {
    min-height: 0 !important;
    flex: 0 0 auto;
}

/*
  Full-page grids only (direct child of the page container, or opt-in class).
  Nested grids inside settings/forms keep a compact height and the page scrolls.
*/
.page-shell:has(> .mud-container > .mud-data-grid),
.page-shell:has(> .mud-container > .portal-full-page-grid) {
    overflow: hidden;
}

.page-shell:has(> .mud-container > .mud-data-grid) > .mud-container,
.page-shell:has(> .mud-container > .portal-full-page-grid) > .mud-container {
    overflow: hidden;
    height: 100%;
    min-height: 0;
}

.page-shell > .mud-container > .mud-data-grid,
.page-shell > .mud-container > .portal-full-page-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    /* Prefer flex fill of the content area; vh-calc remains available as fallback var */
    height: 100% !important;
    display: flex !important;
    flex-direction: column;
}

.page-shell > .mud-container > .mud-data-grid .mud-table-container,
.page-shell > .mud-container > .portal-full-page-grid .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto !important;
}

/* If a page still sets an inline Height, neutralize it on full-page grids */
.page-shell > .mud-container > .mud-data-grid.mud-table,
.page-shell > .mud-container > .portal-full-page-grid.mud-table {
    height: 100% !important;
    max-height: none !important;
}

/* Nested grids (settings Put Away, etc.): ~10 dense rows, internal scroll.
   Opt-out: .portal-full-page-grid must always fill the page content area. */
.page-shell .mud-paper .mud-data-grid:not(.portal-full-page-grid),
.page-shell .mud-form .mud-data-grid:not(.portal-full-page-grid),
.page-shell .mud-grid .mud-data-grid:not(.portal-full-page-grid) {
    flex: 0 0 auto !important;
    height: 22rem !important; /* ~10 dense rows + toolbar/pager */
    max-height: 22rem !important;
    min-height: 14rem !important;
    display: flex !important;
    flex-direction: column;
}

.page-shell .mud-paper .mud-data-grid:not(.portal-full-page-grid) .mud-table-container,
.page-shell .mud-form .mud-data-grid:not(.portal-full-page-grid) .mud-table-container,
.page-shell .mud-grid .mud-data-grid:not(.portal-full-page-grid) .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto !important;
}

/* Explicit full-page opt-in (also wins when still wrapped by MudGrid/etc.) */
.page-shell .mud-data-grid.portal-full-page-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column;
}

.page-shell .mud-data-grid.portal-full-page-grid .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto !important;
}

.page-shell:has(.mud-data-grid.portal-full-page-grid) {
    overflow: hidden;
}

.page-shell:has(.mud-data-grid.portal-full-page-grid) > .mud-container {
    overflow: hidden;
    height: 100%;
    min-height: 0;
}

/* Event Definitions: header + tabs + full-height grids */
.page-shell:has(.event-definitions-page) {
    overflow: hidden;
}
.page-shell:has(.event-definitions-page) > .mud-container {
    overflow: hidden;
    height: 100%;
    min-height: 0;
}
.event-definitions-page {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.event-definitions-page__header {
    flex: 0 0 auto;
}
.event-definitions-page__tabs.mud-tabs,
.event-definitions-page .mud-tabs.event-definitions-page__tabs {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
}
.event-definitions-page__tabs .mud-tabs-toolbar,
.event-definitions-page__tabs .mud-tabs-tabbar {
    flex: 0 0 auto !important;
}
.event-definitions-page__tabs .mud-tabs-panels,
.event-definitions-page__tabs .mud-tabs-panels-keep-alive {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}
.event-definitions-page__tabs .mud-tabpanels,
.event-definitions-page__tabs .mud-tabs-panels > .mud-tab-panel,
.event-definitions-page__tabs .event-definitions-page__panel,
.event-definitions-page__tabs .mud-tabs-panels > div {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}
.event-definitions-page__tabs .mud-data-grid.portal-full-page-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
}
.event-definitions-page__tabs .mud-data-grid.portal-full-page-grid .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto !important;
}

/* Side menu: no horizontal scrollbar; clip long labels */
.mud-drawer.portal-drawer,
.mud-drawer.portal-drawer .mud-drawer-content,
.portal-drawer-shell {
    overflow-x: hidden !important;
    max-width: 100%;
}
.mud-drawer.portal-drawer .mud-navmenu,
.mud-drawer.portal-drawer .mud-nav-link,
.mud-drawer.portal-drawer .mud-nav-group {
    max-width: 100%;
    min-width: 0;
}
.mud-drawer.portal-drawer .mud-nav-link .mud-nav-link-text {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    min-width: 0;
}
.mud-drawer.portal-drawer .mud-nav-group-button,
.mud-drawer.portal-drawer .mud-nav-group > .mud-nav-link {
    max-width: calc(100% - 0.2rem);
}

/* Table/grid footer (pager): never show a tiny vertical scrollbar */
.page-shell .mud-data-grid,
.page-shell .mud-table {
    overflow: hidden !important;
}
.page-shell .mud-data-grid > .mud-table-container,
.page-shell .mud-table > .mud-table-container {
    /* only the body area scrolls */
    overflow-x: auto !important;
    overflow-y: auto !important;
}
.page-shell .mud-data-grid-toolbar,
.page-shell .mud-table-toolbar,
.page-shell .mud-data-grid-pager,
.page-shell .mud-table-pagination,
.page-shell .mud-table-pagination-toolbar,
.page-shell .mud-data-grid > .mud-paper,
.page-shell .mud-table-pagination .mud-toolbar {
    overflow: hidden !important;
    flex: 0 0 auto !important;
    min-height: fit-content;
}
.page-shell .mud-table-pagination,
.page-shell .mud-data-grid-pager {
    /* avoid 1px clip that triggers a useless vertical scrollbar */
    max-height: none !important;
    height: auto !important;
}

/* Shell stacking aligned with MudTheme.ZIndex / --mud-zindex-* variables.
   Do NOT force .mud-popover z-index with !important — that breaks Mud's cascading
   values used by MudSelect/MudAutocomplete inside MudDialog
   (.mud-dialog .mud-popover-cascading-value => dialog + 3). */

.mud-main-content.portal-main,
.portal-main {
    position: relative;
    z-index: 1;
    overflow-x: clip;
}

/* Custom app-bar widgets (not Mud popovers) stay above the app bar surface */
.appbar-right-controls,
.appbar-menu-panel {
    z-index: calc(var(--mud-zindex-appbar, 1300) + 20);
}
.appbar-menu-backdrop {
    /* Below app bar (+1); still above .portal-main (z-index: 1) for outside-click dismiss. */
    z-index: calc(var(--mud-zindex-appbar, 1300) - 1);
}

/* Ensure dialog host uses theme dialog layer (select lists cascade above it) */
.mud-dialog-container {
    z-index: var(--mud-zindex-dialog, 1400) !important;
}

/* ---- Dialogs: center in viewport, never under app bar ---- */
.mud-dialog-container {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: calc(var(--portal-topbar-height, 64px) + 0.75rem) 1rem 1.25rem !important;
    box-sizing: border-box !important;
    z-index: var(--mud-zindex-dialog, 1400) !important;
}
.mud-dialog-container.mud-dialog-topcenter,
.mud-dialog-container.mud-dialog-topleft,
.mud-dialog-container.mud-dialog-topright {
    align-items: center !important;
}
.mud-dialog {
    margin-top: 0 !important;
    max-height: calc(100vh - var(--portal-topbar-height, 64px) - 2.5rem) !important;
}
.mud-dialog .mud-dialog-content {
    max-height: calc(100vh - var(--portal-topbar-height, 64px) - 8rem);
    overflow: auto;
}

/* ---- Picklist Wizard: fill shell; sticky stepper actions; large step-2 grid ---- */
.picklist-wizard {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    gap: 0.5rem;
}
.page-shell:has(.picklist-wizard) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.page-shell:has(.picklist-wizard) > .mud-container {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.picklist-wizard__title {
    flex: 0 0 auto;
}
.picklist-wizard .mud-stepper {
    flex: 1 1 auto;
    min-height: 0;
    display: flex !important;
    flex-direction: column !important;
    height: 100%;
}
.picklist-wizard .mud-stepper-nav {
    flex: 0 0 auto;
}
.picklist-wizard .mud-stepper-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto !important;
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    padding: 0.5rem 0 0.75rem !important;
    border: 0 !important;
}
.picklist-wizard .mud-step {
    flex: 1 1 auto;
    min-height: 0;
    height: 100% !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}
/* MudStepper action buttons row (Next/Back/Reset) always visible */
.picklist-wizard .mud-stepper-actions,
.picklist-wizard__actions,
.picklist-wizard .mud-stepper > .mud-stack:last-child,
.picklist-wizard .mud-stepper > .d-flex:last-child,
.picklist-wizard .mud-stepper .mud-stepper-content + .mud-stack,
.picklist-wizard .mud-stepper .mud-stepper-content ~ .mud-stack,
.picklist-wizard .mud-stepper .mud-stepper-content ~ .d-flex {
    flex: 0 0 auto !important;
    padding-top: 0.5rem;
    margin-top: auto;
    border-top: 1px solid var(--int-line, var(--mud-palette-lines-default));
    background: var(--int-canvas, var(--mud-palette-background));
    position: sticky;
    bottom: 0;
    z-index: 2;
}

.picklist-wizard-step-body {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.picklist-wizard-step-body--scroll {
    overflow: auto;
}
.picklist-wizard-documents-grid,
.picklist-wizard-feedback-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    display: flex !important;
    flex-direction: column;
}
.picklist-wizard-documents-grid .mud-table-container,
.picklist-wizard-feedback-grid .mud-table-container {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto !important;
}

/* Wizard grids must ignore compact nested-grid cap */
.page-shell .picklist-wizard .mud-data-grid.picklist-wizard-documents-grid,
.page-shell .picklist-wizard .mud-data-grid.picklist-wizard-feedback-grid {
    height: 100% !important;
    max-height: none !important;
    min-height: 12rem !important;
    flex: 1 1 auto !important;
}

/* MudStepper action bar: last direct flex row with buttons under content */
.picklist-wizard .mud-stepper > .d-flex,
.picklist-wizard .mud-stepper > .mud-stack {
    flex: 0 0 auto !important;
}
.picklist-wizard .mud-stepper > .mud-stepper-content {
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

/* Title + stepper fill page container */
.page-shell:has(.picklist-wizard) > .mud-container > .picklist-wizard {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

/* Picklist wizard stock indicator: distinct red/orange/green in light mode (dark mode keeps palette). */
:root:not(:has(.theme-dark-mode)) .picklist-wizard .picklist-stock-indicator.mud-error-text {
    color: #D92D20 !important;
}
:root:not(:has(.theme-dark-mode)) .picklist-wizard .picklist-stock-indicator.mud-warning-text {
    color: #E67700 !important;
}
:root:not(:has(.theme-dark-mode)) .picklist-wizard .picklist-stock-indicator.mud-success-text {
    color: #16A34A !important;
}

/* ---- Disabled / read-only field text contrast ---- */
.mud-input.mud-disabled,
.mud-input.mud-disabled input,
.mud-input.mud-disabled textarea,
.mud-input-slot.mud-input-root-readonly,
.mud-input input:disabled,
.mud-input textarea:disabled,
.mud-input input[readonly],
.mud-input textarea[readonly],
.mud-select.mud-disabled .mud-select-input,
.mud-input-control.mud-input-control-readonly .mud-input-slot,
.mud-typography.mud-disabled,
.mud-input-label.mud-disabled,
.mud-checkbox.mud-disabled .mud-typography,
.mud-radio.mud-disabled .mud-typography {
    color: var(--mud-palette-text-disabled) !important;
    -webkit-text-fill-color: var(--mud-palette-text-disabled) !important;
    opacity: 1 !important;
}
.mud-input.mud-disabled .mud-icon-root,
.mud-select.mud-disabled .mud-icon-root {
    color: var(--mud-palette-text-disabled) !important;
    opacity: 1 !important;
}

/* Dark mode side menu: darker surface (table-like), keep nav readable */
.theme-dark-mode .mud-drawer.portal-drawer,
.theme-dark-mode .mud-drawer.portal-drawer .mud-drawer-content {
    background: var(--int-sidebar-gradient, #2a3344) !important;
    color: #e8eef5 !important;
    border-right-color: rgba(255, 255, 255, 0.06);
}
.theme-dark-mode .portal-drawer-brand {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}
.theme-dark-mode .mud-drawer.portal-drawer .mud-nav-link {
    color: #d7dee8 !important;
}
.theme-dark-mode .mud-drawer.portal-drawer .mud-nav-link:hover,
.theme-dark-mode .mud-drawer.portal-drawer .mud-nav-link.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.10) !important;
}
.theme-dark-mode .portal-brand-title {
    color: #f3f6fa !important;
}

