:root {
    --shell-bg: #f2f5f9;
    --shell-surface: #ffffff;
    --shell-surface-muted: #f7f8fb;
    --shell-border: #e2e7ef;
    --shell-text: #172033;
    --shell-muted: #697386;
    --shell-primary: #4c5aa5;
    --shell-primary-strong: #344386;
    --shell-primary-soft: #f0f2fa;
    --shell-success: #149b71;
    --shell-sidebar-width: 220px;
    --shell-mobile-bar-height: 64px;
    --shell-radius: 12px;
    --shell-shadow: 0 12px 30px rgba(24, 35, 65, 0.08);
}

* {
    box-sizing: border-box;
}

body.app-shell-page {
    min-height: 100vh;
    margin: 0;
    background: var(--shell-bg);
    color: var(--shell-text);
    overflow-x: hidden;
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    display: flex;
    width: var(--shell-sidebar-width);
    flex-direction: column;
    padding: 18px 10px 14px;
    overflow-y: auto;
    background: var(--shell-surface);
    border-right: 1px solid var(--shell-border);
    box-shadow: 1px 0 0 rgba(23, 32, 51, 0.02);
}

.app-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding: 0 8px;
    margin-bottom: 20px;
}

.app-brand {
    display: inline-flex;
    align-items: center;
}

.app-brand img {
    width: 116px;
    height: auto;
}

.app-sidebar-close {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--shell-muted);
    background: transparent;
    border: 0;
    border-radius: 9px;
}

.app-sidebar-close:hover,
.app-sidebar-close:focus-visible {
    color: var(--shell-text);
    background: var(--shell-surface-muted);
}

.app-sidebar-nav {
    flex: 1 0 auto;
}

.app-nav-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.app-nav-section {
    padding: 0 9px;
    margin: 0 0 7px;
    color: #8a93a5;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.app-nav-section-spaced {
    margin-top: 20px;
}

.app-nav-item {
    margin: 2px 0;
}

.app-nav-link {
    display: flex;
    width: 100%;
    min-height: 36px;
    gap: 9px;
    align-items: center;
    padding: 6px 9px;
    color: var(--shell-muted);
    font-size: 0.82rem;
    font-weight: 560;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    background: transparent;
    border: 0;
    border-radius: 8px;
    transition: color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.app-nav-link:hover,
.app-nav-link:focus-visible {
    color: var(--shell-text);
    background: var(--shell-surface-muted);
    outline: none;
}

.app-nav-link.active {
    color: var(--shell-primary-strong);
    background: var(--shell-primary-soft);
}

.app-nav-link.active .app-nav-icon {
    color: var(--shell-primary-strong);
}

.app-nav-icon {
    display: inline-flex;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    align-items: center;
    justify-content: center;
    color: #7d8797;
    transition: color 140ms ease, background-color 140ms ease;
}

.app-nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav-preview {
    cursor: pointer;
}

.app-nav-preview .app-nav-icon {
    color: #746b98;
}

.app-nav-access {
    margin-left: auto;
    color: #9aa2b1;
    font-size: 0.58rem;
}

.app-nav-status {
    display: inline-flex;
    min-height: 20px;
    gap: 5px;
    align-items: center;
    padding: 3px 6px;
    margin-left: auto;
    color: #657083;
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1;
    background: #f2f4f7;
    border-radius: 999px;
}

.app-nav-status::before {
    width: 5px;
    height: 5px;
    content: "";
    background: currentColor;
    border-radius: 50%;
}

.app-nav-status[data-state="connected"] {
    color: #2f7556;
    background: #edf7f1;
}

.app-nav-status[data-state="personal"] {
    color: #6d6099;
    background: #f2f0f8;
}

.app-nav-status[data-state="disconnected"] {
    color: #5263aa;
    background: #eef1fb;
}

.app-nav-status[hidden],
.app-nav-link.is-loading .app-nav-status {
    display: none;
}

.app-nav-spinner {
    display: none;
    width: 14px;
    height: 14px;
    margin-left: auto;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: shell-spin 700ms linear infinite;
}

.app-nav-link.is-loading .app-nav-access {
    display: none;
}

.app-nav-link.is-loading .app-nav-spinner {
    display: block;
}

@keyframes shell-spin {
    to { transform: rotate(360deg); }
}

.app-enterprise-card {
    padding: 13px;
    margin: 16px 0 10px;
    color: var(--shell-text);
    background: #f8f9fc;
    border: 1px solid var(--shell-border);
    border-radius: 10px;
}

.app-enterprise-eyebrow {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
    color: #655c91;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.app-enterprise-card strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.79rem;
}

.app-enterprise-cta {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    padding: 2px 0;
    color: var(--shell-primary-strong);
    font-size: 0.68rem;
    font-weight: 800;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.app-enterprise-cta:hover,
.app-enterprise-cta:focus-visible {
    color: var(--shell-primary);
    background: transparent;
}

.app-sidebar-footer {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    justify-content: space-between;
    padding: 11px 4px 0;
    border-top: 1px solid var(--shell-border);
}

.app-sidebar-help,
.app-logout {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    color: var(--shell-muted);
    font-size: 0.64rem;
    font-weight: 600;
    text-decoration: none;
}

.app-sidebar-help {
    min-width: 0;
    line-height: 1.3;
}

.app-logout {
    flex: 0 0 auto;
    white-space: nowrap;
}

.app-sidebar-help:hover,
.app-logout:hover {
    color: var(--shell-primary);
}

.app-main {
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--shell-sidebar-width);
}

.personal-dashboard-shell .app-main {
    margin-left: 0;
}

.app-personal-bar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--shell-border);
    backdrop-filter: blur(14px);
}

