/* Customer Self-Service Portal — standalone premium theme.
   Deliberately NOT the internal admin theme (_Layout.cshtml's sidebar/topbar) — the portal
   must read as a modern SaaS product (Zendesk/Stripe/banking-app register), not an ERP screen. */

:root {
    --portal-bg: #f6f7fb;
    --portal-surface: #ffffff;
    --portal-border: #e7e9f2;
    --portal-text: #1a1d29;
    --portal-text-muted: #6b7085;
    /* Tenant white-label tokens (spec §4) — _PortalLayout.cshtml overrides these three per
       customer; --portal-primary(+dark/soft) below is deliberately pointed at --brand-primary
       so every existing component that already uses --portal-primary re-colors for free. The
       hardcoded values here are the system default (no tenant customization yet). */
    --brand-primary: #4338ca;
    --brand-secondary: #2563eb;
    --brand-accent: #16a34a;
    --brand-surface: var(--portal-surface);
    --portal-primary: var(--brand-primary);
    --portal-primary-dark: color-mix(in srgb, var(--brand-primary) 85%, black);
    --portal-primary-soft: color-mix(in srgb, var(--brand-primary) 12%, white);
    --portal-success: #16a34a;
    --portal-success-soft: #eafaf0;
    --portal-warning: #d97706;
    --portal-warning-soft: #fef6e7;
    --portal-danger: #dc2626;
    --portal-danger-soft: #fdeeee;
    --portal-radius: 14px;
    --portal-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .06);

    /* Authenticated app-shell sidebar — fixed chrome, not tenant-themed (spec §4 scopes
       white-labeling to buttons/links/badges, not the shell's dark navy register). */
    --portal-sidebar-bg: #0b1530;
    --portal-sidebar-bg-2: #0f1e42;
    --portal-sidebar-text: #aab4d4;
    --portal-sidebar-text-dim: #6b7699;
    --portal-sidebar-active-bg: #2563eb;
}

body.portal-body {
    background: var(--portal-bg);
    color: var(--portal-text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
}

/* ── Auth pages (Login / Forgot / Reset) ──────────────────────────
   Split-screen pattern (Stripe/Linear/Auth0 Universal Login): a branded
   gradient panel carries the trust/value messaging so the form panel can
   stay minimal — one job, no distractions. Single column below 992px. */
.portal-auth-split {
    min-height: 100vh;
    display: flex;
}

.portal-auth-visual {
    flex: 1 1 46%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(155deg, #0f1e42 0%, #1e3a8a 50%, #2563eb 100%);
    color: #fff;
    padding: 28px 48px;
    display: flex;
    flex-direction: column;
    /* NOT space-between: on a full-viewport-height column that stretches the gap between
       each of the 3 sections evenly, dragging the copy block down into the vertical middle
       instead of sitting just below the header. Top-align instead and pin only the tagline
       to the bottom via margin-top:auto below. */
    justify-content: flex-start;
}

.portal-auth-visual::before,
.portal-auth-visual::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.12), transparent 70%);
}
.portal-auth-visual::before { width: 460px; height: 460px; top: -180px; right: -160px; }
.portal-auth-visual::after { width: 340px; height: 340px; bottom: -140px; left: -110px; background: radial-gradient(circle, rgba(255,255,255,.07), transparent 70%); }

.portal-auth-visual > * { position: relative; z-index: 1; }

/* Must come AFTER ".portal-auth-visual > *" above — same specificity (one class each,
   ">*" contributes nothing), so source order decides the tie-break. Without this ordering
   the generic rule's "position: relative" wins, turning this decorative background element
   into a real flex item that pushes the brand/copy/tagline content down below it instead of
   sitting behind them. */
.portal-auth-skyline { position: absolute !important; left: 0; right: 0; bottom: 0; height: 45%; z-index: 0; }

.portal-auth-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.portal-auth-visual .portal-auth-brand { color: #fff; margin-bottom: 0; }
.portal-auth-visual .portal-auth-brand .wordmark { font-size: 1.3rem; font-weight: 800; color: #fff; line-height: 1.1; }
.portal-auth-visual .portal-auth-brand .subtitle { font-size: .78rem; color: rgba(255,255,255,.7); font-weight: 500; }
.portal-auth-visual .portal-auth-brand .portal-mark {
    width: 42px; height: 42px; border-radius: 12px; font-size: 1.2rem;
    background: linear-gradient(135deg, #60a5fa, #2563eb);
    box-shadow: 0 6px 16px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.3);
}
.portal-auth-visual .portal-auth-brand .portal-auth-mark-logo {
    width: 42px; height: 42px; object-fit: contain; border-radius: 12px; flex-shrink: 0;
}

.portal-auth-secure-badge {
    display: flex; align-items: center; gap: 7px;
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14);
    border-radius: 999px; padding: 6px 14px; font-size: .78rem; font-weight: 600; color: rgba(255,255,255,.9);
    white-space: nowrap;
}

/* flex:1 makes this block claim all the space between the topline and the tagline (rather
   than sizing to its own content and leaving a dead gap above the tagline on a tall viewport);
   its own justify-content:center then centers the headline/feature-list within THAT space —
   not the whole panel, so it never drifts back toward the old "dragged to the true vertical
   center including the topline/tagline" bug this replaced. */
.portal-auth-copy { margin: 18px 0; flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; min-height: 0; }

.portal-auth-visual h2 {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.26;
    margin: 0 0 8px;
    max-width: 440px;
}
.portal-auth-visual h2 .accent { color: #7dd3fc; }

.portal-auth-visual p.lead {
    color: rgba(255,255,255,.75);
    font-size: .87rem;
    max-width: 400px;
    margin-bottom: 18px;
}

.portal-auth-feature {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 11px;
}
.portal-auth-feature .icon {
    width: 34px; height: 34px; flex-shrink: 0;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: .92rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.portal-auth-feature .icon.icon-blue { background: linear-gradient(135deg, #3b82f6, #4f46e5); }
.portal-auth-feature .icon.icon-teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.portal-auth-feature .icon.icon-purple { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.portal-auth-feature .text { font-size: .8rem; color: rgba(255,255,255,.85); line-height: 1.35; padding-top: 5px; }
.portal-auth-feature .text strong { display: block; color: #fff; font-size: .87rem; margin-bottom: 1px; }

.portal-auth-tagline {
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    color: rgba(255,255,255,.85);
    margin-top: auto; /* pins to the bottom of the flex column without stretching the gap above it */
    padding-top: 14px;
}

.portal-auth-panel {
    flex: 1 1 54%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--portal-surface);
}

.portal-auth-card {
    width: 100%;
    max-width: 420px;
    padding: 8px 4px;
}

.portal-auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--portal-text);
}

.portal-auth-brand .portal-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--portal-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}

.portal-auth-brand .portal-auth-mark-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 9px;
    flex-shrink: 0;
    vertical-align: middle;
}

.portal-auth-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--portal-primary-soft); color: var(--portal-primary);
    border-radius: 999px; padding: 5px 14px; font-size: .78rem; font-weight: 700;
    margin-bottom: 16px;
}

.portal-auth-card h1 {
    font-size: 1.55rem;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: -.01em;
}

.portal-auth-card p.portal-sub {
    color: var(--portal-text-muted);
    margin-bottom: 26px;
    font-size: .92rem;
}

/* ── Input fields with a leading icon (Login/Reset) ─────────────────── */
.portal-input-icon { position: relative; }
.portal-input-icon .field-icon {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    color: var(--portal-text-muted); font-size: .95rem; pointer-events: none;
}
.portal-input-icon .portal-form-control { padding-left: 40px; }
.portal-input-icon.portal-password-field .portal-form-control { padding-right: 44px; }

/* ── Gradient CTA button used on auth pages (arrow-suffixed) ─────────── */
.portal-btn-auth {
    background: linear-gradient(135deg, var(--portal-primary), #2563eb);
    border: none; color: #fff; border-radius: 10px; padding: .75rem 1rem;
    font-weight: 700; font-size: .95rem; width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 8px 20px rgba(79,70,229,.28);
    transition: transform .15s ease, box-shadow .15s ease;
}
.portal-btn-auth:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 10px 24px rgba(79,70,229,.35); }
.portal-btn-auth:disabled { opacity: .85; transform: none; }
.portal-btn-auth .spinner-border { display: none; width: .9rem; height: .9rem; border-width: .15em; }
.portal-btn-auth.loading .spinner-border { display: inline-block; }
.portal-btn-auth.loading .btn-label::after { content: attr(data-loading); }
.portal-btn-auth.loading .btn-label > span { display: none; }
.portal-btn-auth.loading .btn-arrow { display: none; }

