@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root,
.portal-theme-platform {
    --portal-primary: #0F766E;
    --portal-primary-hover: #115E59;
    --portal-primary-soft: #CCFBF1;
    --portal-primary-soft-hover: #99F6E4;
    --portal-primary-soft-border: #5EEAD4;
    --portal-accent: #059669;
    --portal-accent-soft: #D1FAE5;
    --portal-accent-border: #A7F3D0;
    --portal-text: #0F172A;
    --portal-text-muted: #475569;
    --portal-surface: #F8FAFC;
    --portal-border: #CBD5E1;
    --portal-nav-gradient-start: #0F766E;
    --portal-nav-gradient-end: #115E59;
    --portal-nav-icon: #99F6E4;
    --portal-nav-link-hover-bg: rgba(255, 255, 255, 0.14);
    --portal-nav-link-active-bg: rgba(255, 255, 255, 0.22);
    --portal-overlay-header-gradient-start: #0F766E;
    --portal-overlay-header-gradient-end: #059669;
    --portal-row-hover: #F0FDFA;
    --portal-row-selected: #CCFBF1;
    --portal-row-selected-hover: #99F6E4;
    --portal-focus-ring: rgba(15, 118, 110, 0.14);
}

.portal-theme-tenant {
    --portal-primary: #1565C0;
    --portal-primary-hover: #0D47A1;
    --portal-primary-soft: #E8F0FE;
    --portal-primary-soft-hover: #D2E4FC;
    --portal-primary-soft-border: #C5D8F8;
    --portal-accent: #1976D2;
    --portal-accent-soft: #E3F2FD;
    --portal-accent-border: #CFE3FC;
    --portal-text: #0F172A;
    --portal-text-muted: #757575;
    --portal-surface: #F8FAFC;
    --portal-border: #CBD5E1;
    --portal-nav-gradient-start: rgb(5, 39, 103);
    --portal-nav-gradient-end: #1E1165;
    --portal-nav-icon: #7CB3FF;
    --portal-nav-link-hover-bg: rgba(255, 255, 255, 0.12);
    --portal-nav-link-active-bg: rgba(255, 255, 255, 0.18);
    --portal-overlay-header-gradient-start: #1565C0;
    --portal-overlay-header-gradient-end: #1976D2;
    --portal-row-hover: #FAFCFF;
    --portal-row-selected: #E8F0FE;
    --portal-row-selected-hover: #DCE8FB;
    --portal-focus-ring: rgba(21, 101, 192, 0.12);
}

html, body {
    font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: var(--portal-text);
    background-color: var(--portal-surface);
}

a, .btn-link {
    color: var(--portal-primary);
}

.btn-primary {
    color: #fff;
    background-color: var(--portal-primary);
    border-color: var(--portal-primary);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--portal-focus-ring);
}

/* ── Page content area ───────────────────────────────────────── */
.content {
    padding: 2rem;
}

/* ── Suppress the oversized default h1 ──────────────────────── */
/*    Pages should use .page-header instead of bare <h1>         */
h1 {
    font-size: 1.5rem !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em;
    margin-bottom: 1rem;
    color: #212121;
}

h1:focus {
    outline: none;
}

/* ── Material-style tables ───────────────────────────────────── */
.table {
    font-size: 0.875rem;
    border-collapse: collapse;
    border: none;
}

.table thead th {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #757575;
    border-top: none;
    border-bottom: 2px solid #e0e0e0;
    padding: 12px 16px;
}

.table tbody td {
    padding: 12px 16px;
    border-top: none;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table-bordered,
.table-bordered thead th,
.table-bordered tbody td {
    border: none;
    border-bottom: 1px solid #e0e0e0;
}

/* ── Radzen buttons: Material border-radius + primary blue ───── */
.rz-button {
    border-radius: 4px !important;
}

.rz-button.rz-primary {
    background-color: var(--portal-primary) !important;
    border-color: var(--portal-primary) !important;
    color: #fff !important;
}

.rz-button.rz-primary:hover {
    background-color: var(--portal-primary-hover) !important;
    border-color: var(--portal-primary-hover) !important;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e51420;
}

.validation-message {
    color: #e51420;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ── Heartbeat pulse animation for Fresh indicators ────────── */
@keyframes pulse {
    0%   { opacity: 1; transform: scale(1); }
    50%  { opacity: 0.5; transform: scale(1.3); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── Document Feed Overlay ───────────────────────────────────────── */

.mp-feed-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1499;
    background: rgba(0,0,0,0.42);
    backdrop-filter: blur(2px);
}

.mp-feed-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

@media (min-width: 768px) {
    .mp-feed-overlay {
        top: 4vh;
        left: 50%;
        transform: translateX(-50%);
        width: min(1060px, 96vw);
        height: 92vh;
        inset: unset;
        top: 4vh;
        left: 50%;
        border-radius: 10px;
        box-shadow: 0 20px 60px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.1);
    }
}

.mp-feed-overlay-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 0.9rem;
    background: linear-gradient(90deg, var(--portal-overlay-header-gradient-start), var(--portal-overlay-header-gradient-end));
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    flex-shrink: 0;
    min-height: 2.6rem;
}

.mp-feed-overlay-header .material-symbols-outlined {
    font-size: 1.1rem;
    opacity: 0.9;
}

.mp-feed-close-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    border-radius: 4px;
    padding: 0.2rem;
    display: flex;
    align-items: center;
    line-height: 1;
    transition: background 0.12s, color 0.12s;
}

.mp-feed-close-btn:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

.mp-feed-overlay-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ── Embedded doc feed panel ─────────────────────────────────────── */

.doc-feed-panel {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.doc-feed-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    background: #f5f7fa;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #616161;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.doc-feed-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.doc-feed-node-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: #eef2fb;
    border: 1px solid #c5d3f0;
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    font-size: 0.72rem;
    color: #3b5bdb;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

.doc-feed-node-pill .material-symbols-outlined {
    font-size: 0.8rem;
}

/* Buttons */
.doc-feed-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.28rem 0.6rem;
    border-radius: 4px;
    border: 1px solid #bdbdbd;
    background: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    color: #424242;
    line-height: 1.2;
    transition: background 0.12s, border-color 0.12s;
}

