/* ── Retention Insights — Brand Styles ── */

:root {
    --brand-retention-color: #111827;
    --brand-insights-color: #1d8fe1;
    --brand-dash-color: #d94b93;
    --mobile-shell-header-height: 4.25rem;
    --app-viewport-height: 100dvh;
    --chat-keyboard-offset: 0px;
    --chat-shell-bottom: max(env(safe-area-inset-bottom, 0px), 0.75rem);
}

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

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.app-shell,
.app-main,
.app-main-inner {
    min-width: 0;
    max-width: 100%;
}

.app-main,
.app-main-inner {
    overflow-x: hidden;
}

@media (min-width: 1024px) {
    html,
    body {
        height: 100%;
    }

    body {
        overflow: hidden;
    }

    .app-shell {
        position: fixed;
        inset: 0;
        height: auto;
        min-height: 0;
        overflow: hidden;
    }

    .app-main {
        height: 100%;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    body.chat-page-active .app-main {
        overflow: hidden;
    }

    .app-main-inner {
        min-height: 100%;
    }
}

.brand-header-link {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    text-decoration: none;
    min-width: 0;
}

.logo-prominent {
    width: 3.25rem;
    height: 3.25rem;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(0, 153, 214, 0.35));
}

.logo-prominent-mobile {
    width: 2.5rem;
    height: 2.5rem;
}

.logo-glow-aura {
    position: absolute;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(0, 153, 214, 0.1) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1;
    pointer-events: none;
}

.brand-wordmark {
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    user-select: none;
}

.brand-wordmark-retention {
    display: block;
    color: var(--brand-retention-color);
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    letter-spacing: -0.045em;
    text-align: center;
    white-space: nowrap;
}

.brand-wordmark-subline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    margin-top: 0.1rem;
}

.brand-wordmark-insights {
    display: block;
    color: var(--brand-insights-color);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.34em;
    line-height: 1;
    white-space: nowrap;
    padding-left: 0.34em;
}

.brand-wordmark-dash {
    display: block;
    width: 1rem;
    height: 2px;
    border-radius: 9999px;
    background-color: var(--brand-dash-color);
    opacity: 0.88;
}

.brand-wordmark-sidebar {
    width: 9.35rem;
}

.brand-wordmark-sidebar .brand-wordmark-retention {
    font-size: 1.72rem;
}

.brand-wordmark-sidebar .brand-wordmark-insights {
    font-size: 0.62rem;
}

.brand-wordmark-sidebar .brand-wordmark-dash {
    width: 1.1rem;
}

.brand-wordmark-mobile {
    width: 6.15rem;
}

.brand-wordmark-mobile .brand-wordmark-retention {
    font-size: 1.08rem;
}

.brand-wordmark-mobile .brand-wordmark-insights {
    font-size: 0.39rem;
}

.brand-wordmark-mobile .brand-wordmark-dash {
    width: 0.75rem;
}

.mobile-app-header {
    min-height: var(--mobile-shell-header-height);
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.mobile-brand-link {
    flex: 1 1 auto;
    max-width: calc(100% - 8.75rem);
    gap: 0.65rem;
}

.mobile-header-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.7rem;
    min-width: 0;
}

/* Navigation link base */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
}
.nav-link:hover {
    background: #f1f5f9;
    color: #0d0d0d;
}
.nav-link i {
    font-size: 0.875rem;
    color: #94a3b8;
    transition: color 0.2s ease;
}
.nav-link:hover i {
    color: #0099d6;
}

/* Active nav state */
.nav-active {
    background: linear-gradient(135deg, rgba(0, 153, 214, 0.08), rgba(232, 57, 122, 0.04));
    color: #0099d6;
    font-weight: 600;
}
.nav-active i {
    color: #0099d6;
}