/* ── Bottom trust/security info card on auth pages ────────────────────── */
.portal-security-card {
    display: flex; align-items: flex-start; gap: 12px;
    background: var(--portal-bg); border: 1px solid var(--portal-border);
    border-radius: 12px; padding: 14px 16px; margin-top: 24px;
}
.portal-security-card .shield { width: 34px; height: 34px; border-radius: 9px; background: var(--portal-primary-soft); color: var(--portal-primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.portal-security-card .body { flex: 1; min-width: 0; }
.portal-security-card .body strong { display: block; font-size: .83rem; color: var(--portal-text); }
.portal-security-card .body span { font-size: .76rem; color: var(--portal-text-muted); line-height: 1.4; }
.portal-security-card .ssl-badge { flex-shrink: 0; background: var(--portal-success-soft); color: var(--portal-success); font-size: .68rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

@media (max-width: 991.98px) {
    .portal-auth-visual { display: none; }
    .portal-auth-panel { flex: 1 1 100%; }
}

/* ── Password field: show/hide toggle ─────────────────────────────── */
.portal-password-field { position: relative; }
.portal-password-field .portal-form-control { padding-right: 44px; }
.portal-password-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; border: none; background: transparent;
    color: var(--portal-text-muted); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.portal-password-toggle:hover { background: var(--portal-bg); color: var(--portal-text); }

/* ── Password strength meter + live requirements checklist ─────────── */
.portal-strength-meter { display: flex; gap: 4px; margin-top: 10px; }
.portal-strength-meter .seg { height: 4px; flex: 1; border-radius: 999px; background: var(--portal-border); transition: background .2s ease; }
.portal-strength-label { font-size: .76rem; font-weight: 600; margin-top: 6px; color: var(--portal-text-muted); }

.portal-requirements { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.portal-requirements li {
    font-size: .8rem; color: var(--portal-text-muted);
    display: flex; align-items: center; gap: 6px;
    transition: color .15s ease;
}
.portal-requirements li .dot {
    width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0;
    background: var(--portal-bg); border: 1.5px solid var(--portal-border);
    display: flex; align-items: center; justify-content: center;
    font-size: .62rem; color: transparent;
    transition: all .15s ease;
}
.portal-requirements li.met { color: var(--portal-text); }
.portal-requirements li.met .dot { background: var(--portal-success); border-color: var(--portal-success); color: #fff; }

/* ── Button loading state ────────────────────────────────────────── */
.portal-btn-primary .spinner-border { display: none; width: .9rem; height: .9rem; border-width: .15em; margin-right: 8px; }
.portal-btn-primary.loading .spinner-border { display: inline-block; }
.portal-btn-primary.loading .btn-label::after { content: attr(data-loading); }
.portal-btn-primary.loading .btn-label > span { display: none; }
.portal-btn-primary:disabled { opacity: .8; cursor: default; }

.portal-form-control {
    border-radius: 10px;
    border: 1px solid var(--portal-border);
    padding: .65rem .85rem;
    font-size: .93rem;
}

.portal-form-control:focus {
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px var(--portal-primary-soft);
}

.portal-btn-primary {
    background: var(--portal-primary);
    border: none;
    color: #fff;
    border-radius: 10px;
    padding: .65rem 1rem;
    font-weight: 600;
    font-size: .93rem;
    transition: background .15s ease;
}

.portal-btn-primary:hover { background: var(--portal-primary-dark); color: #fff; }

/* ── App shell (Dashboard and beyond) ─────────────────────────────
   Dark sidebar + light content, the register of Vercel/Linear/modern banking
   apps' authenticated shell — deliberately different weight from the light
   auth-split screens so "logged in" reads as a distinct, denser workspace. */
.portal-shell { display: flex; min-height: 100vh; }

.portal-sidebar {
    width: 264px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--portal-sidebar-bg), var(--portal-sidebar-bg-2));
    padding: 18px 14px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* flex: 1 1 auto (not 0 0 auto) + min-height: 0 lets this actually shrink and scroll instead of
   always sizing to its full content height — without min-height:0, a flex item defaults to
   min-height:auto, which silently blocks shrinkage/scrolling below content size. Without this,
   once the sidebar's total content (nav + help card + footer) exceeds the 100vh sidebar (which
   has overflow:hidden), the last nav items get clipped off-screen with no way to reach them —
   exactly what happened when the "Portal Settings" link was added as the last item. */
.portal-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 10px; }

.portal-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--portal-sidebar-text);
    font-size: .89rem;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 2px;
}
.portal-nav a i { font-size: 1rem; width: 18px; text-align: center; }
.portal-nav a .nav-badge {
    margin-left: auto; background: rgba(255,255,255,.14); color: #fff;
    font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
}
.portal-nav a.active .nav-badge { background: rgba(255,255,255,.25); }

.portal-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.portal-nav a.active { background: var(--portal-sidebar-active-bg); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.portal-nav .portal-nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--portal-sidebar-text-dim); margin: 18px 12px 6px; font-weight: 700; }

.portal-sidebar-help {
    margin: 14px 4px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    padding: 16px;
    flex-shrink: 0;
}
.portal-sidebar-help .icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: rgba(255,255,255,.1); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
    margin-bottom: 10px;
}
.portal-sidebar-help h6 { color: #fff; font-size: .85rem; font-weight: 700; margin-bottom: 4px; }
.portal-sidebar-help p { color: var(--portal-sidebar-text); font-size: .74rem; line-height: 1.4; margin-bottom: 10px; }
.portal-sidebar-help .btn { width: 100%; background: #2563eb; border: none; color: #fff; font-size: .78rem; font-weight: 600; border-radius: 8px; padding: 7px; }
.portal-sidebar-help .btn:hover { background: #1d4ed8; color: #fff; }

.portal-sidebar-footer {
    position: relative;
    flex-shrink: 0;
    height: 64px;
    margin: 8px -14px 0;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    color: rgba(255,255,255,.45);
    font-size: .68rem;
    font-style: italic;
    padding-bottom: 8px;
}
.portal-sidebar-footer svg { position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; opacity: .5; }

.portal-main { flex: 1; min-width: 0; }

.portal-topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 28px;
    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.portal-topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.portal-topbar-brand .wordmark { font-weight: 800; font-size: 1.15rem; color: var(--portal-text); line-height: 1.1; }
.portal-topbar-brand .subtitle { font-size: .7rem; color: var(--portal-text-muted); font-weight: 600; }
.portal-topbar-brand .portal-mark {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand-primary, var(--portal-primary)), var(--brand-secondary, #2563eb));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.1rem;
}
.portal-topbar-brand .portal-mark-logo {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; object-fit: contain;
    background: var(--portal-bg); padding: 3px;
}

/* Global footer (spec §1) — small, muted, never visually dominant. */
.portal-footer { border-top: 1px solid var(--portal-border); margin-top: 32px; padding: 18px 0 24px; }
.portal-footer-inner {
    max-width: 1180px; margin: 0 auto; padding: 0 28px;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
    font-size: 12.5px; color: var(--portal-text-muted);
}
.portal-footer-brand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.portal-footer-sep { opacity: .6; }
.portal-footer-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.portal-footer-links a { color: var(--portal-text-muted); text-decoration: none; }
.portal-footer-links a:hover { color: var(--portal-primary); text-decoration: underline; }
.portal-footer-version { font-size: 11px; opacity: .7; }
@media (max-width: 600px) {
    .portal-footer-inner { flex-direction: column; align-items: flex-start; text-align: left; }
}

/* Shared empty/error state (spec §7) — see portal.js portalEmptyState()/portalErrorState(). */
.portal-state { text-align: center; padding: 48px 20px; }
.portal-state-icon { font-size: 30px; color: var(--portal-text-muted); margin-bottom: 12px; }
.portal-state-error .portal-state-icon { color: var(--portal-warning); }
.portal-state-title { font-size: 14px; font-weight: 600; color: var(--portal-text); margin-bottom: 4px; }
.portal-state-sub { font-size: 12.5px; color: var(--portal-text-muted); }

.portal-search { flex: 1 1 auto; max-width: 460px; position: relative; }
.portal-search input {
    width: 100%; border: 1px solid var(--portal-border); background: var(--portal-bg);
    border-radius: 10px; padding: 9px 14px 9px 38px; font-size: .87rem; color: var(--portal-text);
}
.portal-search input:focus { outline: none; border-color: var(--portal-primary); background: #fff; box-shadow: 0 0 0 3px var(--portal-primary-soft); }
.portal-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--portal-text-muted); }
.portal-search .kbd-hint {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    font-size: .68rem; color: var(--portal-text-muted); background: #fff; border: 1px solid var(--portal-border);
    border-radius: 5px; padding: 1px 6px; font-weight: 600;
}
.portal-search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff;
    border: 1px solid var(--portal-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.12);
    max-height: 380px; overflow-y: auto; z-index: 30;
}
.portal-search-results a { display: block; padding: 10px 14px; text-decoration: none; color: var(--portal-text); border-bottom: 1px solid var(--portal-border); }
.portal-search-results a:last-child { border-bottom: none; }
.portal-search-results a:hover { background: var(--portal-bg); }
.portal-search-results .type { font-size: .68rem; text-transform: uppercase; font-weight: 700; color: var(--portal-primary); letter-spacing: .03em; }
.portal-search-results .title { font-size: .85rem; font-weight: 600; }
.portal-search-results .sub { font-size: .76rem; color: var(--portal-text-muted); }
.portal-search-empty { padding: 18px; text-align: center; color: var(--portal-text-muted); font-size: .82rem; }

.portal-topbar-icon-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--portal-border);
    background: #fff; color: var(--portal-text-muted);
    display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0;
}
.portal-topbar-icon-btn:hover { background: var(--portal-bg); color: var(--portal-text); }

