:root {
    --portal-bg: #f4f7ff;
    --portal-surface: #ffffff;
    --portal-sidebar: #05182e;
    --portal-sidebar-soft: #0a2746;
    --portal-primary: #0b6ccf;
    --portal-primary-strong: #084e97;
    --portal-accent: #18b7b8;
    --portal-text: #0f2238;
    --portal-muted: #607085;
    --portal-border: #d9e2ef;
    --portal-shadow: 0 14px 30px rgba(8, 26, 53, 0.08);
}

* {
    box-sizing: border-box;
}

body.client-portal-body {
    margin: 0;
    background: radial-gradient(1200px 600px at -5% -10%, rgba(24, 183, 184, 0.12), transparent 40%),
                radial-gradient(900px 500px at 105% 10%, rgba(11, 108, 207, 0.14), transparent 50%),
                var(--portal-bg);
    color: var(--portal-text);
    font-family: 'Outfit', 'Segoe UI', sans-serif;
    min-height: 100vh;
}

.portal-bg-orb {
    position: fixed;
    z-index: 0;
    border-radius: 999px;
    filter: blur(2px);
    pointer-events: none;
}

.portal-bg-orb.orb-a {
    width: 280px;
    height: 280px;
    top: -80px;
    right: -80px;
    background: linear-gradient(160deg, rgba(11, 108, 207, 0.35), rgba(24, 183, 184, 0.12));
}

.portal-bg-orb.orb-b {
    width: 220px;
    height: 220px;
    bottom: -70px;
    left: -70px;
    background: linear-gradient(140deg, rgba(24, 183, 184, 0.24), rgba(11, 108, 207, 0.08));
}

.portal-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.portal-sidebar {
    width: 280px;
    background: linear-gradient(190deg, var(--portal-sidebar) 0%, var(--portal-sidebar-soft) 100%);
    color: #dfe8f4;
    padding: 22px 16px 18px;
    box-shadow: 10px 0 30px rgba(5, 24, 46, 0.22);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #fff;
    margin-bottom: 20px;
    padding: 10px 8px;
}

.portal-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    background: linear-gradient(145deg, #17b7b8 0%, #0b6ccf 100%);
    box-shadow: 0 8px 20px rgba(11, 108, 207, 0.35);
}

.portal-brand-text {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.1;
}

.portal-brand-text strong {
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.portal-brand-text small {
    color: #9eb4cf;
    font-size: 0.78rem;
}

.portal-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow: auto;
    padding-right: 2px;
}

.portal-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #c9d8ea;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 11px 12px;
    font-weight: 500;
    transition: all 0.22s ease;
}

.portal-nav-link i {
    width: 18px;
    text-align: center;
}

.portal-nav-link:hover {
    color: #fff;
    background: rgba(24, 183, 184, 0.14);
    border-color: rgba(24, 183, 184, 0.22);
}

.portal-nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(11, 108, 207, 0.38) 0%, rgba(24, 183, 184, 0.28) 100%);
    border-color: rgba(180, 212, 244, 0.28);
}

.portal-logout-form {
    margin-top: 14px;
}

.portal-logout-btn {
    width: 100%;
    border: 1px solid rgba(236, 247, 255, 0.2);
    border-radius: 12px;
    background: rgba(236, 247, 255, 0.06);
    color: #eff5fc;
    padding: 10px 12px;
    font-weight: 600;
    display: flex;
    justify-content: center;
    gap: 8px;
    transition: all 0.22s ease;
}

.portal-logout-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
}

.portal-stage {
    flex: 1;
    padding: 20px 22px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.portal-topbar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(176, 198, 222, 0.4);
    border-radius: 18px;
    box-shadow: var(--portal-shadow);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.portal-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.portal-kicker {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    font-size: 0.68rem;
    color: var(--portal-primary);
}

.portal-page-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f233b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(70vw, 520px);
}

.portal-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--portal-border);
    border-radius: 999px;
    padding: 8px 12px;
    background: #fff;
    font-weight: 600;
    color: #1d3552;
    box-shadow: 0 8px 20px rgba(7, 20, 47, 0.08);
}

.portal-main {
    margin-top: 18px;
    flex: 1;
}

.portal-main h2 {
    font-size: 1.45rem;
    font-weight: 700;
    color: #122a45;
    margin-bottom: 14px;
}

.portal-main .card {
    border: 1px solid var(--portal-border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--portal-shadow);
    background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
}