.app-personal-brand {
    gap: 14px;
    color: var(--shell-muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-decoration: none;
}

.app-personal-brand span {
    padding-left: 14px;
    border-left: 1px solid var(--shell-border);
}

.app-personal-logout {
    display: inline-flex;
    min-height: 36px;
    gap: 7px;
    align-items: center;
    padding: 7px 10px;
    color: var(--shell-muted);
    font-size: 0.72rem;
    font-weight: 650;
    text-decoration: none;
    border-radius: 8px;
}

.app-personal-logout:hover,
.app-personal-logout:focus-visible {
    color: var(--shell-primary);
    background: var(--shell-primary-soft);
}

.app-personal-content {
    padding-top: 24px;
}

.app-mobile-bar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: none;
    min-height: var(--shell-mobile-bar-height);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.93);
    border-bottom: 1px solid var(--shell-border);
    backdrop-filter: blur(14px);
}

.app-mobile-bar-primary {
    display: flex;
    gap: 12px;
    align-items: center;
}

.app-menu-toggle,
.app-contact-sales {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--shell-muted);
    background: var(--shell-surface);
    border: 1px solid var(--shell-border);
    border-radius: 9px;
}

.app-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
}

.app-contact-sales {
    gap: 7px;
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.76rem;
    font-weight: 700;
}

.app-menu-toggle:hover,
.app-contact-sales:hover {
    color: var(--shell-primary);
    border-color: #cfd6ed;
    box-shadow: 0 4px 12px rgba(28, 43, 82, 0.06);
}

.app-mobile-brand {
    display: none;
}

.app-content {
    min-width: 0;
    padding: 30px;
}

.app-content > .page-container {
    width: 100%;
    max-width: 1480px;
    padding: 0;
    margin: 0 auto;
}

.app-content .body-container {
    width: 100%;
}

.app-sidebar-backdrop {
    display: none;
}

.app-modal[hidden] {
    display: none;
}

.app-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    place-items: center;
    padding: 20px;
}

.app-modal-backdrop {
    position: absolute;
    inset: 0;
    padding: 0;
    background: rgba(13, 20, 37, 0.55);
    border: 0;
    backdrop-filter: blur(4px);
}

.app-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 500px);
    padding: 30px;
    background: #fff;
    border: 1px solid var(--shell-border);
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(15, 25, 50, 0.28);
}

.app-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    color: var(--shell-muted);
    background: var(--shell-surface-muted);
    border: 0;
    border-radius: 9px;
}