.portal-user-chip { display: flex; align-items: center; gap: 9px; border: none; background: transparent; padding: 4px 6px 4px 4px; border-radius: 10px; }
.portal-user-chip:hover { background: var(--portal-bg); }
.portal-user-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--portal-primary), #2563eb); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem;
}
.portal-user-chip .name { font-size: .84rem; font-weight: 600; color: var(--portal-text); line-height: 1.1; text-align: left; }
.portal-user-chip .name small { display: block; font-weight: 500; color: var(--portal-text-muted); font-size: .7rem; }

.portal-content { padding: 26px 28px; max-width: 1360px; margin: 0 auto; }

.portal-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    padding: 22px;
}

.portal-kpi-label { font-size: .8rem; color: var(--portal-text-muted); font-weight: 600; margin-bottom: 6px; }
.portal-kpi-value { font-size: 1.6rem; font-weight: 700; }

.portal-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 600;
}

.portal-badge-success { background: var(--portal-success-soft); color: var(--portal-success); }
.portal-badge-warning { background: var(--portal-warning-soft); color: var(--portal-warning); }
.portal-badge-danger { background: var(--portal-danger-soft); color: var(--portal-danger); }
.portal-badge-neutral { background: var(--portal-bg); color: var(--portal-text-muted); }

.portal-empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--portal-text-muted);
}

.portal-empty-state i { font-size: 2rem; color: #c7cbe0; margin-bottom: 12px; display: block; }

/* ── Dashboard hero ────────────────────────────────────────────────── */
.portal-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--portal-radius);
    background: linear-gradient(120deg, #0f1e42 0%, #1e3a8a 55%, #2563eb 100%);
    color: #fff;
    padding: 26px 30px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.portal-hero .decor { position: absolute; inset: 0; opacity: .35; pointer-events: none; }
.portal-hero h2 { position: relative; font-size: 1.4rem; font-weight: 800; margin: 0 0 6px; }
.portal-hero p { position: relative; margin: 0; color: rgba(255,255,255,.82); font-size: .88rem; max-width: 520px; }
.portal-hero .chips { position: relative; display: flex; gap: 10px; flex-shrink: 0; }
.portal-hero .chip {
    background: rgba(255,255,255,.14); border-radius: 10px; padding: 8px 14px;
    font-size: .8rem; font-weight: 600; display: flex; align-items: center; gap: 7px; white-space: nowrap;
}

/* ── KPI cards (icon + chevron + caption) ─────────────────────────── */
.portal-kpi-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--portal-surface); border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius); box-shadow: var(--portal-shadow);
    padding: 16px 18px; text-decoration: none; color: inherit;
    transition: transform .15s ease, box-shadow .15s ease;
}
.portal-kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,.09); color: inherit; }
.portal-kpi-card .kpi-icon {
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.portal-kpi-card .kpi-body { flex: 1; min-width: 0; }
.portal-kpi-card .kpi-title { font-size: .8rem; font-weight: 600; color: var(--portal-text-muted); }
.portal-kpi-card .kpi-num { font-size: 1.5rem; font-weight: 800; color: var(--portal-text); line-height: 1.15; }
.portal-kpi-card .kpi-caption { font-size: .72rem; color: var(--portal-text-muted); }
.portal-kpi-card .kpi-chevron { color: #c7cbe0; flex-shrink: 0; }
.kpi-icon-blue { background: var(--portal-primary-soft); color: var(--portal-primary); }
.kpi-icon-green { background: var(--portal-success-soft); color: var(--portal-success); }
.kpi-icon-amber { background: var(--portal-warning-soft); color: var(--portal-warning); }
.kpi-icon-teal { background: #e6fbfa; color: #0d9488; }

/* ── Outstanding-balance donut ─────────────────────────────────────── */
.portal-donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.portal-donut {
    width: 148px; height: 148px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; position: relative;
}
.portal-donut::before {
    content: ''; position: absolute; inset: 14px; background: var(--portal-surface); border-radius: 50%;
}
.portal-donut .donut-center { position: relative; text-align: center; }
.portal-donut .donut-center .amount { font-size: 1.05rem; font-weight: 800; color: var(--portal-text); line-height: 1.15; }
.portal-donut .donut-center .label { font-size: .68rem; color: var(--portal-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.portal-donut-legend { flex: 1; min-width: 180px; }
.portal-donut-legend .row-item { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--portal-border); font-size: .85rem; }
.portal-donut-legend .row-item:last-child { border-bottom: none; }
.portal-donut-legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; }

/* ── Recent Activity feed ─────────────────────────────────────────── */
.portal-activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--portal-border); }
.portal-activity-item:last-child { border-bottom: none; }
.portal-activity-item .activity-icon {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.activity-icon-primary { background: var(--portal-primary-soft); color: var(--portal-primary); }
.activity-icon-success { background: var(--portal-success-soft); color: var(--portal-success); }
.activity-icon-warning { background: var(--portal-warning-soft); color: var(--portal-warning); }
.portal-activity-item .body { flex: 1; min-width: 0; }
.portal-activity-item .title { font-size: .84rem; font-weight: 600; color: var(--portal-text); }
.portal-activity-item .sub { font-size: .76rem; color: var(--portal-text-muted); }
.portal-activity-item .when { font-size: .72rem; color: var(--portal-text-muted); white-space: nowrap; flex-shrink: 0; }

/* ── Quick actions: horizontal row (main content) ─────────────────── */
.portal-qa-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.portal-qa-row-item {
    flex: 1 1 180px; min-width: 180px; display: flex; align-items: center; gap: 12px;
    border: 1px solid var(--portal-border); border-radius: 12px; padding: 12px 14px;
    text-decoration: none; color: inherit; transition: border-color .15s ease, background .15s ease;
}
.portal-qa-row-item:hover { border-color: var(--portal-primary); background: var(--portal-primary-soft); color: inherit; }
.portal-qa-row-item .qa-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.portal-qa-row-item .qa-title { font-size: .84rem; font-weight: 700; color: var(--portal-text); }
.portal-qa-row-item .qa-sub { font-size: .72rem; color: var(--portal-text-muted); }

/* ── Quick actions: 2-column grid (right rail) ─────────────────────── */
.portal-qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.portal-qa-tile {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
    border: 1px solid var(--portal-border); border-radius: 12px; padding: 14px 8px;
    text-decoration: none; color: inherit; transition: border-color .15s ease, transform .15s ease;
}
.portal-qa-tile:hover { border-color: var(--portal-primary); transform: translateY(-2px); color: inherit; }
.portal-qa-tile .qa-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.portal-qa-tile .qa-label { font-size: .74rem; font-weight: 600; color: var(--portal-text); line-height: 1.25; }

/* ── "We're here to help" dark card (right rail) ───────────────────── */
.portal-help-card {
    position: relative; overflow: hidden;
    background: linear-gradient(135deg, #0f1e42, #1e3a8a);
    color: #fff; border-radius: var(--portal-radius); padding: 20px;
}
.portal-help-card .icon { width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.14); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 12px; }
.portal-help-card h6 { font-weight: 700; margin-bottom: 6px; }
.portal-help-card p { font-size: .82rem; color: rgba(255,255,255,.75); margin-bottom: 14px; }
.portal-help-card .btn-light { font-weight: 600; font-size: .82rem; }

@media (max-width: 1199.98px) {
    .portal-qa-grid { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 900px) {
    .portal-sidebar { display: none; }
    .portal-content { padding: 18px; }
    .portal-topbar-brand .wordmark, .portal-topbar-brand .subtitle { display: none; }
    .portal-search { display: none; }
    .portal-hero { padding: 20px; }
}

/* ── Implementation / Project Progress (read-only, ProjectMaster.CustomerID) ────────── */
.portal-impl-progress-track {
    height: 8px; border-radius: 999px; background: var(--portal-bg); overflow: hidden;
}
.portal-impl-progress-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--portal-primary), #7c72f0);
}

.portal-impl-milestones {
    position: relative;
    margin-top: 6px;
    padding-left: 22px;
    border-left: 2px solid var(--portal-border);
}
.portal-impl-milestone-item {
    position: relative;
    display: flex;
    gap: 12px;
    padding: 10px 0;
}
.portal-impl-milestone-item .dot {
    position: absolute;
    left: -28px;
    top: 14px;
    width: 10px; height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px var(--portal-surface);
}
.portal-impl-milestone-item .body { flex: 1; }
.portal-impl-clickable { cursor: pointer; border-radius: 8px; transition: background .12s; }
.portal-impl-clickable:hover { background: var(--portal-bg); }

/* ── Task detail page (authenticated portal equivalent of the anonymous share-link page) ── */
.portal-impl-back {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .84rem; font-weight: 600; color: var(--portal-text-muted);
    text-decoration: none; margin-bottom: 14px; transition: color .12s;
}
.portal-impl-back:hover { color: var(--portal-primary); }

/* Loading skeleton — shown the instant the page opens, before the fetch resolves */
.portal-impl-skeleton { background: var(--portal-surface); border: 1px solid var(--portal-border); border-radius: var(--portal-radius); padding: 22px; }
.portal-impl-skeleton .sk-line {
    height: 14px; border-radius: 6px; margin-bottom: 12px;
    background: linear-gradient(90deg, var(--portal-bg) 25%, #eef0f6 37%, var(--portal-bg) 63%);
    background-size: 400% 100%;
    animation: portal-impl-shimmer 1.4s ease infinite;
}
.portal-impl-skeleton .h-lg { height: 22px; }
.portal-impl-skeleton .w-40 { width: 40%; }
.portal-impl-skeleton .w-70 { width: 70%; }
.portal-impl-skeleton .w-100 { width: 100%; }
@keyframes portal-impl-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Hero card — task identity, status, description, meta chips, overall progress */
.portal-impl-hero {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    padding: 24px 26px;
    position: relative;
    overflow: hidden;
}
.portal-impl-hero::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--portal-primary), #7c72f0);
}
.portal-impl-hero .crumb { font-size: .78rem; font-weight: 600; color: var(--portal-text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.portal-impl-hero .crumb .sep { color: var(--portal-border); }
.portal-impl-hero h3 { font-weight: 800; margin: 0 0 4px; font-size: 1.4rem; letter-spacing: -.01em; }
.portal-impl-hero .desc { color: var(--portal-text-muted); margin: 8px 0 4px; line-height: 1.55; }

.portal-impl-status-pill { border: 1px solid; padding: 5px 12px 5px 10px; font-size: .78rem; flex-shrink: 0; }
.portal-impl-status-pill .ring { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.meta-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 18px; }
.meta-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .8rem; font-weight: 600; color: var(--portal-text-muted);
    background: var(--portal-bg); border-radius: 999px; padding: 6px 12px;
}
.meta-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.meta-chip.tone-success { background: var(--portal-success-soft); color: var(--portal-success); }
.meta-chip.tone-warning { background: var(--portal-warning-soft); color: var(--portal-warning); }
.meta-chip.tone-danger { background: var(--portal-danger-soft); color: var(--portal-danger); }

.portal-impl-progress-track.lg { height: 10px; }
.portal-impl-hero .pct-label { font-size: .78rem; font-weight: 700; color: var(--portal-primary); margin-top: 6px; }

.portal-impl-section-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: .92rem; color: var(--portal-text);
    margin-bottom: 14px;
}
.portal-impl-section-title .count {
    font-size: .7rem; font-weight: 700; color: var(--portal-text-muted);
    background: var(--portal-bg); border-radius: 999px; padding: 1px 8px;
}