.doc-feed-btn:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #9e9e9e;
}

.doc-feed-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.doc-feed-btn .material-symbols-outlined {
    font-size: 0.88rem;
}

.doc-feed-btn-secondary { border-color: #bdbdbd; color: #424242; }

.doc-feed-btn-warn {
    border-color: #fb8c00;
    color: #e65100;
    background: #fff8e1;
}
.doc-feed-btn-warn:hover:not(:disabled) { background: #fff3e0; }

/* Loading / empty */
.doc-feed-loading {
    display: flex;
    justify-content: center;
    padding: 2.5rem;
}

.doc-feed-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #e0e0e0;
    border-top-color: #1565C0;
    border-radius: 50%;
    animation: doc-spin 0.75s linear infinite;
}

@keyframes doc-spin { to { transform: rotate(360deg); } }

.doc-feed-empty {
    text-align: center;
    color: #9e9e9e;
    padding: 2.5rem 1rem;
    font-size: 0.9rem;
}

/* ── Desktop table ───────────────────────────────────────────────── */
.doc-feed-table-wrap {
    overflow-x: auto;
}

.doc-feed-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.doc-feed-table thead tr {
    background: #fafafa;
    border-bottom: 2px solid #e8e8e8;
}

.doc-feed-table thead th {
    padding: 0.45rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #757575;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    text-align: left;
}

.doc-feed-table tbody tr {
    border-bottom: 1px solid #f2f2f2;
    transition: background 0.1s;
}

.doc-feed-table tbody tr:hover {
    background: #f7faff;
}

.doc-feed-table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
}

