/* Portal app/auth surfaces on top of Insight theme */
.portal-auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background:
        radial-gradient(ellipse 75% 45% at 50% -15%, rgba(59, 130, 246, 0.12), transparent 60%),
        radial-gradient(ellipse 50% 35% at 100% 100%, rgba(37, 99, 235, 0.06), transparent 50%),
        var(--pbi-bg, #f4f7fa);
}

.portal-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--pbi-canvas, #ffffff);
    border: 1px solid var(--pbi-border-light, rgba(18, 32, 51, 0.08));
    border-radius: 14px;
    padding: 36px 32px;
    box-shadow: 0 10px 28px rgba(18, 32, 51, 0.08);
}

.portal-auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}

.bx-brand-mark {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin: 0 0 20px 4px;
    text-decoration: none !important;
    line-height: 1;
}

.bx-brand-mark:hover {
    text-decoration: none !important;
}

.bx-brand-mark__logo {
    display: none;
}

.bx-brand-mark__primary {
    font-family: 'Inter', 'Roboto', sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #122033;
    line-height: 1.1;
    white-space: nowrap;
}

.bx-brand-mark__secondary {
    font-family: 'Inter', 'Roboto', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.28em;
    color: #3ba0b3;
    white-space: nowrap;
    text-transform: uppercase;
}

.bx-brand-mark--auth {
    align-items: center;
    justify-content: center;
    margin: 0;
    text-align: center;
}

.bx-brand-mark--auth .bx-brand-mark__primary {
    font-size: 26px;
}

.bx-brand-mark--auth .bx-brand-mark__secondary {
    font-size: 13px;
    letter-spacing: 0.28em;
}