.app-modal-icon {
    display: inline-flex;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    color: #fff;
    font-size: 1.1rem;
    background: linear-gradient(145deg, #4256b3, #6b4fb0);
    border-radius: 13px;
    box-shadow: 0 9px 20px rgba(66, 86, 179, 0.22);
}

.app-modal-eyebrow {
    display: block;
    margin-bottom: 6px;
    color: var(--shell-primary);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.app-modal-dialog h2 {
    margin: 0 40px 9px 0;
    color: var(--shell-text);
    font-size: 1.45rem;
    font-weight: 750;
    letter-spacing: -0.025em;
}

.app-modal-dialog > p {
    margin: 0 0 18px;
    color: var(--shell-muted);
    font-size: 0.86rem;
    line-height: 1.65;
}

.app-modal-features {
    display: grid;
    gap: 10px;
    padding: 15px;
    margin: 0 0 20px;
    list-style: none;
    background: var(--shell-surface-muted);
    border: 1px solid var(--shell-border);
    border-radius: 12px;
}

.app-modal-features li {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    color: #3d475a;
    font-size: 0.8rem;
}

.app-modal-features i {
    margin-top: 2px;
    color: var(--shell-success);
}

.app-modal-cta,
.app-modal-dismiss {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.app-modal-cta {
    gap: 8px;
    min-height: 44px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 750;
    text-decoration: none;
    background: var(--shell-primary);
    box-shadow: 0 8px 18px rgba(66, 86, 179, 0.18);
}

.app-modal-cta:hover {
    color: #fff;
    background: var(--shell-primary-strong);
}

.app-modal-dismiss {
    padding: 9px;
    margin-top: 6px;
    color: var(--shell-muted);
    font-size: 0.76rem;
    font-weight: 650;
    background: transparent;
    border: 0;
}

.app-modal-dismiss:hover {
    color: var(--shell-text);
}

.public-shell-page {
    min-height: 100vh;
    background: #edf7ff;
}

.public-shell-header {
    display: flex;
    align-items: center;
    min-height: 78px;
    border-bottom: 1px solid rgba(45, 67, 128, 0.1);
}

.public-shell-brand img {
    width: 124px;
    height: auto;
}

/* Authenticated page content follows the quieter OrgPulse visual density. */
.app-shell-page .body-container {
    margin-top: 0;
}

.app-shell-page .page-header {
    padding: 0;
    margin-bottom: 22px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.app-shell-page .page-title {
    gap: 8px;
    margin: 0 0 4px;
    color: #172033;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.app-shell-page .page-title i {
    color: #5d6fc2;
    font-size: 1.05rem;
}

.app-shell-page .page-subtitle {
    max-width: 820px;
    color: #697386;
    font-size: 0.8rem;
    line-height: 1.55;
}

.app-shell-page .page-header .alert {
    padding: 8px 11px;
    color: #526078;
    font-size: 0.76rem;
    line-height: 1.45;
    text-align: left !important;
    background: #f7f8fc;
    border: 1px solid #e6eaf2;
}

.app-shell-page .chart-card,
.app-shell-page .settings-panel,
.app-shell-page .controls-bar,
.app-shell-page .stat-card,
.app-shell-page .card,
.app-shell-page .features-panel .card,
.app-shell-page .table-container-section {
    background: #fff;
    border-color: #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.045), 0 1px 2px rgba(15, 23, 42, 0.025);
}

.app-shell-page .chart-card,
.app-shell-page .settings-panel {
    padding: 18px;
    margin-bottom: 18px;
}

.app-shell-page .chart-header,
.app-shell-page .panel-header {
    min-height: 24px;
    padding-bottom: 0;
    margin-bottom: 15px;
    border-bottom: 0;
}

.app-shell-page .chart-title,
.app-shell-page .panel-title {
    gap: 7px;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.065em;
    text-transform: uppercase;
}

.app-shell-page .chart-title i,
.app-shell-page .panel-title i {
    color: #7182ca;
    font-size: 0.78rem;
}

.app-shell-page .stats-grid {
    gap: 14px;
    margin-bottom: 18px;
}

.app-shell-page .stat-card {
    padding: 16px;
}

.app-shell-page .stat-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
    font-size: 0.88rem;
    border-radius: 9px;
}

.app-shell-page .stat-icon.blue {
    color: #4256b3;
    background: #eef1ff;
}

.app-shell-page .stat-icon.green {
    color: #168660;
    background: #e8f7f1;
}

.app-shell-page .stat-icon.orange {
    color: #c8661e;
    background: #fff2e7;
}

.app-shell-page .stat-icon.purple {
    color: #7656a8;
    background: #f3edff;
}

.app-shell-page .stat-label {
    margin-bottom: 5px;
    color: #7b8495;
    font-size: 0.69rem;
    font-weight: 700;
    letter-spacing: 0.055em;
}

.app-shell-page .stat-value {
    color: #172033;
    font-size: 1.45rem;
    letter-spacing: -0.025em;
}

.app-shell-page .stat-change {
    margin-top: 5px;
    color: #7b8495;
    font-size: 0.72rem;
}

.app-shell-page .controls-bar {
    padding: 10px 12px;
    margin-bottom: 18px;
}

.app-shell-page .form-control,
.app-shell-page .form-select,
.app-shell-page .month-selector,
.app-shell-page .range-pill {
    border-color: #dfe4ec;
    border-radius: 8px;
    font-size: 0.8rem;
    box-shadow: none;
}

.app-shell-page .range-pill,
.app-shell-page .selected-range-badge,
.app-shell-page .btn-modern,
.app-shell-page .btn-secondary-modern,
.app-shell-page .btn-outline-secondary {
    min-height: 36px;
    padding: 7px 11px;
    font-size: 0.78rem;
    border-radius: 8px;
}

.app-shell-page .table {
    border-radius: 10px;
}

.app-shell-page .table thead {
    background: #f7f8fb;
}

.app-shell-page .table th {
    padding: 11px 12px;
    color: #697386;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: transparent;
    border-bottom: 1px solid #e2e8f0;
}

.app-shell-page .table td {
    padding: 11px 12px;
    color: #475467;
    font-size: 0.8rem;
    border-bottom-color: #edf0f5;
}

.app-shell-page .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: #fafbfc;
}

.app-shell-page .table tbody tr:hover > * {
    --bs-table-accent-bg: #f7f8fb;
}

.app-shell-page .list-group-item:hover {
    background: #f7f8fb;
    transform: none;
}

.app-shell-page .list-group-item {
    border-color: #e6eaf0;
}

.app-shell-page .filter-header {
    padding-bottom: 0;
    margin-bottom: 14px;
    border-bottom: 0;
}

.app-shell-page .card:hover,
.app-shell-page .chart-card:hover,
.app-shell-page .features-panel .card:hover {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.app-shell-page .nav-tabs {
    gap: 4px;
    padding: 4px;
    margin-bottom: 20px !important;
    background: #eef1f5;
    border: 0;
    border-radius: 10px;
}

.app-shell-page .nav-tabs .nav-link {
    padding: 8px 12px;
    color: #697386;
    font-size: 0.78rem;
    font-weight: 650;
    background: transparent;
    border: 0;
    border-radius: 7px;
}

.app-shell-page .nav-tabs .nav-link.active {
    color: #30428f;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.07);
}

body.app-modal-open,
body.app-sidebar-open {
    overflow: hidden;
}

@media (max-width: 1199.98px) {
    .app-sidebar {
        width: min(var(--shell-sidebar-width), calc(100vw - 48px));
        transform: translateX(-105%);
        box-shadow: var(--shell-shadow);
        transition: transform 180ms ease;
    }

    .app-sidebar-close,
    .app-menu-toggle,
    .app-mobile-brand {
        display: inline-flex;
    }

    .app-mobile-bar {
        display: flex;
    }

    .app-main {
        margin-left: 0;
    }

    .app-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1035;
        display: block;
        padding: 0;
        pointer-events: none;
        visibility: hidden;
        background: rgba(13, 20, 37, 0.45);
        border: 0;
        opacity: 0;
        transition: opacity 180ms ease, visibility 180ms ease;
    }

    .app-sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-sidebar-open .app-sidebar-backdrop {
        pointer-events: auto;
        visibility: visible;
        opacity: 1;
    }

    .app-mobile-brand img {
        width: 112px;
        height: auto;
    }

}

@media (max-width: 767.98px) {
    .app-personal-bar {
        padding: 0 14px;
    }

    .app-personal-brand {
        gap: 8px;
    }

    .app-personal-brand img {
        width: 104px;
    }

    .app-personal-brand span {
        padding-left: 8px;
        font-size: 0.66rem;
    }

    .app-personal-logout {
        width: 38px;
        height: 38px;
        justify-content: center;
        padding: 0;
    }

    .app-personal-logout i {
        font-size: 0.82rem;
    }

    .app-personal-logout {
        font-size: 0;
    }

    .app-content {
        padding: 20px 14px 32px;
    }

    .app-shell-page .page-header {
        margin-bottom: 18px;
    }

    .app-shell-page .page-title {
        font-size: 1.2rem;
    }

    .app-shell-page .chart-card,
    .app-shell-page .settings-panel {
        padding: 15px;
    }

    .app-contact-sales {
        width: 40px;
        height: 40px;
        padding: 0;
    }

    .app-modal-dialog {
        padding: 24px 20px 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar,
    .app-sidebar-backdrop,
    .app-nav-link {
        transition: none;
    }

    .app-nav-spinner {
        animation-duration: 1.4s;
    }
}