/* Stepper — horizontal line running through the dots, checkmarks for passed stages */
.portal-impl-stepper {
    display: flex;
    align-items: flex-start;
    overflow-x: auto;
    padding: 6px 4px 2px;
}
.portal-impl-step {
    position: relative;
    flex: 1 0 110px;
    text-align: center;
    padding: 0 6px;
}
.portal-impl-step .line {
    position: absolute;
    top: 11px; right: 50%; width: 100%; height: 2px;
    background: var(--portal-border);
    z-index: 0;
}
.portal-impl-step .line.done { background: var(--portal-primary); }
.portal-impl-step .dot {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--portal-surface);
    border: 2px solid var(--portal-border);
    margin: 0 auto 8px;
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .8rem;
}
.portal-impl-step.current .dot {
    box-shadow: 0 0 0 5px var(--portal-primary-soft);
    border-color: var(--portal-primary); background: var(--portal-primary);
    animation: portal-impl-pulse 1.8s ease-out infinite;
}
@keyframes portal-impl-pulse {
    0% { box-shadow: 0 0 0 5px var(--portal-primary-soft); }
    50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--portal-primary) 12%, transparent); }
    100% { box-shadow: 0 0 0 5px var(--portal-primary-soft); }
}
.portal-impl-step .label { font-size: .78rem; font-weight: 700; color: var(--portal-text); }
.portal-impl-step.pending .label { color: var(--portal-text-muted); font-weight: 600; }
.portal-impl-step .date { font-size: .7rem; color: var(--portal-text-muted); margin-top: 2px; }

/* Attachments */
.portal-impl-attachments { display: flex; flex-direction: column; gap: 6px; }
.portal-impl-attachment {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px; background: var(--portal-bg);
    text-decoration: none; color: var(--portal-text); transition: background .12s;
}
.portal-impl-attachment:hover { background: var(--portal-primary-soft); color: var(--portal-text); }
.portal-impl-attachment .file-icon { font-size: 1.15rem; }
.portal-impl-attachment .file-name { flex: 1; font-weight: 600; font-size: .88rem; }
.portal-impl-attachment .dl-icon { color: var(--portal-text-muted); }

/* Comment thread — chat-style bubbles for people, a thin timeline row for system entries */
.portal-impl-thread { display: flex; flex-direction: column; gap: 12px; }
.portal-impl-sys-entry {
    display: flex; align-items: center; gap: 6px;
    font-size: .78rem; color: var(--portal-text-muted); font-style: italic;
    padding-left: 4px;
}
.portal-impl-sys-entry .ts { margin-left: auto; font-style: normal; opacity: .75; }
.portal-impl-comment { display: flex; gap: 10px; align-items: flex-start; }
.portal-impl-comment .avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .78rem;
}
.portal-impl-comment .bubble {
    background: var(--portal-bg); border-radius: 12px; padding: 10px 14px;
    max-width: 78%;
}
.portal-impl-comment.customer .bubble { background: var(--portal-primary-soft); }
.portal-impl-comment .bubble strong { font-size: .84rem; }
.portal-impl-comment .bubble .ts { font-size: .72rem; color: var(--portal-text-muted); white-space: nowrap; }
.portal-impl-comment .bubble .text { font-size: .88rem; margin-top: 2px; line-height: 1.5; white-space: pre-wrap; }

/* Composer */
.portal-impl-composer { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--portal-border); }
.portal-impl-composer .avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .78rem;
}
.portal-impl-composer .portal-btn-auth { max-width: 180px; }

/* ── Shared "attach an image to a comment" widgets — Implementation task comments and
   Support Ticket replies both use this same look/token convention (see
   CoreERP.Infrastructure.CommentBodyRenderer). ── */
.comment-img-gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.comment-inline-img { max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--portal-border); cursor: zoom-in; display: block; object-fit: cover; }
.reply-img-chip { position: relative; width: 60px; height: 60px; border-radius: 9px; overflow: hidden; border: 1px solid var(--portal-border); background: var(--portal-bg); flex-shrink: 0; }
.reply-img-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reply-img-chip .chip-remove { position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%; background: rgba(15,23,42,.68); color: #fff; border: none; display: flex; align-items: center; justify-content: center; font-size: .58rem; cursor: pointer; line-height: 1; }
.reply-img-chip .chip-remove:hover { background: var(--portal-danger); }
.reply-img-chip .chip-spinner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.75); }