.doc-feed-row-action { background: #fff8f8; }
.doc-feed-row-review { background: #fffdf2; }

.doc-feed-col-icon { width: 32px; text-align: center; padding-left: 0.5rem; }
.doc-feed-col-dot  { width: 24px; text-align: center; padding-right: 0.5rem; }

.doc-feed-icon { font-size: 1rem; vertical-align: middle; }

.doc-feed-cell-label { font-weight: 500; }
.doc-feed-label-warn { color: #e65100; }

.doc-feed-cell-muted {
    color: #9e9e9e;
    font-size: 0.78rem;
}

.doc-feed-cell-sender {
    font-size: 0.8rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.doc-feed-cell-time {
    white-space: nowrap;
    font-size: 0.78rem;
    color: #757575;
}

.doc-feed-confidence {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: #616161;
}

/* Status */
.doc-feed-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.doc-feed-status .material-symbols-outlined { font-size: 0.88rem; }
.doc-feed-status-danger { color: #c62828; }
.doc-feed-status-warn   { color: #e65100; }
.doc-feed-status-success { color: #2e7d32; }

/* Node dot */
.doc-feed-node-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    vertical-align: middle;
}

/* Badges */
.doc-feed-badge {
    display: inline-block;
    padding: 0.12em 0.45em;
    border-radius: 3px;
    font-size: 0.67rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: middle;
}

.doc-feed-badge-info    { background: #e3f2fd; color: #1565C0; }
.doc-feed-badge-warn    { background: #fff8e1; color: #e65100; }
.doc-feed-badge-danger  { background: #ffebee; color: #c62828; }
.doc-feed-badge-success { background: #e8f5e9; color: #2e7d32; }

/* PHI */
.doc-feed-phi {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    color: #e65100;
    font-style: italic;
}
.doc-feed-phi .material-symbols-outlined { font-size: 0.82rem; }

/* ── Mobile cards ────────────────────────────────────────────────── */
.doc-feed-cards {
    padding: 0.5rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.doc-feed-card {
    padding: 0.6rem 0.7rem;
    border: 1px solid #e8ecf2;
    border-radius: 7px;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: #fff;
}

.doc-feed-card-action { border-left: 3px solid #c62828; background: #fff9f9; }
.doc-feed-card-review { border-left: 3px solid #fb8c00; background: #fffdf5; }
.doc-feed-card-info   { border-left: 3px solid #e0e4ef; }

.doc-feed-card-row1 {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
}

.doc-feed-card-label {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    min-width: 0;
    color: #212121;
}

.doc-feed-card-badges {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.doc-feed-card-row2 {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    font-size: 0.73rem;
    color: #9e9e9e;
}

/* ── Edit Tenant dialog title styling ───────────────────────── */
.tenant-edit-dialog .rz-dialog-titlebar {
    background: linear-gradient(90deg, #0d6efd, #0a58ca);
    color: #ffffff;
    border-bottom: 1px solid #0a4fb8;
    padding: 0.55rem 0.85rem;
    min-height: 2.2rem;
    display: flex;
    align-items: center;
}

.tenant-edit-dialog .rz-dialog-title {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
}

.tenant-edit-dialog .rz-dialog-titlebar .rz-dialog-titlebar-close {
    color: #ffffff;
    align-self: center;
    margin-top: 0;
}

/* ── Compact form: smaller font for all Radzen inputs & dropdowns ── */
/*    Apply class="tandem-compact-form" to any container.            */
/*    --rz-body-font-size is the root from which every Radzen        */
/*    component derives its font: inputs, dropdowns, datepickers,    */
/*    textareas, datagrid cells, and popup list items all chain back  */
/*    to it via --rz-input-font-size: var(--rz-body-font-size).      */
.tandem-compact-form {
    --rz-body-font-size: 0.82rem;
}

/* ── Radzen badges: consistent size & padding in compact grids ── */
/*    Prevents badge text from being clipped when parent font is    */
/*    scaled down via --rz-body-font-size.                          */
.rz-badge {
    font-size: 0.7rem !important;
    padding: 0.2em 0.55em !important;
    line-height: 1.4 !important;
    border-radius: 4px !important;
    white-space: nowrap;
    display: inline-block;
}

/* ── Page header block ───────────────────────────────────────────── */
/*    Usage:                                                          */
/*    <div class="page-header">                                       */
/*        <div class="page-header-title">                             */
/*            <span class="material-symbols-outlined">dashboard</span>*/
/*            Global Management                                       */
/*        </div>                                                      */
/*        <p class="page-header-subtitle">Optional subtitle text</p> */
/*    </div>                                                          */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1.75rem;
    padding-bottom: 0.875rem;
    border-bottom: 2px solid var(--portal-border);
}

.page-header-title {
    display: flex !important;
    align-items: center !important;
    gap: 0.6rem;
    font-family: 'Roboto', sans-serif !important;
    font-size: 1.35rem !important;
    font-weight: 500 !important;
    color: var(--portal-text) !important;
    letter-spacing: 0.01em;
    line-height: 1.3;
    margin: 0 !important;
}

.page-header-title .material-symbols-outlined,
.page-header-title .material-icons {
    font-size: 1.5rem;
    color: var(--portal-primary);
    flex-shrink: 0;
    vertical-align: middle;
}

.page-header-subtitle {
    font-size: 0.82rem !important;
    color: var(--portal-text-muted) !important;
    margin: 0 !important;
    padding-left: 2.1rem;
    font-weight: 400;
}

.components-reconnect-hide {
    display: none;
}

.components-reconnect-show,
.components-reconnect-failed,
.components-reconnect-rejected {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.components-reconnect-card {
    width: min(520px, 100%);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
    border-top: 4px solid #b71c1c;
    padding: 1rem 1.25rem;
    color: #212121;
}

.components-reconnect-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.components-reconnect-message,
.components-reconnect-attempt {
    font-size: 0.85rem;
    color: #424242;
}

.components-reconnect-attempt {
    margin-top: 0.35rem;
}

.components-reconnect-actions {
    margin-top: 0.9rem;
}

.components-reconnect-actions .reload {
    color: #1565C0;
}

/* ── Manage Profiles Page ───────────────────────────────────────── */

/* Two-column flex layout */
.mp-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.mp-sidebar-col {
    width: 210px;
    flex-shrink: 0;
}

.mp-detail-col {
    flex: 1;
    min-width: 0;
}

/* Shared panel container */
.mp-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* Panel header row */
.mp-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    background: #f5f7fa;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #616161;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Icon-only button (e.g. the + in the sidebar header) */
.mp-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.15rem;
    cursor: pointer;
    border-radius: 4px;
    color: #757575;
    line-height: 1;
    transition: background 0.12s, color 0.12s;
}
.mp-icon-btn:hover {
    background: #e3f2fd;
    color: #1565C0;
}

/* Active state for toggled icon buttons (e.g. view switchers) */
.mp-icon-btn-active {
    background: #e8f0fe !important;
    color: #1565C0 !important;
}

.mp-icon-btn .material-symbols-outlined {
    font-size: 1.1rem;
}

/* Profile list */
.mp-profile-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
    max-height: 62vh;
    overflow-y: auto;
}
.mp-profile-item {
    padding: 0.52rem 1rem;
    font-size: 0.82rem;
    color: #424242;
    cursor: pointer;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    user-select: none;
}
.mp-profile-item:hover {
    background: #f0f4ff;
    color: #1565C0;
}
.mp-profile-item.active {
    background: #e8f0fe;
    border-left-color: #1565C0;
    font-weight: 600;
    color: #1565C0;
}

/* Empty states */
.mp-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 2rem 1rem;
    color: #9e9e9e;
    font-size: 0.82rem;
}
.mp-empty-icon {
    font-size: 2rem;
    color: #e0e0e0;
}
.mp-empty-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 200px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
}
.mp-empty-panel-icon {
    font-size: 2.5rem;
    color: #e0e0e0;
}
.mp-empty-panel-text {
    font-size: 0.85rem;
    color: #9e9e9e;
    margin: 0;
}

/* Assigned Nodes table */
.mp-nodes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.mp-nodes-table thead th {
    padding: 0.5rem 1rem;
    background: #f5f7fa;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.72rem;
    font-weight: 600;
    color: #757575;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    white-space: nowrap;
}
.mp-nodes-table thead th:last-child {
    text-align: center;
}
.mp-nodes-table tbody tr {
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.1s;
}
.mp-nodes-table tbody tr:last-child {
    border-bottom: none;
}
.mp-nodes-table tbody tr:hover {
    background: #fafcff;
}
.mp-nodes-table tbody td {
    padding: 0.48rem 1rem;
    color: #424242;
    vertical-align: middle;
}
.mp-nodes-table tbody td:last-child {
    text-align: center;
}
.mp-table-empty {
    text-align: center !important;
    color: #9e9e9e;
    font-style: italic;
    padding: 1.5rem !important;
}

/* Alignment / status dots */
.mp-status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mp-dot-green {
    background: #43a047;
    box-shadow: 0 0 5px rgba(67,160,71,0.45);
}
.mp-dot-red {
    background: #e53935;
    box-shadow: 0 0 5px rgba(229,57,53,0.45);
}
.mp-dot-yellow {
    background: #fb8c00;
    box-shadow: 0 0 5px rgba(251,140,0,0.45);
}

/* Last-seen text colours */
.mp-lastseen-warn {
    color: #fb8c00;
    font-weight: 500;
}
.mp-lastseen-stale {
    color: #bdbdbd;
}

/* Component versions area (below the table) */
.mp-components-area {
    padding: 1rem;
    border-top: 1px solid #e8e8e8;
}

.mp-component-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.mp-component-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    min-width: 155px;
}

.mp-component-card-title {
    padding: 0.35rem 0.85rem;
    background: #f5f7fa;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.72rem;
    font-weight: 600;
    color: #424242;
    text-align: center;
    letter-spacing: 0.03em;
}

/* Radio-button version rows */
.mp-version-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.38rem 0.85rem;
    font-size: 0.8rem;
    color: #212121;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    margin: 0;
    font-weight: 400;
    transition: background 0.1s;
}
.mp-version-option:last-child {
    border-bottom: none;
}
.mp-version-option:not(.mp-version-disabled):hover {
    background: #f0f4ff;
}
.mp-version-option input[type="radio"] {
    cursor: pointer;
    accent-color: #1565C0;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    margin: 0;
}
.mp-version-option input[type="radio"]:disabled {
    cursor: default;
}
.mp-version-disabled {
    color: #bdbdbd;
    cursor: default;
    pointer-events: none;
}

/* Legacy node chips (kept for backward compatibility) */
.mp-nodes-empty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
}

.mp-node-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.mp-node-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25em 0.65em;
    background: var(--portal-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 12px;
    white-space: nowrap;
    font-family: 'Roboto Mono', monospace, sans-serif;
    letter-spacing: 0.01em;
}

.components-reconnect-actions .reload:hover {
    text-decoration: underline;
}

/* ── Manage Profiles: Tab navigation ────────────────────────────── */
.mp-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    gap: 0;
    margin-bottom: 0;
}

.mp-tab {
    padding: 0.55rem 1.25rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: #757575;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.mp-tab:hover {
    color: var(--portal-primary);
}
.mp-tab.active {
    color: var(--portal-primary);
    border-bottom-color: var(--portal-primary);
    font-weight: 600;
}

.mp-tab-content {
    padding-top: 1rem;
}

@media (max-width: 767.98px) {
    .mp-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .mp-tab {
        flex: 0 0 auto;
        min-width: fit-content;
        padding: 0.5rem 0.85rem;
        font-size: 0.78rem;
    }
}

/* ── Profile detail header ──────────────────────────────────────── */
.mp-detail-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #e8e8e8;
    min-height: 50px;
    background: #fff;
}

.mp-profile-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.mp-profile-label-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: #212121;
}

/* Inline name edit row */
.mp-name-edit-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.mp-name-input {
    font-size: 0.88rem;
    font-weight: 600;
    color: #212121;
    border: 1.5px solid var(--portal-primary);
    border-radius: 4px;
    padding: 0.18rem 0.5rem;
    outline: none;
    width: 220px;
    background: #fff;
}
.mp-name-input:focus {
    box-shadow: 0 0 0 3px var(--portal-focus-ring);
}

/* Confirm icon button variant */
.mp-icon-btn-confirm {
    color: #43a047;
}
.mp-icon-btn-confirm:hover {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Right-side actions area */
.mp-detail-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* "Select Component Versions" button */
.mp-select-versions-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.8rem;
    font-size: 0.79rem;
    font-weight: 500;
    color: var(--portal-primary);
    background: var(--portal-primary-soft);
    border: 1px solid var(--portal-primary-soft-border);
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s;
    line-height: 1.5;
}
.mp-select-versions-btn:hover {
    background: var(--portal-primary-soft-hover);
    border-color: var(--portal-primary);
}
.mp-select-versions-btn .material-symbols-outlined {
    font-size: 1rem;
}

/* Cancel text link */
.mp-cancel-link {
    font-size: 0.8rem;
    color: #757575;
    background: none;
    border: none;
    padding: 0.2rem 0.35rem;
    cursor: pointer;
    border-radius: 3px;
    line-height: 1.5;
    transition: color 0.12s;
}
.mp-cancel-link:hover:not(:disabled) {
    color: #212121;
    text-decoration: underline;
}

/* Small pill badge (panel header counts) */
.mp-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--portal-accent-soft);
    color: var(--portal-primary);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1em 0.6em;
    border-radius: 10px;
    white-space: nowrap;
    line-height: 1.5;
}

.mp-pill-green {
    background: #e8f5e9;
    color: #2e7d32;
}

.mp-pill-warn {
    background: #fff8e1;
    color: #f57f17;
}

/* ── Component Versions tab – toolbar ──────────────────────────────── */
.mp-cv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #e8e8e8;
    background: #fafafa;
    flex-wrap: wrap;
}
.mp-cv-filters {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.mp-filter-select {
    font-size: 0.8rem;
    color: #424242;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    padding: 0.28rem 2rem 0.28rem 0.65rem;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23757575'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    cursor: pointer;
    outline: none;
    min-width: 160px;
    transition: border-color 0.12s;
}
.mp-filter-select:hover, .mp-filter-select:focus {
    border-color: var(--portal-primary);
}
.mp-cv-toolbar-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.mp-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.28rem 0.75rem;
    font-size: 0.79rem;
    font-weight: 500;
    color: #424242;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    line-height: 1.5;
}
.mp-toolbar-btn .material-symbols-outlined {
    font-size: 0.95rem;
}
.mp-toolbar-btn:hover:not(:disabled) {
    background: var(--portal-primary-soft);
    border-color: var(--portal-primary);
    color: var(--portal-primary);
}
.mp-toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.mp-toolbar-btn-primary {
    color: var(--portal-primary);
    border-color: var(--portal-primary-soft-border);
    background: var(--portal-primary-soft);
}
.mp-toolbar-btn-primary:hover:not(:disabled) {
    background: var(--portal-primary-soft-hover);
    border-color: var(--portal-primary);
    color: var(--portal-primary-hover);
}
.mp-toolbar-btn-danger {
    color: #c62828;
    border-color: #ffcdd2;
    background: #fff5f5;
}
.mp-toolbar-btn-danger:hover:not(:disabled) {
    background: #ffebee;
    border-color: #e53935;
    color: #b71c1c;
}

/* ── Component Versions tab – inline edit form ───────────────────── */
.mp-cv-form {
    padding: 1rem 1.25rem;
    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-accent-border);
    border-top: 1px solid var(--portal-accent-border);
}
.mp-cv-form-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--portal-primary);
    margin-bottom: 0.85rem;
}
.mp-cv-form-title .material-symbols-outlined {
    font-size: 1rem;
}
.mp-cv-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.65rem 1rem;
    align-items: end;
}
.mp-cv-form-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.mp-cv-form-field-wide {
    grid-column: span 2;
}
.mp-cv-form-field label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #757575;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.mp-cv-input {
    font-size: 0.82rem;
    color: #212121;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    outline: none;
    width: 100%;
    transition: border-color 0.12s, box-shadow 0.12s;
    font-family: inherit;
}
.mp-cv-input:focus {
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px var(--portal-focus-ring);
}
.mp-cv-form-footer {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.9rem;
}

