:root {
    --portal-font: 'Plus Jakarta Sans', system-ui, sans-serif;
    --portal-bg: #f0f4f8;
    --portal-surface: #ffffff;
    --portal-border: #e2e8f0;
    --portal-text: #0f172a;
    --portal-muted: #64748b;
    --portal-primary: #4f46e5;
    --portal-primary-hover: #4338ca;
    --portal-primary-soft: #eef2ff;
    --portal-accent: #06b6d4;
    --portal-success: #10b981;
    --portal-warning: #f59e0b;
    --portal-danger: #ef4444;
    --portal-nav: linear-gradient(180deg, #1e1b4b 0%, #312e81 55%, #1e3a5f 100%);
    --portal-sidebar-width: 260px;
    --portal-topbar-height: 64px;
    --portal-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
    --portal-radius: 12px;
    --portal-radius-lg: 16px;
}

* {
    box-sizing: border-box;
}

body.portal-body {
    font-family: var(--portal-font);
    background: var(--portal-bg);
    color: var(--portal-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ——— Two-column app shell ——— */
body.portal-body-app {
    overflow-x: hidden;
}

.portal-app {
    display: flex;
    min-height: 100vh;
}

.portal-main-wrap {
    flex: 1;
    min-width: 0;
    margin-left: var(--portal-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Sidebar */
.portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: var(--portal-sidebar-width);
    height: 100vh;
    background: var(--portal-nav);
    color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
    transition: transform 0.25s ease;
}

.portal-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.15rem 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.portal-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: #fff;
}

.portal-sidebar-logo-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
}

.portal-sidebar-logo-text {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.03em;
}

.portal-sidebar-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    padding: 0.35rem;
    border-radius: 8px;
}

.portal-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.portal-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.65rem 1rem;
}

.portal-sidebar-section {
    margin-bottom: 0.5rem;
}

.portal-sidebar-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.45);
    padding: 0.5rem 0.75rem 0.35rem;
}

.portal-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    margin-bottom: 2px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    border: 1px solid transparent;
}

.portal-sidebar-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.portal-sidebar-link.active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: inset 3px 0 0 #fbbf24;
}

.portal-sidebar-icon {
    display: flex;
    opacity: 0.9;
    flex-shrink: 0;
}

.portal-sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.35rem 0.75rem;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
}

.portal-sidebar-group-toggle:hover {
    color: rgba(255, 255, 255, 0.7);
}

.portal-sidebar-chevron {
    transition: transform 0.2s;
    opacity: 0.7;
}

.portal-sidebar-group-toggle:not(.collapsed) .portal-sidebar-chevron,
.portal-sidebar-group-toggle[aria-expanded="true"] .portal-sidebar-chevron {
    transform: rotate(180deg);
}

.portal-sidebar-subnav {
    padding: 0.15rem 0 0.35rem 0.35rem;
}

.portal-sidebar-sublink {
    display: block;
    padding: 0.45rem 0.75rem 0.45rem 2.25rem;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 1px;
}

.portal-sidebar-sublink:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.portal-sidebar-sublink.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-weight: 600;
}

.portal-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.portal-sidebar-user-mini {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.portal-sidebar-user-avatar,
.portal-topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.portal-sidebar-user-name {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.portal-sidebar-user-role {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
}

.portal-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

/* Top bar */
.portal-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    height: var(--portal-topbar-height);
    min-height: var(--portal-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-border);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

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

.portal-topbar-menu-btn {
    background: var(--portal-primary-soft);
    border: none;
    color: var(--portal-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.portal-topbar-titles {
    min-width: 0;
}

.portal-breadcrumb {
    font-size: 0.75rem;
    color: var(--portal-muted);
    margin-bottom: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-breadcrumb a {
    color: var(--portal-muted);
    text-decoration: none;
}

.portal-breadcrumb a:hover {
    color: var(--portal-primary);
}

.portal-breadcrumb-sep {
    margin: 0 0.35rem;
    opacity: 0.5;
}

.portal-breadcrumb-current {
    color: var(--portal-text);
    font-weight: 500;
}

.portal-topbar-title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-topbar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: transparent;
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 0.35rem 0.65rem 0.35rem 0.35rem;
}

.portal-topbar-user::after {
    margin-left: 0.25rem;
}

.portal-topbar-user-text {
    text-align: left;
    line-height: 1.2;
}

.portal-topbar-user-name {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--portal-text);
}

.portal-topbar-user-email {
    display: block;
    font-size: 0.7rem;
    color: var(--portal-muted);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-topbar-avatar {
    background: var(--portal-primary);
    color: #fff;
}

.portal-user-dropdown {
    border: none;
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    min-width: 220px;
}

.portal-user-dropdown .dropdown-item {
    font-size: 0.875rem;
}

/* Main content */
.portal-content {
    flex: 1;
    padding: 1.5rem;
    overflow-x: auto;
}

.portal-main-guest {
    padding-bottom: 3rem;
}

.portal-main {
    padding-bottom: 3rem;
}

.portal-page-header {
    margin-bottom: 1.5rem;
}

.portal-page-header h1,
.portal-page-header h4 {
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.portal-page-header .subtitle {
    color: var(--portal-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* Cards */
.portal-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-lg);
    box-shadow: var(--portal-shadow);
    overflow: hidden;
}

.portal-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--portal-border);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 1rem 1.25rem;
    color: var(--portal-text);
}

.portal-card .card-body {
    padding: 1.25rem;
}

/* Stat cards */
.portal-stat {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--portal-shadow);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.portal-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--stat-accent, var(--portal-primary));
}

.portal-stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
    color: var(--portal-text);
}