/* ── Project Progress list — overview strip, filter bar, grouped task labels ─────────── */
.portal-impl-summary-row {
    display: grid;
    /* auto-fit instead of a hardcoded column count — this row is shared by pages with different
       tile counts (4 on Project Progress, 5 on My Tickets); a fixed repeat(4,1fr) left a 5th tile
       stranded alone on its own row with three empty column-widths next to it. */
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.portal-impl-summary-tile {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    padding: 16px 18px;
    display: flex; align-items: center; gap: 12px;
}
.portal-impl-summary-tile .icon {
    width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.portal-impl-summary-tile .icon.blue { background: #eaf1fe; color: #2563eb; }
.portal-impl-summary-tile .icon.indigo { background: var(--portal-primary-soft); color: var(--portal-primary); }
.portal-impl-summary-tile .icon.green { background: var(--portal-success-soft); color: var(--portal-success); }
.portal-impl-summary-tile .icon.red { background: var(--portal-danger-soft); color: var(--portal-danger); }
.portal-impl-summary-tile .icon.amber { background: var(--portal-warning-soft); color: var(--portal-warning); }
.portal-impl-summary-tile .value { font-size: 1.4rem; font-weight: 800; line-height: 1.1; }
.portal-impl-summary-tile .label { font-size: .76rem; color: var(--portal-text-muted); font-weight: 600; }
.portal-impl-summary-tile#sumOverdueTile.zero { opacity: .55; }
@media (max-width: 900px) { .portal-impl-summary-row { grid-template-columns: repeat(2, 1fr); } }

.portal-impl-filterbar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 16px;
}
.portal-impl-filterbar .portal-input-icon { max-width: 280px; }
.portal-impl-chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.portal-impl-chip {
    border: 1px solid var(--portal-border); background: var(--portal-surface);
    border-radius: 999px; padding: 6px 14px; font-size: .8rem; font-weight: 600;
    color: var(--portal-text-muted); cursor: pointer; transition: all .12s;
}
.portal-impl-chip:hover { border-color: var(--portal-primary); color: var(--portal-primary); }
.portal-impl-chip.active { background: var(--portal-primary); border-color: var(--portal-primary); color: #fff; }
.portal-impl-chip .chip-count {
    display: inline-block; margin-left: 6px; padding: 1px 7px;
    border-radius: 999px; font-size: .72rem; font-weight: 700;
    background: rgba(0, 0, 0, .06); color: inherit;
}
.portal-impl-chip.active .chip-count { background: rgba(255, 255, 255, .25); }

.portal-impl-group-label {
    display: flex; align-items: center; gap: 6px;
    font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--portal-text-muted); margin-bottom: 2px;
}
.portal-impl-milestone-item .chevron { color: var(--portal-border); align-self: center; font-size: 1rem; }
.portal-impl-milestone-item:hover .chevron { color: var(--portal-primary); }

/* Dashboard "Active Project" preview card */
.portal-impl-dash-card { color: var(--portal-text); transition: box-shadow .15s, transform .15s; }
.portal-impl-dash-card:hover { box-shadow: 0 4px 16px rgba(16,24,40,.1); transform: translateY(-1px); color: var(--portal-text); }
.portal-impl-dash-next {
    display: flex; align-items: center; gap: 6px;
    margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--portal-border);
    font-size: .78rem; color: var(--portal-text-muted);
}
.portal-impl-dash-next i { color: var(--portal-primary); }

/* ── My Tickets — premium list (Zendesk/Intercom-style) ──────────────────────────────── */
.portal-ticket-table thead th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--portal-text-muted); font-weight: 700; border-bottom: 1px solid var(--portal-border);
    padding-bottom: 10px;
}
.portal-ticket-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.portal-ticket-table th.sortable:hover { color: var(--portal-text); }
.sort-ic { font-size: .7rem; margin-left: 3px; opacity: .4; }
.sort-ic.active { opacity: 1; color: var(--portal-primary); }

.ticket-row { cursor: pointer; transition: background .12s; }
.ticket-row:hover { background: var(--portal-bg); }
.ticket-row td { padding-top: 12px; padding-bottom: 12px; }
.ticket-row.attention { background: color-mix(in srgb, var(--portal-warning) 5%, transparent); }
.ticket-row.attention:hover { background: color-mix(in srgb, var(--portal-warning) 10%, transparent); }
.cat-cell { width: 28px; color: var(--portal-text-muted); font-size: 1rem; }

.attn-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--portal-danger); flex-shrink: 0;
    box-shadow: 0 0 0 3px var(--portal-danger-soft);
    animation: portal-attn-pulse 1.8s ease-out infinite;
}
@keyframes portal-attn-pulse {
    0% { box-shadow: 0 0 0 3px var(--portal-danger-soft); }
    50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--portal-danger) 10%, transparent); }
    100% { box-shadow: 0 0 0 3px var(--portal-danger-soft); }
}

.priority-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; font-weight: 600; }
.priority-pill .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.agent-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; }
.agent-chip .av {
    width: 22px; height: 22px; border-radius: 50%; background: #0f1e42; color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: .64rem; font-weight: 700; flex-shrink: 0;
}
#tileAttention .icon.red { background: var(--portal-danger-soft); color: var(--portal-danger); }
#tileAttention.zero { opacity: .55; }

/* ── Portal finance / list pages — Payments, Transactions, Documents ─────────────
   Shared visual language: page header with an icon badge + eyebrow, per-currency
   summary tiles, a compact filter bar, a quiet sortable table, and a numbered pager. */
.pf-head-icon {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    background: var(--portal-primary-soft); color: var(--portal-primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.pf-eyebrow { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--portal-primary); }

.pf-sum-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.pf-sum-tile { background: var(--portal-surface); border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); padding: 16px 18px; }
.pf-sum-tile.tint-red { background: linear-gradient(180deg, var(--portal-danger-soft), var(--portal-surface) 60%); }
.pf-sum-tile.tint-green { background: linear-gradient(180deg, var(--portal-success-soft), var(--portal-surface) 60%); }
.pf-sum-tile .lbl { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--portal-text-muted); }
.pf-sum-tile .val { font-size: 1.45rem; font-weight: 800; line-height: 1.15; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.pf-sum-tile .subs { display: flex; flex-wrap: wrap; gap: 6px; }
.pf-chip { font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--portal-bg); color: var(--portal-text-muted); white-space: nowrap; }
.pf-chip.danger { background: var(--portal-danger-soft); color: var(--portal-danger); }
.pf-chip.success { background: var(--portal-success-soft); color: var(--portal-success); }

.pf-filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.pf-filterbar .grow { flex: 1 1 220px; min-width: 200px; }
.pf-filter-select, .pf-date { max-width: 175px; }

.pf-table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--portal-text-muted); font-weight: 700; border-bottom: 1px solid var(--portal-border); padding-bottom: 10px; white-space: nowrap; }
.pf-table th.sortable { cursor: pointer; user-select: none; }
.pf-table th.sortable:hover { color: var(--portal-text); }
.pf-table .sort-ic { font-size: .68rem; opacity: .4; margin-left: 3px; }
.pf-table .sort-ic.active { opacity: 1; color: var(--portal-primary); }
.pf-table .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-row { transition: background .12s; }
.pf-row:hover { background: var(--portal-bg); }
.pf-row td { padding-top: 12px; padding-bottom: 12px; vertical-align: middle; }
.pf-row.clickable { cursor: pointer; }
.pf-row.expander-open { background: var(--portal-bg); }
.pf-subrow td { background: var(--portal-bg); padding: 0; }
.pf-subrow .inner { padding: 10px 16px 14px; }
.pf-alloc-line { display: flex; justify-content: space-between; font-size: .8rem; padding: 4px 0; border-bottom: 1px dashed var(--portal-border); }
.pf-alloc-line:last-child { border-bottom: 0; }
.pf-icon-btn { border: 0; background: transparent; color: var(--portal-text-muted); padding: 4px 7px; border-radius: 8px; font-size: 1rem; }
.pf-icon-btn:hover { background: var(--portal-primary-soft); color: var(--portal-primary); }
.pf-page-btn { min-width: 32px; }
.pf-txn-type { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; }
.pf-txn-type .ic { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: .72rem; flex-shrink: 0; }
.pf-amt-debit { color: var(--portal-text); }
.pf-amt-credit { color: var(--portal-success); }

.pf-doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.pf-doc-card {
    border: 1px solid var(--portal-border); border-radius: 12px; padding: 16px;
    display: flex; flex-direction: column; text-decoration: none; color: var(--portal-text);
    background: var(--portal-surface); transition: border-color .12s, box-shadow .12s, transform .12s;
}
.pf-doc-card:hover { border-color: var(--portal-primary); box-shadow: 0 6px 18px rgba(16, 24, 40, .08); transform: translateY(-1px); color: var(--portal-text); }
.pf-doc-card .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--portal-primary-soft); color: var(--portal-primary); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-bottom: 10px; }
.pf-doc-card .nm { font-weight: 700; font-size: .9rem; line-height: 1.25; }
.pf-doc-card .meta { font-size: .76rem; color: var(--portal-text-muted); margin-top: 2px; }
.pf-doc-card .dl { margin-top: 10px; font-size: .78rem; font-weight: 600; color: var(--portal-primary); display: flex; align-items: center; gap: 5px; }