.mp-pkg-drop-zone {
    position: relative;
    border: 2px dashed var(--portal-accent-border);
    border-radius: 8px;
    padding: 1rem 1rem;
    text-align: center;
    background: var(--portal-surface);
    color: var(--portal-text);
    transition: border-color 0.12s ease, background-color 0.12s ease, box-shadow 0.12s ease;
}

.mp-pkg-drop-zone .material-symbols-outlined {
    font-size: 1.5rem;
    color: var(--portal-primary);
    margin-bottom: 0.3rem;
}

.mp-pkg-drop-zone-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
}

.mp-pkg-drop-zone-subtitle {
    font-size: 0.77rem;
    color: var(--portal-text-muted);
}

.mp-pkg-drop-zone.drag-active {
    border-color: var(--portal-primary);
    background: var(--portal-primary-soft);
    box-shadow: 0 0 0 3px var(--portal-focus-ring);
}

.mp-pkg-file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ── Component Versions tab – table row states ───────────────────── */
.mp-cv-row {
    cursor: pointer;
}
.mp-cv-row:hover td {
    background: var(--portal-row-hover);
}
.mp-row-selected td {
    background: var(--portal-row-selected) !important;
}
.mp-row-selected:hover td {
    background: var(--portal-row-selected-hover) !important;
}
.mp-cell-muted {
    color: #757575;
    font-size: 0.79rem;
}
.mp-cell-mono {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.77rem;
    color: #546e7a;
}
.mp-cell-truncate {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Inline form error message ───────────────────────────────────── */
.mp-form-error {
    font-size: 0.78rem;
    color: #c62828;
    background: #fce4e4;
    border: 1px solid #ffcdd2;
    border-radius: 4px;
    padding: 0.3rem 0.7rem;
    margin-top: 0.4rem;
}

/* ── Inline form success message ─────────────────────────────────── */
.mp-form-success {
    font-size: 0.78rem;
    color: #2e7d32;
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 4px;
    padding: 0.3rem 0.7rem;
    margin-top: 0.4rem;
}

/* ── Add New Popover ─────────────────────────────────────────────── */
.mp-popover-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1400;
    background: rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(1px);
}
.mp-popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1401;
    width: 520px;
    max-width: calc(100vw - 2rem);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
    overflow: hidden;
    animation: mp-popover-in 0.15s ease;
}
@keyframes mp-popover-in {
    from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.mp-popover-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--portal-overlay-header-gradient-start) 0%, var(--portal-overlay-header-gradient-end) 100%);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
}
.mp-popover-header .material-symbols-outlined {
    font-size: 1.1rem;
    opacity: 0.9;
}
.mp-popover-header .mp-icon-btn {
    color: rgba(255,255,255,0.8);
}
.mp-popover-header .mp-icon-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.mp-popover-body {
    padding: 1.1rem 1.25rem 1rem;
}
.mp-popover-footer {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
    padding: 0.85rem 1.25rem 1rem;
    border-top: 1px solid #eee;
}