.portal-auth-lang {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 100%;
    margin: 0 0 24px;
    padding: 3px;
    border-radius: 999px;
    border: 1px solid var(--pbi-border, #243044);
    background: transparent;
    box-sizing: border-box;
}

.portal-auth-lang .lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 26px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    text-decoration: none;
    color: var(--pbi-text-secondary, #94a3b8);
    background: transparent;
    border: none;
}

.portal-auth-lang .lang-btn:hover {
    color: var(--pbi-teal, #1fb6ff);
    background: rgba(31, 182, 255, 0.1);
}

.portal-auth-lang .lang-btn.active {
    color: #ffffff;
    background: var(--pbi-teal, #1fb6ff);
}

.portal-auth-title {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--pbi-text, #e8edf5);
    margin-bottom: 8px;
}

.portal-auth-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--pbi-text-secondary, #94a3b8);
    margin-bottom: 28px;
    line-height: 1.45;
}

.portal-field {
    margin-bottom: 18px;
}

.portal-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--pbi-text-secondary, #94a3b8);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.portal-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--pbi-border, #243044);
    background: var(--pbi-bg, #0b1220);
    color: var(--pbi-text, #e8edf5);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.portal-input:focus {
    border-color: var(--pbi-teal, #1fb6ff);
    box-shadow: 0 0 0 3px rgba(31, 182, 255, 0.18);
}

.portal-input-affix {
    position: relative;
    display: flex;
    align-items: center;
}

.portal-input-affix .portal-input {
    padding-right: 84px;
}

.portal-input-affix__suffix {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--pbi-text-secondary, #94a3b8);
    pointer-events: none;
}

.portal-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--pbi-text-secondary, #94a3b8);
    margin: 10px 0 20px;
}

.portal-check input {
    accent-color: var(--pbi-teal, #1fb6ff);
}

.portal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: 10px;
    border: none;
    background: var(--section-accent, var(--pbi-teal, #3b82f6));
    color: #fff !important;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none !important;
    transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 8px 20px var(--section-accent-shadow, color-mix(in srgb, var(--section-accent, #3b82f6) 28%, transparent));
}

.portal-btn:hover {
    filter: brightness(1.06);
    color: #fff !important;
    text-decoration: none !important;
}

.portal-filter-actions .portal-btn {
    min-height: 38px;
    padding: 0 14px;
    font-size: 13px;
}

.portal-filter-actions .portal-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.portal-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    color: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
}

.portal-btn-secondary .portal-tab-count {
    background: rgba(31, 182, 255, 0.16);
    color: var(--pbi-teal, #1fb6ff);
}

.portal-btn-block {
    width: 100%;
}

.portal-btn-secondary {
    background: var(--pbi-hover, #1a2436);
    border: 1px solid var(--pbi-border, #243044);
    color: var(--pbi-text, #e8edf5) !important;
    box-shadow: none;
}

.portal-btn-danger {
    background: var(--pbi-red, #ef4444);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.2);
}

.portal-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
}

.portal-row-actions form {
    display: inline-flex;
    margin: 0;
}

.portal-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--pbi-border, #334155);
    background: transparent;
    color: var(--pbi-text-secondary, #94a3b8) !important;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none !important;
    text-transform: capitalize !important;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.bx-table a.portal-action-btn,
.bx-table tbody td a.portal-action-btn,
.bx-table .portal-action-btn {
    text-transform: capitalize !important;
    letter-spacing: normal !important;
}

.portal-action-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.portal-action-btn:hover,
.bx-table a.portal-action-btn:hover,
.bx-table tbody td a.portal-action-btn:hover {
    text-decoration: none !important;
    background: rgba(31, 182, 255, 0.08);
    border-color: var(--pbi-teal, #1fb6ff);
    color: var(--pbi-teal, #1fb6ff) !important;
}

.portal-action-btn--edit:hover {
    border-color: var(--pbi-teal, #1fb6ff);
    color: var(--pbi-teal, #1fb6ff) !important;
}

.portal-action-btn--archive {
    border-color: rgba(245, 158, 11, 0.45);
    color: #f59e0b !important;
}

.portal-action-btn--archive:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: #f59e0b;
    color: #fbbf24 !important;
}

.portal-action-btn--restore {
    border-color: rgba(52, 211, 153, 0.45);
    color: #34d399 !important;
}

.portal-action-btn--restore:hover {
    background: rgba(52, 211, 153, 0.12);
    border-color: #34d399;
    color: #6ee7b7 !important;
}

.portal-action-btn--ghost {
    border-color: var(--pbi-border, #334155);
}

.portal-link {
    color: var(--pbi-teal, #1fb6ff);
    font-size: 13px;
    text-decoration: none;
}

.portal-link:hover {
    text-decoration: underline;
}

.portal-error {
    color: var(--pbi-red, #ef4444);
    font-size: 12px;
    margin-top: 6px;
}

.portal-status {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 18px;
}

.portal-auth-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.portal-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.portal-services-parent-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -6px 0 18px;
    flex-wrap: wrap;
}

.portal-services-parent-filter label {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--pbi-text-secondary, #94a3b8);
}

.portal-services-parent-filter__select {
    width: auto;
    min-width: 220px;
    max-width: 360px;
    height: 40px;
}

.portal-access-block {
    margin: 22px 0 8px;
    padding: 16px;
    border: 1px solid var(--pbi-border, #243044);
    border-radius: 12px;
    background: color-mix(in srgb, var(--pbi-canvas, #121a2b) 92%, #000);
}

.portal-access-block__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.portal-access-block__title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: var(--pbi-text, #e8edf5);
}

.portal-access-block__hint {
    margin: 0;
    font-size: 12px;
    color: var(--pbi-text-secondary, #94a3b8);
}

.portal-access-block__tools {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.portal-access-tree {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 520px;
    overflow: auto;
    padding-right: 4px;
}

.portal-access-node {
    border: 1px solid color-mix(in srgb, var(--pbi-border, #243044) 80%, transparent);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
}

.portal-access-children {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-left: 18px;
    border-left: 1px dashed color-mix(in srgb, var(--pbi-teal, #1fb6ff) 35%, transparent);
}

.portal-access-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    cursor: pointer;
}

.portal-access-item input {
    margin-top: 3px;
    accent-color: var(--pbi-teal, #1fb6ff);
}

.portal-access-item__label {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--pbi-text, #e8edf5);
    font-size: 13px;
}

.portal-access-item__label em {
    font-style: normal;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pbi-text-secondary, #94a3b8);
}

.portal-access-empty {
    padding: 18px 8px;
    text-align: center;
    color: var(--pbi-text-secondary, #94a3b8);
    font-size: 13px;
}

body.light-theme .portal-access-block,
body.light-theme .portal-access-node {
    background: rgba(255, 255, 255, 0.9);
}

.portal-page-head h1,
.portal-page-head h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--pbi-text, #e8edf5);
    margin: 0;
    letter-spacing: -0.01em;
}

.portal-dashboard {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: calc(100vh - 140px);
}

.portal-stat-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.portal-dash-alerts {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 220px;
    background: var(--pbi-canvas, #121826);
    border: 1px solid var(--pbi-border-light, rgba(148, 163, 184, 0.12));
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.portal-dash-alerts__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex: 0 0 auto;
}

.portal-dash-alerts__title-wrap {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.portal-dash-alerts__bell {
    position: relative;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--pbi-border, #334155);
    border-radius: 12px;
    background: rgba(31, 182, 255, 0.08);
    color: var(--pbi-teal, #1fb6ff);
    flex-shrink: 0;
}

.portal-dash-alerts__count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.portal-dash-alerts__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--pbi-text, #e8edf5);
}

.portal-dash-alerts__subtitle {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--pbi-text-secondary, #94a3b8);
}

.portal-dash-alerts__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1 1 auto;
    overflow: hidden;
    border: 1px solid var(--pbi-border-light, rgba(148, 163, 184, 0.12));
    border-radius: 10px;
    background: var(--pbi-surface, #182234);
}

.portal-dash-alerts__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 68px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--pbi-border-light, rgba(148, 163, 184, 0.12));
    color: var(--pbi-text, #e8edf5);
    font-size: 13px;
    line-height: 1.4;
}

.portal-dash-alerts__item:last-child {
    border-bottom: none;
}

.portal-dash-alerts__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--pbi-teal, #1fb6ff);
}

.portal-dash-alerts__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(140px, 1.1fr) minmax(140px, 1.1fr) minmax(110px, 130px);
    align-items: center;
    column-gap: 12px;
    row-gap: 8px;
    width: 100%;
    min-width: 0;
}

.portal-dash-alerts__body.is-admin {
    grid-template-columns: minmax(0, 1.3fr) minmax(110px, 0.85fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(110px, 130px);
}

.portal-dash-alerts__item.is-head {
    min-height: 0;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--pbi-hover, #1c283c) 70%, transparent);
    border-bottom-color: var(--pbi-border, #334155);
}

.portal-dash-alerts__dot.is-head {
    visibility: hidden;
}

.portal-dash-alerts__col-title {
    display: block;
    min-width: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pbi-text-secondary, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-dash-alerts__col-title.is-date {
    justify-self: end;
    text-align: right;
}

.portal-dash-alerts__text {
    min-width: 0;
    color: var(--pbi-text, #e8edf5);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
}

.portal-dash-alerts__badge {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-dash-alerts__badge.is-partner {
    color: #34d399;
    background: rgba(52, 211, 153, 0.12);
    border-color: rgba(52, 211, 153, 0.28);
}

.portal-dash-alerts__badge.is-report {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.28);
}

.portal-dash-alerts__badge.is-kpi {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.12);
    border-color: rgba(167, 139, 250, 0.28);
}

.portal-dash-alerts__date {
    justify-self: end;
    font-size: 12px;
    font-weight: 600;
    color: var(--pbi-text-secondary, #94a3b8);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.portal-dash-alerts__item.is-warning .portal-dash-alerts__dot {
    background: #f59e0b;
}

.portal-dash-alerts__item.is-danger .portal-dash-alerts__dot {
    background: #ef4444;
}

.portal-dash-alerts__item.is-info .portal-dash-alerts__dot {
    background: #1fb6ff;
}

@media (max-width: 900px) {
    .portal-dashboard {
        min-height: 0;
    }

    .portal-dash-alerts {
        min-height: 0;
        overflow: visible;
    }

    .portal-dash-alerts__list {
        overflow: visible;
    }

    .portal-dash-alerts__body,
    .portal-dash-alerts__body.is-admin {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .portal-dash-alerts__item.is-head {
        display: none;
    }

    .portal-dash-alerts__date,
    .portal-dash-alerts__col-title.is-date {
        justify-self: start;
        text-align: left;
    }
}

.portal-stat-grid--partner {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.portal-stat-grid--admin {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1100px) {
    .portal-stat-grid--partner {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .portal-stat-grid--admin {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .portal-stat-grid--partner {
        grid-template-columns: 1fr;
    }
}

.portal-stat-row {
    display: grid;
    gap: 16px;
}

.portal-stat-row--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
    .portal-stat-row--3 {
        grid-template-columns: 1fr;
    }
}

.portal-stat {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--pbi-canvas, #121a2b);
    border: 1px solid var(--pbi-border-light, rgba(148, 163, 184, 0.12));
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: var(--pbi-shadow, 0 8px 24px rgba(2, 8, 23, 0.28));
}

a.portal-stat {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

a.portal-stat:hover {
    border-color: color-mix(in srgb, var(--pbi-teal, #1fb6ff) 45%, transparent);
    background: color-mix(in srgb, var(--pbi-canvas, #121a2b) 88%, var(--pbi-teal, #1fb6ff));
}

a.portal-stat:focus-visible {
    outline: 2px solid var(--pbi-teal, #1fb6ff);
    outline-offset: 2px;
}

.portal-stat__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 14px;
    flex-shrink: 0;
    color: var(--pbi-teal, #1fb6ff);
    background: var(--pbi-teal-soft, rgba(31, 182, 255, 0.12));
    border: 1px solid color-mix(in srgb, var(--pbi-teal, #1fb6ff) 28%, transparent);
}

.portal-stat__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.portal-stat .label {
    font-size: 12px;
    color: var(--pbi-text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.portal-stat .value {
    margin-top: 0;
    font-size: 28px;
    font-weight: 700;
    color: var(--pbi-text, #e8edf5);
    letter-spacing: -0.02em;
}

.portal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.portal-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.portal-badge.is-on {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.portal-badge.is-off {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
}

.portal-form-card {
    max-width: 640px;
}

.portal-form-card--wide {
    max-width: none !important;
    width: 100% !important;
    box-sizing: border-box;
}

.portal-form-grid--equal {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
    width: 100%;
    margin-bottom: 8px;
    align-items: start;
}

.portal-form-grid--equal .portal-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    min-width: 0;
}

.portal-form-grid--equal .portal-field > label,
.portal-form-grid--equal .portal-field__label-spacer {
    display: block;
    min-height: 32px;
    margin-bottom: 8px;
    line-height: 1.25;
}

.portal-form-grid--equal .portal-input {
    width: 100%;
    height: 44px;
    box-sizing: border-box;
}

.portal-form-grid--equal .portal-hint,
.portal-form-grid--equal .portal-hint--spacer {
    min-height: 18px;
    margin: 8px 0 0;
    line-height: 1.4;
}

.portal-form-grid--equal .portal-hint--spacer {
    visibility: hidden;
}

.portal-check--input-height {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.portal-switch-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    height: 44px;
    min-height: 44px;
    width: 100%;
}

.portal-actions.portal-actions--inline {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: 10px;
    height: 44px;
}

.portal-actions.portal-actions--inline .portal-btn {
    height: 44px;
    margin: 0;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
}

.portal-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 44px;
    min-height: 44px;
    margin: 0;
    cursor: pointer;
    user-select: none;
    flex: 0 0 auto;
    align-self: center;
}

.portal-switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
}

.portal-switch__track {
    position: relative;
    display: inline-block;
    width: 76px;
    height: 44px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.35);
    border: 1px solid var(--pbi-border, #243044);
    box-sizing: border-box;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.portal-switch__thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease;
}

.portal-switch input:checked + .portal-switch__track {
    background: rgba(31, 182, 255, 0.35);
    border-color: rgba(31, 182, 255, 0.7);
}

.portal-switch input:checked + .portal-switch__track .portal-switch__thumb {
    transform: translateX(32px);
    background: #1fb6ff;
}

.portal-switch input:focus-visible + .portal-switch__track {
    box-shadow: 0 0 0 3px rgba(31, 182, 255, 0.18);
}

body.light-theme .portal-switch__track {
    background: rgba(148, 163, 184, 0.45);
}

body.light-theme .portal-switch input:checked + .portal-switch__track {
    background: rgba(31, 182, 255, 0.25);
}

.portal-form-card .portal-field {
    margin-bottom: 16px;
}

@media (max-width: 900px) {
    .portal-form-grid--equal {
        grid-template-columns: 1fr;
    }
}

.portal-check-list {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.portal-check-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--pbi-text, #e8edf5);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}

.bx-user-actions {
    display: none;
}

/* Shared professional form/card polish for legacy settings pages */
.bx-card-form {
    border-radius: 12px !important;
    border: 1px solid var(--pbi-border-light) !important;
    padding: 22px 24px !important;
    background: var(--pbi-canvas) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
}

.bx-form-group {
    margin-bottom: 16px;
}

.bx-form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--pbi-text-secondary);
    letter-spacing: 0.03em;
}

.bx-form-input,
.bx-form-textarea,
.bx-form-select {
    border-radius: 10px !important;
    border: 1px solid var(--pbi-border) !important;
    background: var(--pbi-bg) !important;
    color: var(--pbi-text) !important;
    padding: 10px 12px !important;
}

.bx-form-help {
    margin-top: 6px;
    font-size: 12px;
    color: var(--pbi-text-secondary);
    line-height: 1.4;
}

.bx-export-btn {
    border-radius: 10px !important;
    padding: 0 16px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
}

.sidebar-switchers {
    padding-top: 12px !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
}

.bx-user-profile {
    padding-top: 8px !important;
    margin-top: 0 !important;
}

.portal-history-filters__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px 14px;
}

.portal-history-filters label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--pbi-text-secondary, #94a3b8);
}

.portal-history-filters input,
.portal-history-filters select {
    width: 100%;
    border: 1px solid var(--pbi-border-light, rgba(148, 163, 184, 0.18));
    background: var(--pbi-canvas, #121826);
    color: var(--pbi-text, #e8edf5);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
}

.portal-impersonate-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.portal-impersonate-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.portal-impersonate-badge-form {
    margin: 0;
}

.portal-impersonate-badge {
    cursor: pointer;
    border: 0;
    font: inherit;
    line-height: 1.2;
}

.portal-impersonate-badge:hover {
    filter: brightness(1.08);
}

.portal-impersonate-select {
    min-width: 180px;
    max-width: 260px;
    border: 1px solid var(--pbi-border-light, rgba(148, 163, 184, 0.18));
    background: var(--pbi-canvas, #121826);
    color: var(--pbi-text, #e8edf5);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
}

.portal-impersonation-leave {
    padding: 0 14px 14px;
}

.portal-logout-confirm {
    z-index: 10070;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
    background: rgba(0, 0, 0, 0.62) !important;
}

.portal-logout-confirm__dialog {
    max-width: 420px !important;
    margin-top: 0 !important;
    border-radius: 14px !important;
}

.portal-logout-confirm__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.bx-table thead th.portal-col-name,
.bx-table tbody td.portal-col-name {
    width: auto !important;
    text-align: left !important;
    padding-left: 16px;
}

.bx-table thead th.portal-col-sort,
.bx-table tbody td.portal-col-sort {
    width: 88px;
    text-align: center !important;
}

.portal-sort-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.portal-sort-handle {
    display: inline-flex;
    color: var(--pbi-text-secondary, #94a3b8);
    cursor: grab;
}

.portal-sort-handle:active {
    cursor: grabbing;
}

.bx-table tbody tr.is-sortable-row {
    cursor: grab;
}

.bx-table tbody tr.is-dragging {
    opacity: 0.55;
}

.bx-table tbody tr.is-drop-target {
    outline: 1px dashed color-mix(in srgb, var(--pbi-teal, #1fb6ff) 55%, transparent);
    outline-offset: -2px;
}

#adminServicesSort.is-saving-order {
    opacity: 0.85;
    pointer-events: none;
}

body:not(.light-theme) .portal-sort-handle {
    color: #ffffff;
}

.portal-service-name {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
    width: 100%;
    text-align: left;
}

.portal-service-name .portal-service-type-icon {
    flex-shrink: 0;
    color: #ffffff;
    opacity: 0.95;
}

body.light-theme .portal-service-name .portal-service-type-icon {
    color: var(--pbi-teal, #14b8a6);
    opacity: 0.9;
}

.portal-service-name a,
.portal-service-name span {
    min-width: 0;
    text-align: left;
}

/* Light mode surfaces for portal app components */
body.light-theme .portal-auth-page {
    background:
        radial-gradient(ellipse 75% 45% at 50% -15%, rgba(59, 130, 246, 0.12), transparent 60%),
        radial-gradient(ellipse 50% 35% at 100% 100%, rgba(37, 99, 235, 0.06), transparent 50%),
        var(--pbi-bg);
}

body.light-theme .portal-auth-card,
body.light-theme .portal-dash-alerts,
body.light-theme .portal-stat,
body.light-theme .bx-card-form {
    background: var(--pbi-canvas) !important;
    border-color: var(--pbi-border) !important;
    box-shadow: var(--pbi-shadow) !important;
}

body.light-theme .portal-dash-alerts__list {
    background: var(--pbi-surface);
    border-color: var(--pbi-border);
}

body.light-theme .portal-dash-alerts__item.is-head {
    background: var(--pbi-hover, #e8eef7);
}

body.light-theme .portal-input,
body.light-theme .portal-history-filters input,
body.light-theme .portal-history-filters select,
body.light-theme .portal-impersonate-select,
body.light-theme .bx-form-input,
body.light-theme .bx-form-textarea,
body.light-theme .bx-form-select {
    background: var(--pbi-canvas) !important;
    color: var(--pbi-text) !important;
    border-color: var(--pbi-border) !important;
}

body.light-theme .portal-btn-secondary {
    background: var(--pbi-hover) !important;
    color: var(--pbi-text) !important;
}

.portal-user-cell {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    min-width: 0;
}

.portal-user-cell__avatar {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    object-fit: cover;
    overflow: hidden;
    line-height: 1;
    flex: 0 0 32px;
    border: 1px solid var(--pbi-border, #243044);
    background: var(--pbi-teal, #1fb6ff);
}

.portal-user-cell__avatar--placeholder {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
}

.portal-user-cell__name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.light-theme .portal-user-cell__avatar {
    border-color: var(--pbi-border);
}

.portal-avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.portal-avatar-preview {
    width: 72px;
    height: 72px;
    border-radius: 999px;
    object-fit: cover;
    border: 1px solid var(--pbi-border, #243044);
    background: var(--pbi-teal, #1fb6ff);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    flex-shrink: 0;
}

.portal-avatar-preview--placeholder {
    letter-spacing: 0.02em;
}

.portal-avatar-controls {
    flex: 1 1 220px;
    min-width: 0;
}

.portal-input-file {
    height: auto;
    min-height: 44px;
    padding: 10px 12px;
    cursor: pointer;
}

.portal-hint {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--pbi-text-secondary, #94a3b8);
    line-height: 1.4;
}

body.light-theme .portal-avatar-preview {
    border-color: var(--pbi-border);
}

.portal-companies-cell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.portal-companies-count {
    font-weight: 700;
    color: var(--pbi-text, #e8edf5);
}

.portal-companies-info {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 27px;
    height: 27px;
    border-radius: 999px;
    color: #8adfff;
    cursor: help;
}

.portal-companies-info:hover,
.portal-companies-info:focus-visible {
    color: #1fb6ff;
    outline: none;
}

.portal-companies-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 20;
    display: none;
    min-width: 140px;
    max-width: 260px;
    padding: 8px 10px;
    border: 1px solid var(--pbi-border, #273349);
    border-radius: 10px;
    background: #0f172a;
    box-shadow: 0 10px 24px rgba(2, 8, 23, 0.45);
    color: #dbe7f5;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    transform: translateX(-50%);
    pointer-events: none;
}

.portal-companies-tooltip > span {
    display: block;
}

.portal-companies-tooltip > span + span {
    margin-top: 4px;
}

.portal-companies-info:hover .portal-companies-tooltip,
.portal-companies-info:focus-visible .portal-companies-tooltip {
    display: grid;
    gap: 0;
}

body.light-theme .portal-companies-tooltip {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}