/* ── Help Center (Knowledge Base) — public-facing; benchmarked against Zendesk
   Guide / Intercom / Stripe Docs: search-first hero, category cards, scannable
   article rows, instant-search dropdown. ── */
.hc-body { font-family: 'Inter', 'Segoe UI', Arial, sans-serif; }
.hc-header { background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--portal-border); position: sticky; top: 0; z-index: 30; }
.hc-header-inner { max-width: 1160px; margin: 0 auto; padding: 16px 28px; display: flex; align-items: center; gap: 22px; }
.hc-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--portal-text); flex-shrink: 0; }
/* .portal-mark is normally scoped under .portal-topbar-brand (the authenticated shell); the
   Help Center's own header never gets that ancestor, so it needs its own copy of the same
   gradient-tile treatment or the brand mark renders as bare unstyled text. */
.hc-brand .portal-mark {
    width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand-primary, var(--portal-primary)), var(--brand-secondary, #2563eb));
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
}
.hc-brand-name { font-weight: 800; font-size: .95rem; line-height: 1.15; }
.hc-brand-sub { font-size: .73rem; color: var(--portal-text-muted); font-weight: 600; }
.hc-header-search { flex: 1; max-width: 380px; position: relative; }
.hc-header-search input {
    width: 100%; padding: 9px 14px 9px 36px; border-radius: 999px; border: 1px solid var(--portal-border);
    font-size: .85rem; background: var(--portal-bg); transition: border-color .12s, background .12s;
}
.hc-header-search input:focus { outline: none; border-color: var(--portal-primary); background: #fff; box-shadow: 0 0 0 3px var(--portal-primary-soft); }
.hc-header-search .bi-search { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--portal-text-muted); font-size: .85rem; }
.hc-header .btn-primary { border-radius: 9px; font-weight: 700; padding: 8px 16px; font-size: .84rem; }
.hc-header .btn-outline-secondary { border-radius: 9px; font-weight: 600; padding: 8px 14px; font-size: .84rem; }
.hc-main { max-width: 1120px; margin: 0 auto; padding: 0 24px 70px; min-height: 60vh; }
.hc-footer { border-top: 1px solid var(--portal-border); background: linear-gradient(180deg, var(--portal-surface), var(--portal-bg)); margin-top: 50px; }
.hc-footer-inner { max-width: 1120px; margin: 0 auto; padding: 22px 24px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: .8rem; color: var(--portal-text-muted); }
.hc-footer-links a { color: var(--portal-text-muted); text-decoration: none; margin-left: 18px; }
.hc-footer-links a:first-child { margin-left: 0; }
.hc-footer-links a:hover { color: var(--portal-primary); }

/* Hero — gradient banner on the Help Center home page */
.hc-hero {
    text-align: center; padding: 64px 32px 56px; margin: 28px 0 44px; border-radius: 22px;
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 45%, #2563eb 100%);
    box-shadow: 0 20px 44px rgba(67,56,202,.28); position: relative; overflow: hidden;
}
.hc-hero::before, .hc-hero::after { content: ''; position: absolute; border-radius: 50%; pointer-events: none; }
.hc-hero::before { width: 440px; height: 440px; top: -200px; right: -120px; background: radial-gradient(circle, rgba(255,255,255,.16), transparent 70%); }
.hc-hero::after { width: 340px; height: 340px; bottom: -170px; left: -100px; background: radial-gradient(circle, rgba(255,255,255,.1), transparent 70%); }
.hc-hero > * { position: relative; z-index: 1; }
.hc-hero h1 { font-size: 2.4rem; font-weight: 800; color: #fff; margin-bottom: 10px; letter-spacing: -.015em; }
.hc-hero p { color: rgba(255,255,255,.85); margin-bottom: 28px; font-size: 1.02rem; }
.hc-search { max-width: 600px; margin: 0 auto; position: relative; }
.hc-search input {
    width: 100%; padding: 17px 22px 17px 52px; border-radius: 14px; border: none; font-size: 1rem;
    box-shadow: 0 14px 36px rgba(15,23,42,.25);
}
.hc-search input:focus { outline: none; box-shadow: 0 14px 36px rgba(15,23,42,.25), 0 0 0 4px rgba(255,255,255,.35); }
.hc-search .bi-search { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--portal-text-muted); font-size: 1.05rem; }

/* Instant-results dropdown for both the hero and header search boxes — reuses the existing
   /customer/help/api/search endpoint (already backs the full results page); see
   wwwroot/js/portal-helpcenter.js. Purely a client-side UX layer, no new backend surface. */
.hc-search-wrap { position: relative; }
.hc-search-results {
    position: absolute; top: calc(100% + 10px); left: 0; right: 0; background: #fff; text-align: left;
    border-radius: 14px; box-shadow: 0 18px 44px rgba(15,23,42,.18); overflow: hidden; z-index: 25;
}
.hc-search-results a { display: block; padding: 12px 18px; text-decoration: none; color: var(--portal-text); border-bottom: 1px solid var(--portal-border); }
.hc-search-results a:last-child { border-bottom: none; }
.hc-search-results a:hover { background: var(--portal-bg); }
.hc-search-results .ttl { font-weight: 650; font-size: .88rem; }
.hc-search-results .summary { font-size: .78rem; color: var(--portal-text-muted); margin-top: 2px; }
.hc-search-results .empty { padding: 16px 18px; text-align: center; color: var(--portal-text-muted); font-size: .84rem; }
.hc-header-search.hc-search-wrap .hc-search-results { top: calc(100% + 8px); border-radius: 12px; }

.hc-popular-searches { margin-top: 18px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: center; }
.hc-popular-searches span { color: rgba(255,255,255,.7); font-size: .78rem; font-weight: 600; }
.hc-popular-searches a { background: rgba(255,255,255,.14); color: #fff; border-radius: 999px; padding: 5px 14px; font-size: .78rem; font-weight: 600; text-decoration: none; transition: background .12s; }
.hc-popular-searches a:hover { background: rgba(255,255,255,.26); color: #fff; }

.hc-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin: 0 0 44px; }
.hc-cat-card {
    background: var(--portal-surface); border: 1px solid var(--portal-border); border-radius: 16px;
    padding: 24px; text-decoration: none; color: var(--portal-text); transition: border-color .15s, box-shadow .18s, transform .18s;
    position: relative; overflow: hidden; min-height: 168px; display: flex; flex-direction: column;
}
.hc-cat-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--cat-fg, var(--portal-primary)); opacity: 0; transition: opacity .15s; }
.hc-cat-card:hover { border-color: transparent; box-shadow: 0 16px 36px rgba(16,24,40,.12); transform: translateY(-4px); color: var(--portal-text); }
.hc-cat-card:hover::before { opacity: 1; }
.hc-cat-card .ic { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; margin-bottom: 16px; }
.hc-cat-card .nm { font-weight: 700; font-size: 1.04rem; }
.hc-cat-card .desc { font-size: .83rem; color: var(--portal-text-muted); margin-top: 5px; line-height: 1.45; }
.hc-cat-card .count { font-size: .74rem; color: var(--portal-text-muted); margin-top: auto; padding-top: 14px; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.hc-cat-card .go { position: absolute; right: 22px; bottom: 22px; color: var(--portal-text-muted); opacity: 0; transition: opacity .15s, transform .15s; }
.hc-cat-card:hover .go { opacity: 1; transform: translateX(2px); }

.hc-section-title { font-weight: 800; font-size: 1.22rem; margin: 0 0 16px; letter-spacing: -.01em; display: flex; align-items: center; }
.hc-section-title .bi { color: var(--portal-primary); margin-right: 8px; }
.hc-article-list { display: flex; flex-direction: column; gap: 9px; }
.hc-article-row {
    display: flex; align-items: center; gap: 15px; padding: 17px 20px; border-radius: 13px;
    text-decoration: none; color: var(--portal-text); border: 1px solid var(--portal-border);
    background: var(--portal-surface); transition: border-color .12s, box-shadow .15s, transform .12s;
}
.hc-article-row:hover { border-color: var(--portal-primary); box-shadow: 0 10px 24px rgba(16,24,40,.08); transform: translateX(3px); color: var(--portal-text); }
.hc-article-row .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--portal-primary-soft); color: var(--portal-primary); display: flex; align-items: center; justify-content: center; font-size: 1.02rem; flex-shrink: 0; }
.hc-article-row .ttl { font-weight: 650; font-size: .94rem; flex-grow: 1; }
.hc-article-row .summary { font-size: .81rem; color: var(--portal-text-muted); margin-top: 2px; }
.hc-article-row .bi-chevron-right { color: var(--portal-text-muted); flex-shrink: 0; transition: transform .12s; }
.hc-article-row:hover .bi-chevron-right { transform: translateX(2px); }