.mp-popover-dialog-host {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.mp-popover-dialog-host .rz-dialog-content {
    padding: 0 !important;
    background: transparent !important;
}

/* ── Is Active badge ─────────────────────────────────────────────── */
.mp-active-badge {    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 10px;
    padding: 0.1em 0.65em;
    line-height: 1.5;
    white-space: nowrap;
}
.mp-active-yes {
    background: #e8f5e9;
    color: #2e7d32;
}
.mp-active-no {
    background: #fce4e4;
    color: #c62828;
}

/* ── Inactive tenant card tint ───────────────────────────────────── */
.mp-tenant-card-inactive {
    background-color: #fdecea !important;
    border-color: #f5c2c7 !important;
}

/* ── Retained utility badges ─────────────────────────────────────── */
.mp-mono-badge {
    display: inline-block;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 0.78rem;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 0.05em 0.45em;
    color: #37474f;
}
.mp-usage-pill {
    display: inline-block;
    font-size: 0.72rem;
    background: var(--portal-accent-soft);
    color: var(--portal-primary);
    border-radius: 10px;
    padding: 0.1em 0.6em;
    font-weight: 500;
}
.mp-unused {
    color: #bdbdbd;
    font-size: 0.82rem;
}

#global-client-error-ui {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 3500;
    background: #b71c1c;
    color: #fff;
    border-radius: 6px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
    padding: 0.75rem 2.5rem 0.75rem 0.9rem;
    font-size: 0.85rem;
}

.global-client-error-hide {
    display: none;
}

.global-client-error-show {
    display: block;
}

#global-client-error-ui .reload {
    color: #fff;
    font-weight: 500;
    text-decoration: underline;
    margin-left: 0.75rem;
}

#global-client-error-ui .dismiss {
    color: #fff;
    text-decoration: none;
    position: absolute;
    right: 0.7rem;
    top: 0.45rem;
    font-size: 0.95rem;
    line-height: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   Clinic Users page — responsive layout (cu-*)
   Desktop: mp-nodes-table visible, cu-card-list hidden.
   Mobile  : mp-nodes-table hidden, cu-card-list visible as stacked cards.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Desktop: hide card list ──────────────────────────────────────── */
.cu-card-list {
    display: none;
}