/* Brand gradient text */
.gradient-text {
    background: linear-gradient(135deg, #0d0d0d 30%, #0099d6 70%, #e8397a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Glass card */
.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 1rem;
    box-shadow: 0 4px 24px rgba(20, 30, 60, 0.04);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.glass-card:hover {
    box-shadow: 0 8px 32px rgba(20, 30, 60, 0.08);
}

/* Elevated card */
.card {
    background: white;
    border: 1px solid #f0f0f0;
    border-radius: 1rem;
    box-shadow: 0 2px 12px rgba(20, 30, 60, 0.04);
    min-width: 0;
    max-width: 100%;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
}
.badge-green  { background: #ecfdf5; color: #059669; }
.badge-yellow { background: #fffbeb; color: #d97706; }
.badge-red    { background: #fef2f2; color: #dc2626; }
.badge-blue   { background: #eff6ff; color: #2563eb; }
.badge-gray   { background: #f8fafc; color: #64748b; }

/* Sentiment badges */
.sentiment-positive { background: #ecfdf5; color: #059669; }
.sentiment-negative { background: #fef2f2; color: #dc2626; }
.sentiment-neutral  { background: #f8fafc; color: #64748b; }
.sentiment-mixed    { background: #fffbeb; color: #d97706; }

/* Form inputs */
.form-input {
    width: 100%;
    max-width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    color: #0d0d0d;
    background: white;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input:focus {
    outline: none;
    border-color: #0099d6;
    box-shadow: 0 0 0 3px rgba(0, 153, 214, 0.12);
}

/* Select styling */
.form-select {
    width: 100%;
    max-width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    color: #0d0d0d;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}
.form-select:focus {
    outline: none;
    border-color: #0099d6;
    box-shadow: 0 0 0 3px rgba(0, 153, 214, 0.12);
}

/* Primary button */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: linear-gradient(135deg, #0099d6, #0077a8);
    color: white;
    border: none;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #00ade8, #0099d6);
    box-shadow: 0 4px 16px rgba(0, 153, 214, 0.25);
    transform: translateY(-1px);
}

/* Secondary button */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-secondary:hover {
    border-color: #0099d6;
    color: #0099d6;
    background: rgba(0, 153, 214, 0.04);
}

/* Danger button */
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-danger:hover {
    background: #fef2f2;
    border-color: #dc2626;
}

/* Details/summary (accordion) styling */
details.factor-card {
    border: 1px solid #f0f0f0;
    border-radius: 0.75rem;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
    min-width: 0;
    max-width: 100%;
}
details.factor-card[open] {
    box-shadow: 0 2px 12px rgba(20, 30, 60, 0.06);
}
details.factor-card > summary {
    padding: 1rem 1.25rem;
    cursor: pointer;
    font-weight: 500;
    color: #334155;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.15s ease;
    min-width: 0;
    max-width: 100%;
}
details.factor-card > summary:hover {
    background: #f8fafc;
}
details.factor-card > summary::before {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.625rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
details.factor-card[open] > summary::before {
    transform: rotate(90deg);
}
details.factor-card .detail-body {
    padding: 0 1.25rem 1.25rem;
    color: #475569;
    font-size: 0.875rem;
    line-height: 1.7;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
}

details.factor-card > summary.factor-explorer-summary {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.25rem;
}

details.factor-card > summary.factor-explorer-summary::before {
    grid-column: 1;
    justify-self: center;
}

.factor-explorer-number {
    grid-column: 2;
    color: #0099d6;
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
}

.factor-explorer-title {
    grid-column: 3;
    min-width: 0;
    color: #334155;
    font-weight: 600;
    line-height: 1.45;
    overflow-wrap: break-word;
}

.factor-explorer-status {
    grid-column: 4;
    justify-self: end;
    margin-left: 0;
}

.factor-explorer-detail {
    border-top: 1px solid #f1f5f9;
    padding-top: 1rem;
}

.related-factor-picker {
    max-height: 14rem;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #ffffff;
}

.related-factor-picker > div,
.related-factor-picker ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.related-factor-picker li {
    list-style: none;
}

.related-factor-picker label {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    min-height: 2.75rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 0.625rem;
    color: #334155;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.35;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.related-factor-picker label:hover {
    border-color: #e2e8f0;
    background: #f8fafc;
}

.related-factor-picker label:has(input:checked) {
    border-color: rgba(0, 153, 214, 0.25);
    background: rgba(0, 153, 214, 0.08);
    color: #1e3a8a;
}

.related-factor-picker input[type="checkbox"] {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    margin-top: 0.125rem;
    accent-color: #0099d6;
}

.sub-action-form,
.sub-action-edit-form {
    display: grid;
    align-items: end;
    gap: 0.625rem;
}

.sub-action-form {
    grid-template-columns: minmax(0, 1fr) minmax(9.5rem, 10.5rem) auto;
}

.sub-action-edit-form {
    grid-template-columns: minmax(0, 1fr) 10rem auto;
}

.sub-action-field {
    display: grid;
    min-width: 0;
    gap: 0.35rem;
}

.sub-action-field-label {
    color: #94a3b8;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1;
    text-transform: uppercase;
}

.sub-action-field .form-input {
    width: 100%;
}

.sub-action-form > *,
.sub-action-edit-form > * {
    min-width: 0;
}

.sub-action-date-field input[type="date"] {
    box-sizing: border-box;
    display: block;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    text-align: left;
}

.sub-action-submit {
    white-space: nowrap;
}

.sub-action-edit-actions {
    display: flex;
    gap: 0.5rem;
}

.sub-action-form-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.625rem;
}

.action-item-list {
    display: grid;
    gap: 1rem;
}

details.factor-card.action-item-card {
    border: 1px solid #e6edf5;
    border-radius: 0.875rem;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.035);
    overflow: hidden;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

details.factor-card.action-item-card:hover {
    border-color: #d7e3ef;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.055);
}

details.factor-card.action-item-card[open] {
    border-color: rgba(0, 153, 214, 0.28);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

details.factor-card.action-item-card[open] > summary.action-item-summary {
    border-bottom: 1px solid #e6edf5;
    background: #fbfdff;
}

.action-item-summary {
    position: relative;
    display: grid !important;
    grid-template-columns: 2.25rem minmax(0, 1fr);
    align-items: center;
    column-gap: 0.875rem;
    min-height: 5.25rem;
    padding: 1rem 1.25rem;
    min-width: 0;
    max-width: 100%;
}

details.factor-card > summary.action-item-summary::before {
    grid-column: 1;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid #dbe6f0;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.75rem;
    justify-self: center;
    align-self: center;
}

details.factor-card > summary.action-item-summary:hover::before {
    border-color: rgba(0, 153, 214, 0.28);
    background: rgba(0, 153, 214, 0.08);
    color: #0099d6;
}

details.factor-card.action-item-card[open] > summary.action-item-summary::before {
    border-color: rgba(0, 153, 214, 0.32);
    background: rgba(0, 153, 214, 0.1);
    color: #0099d6;
}

details.factor-card.action-item-card[open] > summary.action-item-summary::after {
    content: '';
    position: absolute;
    top: 0.75rem;
    bottom: 0.75rem;
    left: 0;
    width: 3px;
    border-radius: 999px;
    background: #0099d6;
}

.action-item-main {
    grid-column: 2;
    display: grid;
    gap: 0.45rem;
    min-width: 0;
}

.action-item-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-width: 0;
}

.action-item-id {
    color: #0099d6;
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
}

.action-item-status {
    flex: 0 0 auto;
    white-space: nowrap;
    overflow-wrap: normal;
}

.action-item-title {
    min-width: 0;
    color: #334155;
    font-weight: 600;
    line-height: 1.4;
    overflow: hidden;
    overflow-wrap: break-word;
}

details.factor-card.action-item-card .detail-body.action-item-detail {
    display: grid;
    gap: 1.25rem;
    padding: 1.25rem 1.5rem 1.5rem;
}

.action-item-overview {
    display: grid;
    gap: 0.75rem;
}

.action-item-section-label {
    color: #94a3b8;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: uppercase;
}

.action-item-description {
    margin: 0;
    color: #475569;
}

.action-item-related {
    display: grid;
    gap: 0.45rem;
}

.action-item-related-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-width: 0;
}

.action-subactions-section {
    display: grid;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid #eef2f7;
}

.action-subactions-heading {
    margin: 0;
    color: #334155;
    font-size: 0.875rem;
    font-weight: 700;
}

.sub-action-list {
    margin-bottom: 0.25rem;
}

.sub-action-entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: #f8fafc;
    font-size: 0.875rem;
}

.sub-action-body {
    min-width: 0;
}

.sub-action-empty {
    margin: 0;
    padding: 0.75rem;
    border: 1px dashed #e2e8f0;
    border-radius: 0.75rem;
    color: #94a3b8;
    font-size: 0.875rem;
    text-align: center;
}

.sub-action-check {
    display: grid;
    place-items: center;
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 auto;
    color: rgba(0, 153, 214, 0.45);
}

.sub-action-date {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.2rem;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 600;
}

.sub-action-date i {
    color: rgba(0, 153, 214, 0.55);
    font-size: 0.75rem;
}

.sub-action-text {
    margin: 0;
    color: #475569;
    line-height: 1.45;
    overflow-wrap: break-word;
}

.action-item-meta,
.action-item-actions,
.sub-action-entry,
.sub-action-controls,
.dashboard-risk-form,
.dashboard-risk-layout,
.chat-input-bar {
    min-width: 0;
    max-width: 100%;
}

img,
picture,
video {
    max-width: 100%;
}

/* Qualitative subtopic rows */
.qualitative-subtopic-list {
    margin-left: 0.5rem;
}

details.factor-card > summary.qualitative-subtopic-summary {
    display: grid;
    grid-template-columns: 0.75rem minmax(12rem, 16rem) minmax(0, 1fr);
    align-items: center;
    column-gap: 1.25rem;
    row-gap: 0.35rem;
}

details.factor-card > summary.qualitative-subtopic-summary::before {
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
}

.qualitative-subtopic-title {
    grid-column: 2;
    color: #334155;
    font-weight: 600;
    line-height: 1.45;
    min-width: 0;
}

.qualitative-subtopic-description {
    grid-column: 3;
    color: #94a3b8;
    font-weight: 400;
    line-height: 1.5;
    min-width: 0;
}

.qualitative-subtopic-expanded-description {
    display: none;
}

/* Page title */
.page-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.875rem;
    font-weight: 700;
    color: #0d0d0d;
}

/* Chat styles */
.chat-page-shell {
    min-width: 0;
}

.chat-container {
    position: relative;
    --chat-latest-composer-space: 4.75rem;
    --chat-latest-gap: 0.75rem;
    --chat-latest-inline-offset: 1.5rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 12rem);
    border: 1px solid #f0f0f0;
    border-radius: 1rem;
    overflow: hidden;
    background: #fafbfc;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.chat-bubble {
    flex: 0 0 auto;
    max-width: 75%;
    padding: 0.875rem 1.125rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    word-wrap: break-word;
}
.chat-bubble-user {
    align-self: flex-end;
    max-width: min(66%, 32rem);
    padding: 0.65rem 0.9rem;
    background: linear-gradient(135deg, #0099d6, #0077a8);
    color: white;
    border-radius: 0.875rem;
    border-bottom-right-radius: 0.25rem;
    line-height: 1.45;
}
.chat-bubble-bot {
    align-self: flex-start;
    background: white;
    border: 1px solid #e8e8e8;
    color: #334155;
    border-bottom-left-radius: 0.25rem;
}
.chat-input-bar {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: white;
    border-top: 1px solid #f0f0f0;
}

.chat-input-bar .form-input {
    min-width: 0;
    flex: 1 1 auto;
}

.chat-input-bar .btn-primary {
    flex: 0 0 auto;
    min-width: 3.5rem;
    justify-content: center;
}

.chat-jump-latest {
    position: absolute;
    right: var(--chat-latest-inline-offset);
    bottom: calc(var(--chat-latest-composer-space) + var(--chat-latest-gap));
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.25rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.96);
    color: #334155;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.chat-jump-latest[hidden] {
    display: none;
}

.chat-jump-latest:hover,
.chat-jump-latest:focus-visible {
    border-color: #0099d6;
    color: #0077a8;
    box-shadow: 0 10px 28px rgba(0, 153, 214, 0.16);
    outline: none;
    transform: translateY(-1px);
}
/* Loading spinner for HTMX */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-flex;
}
.htmx-request.htmx-indicator {
    display: inline-flex;
}

/* Smooth transitions for HTMX swaps */
.htmx-swapping { opacity: 0; transition: opacity 0.15s ease; }
.htmx-settling { opacity: 1; transition: opacity 0.15s ease; }

/* Chart sizing */
.chart-panel {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.chart-panel-line {
    height: 20rem;
    min-height: 20rem;
}

.chart-panel-bar {
    height: 16rem;
    min-height: 16rem;
}

.chart-canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

@media (max-width: 768px) {
    html.chat-page-active,
    body.chat-page-active {
        height: 100dvh;
        overflow: hidden;
        overscroll-behavior: none;
    }

    body.chat-page-active .mobile-app-header {
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        z-index: 80;
    }

    .form-input,
    .form-select {
        font-size: 1rem;
        min-height: 2.75rem;
        line-height: 1.25;
    }

    .app-main-inner {
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }

    .app-shell,
    .app-main,
    .app-main-inner {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .app-main-inner > * {
        min-width: 0;
        max-width: 100%;
    }

    #mobile-sidebar-toggle {
        display: grid;
        flex: 0 0 auto;
        width: 2.75rem;
        height: 2.75rem;
        margin-right: -0.5rem;
        place-items: center;
        border-radius: 0.75rem;
        touch-action: manipulation;
    }

    #mobile-sidebar-toggle:active {
        background: #f1f5f9;
    }

    .nav-link {
        min-height: 2.75rem;
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger {
        min-height: 2.75rem;
        justify-content: center;
        touch-action: manipulation;
    }

    details.factor-card > summary {
        min-height: 3.5rem;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 153, 214, 0.12);
    }

    details.factor-card > summary:focus-visible {
        outline: 2px solid rgba(0, 153, 214, 0.28);
        outline-offset: -2px;
    }

    details.factor-card > summary.factor-explorer-summary {
        grid-template-columns: 2rem minmax(0, 1fr) auto;
        align-items: center;
        min-height: 5rem;
        padding: 1rem;
        column-gap: 0.75rem;
        row-gap: 0.35rem;
    }

    details.factor-card > summary.factor-explorer-summary::before {
        grid-column: 1;
        grid-row: 1 / span 2;
        display: grid;
        place-items: center;
        width: 2rem;
        height: 2rem;
        border: 1px solid #e2e8f0;
        border-radius: 999px;
        background: #f8fafc;
        color: #64748b;
        font-size: 0.75rem;
        align-self: center;
    }

    details.factor-card.factor-explorer-card[open] > summary.factor-explorer-summary::before {
        border-color: rgba(0, 153, 214, 0.22);
        background: rgba(0, 153, 214, 0.08);
        color: #0099d6;
    }

    .factor-explorer-number {
        grid-column: 2;
        grid-row: 1;
        color: #64748b;
        font-size: 0.75rem;
        letter-spacing: 0;
        line-height: 1.2;
        text-transform: uppercase;
    }

    .factor-explorer-title {
        grid-column: 2 / span 2;
        grid-row: 2;
        font-size: 0.9375rem;
        line-height: 1.35;
    }

    .factor-explorer-status {
        grid-column: 3;
        grid-row: 1;
        align-self: start;
        justify-self: end;
    }

    .factor-explorer-detail {
        margin: 0 1rem 1rem 3.75rem;
        padding: 0.875rem 0 0;
        border-top: 1px solid #eef2f7;
        font-size: 0.9375rem;
        line-height: 1.65;
    }

    .related-factor-picker {
        max-height: 15rem;
        padding: 0.4rem;
        border-radius: 0.875rem;
    }

    .related-factor-picker > div,
    .related-factor-picker ul {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .related-factor-picker label {
        min-height: 3rem;
        padding: 0.75rem;
        font-size: 0.9375rem;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 153, 214, 0.12);
    }

    .related-factor-picker input[type="checkbox"] {
        width: 1.125rem;
        height: 1.125rem;
    }

    .dashboard-card.card.p-6,
    .action-item-form-card.card.p-6 {
        padding: 1rem !important;
    }

    .dashboard-risk-form {
        gap: 0.875rem;
    }

    .dashboard-risk-form label,
    #dashboard-filter-form label.inline-flex {
        min-height: 2.75rem;
        align-items: center;
    }

    .dashboard-risk-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .dashboard-risk-chart {
        width: 12rem !important;
        height: 12rem !important;
        margin: 0 auto;
    }

    .dashboard-risk-legend {
        display: grid;
        gap: 0.5rem;
    }

    .dashboard-submit {
        width: 100%;
    }

    #chart-loading {
        margin-left: 0;
        margin-top: 0.75rem;
    }

    .action-items-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .action-items-new-button {
        width: 100%;
    }

    .action-item-list {
        display: grid;
        gap: 0.875rem;
    }

    details.factor-card.action-item-card {
        border-radius: 0.875rem;
        background: #ffffff;
    }

    details.factor-card.action-item-card[open] {
        border-color: #e2e8f0;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    }

    .action-item-summary {
        grid-template-columns: 2rem minmax(0, 1fr);
        min-height: 4.75rem;
        padding: 0.95rem 1rem;
        align-items: center;
        column-gap: 0.75rem;
        -webkit-tap-highlight-color: rgba(0, 153, 214, 0.12);
        user-select: none;
    }

    details.factor-card > summary.action-item-summary::before {
        grid-column: 1;
        display: grid;
        place-items: center;
        width: 2rem;
        height: 2rem;
        border: 1px solid #e2e8f0;
        border-radius: 999px;
        background: #f8fafc;
        color: #64748b;
        font-size: 0.75rem;
        align-self: center;
    }

    details.factor-card.action-item-card[open] > summary.action-item-summary::before {
        border-color: rgba(0, 153, 214, 0.22);
        background: rgba(0, 153, 214, 0.08);
        color: #0099d6;
    }

    details.factor-card.action-item-card[open] > summary.action-item-summary {
        border-bottom: 1px solid #eef2f7;
        background: #ffffff;
    }

    .action-item-id {
        color: #0099d6;
        font-size: 0.875rem;
        line-height: 1;
    }

    .action-item-status {
        padding: 0.3rem 0.6rem;
        font-size: 0.6875rem;
        line-height: 1;
        letter-spacing: 0.015em;
        white-space: nowrap;
        text-align: center;
    }

    .action-item-title {
        color: #1f2937;
        font-size: 1rem;
        line-height: 1.35;
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    details.factor-card.action-item-card .detail-body.action-item-detail {
        gap: 0.875rem;
        padding: 1rem;
        font-size: 0.9375rem;
        line-height: 1.6;
    }

    .action-item-overview {
        gap: 0.75rem;
        margin-top: 0.125rem;
        padding: 0.875rem;
        border: 1px solid #eef2f7;
        border-radius: 0.875rem;
        background: #f8fafc;
    }

    .action-item-section-label {
        font-size: 0.75rem;
        letter-spacing: 0.035em;
    }

    .action-item-description {
        font-size: 0.9375rem;
        line-height: 1.55;
    }

    .action-item-related-list .badge {
        border-radius: 0.75rem;
        padding: 0.4rem 0.65rem;
        font-size: 0.6875rem;
        line-height: 1.25;
    }

    .action-item-meta {
        flex-direction: column;
        gap: 0.4rem;
        margin-bottom: 0;
        color: #64748b;
        font-size: 0.875rem;
    }

    .action-item-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.625rem;
        margin-bottom: 0;
    }

    .action-item-actions > *,
    .sub-action-edit-actions > * {
        min-width: 0;
    }

    .sub-action-entry {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        align-items: flex-start;
        gap: 0.65rem;
        padding: 0.875rem;
        border: 1px solid #eef2f7;
        background: #f8fafc;
    }

    .sub-action-body {
        min-width: 0;
        width: 100%;
    }

    .sub-action-date {
        color: #94a3b8;
        font-size: 0.75rem;
    }

    .sub-action-text {
        color: #475569;
        font-size: 0.9375rem;
    }

    .action-subactions-section {
        gap: 0.75rem;
        padding-top: 1rem;
    }

    .sub-action-controls {
        opacity: 1;
        grid-column: 1;
        display: flex;
        gap: 0.5rem;
        width: auto;
        justify-self: end;
    }

    .sub-action-controls button {
        display: grid;
        min-width: 2.5rem;
        min-height: 2.5rem;
        place-items: center;
        border: 1px solid #e2e8f0;
        border-radius: 0.625rem;
        background: #ffffff;
    }

    .sub-action-form,
    .sub-action-edit-form {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 0.7rem;
        width: 100%;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .sub-action-edit-form {
        padding: 0.75rem;
        border: 1px solid #eef2f7;
        border-radius: 0.875rem;
        background: #fbfdff;
    }

    .sub-action-form-footer {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 0.625rem;
        width: 100%;
    }

    .sub-action-field-label {
        font-size: 0.75rem;
    }

    .sub-action-form > *,
    .sub-action-edit-form > *,
    .sub-action-field,
    .sub-action-date-field {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    .sub-action-form .form-input,
    .sub-action-edit-form .form-input {
        box-sizing: border-box;
        min-width: 0;
        max-width: 100%;
        width: 100%;
        min-height: 3rem;
    }

    .sub-action-date-field input[type="date"] {
        -webkit-appearance: none;
        appearance: none;
        padding-right: 0.875rem;
        text-align: left;
    }

    .sub-action-edit-form .btn-primary,
    .sub-action-edit-form .btn-secondary {
        max-width: 100%;
        width: 100%;
    }

    .sub-action-form .btn-secondary {
        max-width: 100%;
        width: 100%;
        min-width: 0;
    }

    .sub-action-edit-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .action-item-form-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .chat-page-shell {
        position: fixed;
        z-index: 20;
        top: var(--mobile-shell-header-height);
        right: 0.75rem;
        bottom: var(--chat-shell-bottom);
        left: 0.75rem;
        display: flex;
        flex-direction: column;
        min-height: 0;
        min-width: 0;
        overflow: hidden;
        padding-top: 0.875rem;
        background: #ffffff;
    }

    .chat-page-title {
        flex: 0 0 auto;
        margin-bottom: 0.875rem;
    }

    .chat-container {
        --chat-latest-composer-space: 4.625rem;
        --chat-latest-gap: 0.875rem;
        --chat-latest-inline-offset: 1rem;
        flex: 1 1 auto;
        height: auto;
        min-height: 0;
        max-height: none;
    }

    .chat-messages {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        padding: 1rem;
        overscroll-behavior: contain;
    }
    .chat-bubble-bot {
        max-width: 92%;
    }

    .chat-bubble-user {
        max-width: 78%;
        padding: 0.6rem 0.8rem;
        border-radius: 0.8125rem;
        border-bottom-right-radius: 0.25rem;
        line-height: 1.45;
    }

    .chat-input-bar {
        gap: 0.75rem;
        padding: 0.875rem 1rem;
    }

    .chat-input-bar .btn-primary {
        min-width: 3.25rem;
        padding-left: 0.875rem;
        padding-right: 0.875rem;
    }

    .chat-jump-latest {
        min-height: 2.125rem;
        padding: 0.4rem 0.7rem;
    }
    body.chat-input-active {
        height: 100dvh;
        overflow: hidden;
    }

    body.chat-input-active .chat-page-shell {
        bottom: calc(var(--chat-keyboard-offset, 0px) + var(--chat-shell-bottom));
    }

    body.chat-input-active .chat-container {
        min-height: 0;
    }

    .welcome-shell {
        padding-top: 1rem;
    }

    .welcome-card {
        padding: 1.5rem;
    }

    .welcome-title {
        line-height: 1.08;
    }

    .chart-panel-line {
        height: 16rem;
        min-height: 16rem;
    }

    .chart-panel-bar {
        height: 14rem;
        min-height: 14rem;
    }

    .qualitative-subtopic-list {
        display: grid;
        gap: 0.625rem;
        margin-left: 0;
    }

    details.factor-card.qualitative-subtopic-card {
        border-radius: 0.75rem;
    }

    details.factor-card.qualitative-topic-card > summary,
    details.factor-card > summary.qualitative-subtopic-summary {
        -webkit-tap-highlight-color: rgba(0, 153, 214, 0.12);
        user-select: none;
    }

    details.factor-card.qualitative-topic-card > summary:focus-visible,
    details.factor-card > summary.qualitative-subtopic-summary:focus-visible {
        outline: 2px solid rgba(0, 153, 214, 0.35);
        outline-offset: -2px;
    }

    details.factor-card.qualitative-topic-card > summary::before,
    details.factor-card > summary.qualitative-subtopic-summary::before {
        display: grid;
        place-items: center;
        width: 2rem;
        height: 2rem;
        border: 1px solid #e2e8f0;
        border-radius: 999px;
        background: #f8fafc;
        color: #64748b;
        font-size: 0.75rem;
        transition: transform 0.2s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    }

    details.factor-card.qualitative-topic-card[open] > summary::before,
    details.factor-card.qualitative-subtopic-card[open] > summary::before {
        border-color: rgba(0, 153, 214, 0.22);
        background: rgba(0, 153, 214, 0.08);
        color: #0099d6;
    }

    details.factor-card.qualitative-topic-card > summary:active,
    details.factor-card > summary.qualitative-subtopic-summary:active {
        background: #f8fafc;
    }

    .qualitative-topic-list {
        display: grid;
        gap: 0.875rem;
    }

    details.factor-card > summary.qualitative-subtopic-summary {
        grid-template-columns: 2rem minmax(0, 1fr);
        align-items: start;
        column-gap: 0.75rem;
        row-gap: 0.45rem;
        min-height: 5rem;
        padding: 1rem;
        touch-action: manipulation;
    }

    details.factor-card > summary.qualitative-subtopic-summary::before {
        grid-column: 1;
        grid-row: 1 / span 2;
        align-self: center;
        justify-self: center;
        margin-top: 0;
    }

    .qualitative-subtopic-title {
        grid-column: 2;
        grid-row: 1;
        font-size: 0.9375rem;
        line-height: 1.35;
        overflow-wrap: break-word;
    }

    .qualitative-subtopic-description {
        grid-column: 2;
        grid-row: 2;
        margin-top: 0;
        color: #64748b;
        font-size: 0.8125rem;
        line-height: 1.45;
        display: -webkit-box;
        overflow: hidden;
        overflow-wrap: break-word;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    details.factor-card.qualitative-subtopic-card .detail-body {
        padding: 0 1rem 1rem 3.75rem;
    }
    details.factor-card.qualitative-topic-card[open],
    details.factor-card.qualitative-subtopic-card[open] {
        border-color: #e2e8f0;
        background: #ffffff;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    }

    details.factor-card.qualitative-topic-card > summary {
        align-items: center;
        min-height: 4rem;
        padding: 1rem;
        line-height: 1.35;
    }

    .qualitative-topic-summary-title {
        color: #1f2937;
        font-size: 1rem;
        font-weight: 600;
        line-height: 1.35;
        overflow-wrap: break-word;
    }

    .qualitative-topic-detail {
        padding: 0 1rem 1.125rem;
        font-size: 0.9375rem;
        line-height: 1.65;
    }

    .qualitative-topic-overview {
        margin-bottom: 1.125rem;
        padding: 0.9375rem;
        border: 1px solid #eef2f7;
        border-radius: 0.75rem;
        background: #f8fafc;
    }

    .qualitative-topic-label-row {
        display: grid;
        gap: 0.35rem;
    }

    .qualitative-topic-name {
        color: #334155;
        font-size: 0.9375rem;
        line-height: 1.45;
    }

    .qualitative-topic-description {
        color: #475569;
        font-size: 0.875rem;
        line-height: 1.55;
    }

    .qualitative-subtopics-heading {
        margin-top: 1.375rem;
        margin-bottom: 0.75rem;
        padding-top: 0.375rem;
        border-top: 1px solid #eef2f7;
        color: #334155;
    }

    details.factor-card.qualitative-subtopic-card[open] > summary.qualitative-subtopic-summary {
        border-bottom: 1px solid #eef2f7;
        background: #ffffff;
    }

    details.factor-card.qualitative-subtopic-card .qualitative-subtopic-detail {
        display: grid;
        gap: 0.875rem;
        padding: 0.875rem 1rem 1rem 3.75rem;
        background: #ffffff;
    }

    .qualitative-subtopic-expanded-description {
        display: block;
        margin: 0;
        color: #475569;
        font-size: 0.875rem;
        line-height: 1.55;
    }

    .qualitative-statements-heading {
        margin-bottom: -0.125rem;
        color: #64748b;
    }

    .qualitative-statement-list {
        display: grid;
        gap: 0.75rem;
    }

    .qualitative-statement-list > .qualitative-statement-item {
        margin-top: 0 !important;
        padding: 0.75rem;
        border: 1px solid #e2e8f0;
        border-left: 3px solid rgba(0, 153, 214, 0.35);
        border-radius: 0.75rem;
        background: #f8fafc;
    }

    .qualitative-statement-text {
        color: #475569;
        font-size: 0.875rem;
        line-height: 1.55;
    }
}

@media (max-width: 1023px) {
    .mobile-app-header {
        position: fixed !important;
        top: 0;
        right: 0;
        left: 0;
        z-index: 80;
    }

    .app-shell {
        min-height: var(--app-viewport-height, 100dvh);
        padding-top: var(--mobile-shell-header-height);
    }

    .app-main {
        min-width: 0;
    }

    #sidebar {
        top: var(--mobile-shell-header-height) !important;
        height: calc(var(--app-viewport-height, 100dvh) - var(--mobile-shell-header-height)) !important;
        max-height: calc(var(--app-viewport-height, 100dvh) - var(--mobile-shell-header-height)) !important;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
        overflow: hidden;
    }

    #sidebar-overlay {
        top: var(--mobile-shell-header-height) !important;
        height: calc(var(--app-viewport-height, 100dvh) - var(--mobile-shell-header-height)) !important;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

@media (max-width: 420px) {
    .brand-header-link {
        gap: 0.6rem;
    }

    .logo-prominent-mobile {
        width: 2.15rem;
        height: 2.15rem;
    }

    .brand-wordmark-mobile {
        width: 5.6rem;
    }

    .brand-wordmark-mobile .brand-wordmark-retention {
        font-size: 0.98rem;
    }

    .brand-wordmark-mobile .brand-wordmark-insights {
        font-size: 0.36rem;
    }

    .brand-wordmark-mobile .brand-wordmark-dash {
        width: 0.65rem;
    }

    .mobile-brand-link {
        max-width: calc(100% - 8.25rem);
    }

    .mobile-header-actions {
        gap: 0.55rem;
    }
}