.hc-breadcrumb { font-size: .82rem; color: var(--portal-text-muted); margin: 22px 0 20px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hc-breadcrumb a { color: var(--portal-text-muted); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.hc-breadcrumb a:hover { color: var(--portal-primary); }
.hc-breadcrumb .sep { color: var(--portal-border); }
.hc-breadcrumb .current { color: var(--portal-text); font-weight: 600; }

.hc-cat-hero { display: flex; align-items: center; gap: 18px; margin-bottom: 30px; }
.hc-cat-hero .ic { width: 60px; height: 60px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; flex-shrink: 0; }
.hc-cat-hero h1 { font-size: 1.65rem; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.hc-cat-hero p { color: var(--portal-text-muted); margin: 4px 0 0; font-size: .89rem; }

.hc-article-title { font-size: 1.9rem; font-weight: 800; margin-bottom: 10px; letter-spacing: -.015em; line-height: 1.25; }
.hc-article-meta { font-size: .8rem; color: var(--portal-text-muted); margin-bottom: 28px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.hc-article-meta span { display: inline-flex; align-items: center; gap: 5px; }
.hc-article-body { font-size: .98rem; line-height: 1.8; color: var(--portal-text); max-width: 720px; }
.hc-article-body img { max-width: 100%; border-radius: 10px; margin: 14px 0; box-shadow: 0 4px 16px rgba(16,24,40,.08); }
.hc-article-body h1, .hc-article-body h2, .hc-article-body h3 { font-weight: 700; margin-top: 26px; margin-bottom: 10px; letter-spacing: -.01em; }
.hc-article-body p { margin-bottom: 15px; }
.hc-article-body ul, .hc-article-body ol { margin-bottom: 15px; padding-left: 1.4em; }
.hc-article-body a { color: var(--portal-primary); }

.hc-feedback { margin-top: 44px; padding: 26px; border: 1px solid var(--portal-border); border-radius: 16px; text-align: center; background: var(--portal-bg); max-width: 720px; }
.hc-feedback .q { font-weight: 700; margin-bottom: 14px; font-size: .98rem; }
.hc-feedback .thanks { color: var(--portal-success); font-weight: 600; }
.hc-feedback .btn { border-radius: 10px; padding: 8px 18px; font-weight: 600; }

.hc-related { margin-top: 40px; max-width: 720px; }
.hc-empty { text-align: center; padding: 60px 20px; color: var(--portal-text-muted); }
.hc-empty-icon {
    width: 68px; height: 68px; border-radius: 50%; margin: 0 auto 18px; background: var(--portal-primary-soft);
    color: var(--portal-primary); display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
}

/* "Still need help?" — the closing CTA every mainstream help center ends on */
.hc-contact-cta {
    margin-top: 48px; padding: 28px 32px; border-radius: 18px; text-align: center;
    background: linear-gradient(135deg, var(--portal-primary-soft), #f3ecfe);
    border: 1px solid var(--portal-border); max-width: 720px;
}
.hc-contact-cta h3 { font-weight: 800; font-size: 1.15rem; margin-bottom: 6px; }
.hc-contact-cta p { color: var(--portal-text-muted); font-size: .88rem; margin-bottom: 16px; }

@media (max-width: 767.98px) {
    .hc-header-inner { padding: 12px 18px; gap: 12px; }
    .hc-brand-sub { display: none; }
    .hc-hero { padding: 44px 20px 40px; margin: 18px 0 32px; border-radius: 18px; }
    .hc-hero h1 { font-size: 1.7rem; }
    .hc-hero p { font-size: .9rem; margin-bottom: 22px; }
    .hc-search input { padding: 14px 18px 14px 44px; font-size: .92rem; }
    .hc-cat-grid { grid-template-columns: 1fr; }
    .hc-cat-hero { flex-direction: column; align-items: flex-start; gap: 12px; }
    .hc-main { padding: 0 16px 50px; }
    .hc-article-title { font-size: 1.5rem; }
}

/* ══════════════════════════════════════════════════════════════════
   Legal & Trust Center (Areas/Portal/Views/Legal/Document.cshtml)
   Shared design system for Terms / Privacy / Cookies / Security & Trust.
   Deliberately light (not the dark .portal-hero used on the Dashboard) —
   an enterprise "legal document" register, not a marketing hero.
   ══════════════════════════════════════════════════════════════════ */
.legal-page { max-width: 1360px; margin: 0 auto; padding: 26px 28px 60px; }
.legal-page.legal-page-standalone { padding-top: 40px; }

.legal-hero {
    position: relative; overflow: hidden;
    background: linear-gradient(180deg, #eef2fb 0%, #f6f8fd 100%);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 32px 34px;
    margin-bottom: 24px;
}
.legal-hero::before {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background-image:
        radial-gradient(circle at 90% 8%, color-mix(in srgb, var(--portal-primary) 10%, transparent) 0%, transparent 45%),
        radial-gradient(circle at 100% 105%, color-mix(in srgb, var(--brand-secondary, #2563eb) 9%, transparent) 0%, transparent 42%);
}
.legal-hero-top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.legal-hero-icon {
    width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
    background: var(--portal-primary-soft); color: var(--portal-primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem; margin-bottom: 14px;
}
.legal-eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--portal-primary); margin-bottom: 6px; }
.legal-hero h1 { font-size: 1.85rem; font-weight: 800; color: #0f1e42; margin: 0 0 10px; letter-spacing: -.01em; }
.legal-hero-desc { position: relative; font-size: .95rem; color: var(--portal-text-muted); max-width: 620px; line-height: 1.6; margin: 0; }
.legal-hero-meta { position: relative; display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--portal-border); font-size: .8rem; color: var(--portal-text-muted); }
.legal-hero-meta span { display: flex; align-items: center; gap: 6px; }
.legal-hero-meta strong { color: var(--portal-text); font-weight: 700; }

.legal-search-box { position: relative; min-width: 240px; flex-shrink: 0; }
.legal-search-box input {
    width: 100%; border: 1px solid var(--portal-border); background: #fff; border-radius: 10px;
    padding: 9px 14px 9px 36px; font-size: .85rem; color: var(--portal-text);
}
.legal-search-box input:focus { outline: none; border-color: var(--portal-primary); box-shadow: 0 0 0 3px var(--portal-primary-soft); }
.legal-search-box .bi-search { position: absolute; left: 12px; top: 13px; color: var(--portal-text-muted); pointer-events: none; }
.legal-search-count { font-size: .72rem; color: var(--portal-text-muted); margin-top: 6px; min-height: 14px; }
.legal-search-count.has-results { color: var(--portal-primary); font-weight: 600; }
mark.legal-hit { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
mark.legal-hit.legal-hit-active { background: var(--portal-primary); color: #fff; }

.legal-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.legal-action-btn {
    display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--portal-border); background: #fff;
    color: var(--portal-text); font-size: .8rem; font-weight: 600; padding: 7px 13px; border-radius: 9px;
    text-decoration: none; cursor: pointer;
}
.legal-action-btn:hover { background: var(--portal-bg); color: var(--portal-text); }
.legal-action-btn-primary { background: var(--portal-primary); color: #fff; border-color: transparent; }
.legal-action-btn-primary:hover { background: var(--portal-primary-dark); color: #fff; }
.legal-action-btn:focus-visible, .legal-nav-card a:focus-visible, .legal-toc-card a:focus-visible, .legal-back-to-top:focus-visible, .legal-heading-link:focus-visible {
    outline: 2px solid var(--portal-primary); outline-offset: 2px;
}

.legal-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 26px; align-items: start; }

.legal-rail { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 104px); overflow-y: auto; }

.legal-nav-card, .legal-toc-card {
    background: #fff; border: 1px solid var(--portal-border); border-radius: var(--portal-radius);
    padding: 16px; box-shadow: var(--portal-shadow);
}
.legal-rail-title { font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--portal-text-muted); margin-bottom: 10px; }
.legal-nav-card a {
    display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px;
    font-size: .85rem; font-weight: 600; color: var(--portal-text-muted); text-decoration: none; margin-bottom: 2px;
}
.legal-nav-card a:hover { background: var(--portal-bg); color: var(--portal-text); }
.legal-nav-card a.active { background: var(--portal-primary-soft); color: var(--portal-primary); }
.legal-nav-card a i { font-size: .95rem; width: 16px; text-align: center; }

.legal-toc-card ol { list-style: none; margin: 0; padding: 0; counter-reset: legal-toc; }
.legal-toc-card li { counter-increment: legal-toc; margin-bottom: 2px; }
.legal-toc-card li.legal-toc-sub { margin-left: 14px; }
.legal-toc-card li.legal-toc-sub { counter-increment: none; }
.legal-toc-card a {
    display: flex; gap: 8px; padding: 6px 10px; border-radius: 8px; font-size: .81rem; color: var(--portal-text-muted);
    text-decoration: none; line-height: 1.35; border-left: 2px solid transparent;
}
.legal-toc-card li:not(.legal-toc-sub) > a::before { content: counter(legal-toc, decimal-leading-zero); font-weight: 700; color: #c7cbe0; flex-shrink: 0; }
.legal-toc-card a:hover { color: var(--portal-text); }
.legal-toc-card a.active { color: var(--portal-primary); font-weight: 700; border-left-color: var(--portal-primary); background: var(--portal-primary-soft); }
.legal-toc-card a.active::before { color: var(--portal-primary); }
.legal-toc-empty { font-size: .78rem; color: var(--portal-text-muted); }

.legal-doc-panel { background: #fff; border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); }

.legal-doc-body { max-width: 72ch; margin: 0 auto; padding: 30px 34px 38px; line-height: 1.75; font-size: .94rem; color: var(--portal-text); }
.legal-doc-body h2 {
    font-size: 1.18rem; font-weight: 800; color: #0f1e42;
    margin: 34px 0 12px; padding-top: 22px; border-top: 1px solid var(--portal-border); scroll-margin-top: 90px;
}
.legal-doc-body h2:first-of-type { margin-top: 6px; padding-top: 0; border-top: none; }
.legal-doc-body h3 { font-size: 1rem; font-weight: 700; color: #0f1e42; margin: 20px 0 8px; scroll-margin-top: 90px; }
.legal-doc-body p { margin: 0 0 14px; }
.legal-doc-body ul, .legal-doc-body ol { margin: 0 0 14px; padding-left: 22px; }
.legal-doc-body li { margin-bottom: 6px; }
.legal-doc-body table { width: 100%; border-collapse: collapse; margin: 6px 0 18px; font-size: .86rem; }
.legal-doc-body th, .legal-doc-body td { border: 1px solid var(--portal-border); padding: 8px 10px; text-align: left; }
.legal-doc-body th { background: var(--portal-bg); font-weight: 700; }
.legal-doc-body a { color: var(--portal-primary); }
.legal-doc-body em { color: var(--portal-text-muted); }

.legal-heading-link { opacity: 0; margin-left: 8px; font-size: .8rem; font-weight: 400; color: var(--portal-text-muted); text-decoration: none; }
.legal-doc-body h2:hover .legal-heading-link, .legal-doc-body h3:hover .legal-heading-link,
.legal-heading-link:focus-visible { opacity: 1; }

.legal-mobile-toc { display: none; }

.legal-cta {
    margin-top: 26px; background: linear-gradient(120deg, #f5f7fd, #eef1fb); border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius); padding: 22px 26px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.legal-cta h4 { font-size: 1rem; font-weight: 800; margin: 0 0 4px; color: #0f1e42; }
.legal-cta p { margin: 0; font-size: .85rem; color: var(--portal-text-muted); max-width: 480px; }

.legal-back-to-top {
    position: fixed; right: 26px; bottom: 26px; width: 42px; height: 42px; border-radius: 50%;
    background: var(--portal-primary); color: #fff; border: none; box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem; opacity: 0; pointer-events: none;
    transition: opacity .2s ease, transform .2s ease; z-index: 40;
}
.legal-back-to-top.show { opacity: 1; pointer-events: auto; }
.legal-back-to-top:hover { transform: translateY(-2px); }

/* ── Trust Center — Security & Trust page only (spec §8-11); richer/more visual
   than the plain document reader used for the other 3 legal pages. ── */
.trust-summary { background: #fff; border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); padding: 22px 26px; margin-bottom: 22px; }
.trust-summary-title { font-size: .72rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--portal-text-muted); margin-bottom: 14px; }
.trust-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; }
.trust-check { display: flex; align-items: flex-start; gap: 9px; font-size: .86rem; color: var(--portal-text); }
.trust-check i { color: var(--portal-success); font-size: 1rem; margin-top: 1px; flex-shrink: 0; }

.trust-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.trust-card { background: #fff; border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); padding: 20px; }
.trust-card-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--portal-primary-soft); color: var(--portal-primary); display: flex; align-items: center; justify-content: center; font-size: 1.05rem; margin-bottom: 12px; }
.trust-card h5 { font-size: .92rem; font-weight: 800; color: #0f1e42; margin: 0 0 6px; }
.trust-card p { font-size: .81rem; color: var(--portal-text-muted); line-height: 1.55; margin: 0; }

.trust-flow { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; background: #fff; border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); padding: 22px; margin-bottom: 22px; }
.trust-flow-step { flex: 1 1 160px; text-align: center; padding: 10px 8px; }
.trust-flow-step .ic { width: 40px; height: 40px; margin: 0 auto 8px; border-radius: 10px; background: var(--portal-primary-soft); color: var(--portal-primary); display: flex; align-items: center; justify-content: center; font-size: 1.05rem; }
.trust-flow-step span { display: block; font-size: .78rem; font-weight: 700; color: var(--portal-text); }
.trust-flow-arrow { color: #c7cbe0; font-size: 1.2rem; flex-shrink: 0; }

.trust-data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.trust-data-card { background: #fff; border: 1px solid var(--portal-border); border-radius: var(--portal-radius); padding: 16px 18px; display: flex; gap: 12px; }
.trust-data-card i { color: var(--portal-primary); font-size: 1.1rem; margin-top: 2px; }
.trust-data-card h6 { font-size: .85rem; font-weight: 700; margin: 0 0 3px; color: #0f1e42; }
.trust-data-card p { font-size: .79rem; color: var(--portal-text-muted); margin: 0; line-height: 1.5; }

@media (max-width: 991.98px) {
    .legal-grid { grid-template-columns: 1fr; }
    .legal-rail { position: static; max-height: none; }
    .legal-toc-card { display: none; }
    .legal-mobile-toc { display: block; margin: 0 0 16px; background: #fff; border: 1px solid var(--portal-border); border-radius: var(--portal-radius); box-shadow: var(--portal-shadow); }
    .legal-mobile-toc summary { padding: 14px 16px; font-size: .85rem; font-weight: 700; color: var(--portal-text); cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; }
    .legal-mobile-toc summary::-webkit-details-marker { display: none; }
    .legal-mobile-toc summary i { font-size: .8rem; color: var(--portal-text-muted); transition: transform .15s ease; }
    .legal-mobile-toc[open] summary i { transform: rotate(180deg); }
    .legal-mobile-toc ul { list-style: none; margin: 0; padding: 0 12px 12px; }
    .legal-mobile-toc a { display: block; padding: 7px 10px; border-radius: 7px; font-size: .82rem; color: var(--portal-text-muted); text-decoration: none; }
    .legal-mobile-toc a.active { color: var(--portal-primary); background: var(--portal-primary-soft); font-weight: 700; }
    .trust-cards { grid-template-columns: repeat(2, 1fr); }
    .trust-summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .legal-page { padding: 18px 16px 48px; }
    .legal-hero { padding: 22px 18px; }
    .legal-hero h1 { font-size: 1.5rem; }
    .legal-hero-top { flex-direction: column; }
    .legal-search-box { width: 100%; }
    .legal-doc-body { padding: 22px 18px 30px; }
    .trust-cards { grid-template-columns: 1fr; }
    .trust-data-grid { grid-template-columns: 1fr; }
    .trust-flow { flex-direction: column; }
    .trust-flow-arrow { transform: rotate(90deg); }
    .legal-back-to-top { right: 16px; bottom: 16px; width: 38px; height: 38px; }
}

/* ── Print — legal documents only (spec §13). Hides the app shell/nav/search/CTA
   so a printed page is just the document, title and last-updated date. ── */
@media print {
    .portal-sidebar, .portal-topbar, .legal-nav-card, .legal-mobile-toc, .legal-search-box,
    .legal-actions, .legal-cta, .legal-back-to-top, .portal-footer, .pwaInstallBtn { display: none !important; }
    .legal-rail { position: static; }
    .legal-toc-card { box-shadow: none; border: none; padding: 0; }
    .legal-grid { grid-template-columns: 1fr; }
    .legal-hero { background: none; border: none; padding: 0 0 14px; }
    .legal-hero::before { display: none; }
    .legal-doc-panel { box-shadow: none; border: none; }
    .legal-doc-body { max-width: 100%; padding: 0; }
    body.portal-body { background: #fff; }
    a { color: inherit !important; text-decoration: none !important; }
}
.hc-contact-cta .btn { border-radius: 10px; padding: 9px 22px; font-weight: 700; }