/* ── Mobile breakpoint ────────────────────────────────────────────── */
@media (max-width: 767.98px) {

    /* Panel header: stack title row and Add button on separate lines */
    .cu-page .mp-panel-header {
        flex-wrap: wrap;
        gap: 0.4rem 0.5rem;
        padding: 0.55rem 0.75rem;
    }
    .cu-page .mp-panel-header .ms-auto {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }

    /* Hide the desktop table, show card list */
    .cu-desktop-table {
        display: none !important;
    }
    .cu-card-list {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    /* ── Individual user card ─────────────────────────────────────── */
    .cu-user-card {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid #f0f0f0;
        background: #fff;
        transition: background 0.1s;
        cursor: pointer;
    }
    .cu-user-card:last-child {
        border-bottom: none;
    }
    .cu-user-card:active,
    .cu-user-card-selected {
        background: #f0f7ff;
    }

    /* Top row: name left, badges right */
    .cu-card-top {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.5rem;
        margin-bottom: 0.2rem;
    }
    .cu-card-name {
        font-size: 0.92rem;
        font-weight: 600;
        color: #212121;
        line-height: 1.3;
    }
    .cu-card-badges {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.3rem;
        flex-shrink: 0;
    }

    /* Email + phone */
    .cu-card-email {
        font-size: 0.78rem;
        color: #616161;
        font-family: 'Roboto Mono', 'Courier New', monospace;
        word-break: break-all;
        margin-bottom: 0.1rem;
    }
    .cu-card-phone {
        font-size: 0.78rem;
        color: #757575;
        margin-bottom: 0.25rem;
    }

    /* Meta row: invited / joined / last login */
    .cu-card-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem 0.9rem;
        font-size: 0.72rem;
        color: #9e9e9e;
        margin-top: 0.35rem;
    }
    .cu-meta-label {
        font-weight: 600;
        color: #bdbdbd;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-right: 0.2rem;
    }

    /* Action buttons row */
    .cu-card-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.6rem;
        flex-wrap: wrap;
    }
    .cu-card-actions .mp-toolbar-btn {
        font-size: 0.78rem;
        padding: 0.3rem 0.7rem;
    }

    /* Popovers become full-screen bottom sheets on mobile */
    .mp-popover {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 12px 12px 0 0;
        max-height: 92dvh;
        overflow-y: auto;
        animation: cu-sheet-in 0.22s ease;
    }
    @keyframes cu-sheet-in {
        from { transform: translateY(40px); opacity: 0; }
        to   { transform: translateY(0);   opacity: 1; }
    }

    /* Popover body: full-width single-column form */
    .mp-popover-body .mp-cv-form-grid {
        grid-template-columns: 1fr;
    }
    .mp-popover-body .mp-cv-form-field-wide {
        grid-column: span 1;
    }

    /* Popover footer: stack button and cancel link */
    .mp-popover-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.85rem 1rem 1.1rem;
    }
    .mp-popover-footer .mp-toolbar-btn {
        width: 100%;
        justify-content: center;
        margin-left: 0 !important;
        margin-bottom: 0 !important;
    }
    .mp-popover-footer .mp-cancel-link {
        text-align: center;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Account Profile page (ap-*)
   ═══════════════════════════════════════════════════════════════ */

/* ── Hero panel (avatar + name + badges + edit button) ──────────────── */
.ap-hero-panel {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.ap-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--portal-overlay-header-gradient-start) 0%, var(--portal-overlay-header-gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(21,101,192,0.28);
}

.ap-avatar-initials {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    font-family: 'Roboto', sans-serif;
}

.ap-hero-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.ap-hero-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #212121;
    line-height: 1.2;
}

.ap-hero-email {
    font-size: 0.82rem;
    color: #616161;
    word-break: break-all;
}

.ap-hero-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.ap-edit-btn {
    align-self: flex-start;
}

/* ── Two-column layout ───────────────────────────────────────────────── */
.ap-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}

.ap-col {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ── Detail grid rows inside panels ───────────────────────────────── */
.ap-detail-grid {
    padding: 0.5rem 0;
}

.ap-detail-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    border-bottom: 1px solid #f5f5f5;
}

.ap-detail-row:last-child {
    border-bottom: none;
}

.ap-detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #9e9e9e;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.ap-detail-value {
    font-size: 0.85rem;
    color: #212121;
}

/* ── Section body (password, notifications, 2FA) ───────────────────── */
.ap-section-body {
    padding: 0.9rem 1rem 1rem;
}

/* ── Toggle row (checkbox + label + description) ───────────────────── */
.ap-toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    cursor: pointer;
}

.ap-toggle-row input[type=checkbox] {
    width: 1rem;
    height: 1rem;
    margin-top: 0.15rem;
    flex-shrink: 0;
    accent-color: var(--portal-primary);
    cursor: pointer;
}

.ap-toggle-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ap-toggle-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #212121;
}

.ap-toggle-desc {
    font-size: 0.78rem;
    color: #9e9e9e;
}

/* ── Mobile responsive ───────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    .ap-hero-panel {
        padding: 1rem;
        gap: 0.85rem;
    }
    .ap-avatar {
        width: 52px;
        height: 52px;
    }
    .ap-avatar-initials {
        font-size: 1.2rem;
    }
    .ap-hero-name {
        font-size: 1rem;
    }
    .ap-edit-btn {
        width: 100%;
        justify-content: center;
        order: 3;
    }
    .ap-columns {
        grid-template-columns: 1fr;
    }
    .ap-detail-row {
        grid-template-columns: 110px 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Tenant Support + Subscription mobile layout fixes
   ═══════════════════════════════════════════════════════════════ */

.tsupport-ticket-cards,
.tsub-invoice-cards {
    display: none;
}

@media (max-width: 767.98px) {
    .tsupport-page .mp-panel-header,
    .tsub-page .mp-panel-header {
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    .tsupport-page .tsupport-ticket-actions {
        width: 100%;
        margin-left: 0 !important;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .tsupport-page .tsupport-ticket-actions .mp-toolbar-btn {
        flex: 1 1 150px;
        justify-content: center;
    }

    .tsupport-page .tsupport-ticket-table {
        display: none;
    }

    .tsupport-page .tsupport-ticket-cards {
        display: flex;
        flex-direction: column;
    }

    .tsupport-page .tsupport-ticket-card {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid #f0f0f0;
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
        cursor: pointer;
    }

    .tsupport-page .tsupport-ticket-card:last-child {
        border-bottom: none;
    }

    .tsupport-page .tsupport-ticket-card-selected {
        background: #eef4ff;
    }

    .tsupport-page .tsupport-ticket-card-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.6rem;
    }

    .tsupport-page .tsupport-ticket-card-title {
        font-size: 0.88rem;
        font-weight: 500;
        color: #212121;
        line-height: 1.3;
    }

    .tsupport-page .tsupport-ticket-card-badges {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        flex-wrap: wrap;
    }

    .tsub-page .tsub-invoice-controls {
        width: 100%;
        margin-left: 0 !important;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.4rem;
    }

    .tsub-page .tsub-invoice-controls .mp-cell-muted {
        font-size: 0.74rem;
    }

    .tsub-page .tsub-invoice-controls .mp-filter-select {
        min-width: 0 !important;
        flex: 1 1 130px;
    }

    .tsub-page .tsub-invoice-controls .mp-toolbar-btn {
        width: 100%;
        justify-content: center;
    }

    .tsub-page .tsub-invoice-table {
        display: none;
    }

    .tsub-page .tsub-invoice-cards {
        display: flex;
        flex-direction: column;
    }

    .tsub-page .tsub-invoice-card {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid #f0f0f0;
        display: flex;
        flex-direction: column;
        gap: 0.45rem;
    }

    .tsub-page .tsub-invoice-card:last-child {
        border-bottom: none;
    }

    .tsub-page .tsub-invoice-card-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.6rem;
    }

    .tsub-page .tsub-invoice-card-meta {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        flex-wrap: wrap;
        color: #424242;
    }

    .tsub-page .tsub-invoice-card-actions {
        display: flex;
        align-items: center;
        gap: 0.45rem;
        flex-wrap: wrap;
    }

    .tsub-page .tsub-invoice-card-actions .mp-toolbar-btn {
        padding: 0.22rem 0.65rem;
        text-decoration: none;
    }
}