.portal-stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--portal-muted);
    margin-top: 0.35rem;
}

.portal-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: var(--portal-primary-soft);
    color: var(--portal-primary);
}

/* Tables */
.portal-table-wrap {
    overflow-x: auto;
}

.table.portal-table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table.portal-table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--portal-border);
    color: var(--portal-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table.portal-table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-color: var(--portal-border);
}

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

.table.portal-table tbody tr.row-unread {
    background: var(--portal-primary-soft);
}

.table.portal-table tbody tr.row-unread:hover {
    background: #e0e7ff;
}

.table.portal-table a.lead-link {
    font-weight: 600;
    color: var(--portal-primary);
    text-decoration: none;
}

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

/* Status badges */
.portal-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.portal-badge-costing { background: #dbeafe; color: #1d4ed8; }
.portal-badge-quoted { background: #fef3c7; color: #b45309; }
.portal-badge-negotiation { background: #fce7f3; color: #be185d; }
.portal-badge-won { background: #d1fae5; color: #047857; }
.portal-badge-default { background: #f1f5f9; color: #475569; }

/* Buttons */
.btn-portal-primary {
    background: var(--portal-primary);
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.4rem 0.85rem;
    font-size: 0.8125rem;
}

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

.btn-portal-outline {
    background: transparent;
    border: 1px solid var(--portal-border);
    color: var(--portal-text);
    font-weight: 500;
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-portal-outline:hover {
    border-color: var(--portal-primary);
    color: var(--portal-primary);
    background: var(--portal-primary-soft);
}

.btn-portal-danger {
    background: transparent;
    border: 1px solid #fecaca;
    color: var(--portal-danger);
    font-weight: 500;
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-portal-danger:hover {
    background: #fef2f2;
    border-color: var(--portal-danger);
}

.portal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

/* Alerts */
.alert.portal-alert-success {
    border: none;
    border-radius: var(--portal-radius);
    background: #ecfdf5;
    color: #047857;
}

.alert.portal-alert-danger {
    border: none;
    border-radius: var(--portal-radius);
    background: #fef2f2;
    color: #b91c1c;
}

/* Detail page */
.portal-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.portal-detail-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--portal-border);
}

.portal-detail-item:last-child {
    border-bottom: none;
}

.portal-detail-item .label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--portal-muted);
    margin-bottom: 0.2rem;
}

.portal-detail-item .value {
    font-weight: 500;
    font-size: 0.9rem;
}

.portal-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--portal-muted);
    margin-bottom: 1rem;
}

/* Forms */
.form-control,
.form-select {
    border-radius: 8px;
    border-color: var(--portal-border);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Login */
.portal-login-wrap {
    min-height: calc(100vh - 2rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.portal-login-card {
    max-width: 420px;
    width: 100%;
    border-radius: var(--portal-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.2);
    border: 1px solid var(--portal-border);
    overflow: hidden;
}

.portal-login-card .card-header {
    background: var(--portal-nav);
    color: #fff;
    text-align: center;
    padding: 1.5rem;
    border: none;
}

.portal-login-card .card-header h5 {
    margin: 0;
    font-weight: 700;
}

/* Dashboard deadline card */
.portal-card-alert .card-header {
    background: linear-gradient(135deg, #fef2f2, #fff1f2);
    color: #b91c1c;
    border-bottom-color: #fecaca;
}

/* Empty state */
.portal-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--portal-muted);
}

/* Mobile sidebar */
@media (max-width: 991.98px) {
    .portal-main-wrap {
        margin-left: 0;
    }

    .portal-sidebar {
        transform: translateX(-100%);
    }

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

    body.portal-sidebar-open .portal-sidebar-backdrop {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .portal-topbar-title {
        font-size: 1rem;
    }

    .portal-content {
        padding: 1rem;
    }
}

/* Bootstrap cards site-wide */
body.portal-body .card {
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-lg);
    box-shadow: var(--portal-shadow);
}

body.portal-body .card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--portal-border);
    font-weight: 600;
}

body.portal-body .btn-primary {
    background: var(--portal-primary);
    border-color: var(--portal-primary);
}

body.portal-body .btn-primary:hover {
    background: var(--portal-primary-hover);
    border-color: var(--portal-primary-hover);
}

body.portal-body .table thead th {
    color: var(--portal-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