.metric-card .card-body {
    position: relative;
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.metric-card h6 {
    color: #5d7290;
    font-weight: 600;
}

.metric-card h3 {
    color: #0f2a46;
    font-size: 1.9rem;
    font-weight: 700;
}

.portal-main .card-header {
    background: linear-gradient(90deg, rgba(11, 108, 207, 0.08) 0%, rgba(24, 183, 184, 0.08) 100%);
    border-bottom: 1px solid var(--portal-border);
    color: #14365b;
    font-weight: 700;
}

.portal-main .table {
    margin-bottom: 0;
    color: #1f3350;
}

.portal-main .table thead th {
    background: #f0f5fc;
    color: #1b3a60;
    border-color: #d8e4f0;
    text-transform: uppercase;
    font-size: 0.76rem;
    letter-spacing: 0.04em;
    font-weight: 700;
}

.portal-main .table tbody td {
    border-color: #e4ecf5;
    vertical-align: middle;
}

.portal-main .table tbody tr:hover {
    background: #f7fbff;
}

.portal-main .progress {
    height: 9px;
    border-radius: 999px;
    background: #e6eef8;
}

.portal-main .progress-bar {
    border-radius: 999px;
    background: linear-gradient(90deg, var(--portal-primary) 0%, var(--portal-accent) 100%);
}

.portal-main .list-group-item {
    border-color: #e3ebf5;
    background: #fff;
}

.project-timeline {
    position: relative;
    padding-left: 22px;
}

.project-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, rgba(11, 108, 207, 0.3) 0%, rgba(24, 183, 184, 0.22) 100%);
}

.timeline-item {
    position: relative;
    padding-left: 34px;
    margin-bottom: 18px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-icon {
    position: absolute;
    left: -1px;
    top: 2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: linear-gradient(145deg, var(--portal-primary) 0%, var(--portal-accent) 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.58rem;
    box-shadow: 0 8px 18px rgba(11, 108, 207, 0.35);
}

.timeline-content {
    border: 1px solid #dce7f4;
    border-radius: 14px;
    background: #fff;
    padding: 12px 14px;
}

.portal-main .btn-primary,
.portal-main .btn-info,
.portal-main .btn-outline-secondary {
    border-radius: 10px;
    font-weight: 600;
}

.portal-main .btn-primary,
.portal-main .btn-info {
    border-color: transparent;
    background: linear-gradient(135deg, var(--portal-primary) 0%, var(--portal-accent) 100%);
    color: #fff;
}

.portal-main .btn-primary:hover,
.portal-main .btn-info:hover {
    background: linear-gradient(135deg, var(--portal-primary-strong) 0%, #0f8e90 100%);
    transform: translateY(-1px);
}

.portal-main .btn-secondary {
    border-radius: 10px;
    font-weight: 600;
}

.portal-main .form-control,
.portal-main .form-select,
.portal-main textarea {
    border-radius: 12px;
    border: 1px solid #ccd9e8;
    padding: 0.62rem 0.75rem;
}

.portal-main .form-control:focus,
.portal-main .form-select:focus,
.portal-main textarea:focus {
    border-color: #50a4f2;
    box-shadow: 0 0 0 0.2rem rgba(11, 108, 207, 0.14);
}

.portal-main .alert {
    border-radius: 12px;
    border: none;
    box-shadow: var(--portal-shadow);
}

.portal-main .text-muted {
    color: #63758b !important;
}

.portal-footnote {
    margin-top: 16px;
    padding: 10px 2px 2px;
    text-align: center;
    color: #617489;
    font-size: 0.88rem;
}

.portal-toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 24px));
}

.portal-toast {
    position: relative;
    border: 1px solid #cfe0f2;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 16px 36px rgba(6, 24, 46, 0.18);
    padding: 14px 16px 12px;
    transform: translateY(16px);
    opacity: 0;
    transition: all 0.22s ease;
}

.portal-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.portal-toast h6 {
    margin: 0 24px 6px 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f2b47;
}

.portal-toast p {
    margin: 0 0 10px;
    color: #2c425e;
    font-size: 0.9rem;
}

.portal-toast-link {
    display: inline-block;
    font-weight: 600;
    font-size: 0.85rem;
    color: #0b6ccf;
    text-decoration: none;
}

.portal-toast-link:hover {
    color: #084e97;
}

.portal-toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    border: 0;
    background: transparent;
    color: #7a8ea6;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1;
}

.portal-toast-close:hover {
    background: #edf3fb;
    color: #2c425e;
}

.portal-mobile-toggle {
    border: 1px solid var(--portal-border);
    background: #fff;
    color: #1e3f67;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(8, 24, 50, 0.08);
}