/* ═════════════════════════════════════════════════════════════════
   Global Management pages -- mobile responsive fixes
   Covers: Tenant Management, Release, Tech Support,
           Tandem Staff, Subscription Plans, Feature Requests
   ═════════════════════════════════════════════════════════════════ */

@media (max-width: 767.98px) {

    /* 0. Content area: tighter padding on mobile */
    .content {
        padding: 1rem 0.75rem;
    }

    /* 1. Panel header: wrap so right-side action buttons go to their own row */
    .mp-panel-header {
        flex-wrap: wrap;
        row-gap: 0.4rem;
    }
    .mp-panel-header > .ms-auto {
        width: 100%;
        margin-left: 0 !important;
        justify-content: flex-end;
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    /* 2. All data tables: contained scroll + tighter padding */
    .mp-nodes-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mp-nodes-table thead th {
        white-space: nowrap;
        padding: 0.4rem 0.6rem;
        font-size: 0.68rem;
    }
    .mp-nodes-table tbody td {
        white-space: normal;
        word-break: break-word;
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    /* 2b. Panels: prevent horizontal overflow from children */
    .mp-panel {
        overflow: hidden;
    }

    /* 3. Two-column mp-layout: stack sidebar above detail */
    .mp-layout {
        flex-direction: column;
    }
    .mp-sidebar-col {
        width: 100% !important;
    }

    /* 4. Toolbar: stack filters above actions, kill inline min-widths */
    .mp-cv-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }
    .mp-cv-filters {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    .mp-filter-select {
        min-width: 0 !important;
    }
    .mp-cv-filters .mp-filter-select,
    .mp-cv-filters .mp-cv-input,
    .mp-cv-filters input {
        flex: 1 1 calc(50% - 0.3rem);
        min-width: 0 !important;
    }
    .mp-cv-toolbar-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.4rem;
    }
    .mp-cv-toolbar-actions .mp-toolbar-btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* 5. Tech Support dashboard: single column on mobile */
    .ts-dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    .ts-dashboard-grid .mp-panel {
        width: 100%;
        min-width: 0;
    }

    /* 5b. Tech Support KPI: 2-column grid on mobile */
    .ts-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .ts-kpi-card {
        padding: 0.7rem 0.8rem;
        gap: 0.6rem;
    }
    .ts-kpi-icon {
        width: 36px;
        height: 36px;
    }
    .ts-kpi-icon .material-symbols-outlined {
        font-size: 1.15rem;
    }
    .ts-kpi-value {
        font-size: 1.2rem;
    }
    .ts-kpi-label {
        font-size: 0.68rem;
    }

    /* 6. Subscription manage row: stack all items vertically */
    .sub-manage-row {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    .sub-manage-row > div {
        width: 100%;
    }
    .sub-manage-row select,
    .sub-manage-row .mp-filter-select {
        width: 100% !important;
        min-width: 0 !important;
    }
    .sub-manage-row .mp-toolbar-btn {
        width: 100%;
        justify-content: center;
    }

    /* 7. Staff page: tenant selector goes full-width */
    .staff-tenant-select {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* 8. Radzen dialogs: constrain to viewport, consistent titlebar */
    .rz-dialog-wrapper {
        padding: 0.5rem !important;
    }
    .rz-dialog {
        max-width: calc(100vw - 1rem) !important;
        width: calc(100vw - 1rem) !important;
        min-width: 0 !important;
    }
    .rz-dialog-content {
        max-height: 80dvh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    /* 8b. Apply styled titlebar to ALL Radzen dialogs on mobile */
    .rz-dialog-titlebar {
        background: linear-gradient(90deg,
            var(--portal-overlay-header-gradient-start),
            var(--portal-overlay-header-gradient-end)) !important;
        color: #fff !important;
        border-bottom: 1px solid rgba(0,0,0,0.12) !important;
        padding: 0.6rem 0.85rem !important;
    }
    .rz-dialog-title {
        color: #fff !important;
        font-weight: 600 !important;
        font-size: 0.92rem !important;
    }
    .rz-dialog-titlebar .rz-dialog-titlebar-close {
        color: #fff !important;
    }

    /* 9. Release: detail header wraps on mobile */
    .mp-detail-header {
        flex-wrap: wrap;
        min-height: unset;
    }
    .mp-detail-actions {
        margin-left: 0 !important;
        width: 100%;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        justify-content: flex-end;
    }
    .mp-name-input {
        width: 100%;
    }
    .mp-name-edit-row {
        width: 100%;
    }

    /* 10. Release: component version grid becomes single column */
    .mp-component-grid {
        grid-template-columns: 1fr !important;
    }

    /* 11. Popover: scroll inner + full-width on small screens */
    .mp-popover-body {
        overflow-x: auto;
    }
    .mp-popover {
        max-width: calc(100vw - 2rem);
    }

    /* 12. KPI row: 2x2 grid on mobile (already handled by col-6 col-md-3) */
    .gm-kpi-row > [class*="col-"] {
        margin-bottom: 0;
    }

    /* 13. Filter toolbar: hide inline label spans — selects are self-describing */
    .mp-cv-filters > .mp-cell-muted {
        display: none;
    }

    /* 14. Tabs: compact on mobile */
    .mp-tabs {
        gap: 0;
    }
    .mp-tab {
        padding: 0.45rem 0.7rem;
        font-size: 0.76rem;
    }

    /* 15. Page header subtitle: smaller on mobile */
    .page-header-title {
        font-size: 1.1rem !important;
    }
    .page-header-subtitle {
        font-size: 0.78rem;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Tenant Management — table / card view toggle
   Desktop: gm-desktop-hidden hides whichever view is toggled off.
   Mobile:  always show cards, never show table.
   ═══════════════════════════════════════════════════════════════ */
.gm-desktop-hidden { display: none; }

@media (max-width: 767.98px) {
    .gm-tenant-table-section { display: none !important; }
    .gm-tenant-card-section  { display: block !important; }
    .gm-view-toggle          { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   Tech Support — KPI cards + dashboard grid (base definitions)
   ═══════════════════════════════════════════════════════════════ */
.ts-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.ts-kpi-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: #fff;
    border: 1px solid #e8ecf2;
    border-radius: 10px;
    padding: 1rem 1.1rem;
    transition: box-shadow 0.15s;
}
.ts-kpi-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.ts-kpi-card-warn {
    border-left: 3px solid #ef4444;
}

.ts-kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
}
.ts-kpi-icon .material-symbols-outlined {
    font-size: 1.35rem;
}

.ts-kpi-body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.ts-kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.15;
}
.ts-kpi-label {
    font-size: 0.74rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.ts-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════════════════
   Tech Support — dashboard full-width fix + ticket/FR card views
   ═══════════════════════════════════════════════════════════════ */
.gts-ticket-cards,
.gts-fr-cards { display: none; }

@media (max-width: 767.98px) {
    /* Ticket queue: hide table, show cards */
    .gts-ticket-table { display: none; }
    .gts-ticket-cards {
        display: flex;
        flex-direction: column;
    }

    /* Feature requests: hide table, show cards */
    .gts-fr-table { display: none; }
    .gts-fr-cards {
        display: flex;
        flex-direction: column;
    }
}

/* Shared GTS card styles */
.gts-ticket-card,
.gts-fr-card {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    cursor: pointer;
    transition: background 0.1s;
}
.gts-ticket-card:last-child,
.gts-fr-card:last-child { border-bottom: none; }

.gts-card-selected { background: #eef4ff; }

.gts-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}
.gts-card-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: #212121;
    line-height: 1.3;
}
.gts-card-badges {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   Release Page — scroll wrappers + node card views
   ═══════════════════════════════════════════════════════════════ */
.rl-node-cards { display: none; }

.rl-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    /* Simple node tables: hide table, show cards */
    .rl-node-table   { display: none; }
    .rl-node-cards   { display: flex; flex-direction: column; }

    /* Component Versions: hide scroll table, show cards */
    .rl-cv-table     { display: none; }

    /* Fleet / Nodes: hide scroll table, show cards */
    .rl-fleet-table  { display: none; }

    /* Component Catalogue: hide scroll table, show cards */
    .rl-compdef-table { display: none; }

    /* Wide tables get contained scroll instead of page-level scroll */
    .rl-table-scroll .mp-nodes-table { min-width: 560px; }
}

.rl-node-card {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.rl-node-card:last-child { border-bottom: none; }

.rl-node-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.rl-node-card-codes {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.rl-node-card-meta {
    font-size: 0.78rem;
    color: #757575;
}

/* ═══════════════════════════════════════════════════════════════
   Release — Component Versions card view (rl-cv-*)
   Desktop: table visible, cards hidden.
   Mobile:  table+scroll hidden, cards shown.
   ═══════════════════════════════════════════════════════════════ */
.rl-cv-cards { display: none; }

@media (max-width: 767.98px) {
    .rl-cv-cards {
        display: flex;
        flex-direction: column;
    }
}

.rl-cv-card {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    cursor: pointer;
    transition: background 0.1s;
}
.rl-cv-card:last-child { border-bottom: none; }
.rl-cv-card-selected   { background: #eef4ff; }

.rl-cv-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}
.rl-cv-card-name {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    font-size: 0.88rem;
    min-width: 0;
}
.rl-cv-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: #757575;
}
.rl-cv-card-file {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}
.rl-cv-card-script {
    font-size: 0.74rem;
    color: #475569;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   Release — Fleet (Nodes) card view (rl-fleet-*)
   Desktop: table visible, cards hidden.
   Mobile:  table+scroll hidden, cards shown.
   ═══════════════════════════════════════════════════════════════ */
.rl-fleet-cards { display: none; }

@media (max-width: 767.98px) {
    .rl-fleet-cards {
        display: flex;
        flex-direction: column;
    }
}

.rl-fleet-card {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: #fff;
}
.rl-fleet-card:last-child { border-bottom: none; }

.rl-fleet-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.rl-fleet-card-check {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
}
.rl-fleet-card-identity {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}
.rl-fleet-card-scheduled {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 0.3rem 0.5rem;
    background: #f8fafc;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
    font-size: 0.82rem;
}
.rl-fleet-card-components {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.rl-fleet-chip {
    display: inline-flex;
    font-size: 0.72rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 0.1rem 0.35rem;
    color: #475569;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   Release — Component Catalogue card view (rl-compdef-*)
   Desktop: table visible, cards hidden.
   Mobile:  table+scroll hidden, cards shown.
   ═══════════════════════════════════════════════════════════════ */
.rl-compdef-cards { display: none; }

@media (max-width: 767.98px) {
    .rl-compdef-cards {
        display: flex;
        flex-direction: column;
    }
}

.rl-compdef-card {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: #fff;
}
.rl-compdef-card:last-child { border-bottom: none; }

.rl-compdef-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}
.rl-compdef-card-identity {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    min-width: 0;
}
.rl-compdef-card-badges {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.rl-compdef-card-desc {
    font-size: 0.78rem;
    line-height: 1.4;
}
.rl-compdef-card-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    justify-content: flex-end;
}