.portal-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 12, 24, 0.45);
    z-index: 9;
    border: 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.24s ease;
}

.portal-sidebar-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.portal-main .badge {
    border-radius: 999px;
    font-weight: 600;
    padding: 6px 10px;
}

.kb-toolbar .card-body {
    background: linear-gradient(125deg, rgba(11, 108, 207, 0.08) 0%, rgba(24, 183, 184, 0.08) 100%);
}

.kb-toolbar-copy {
    color: #4d617c;
    font-size: 0.95rem;
}

.kb-search-form {
    width: min(420px, 100%);
}

.kb-search-form .form-control {
    background: #fff;
}

.kb-category-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.kb-category-chip {
    border: 1px solid #dbe7f3;
    border-radius: 12px;
    background: #f9fbff;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.kb-category-name {
    color: #1e3553;
    font-weight: 600;
}

.kb-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #0c5388;
    background: rgba(11, 108, 207, 0.1);
    border: 1px solid rgba(11, 108, 207, 0.15);
}

.kb-meta {
    color: #5a6e88;
    font-size: 0.82rem;
    font-weight: 600;
}

.kb-article-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.kb-article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 30px rgba(9, 35, 69, 0.1);
    border-color: #c8dbef;
}

.kb-article-card h5 {
    color: #132f4d;
    margin-bottom: 0;
}

.kb-article-excerpt {
    color: #324d6d;
    line-height: 1.65;
}

.kb-article-view-card .card-body {
    padding: 22px;
}

.kb-article-content {
    font-size: 1rem;
    line-height: 1.8;
    color: #1c304d;
    white-space: normal;
}

.kb-article-content h1,
.kb-article-content h2,
.kb-article-content h3,
.kb-article-content h4,
.kb-article-content h5,
.kb-article-content h6 {
    color: #102a47;
    margin-top: 1.35rem;
    margin-bottom: 0.7rem;
    font-weight: 700;
}

.kb-article-content p {
    margin-bottom: 0.95rem;
}

.kb-article-content ul,
.kb-article-content ol {
    padding-left: 1.3rem;
    margin-bottom: 1rem;
}

.kb-article-content a {
    color: #0b6ccf;
    font-weight: 600;
    text-decoration: none;
}

.kb-article-content a:hover {
    color: #084e97;
    text-decoration: underline;
}

.kb-article-content blockquote {
    margin: 1rem 0;
    padding: 0.8rem 1rem;
    border-left: 4px solid rgba(11, 108, 207, 0.35);
    background: #f4f9ff;
    border-radius: 8px;
    color: #274769;
}

.kb-article-content code {
    padding: 2px 6px;
    border-radius: 6px;
    background: #edf4fc;
    color: #1e3553;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 0.92em;
}

.kb-article-content pre {
    padding: 12px;
    border-radius: 10px;
    background: #102036;
    color: #d7e8ff;
    overflow-x: auto;
}

.kb-article-content pre code {
    padding: 0;
    background: transparent;
    color: inherit;
}

.kb-article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.kb-article-content th,
.kb-article-content td {
    border: 1px solid #dce6f2;
    padding: 8px 10px;
}

.kb-article-content th {
    background: #f2f7fd;
    font-weight: 700;
}

.kb-article-content hr {
    border: 0;
    border-top: 1px solid #d9e4f0;
    margin: 1.2rem 0;
}

.kb-article-content img {
    max-width: 100%;
    border-radius: 12px;
    height: auto;
    margin: 0.8rem 0;
}

@media (max-width: 991.98px) {
    .portal-shell {
        display: block;
    }

    .portal-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-108%);
        transition: transform 0.32s ease;
        width: min(85vw, 300px);
        z-index: 12;
    }

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

    .portal-stage {
        padding: 12px;
    }

    .portal-topbar {
        padding: 12px;
    }

    .portal-mobile-toggle {
        display: inline-flex;
    }

    .portal-user-chip {
        padding: 7px 10px;
        font-size: 0.88rem;
    }

    .portal-page-title {
        max-width: 52vw;
        font-size: 1.12rem;
    }

    .kb-search-form {
        width: 100%;
    }

    body.portal-nav-open {
        overflow: hidden;
    }
}

@media (max-width: 575.98px) {
    .portal-stage {
        padding: 10px;
    }

    .portal-topbar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .portal-main h2 {
        font-size: 1.25rem;
    }

    .portal-user-chip {
        width: 100%;
        justify-content: center;
    }
}
