/* Planner styles. Status colours are all dark enough for white text (AA); the amber pill uses dark text. */
:root {
    --pl-grey: #55626d;
    --pl-blue: #1f6fb2;
    --pl-orange: #6b46c1;
    --pl-green: #1e7a46;
    --pl-red: #b42318;
    --pl-purple: #6b46c1;
    --pl-amber: #f5c542;
    --pl-amber-text: #1f2933;
    --pl-surface: var(--ct-card-bg, #ffffff);
    --pl-border: var(--ct-border-color, #dee2e6);
    --pl-muted: #545b62;
}

[data-bs-theme=dark] {
    --pl-muted: #bcc4cc;
}

.pill {
    display: inline-block;
    min-width: 5.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 50rem;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-align: center;
    white-space: nowrap;
}

.icon-lg { font-size: 1.4rem; }
.icon-md { font-size: 1.15rem; }

.dropdown-click-away { position: fixed; inset: 0; z-index: 1000; }
.dropdown.show > .dropdown-menu { z-index: 1001; }
.dropdown-menu .dropdown-item { cursor: pointer; }

.empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto;
    border-radius: 50%;
    background: var(--ct-primary-bg-subtle, #eef2ff);
    color: var(--ct-primary, #4f46e5);
    font-size: 2.2rem;
}

.project-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.project-card:hover { transform: translateY(-3px); box-shadow: 0 10px 32px rgba(15, 23, 42, 0.14); }
.project-card .card-title a { color: inherit; }
.project-card .card-title a:hover { color: var(--ct-primary, #4f46e5); }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.accent-card { border-top: 4px solid var(--ct-primary, #4f46e5); }
.hero-meta dt { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--pl-muted); }
.hero-meta dd { margin-bottom: 0; font-weight: 600; }

.table-premium thead th {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pl-muted);
    border-bottom-width: 1px;
}

.filter-pills .btn { border-radius: 50rem; }
.view-toggle .btn { display: inline-flex; align-items: center; gap: 0.35rem; }

.auth-card { max-width: 26rem; }

.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 2rem; }
.mini-bars span { width: 6px; background: var(--ct-primary, #4f46e5); border-radius: 2px; opacity: 0.8; }

.dep-list li { display: flex; align-items: center; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid var(--pl-border); }

.pill-grey { background: var(--pl-grey); }
.pill-blue { background: var(--pl-blue); }
.pill-orange { background: var(--pl-orange); }
.pill-green { background: var(--pl-green); }
.pill-red { background: var(--pl-red); }
.pill-purple { background: var(--pl-purple); }
.pill-amber { background: var(--pl-amber); color: var(--pl-amber-text); }

select.pill-select {
    appearance: none;
    border: 0;
    cursor: pointer;
    text-align-last: center;
}

.muted { color: var(--pl-muted); }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    border: 2px solid var(--pl-surface);
}

.avatar-stack .avatar + .avatar { margin-left: -0.5rem; }
.avatar-0 { background: #1f6fb2; }
.avatar-1 { background: #1e7a46; }
.avatar-2 { background: #6b46c1; }
.avatar-3 { background: #6b46c1; }
.avatar-4 { background: #b42318; }
.avatar-5 { background: #0e7490; }

.progress-wrap { display: flex; align-items: center; gap: 0.5rem; min-width: 8rem; }
.progress-wrap .progress { flex: 1; height: 0.6rem; }
.progress-wrap .progress-label { font-size: 0.8rem; min-width: 2.5rem; text-align: right; }

.kpi { padding: 1rem; }
.kpi .kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.kpi .kpi-label { color: var(--pl-muted); font-size: 0.85rem; }

.tabs-bar { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--pl-border); margin-bottom: 1rem; }
.tabs-bar button {
    border: 0;
    background: transparent;
    padding: 0.6rem 1rem;
    border-bottom: 3px solid transparent;
    color: var(--pl-muted);
    font-weight: 600;
}
.tabs-bar button.active { color: var(--ct-body-color, #212529); border-bottom-color: var(--ct-primary, #4f46e5); }

.view-toggle button { min-width: 5.5rem; }

.group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-left: 6px solid var(--pl-grey);
    font-weight: 700;
    cursor: pointer;
}
.group-header.pill-grey { border-left-color: var(--pl-grey); background: transparent; color: inherit; }
.group-border-grey { border-left-color: var(--pl-grey); }
.group-border-blue { border-left-color: var(--pl-blue); }
.group-border-orange { border-left-color: var(--pl-orange); }
.group-border-green { border-left-color: var(--pl-green); }
.group-border-red { border-left-color: var(--pl-red); }
.group-border-purple { border-left-color: var(--pl-purple); }
.group-border-amber { border-left-color: var(--pl-amber); }

.board { display: flex; gap: 0.75rem; overflow-x: auto; padding-bottom: 0.5rem; }
.board-column {
    flex: 0 0 17rem;
    min-height: 12rem;
    padding: 0.5rem;
    border: 1px solid var(--pl-border);
    border-radius: 0.4rem;
    background: var(--ct-light, #f3f5f8);
}
.board-column.drag-over { outline: 2px dashed var(--ct-primary, #4f46e5); }
.board-column-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; font-weight: 700; }
.board-card {
    padding: 0.6rem 0.7rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--pl-border);
    border-radius: 0.35rem;
    background: var(--pl-surface);
    cursor: grab;
}
.board-card:hover { border-color: var(--ct-primary, #4f46e5); }

.gantt { position: relative; overflow: auto; max-height: 72vh; min-height: 22rem; border: 1px solid var(--pl-border); border-radius: 0.5rem; background: var(--pl-surface); user-select: none; }
.gantt-wrap.gantt-full { position: fixed; inset: 0; z-index: 1060; display: flex; flex-direction: column; padding: 1rem; background: var(--ct-body-bg, #ffffff); }
.gantt-wrap.gantt-full .gantt { flex: 1 1 auto; max-height: none; }
.gantt-inner { position: relative; }
.gantt-row, .gantt-head { display: flex; border-bottom: 1px solid var(--pl-border); }
.gantt-row { position: relative; z-index: 1; }
.gantt-head { position: sticky; top: 0; z-index: 6; background: var(--ct-light, #f3f5f8); }
.gantt-label {
    position: sticky;
    left: 0;
    z-index: 4;
    flex: 0 0 280px;
    width: 280px;
    padding: 0.35rem 0.75rem;
    background: var(--pl-surface);
    border-right: 1px solid var(--pl-border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.25;
}
.gantt-head .gantt-label { z-index: 7; background: var(--ct-light, #f3f5f8); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; padding-top: 1rem; }
.gantt-group-row .gantt-label { background: var(--ct-light, #f3f5f8); line-height: 36px; padding-top: 0; padding-bottom: 0; }
.gantt-toggle { color: inherit; line-height: 1; vertical-align: middle; }
.gantt-track { position: relative; flex: 0 0 auto; }
.gantt-seg { position: absolute; height: 26px; padding: 0 0.4rem; border-left: 1px solid var(--pl-border); font-size: 0.75rem; font-weight: 600; line-height: 26px; white-space: nowrap; overflow: hidden; }
.gantt-seg.top { top: 0; font-weight: 700; border-bottom: 1px solid var(--pl-border); }
.gantt-seg.bottom { top: 26px; color: var(--pl-muted); }
.gantt-grid { position: absolute; z-index: 0; pointer-events: none; }
.gantt-gridline { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--pl-border); opacity: 0.6; }
.gantt-gridline.weekend { background: rgba(100, 116, 139, 0.08); }
.gantt-today { position: absolute; top: 0; bottom: 0; background: rgba(180, 35, 24, 0.16); border-left: 2px solid var(--pl-red); }
.gantt-bar {
    position: absolute;
    top: 8px;
    height: 28px;
    border-radius: 0.35rem;
    color: #ffffff;
    font-size: 0.75rem;
    line-height: 28px;
    padding: 0 0.8rem;
    overflow: hidden;
    white-space: nowrap;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}
.gantt-bar.dragging { cursor: grabbing; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.35); opacity: 0.92; z-index: 3; }
.gantt-bar.violation { outline: 2px solid var(--pl-red); outline-offset: 1px; }
.gantt-bar.pill-amber { color: var(--pl-amber-text); }
.gantt-bar .gantt-progress { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.3); }
.gantt-bar span { position: relative; }
.gantt-handle { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; background: rgba(255, 255, 255, 0.0); z-index: 2; }
.gantt-handle.left { left: 0; }
.gantt-handle.right { right: 0; }
.gantt-bar:hover .gantt-handle { background: rgba(255, 255, 255, 0.35); }
.gantt-summary { position: absolute; top: 14px; height: 16px; border-radius: 3px; background: #334155; cursor: grab; overflow: hidden; }
.gantt-summary .gantt-progress { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.35); }
.gantt-summary.dragging { cursor: grabbing; opacity: 0.9; }
.gantt-group-span { position: absolute; top: 17px; height: 10px; border-radius: 3px; background: rgba(100, 116, 139, 0.35); }
.gantt-milestone { position: absolute; top: 13px; width: 18px; height: 18px; border-radius: 3px; transform: rotate(45deg); cursor: grab; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3); z-index: 2; }
.gantt-milestone.dragging { cursor: grabbing; z-index: 3; }
.gantt-milestone-label { position: absolute; top: 12px; font-size: 0.75rem; line-height: 20px; white-space: nowrap; pointer-events: none; }
.gantt-deps { position: absolute; pointer-events: none; z-index: 3; overflow: visible; }.matrix { display: grid; grid-template-columns: 2rem repeat(5, 1fr); gap: 3px; max-width: 28rem; }
.matrix-cell { min-height: 3rem; display: flex; align-items: center; justify-content: center; border-radius: 0.25rem; font-weight: 700; color: #ffffff; }
.matrix-low { background: var(--pl-green); }
.matrix-medium { background: var(--pl-amber); color: var(--pl-amber-text); }
.matrix-high { background: var(--pl-orange); }
.matrix-critical { background: var(--pl-red); }
.matrix-axis { display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--pl-muted); }

.feed-item { padding: 0.75rem 0; border-bottom: 1px solid var(--pl-border); }
.feed-item.system { color: var(--pl-muted); font-size: 0.9rem; }

.sticky-actions { position: sticky; bottom: 0; background: var(--pl-surface); padding: 0.5rem 0; border-top: 1px solid var(--pl-border); }

.workload-card { border-left: 5px solid var(--pl-green); }
.workload-card.warn { border-left-color: var(--pl-orange); }

/* Stub sign-in page (served by the API in Development/Staging only) */
.stub-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: radial-gradient(1200px 500px at 50% -10%, var(--ct-primary-bg-subtle, #e0e7ff), transparent), var(--ct-body-bg, #f1f5f9);
}
.stub-login-card {
    width: 100%;
    max-width: 26rem;
    box-shadow: 0 1rem 3rem rgba(15, 23, 42, 0.12);
    border: 0;
}
.stub-user-button {
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--ct-border-color, #e2e8f0);
}
.stub-user-button:hover,
.stub-user-button:focus-visible {
    border-color: var(--ct-primary, #4f46e5);
    background: var(--ct-primary-bg-subtle, #eef2ff);
}

/* The theme hides stat tile icons between 1200px and 1500px wide; the Planner tiles have room for them */
.widget-flat i.widget-icon {
    display: inline-block;
}

/* A card that fills its column (h-100) would swallow its own 24px bottom margin and touch the next row,
   so the column carries the gap instead */
.card.h-100 {
    margin-bottom: 0;
}
[class*="col"]:has(> .card.h-100) {
    margin-bottom: 16px;
}

/* Dashboard tiles and chart slices that link through */
.card-link {
    color: inherit;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card-link:hover,
.card-link:focus-visible {
    color: inherit;
    transform: translateY(-3px);
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.14);
}
.chart-clickable .apexcharts-pie-area,
.chart-clickable .apexcharts-bar-area {
    cursor: pointer;
}

/* Compact figures above the project asset tracker */
.kpi-card {
    height: 100%;
    padding: 0.65rem 0.9rem;
    border-radius: 0.5rem;
    background: var(--ct-card-bg);
    border: 1px solid var(--ct-border-color);
}
.kpi-card .kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--pl-muted);
}
.kpi-card .kpi-value {
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.25;
}

/* ---- Density: less chrome, more information on screen ---- */
.card { margin-bottom: 16px; }
.card-body { padding: 1rem 1.15rem; }
.header-title { font-size: 0.95rem; }
.nav-tabs.nav-bordered .nav-link { padding: 0.55rem 0.9rem; }
.min-w-0 { min-width: 0; }

/* Breadcrumb alone, for pages that carry their own header */
.crumb-bar { padding: 0.85rem 0 0.6rem; font-size: 0.85rem; }

/* Project and job header: name, status, meta on one or two lines, then the figures */
.entity-head .card-body { padding-bottom: 0.85rem; }
.entity-title { margin: 0; font-size: 1.35rem; font-weight: 700; }
.entity-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1.25rem; margin-top: 0.4rem; font-size: 0.875rem; color: var(--pl-muted); }
.entity-meta .mdi { margin-right: 0.15rem; }
.entity-meta a { font-weight: 600; }

.figure-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.6rem; margin-top: 0.9rem; }
.figure {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--pl-border);
    border-radius: 0.5rem;
    background: var(--pl-surface);
    color: inherit;
    text-align: left;
    text-decoration: none;
}
button.figure, a.figure { cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
button.figure:hover, a.figure:hover, button.figure:focus-visible, a.figure:focus-visible { color: inherit; border-color: var(--ct-primary, #4f46e5); box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); }
.figure-wide { grid-column: span 2; }
.figure-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--pl-muted); }
.figure-value { font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.figure-value.figure-text { font-size: 1rem; line-height: 1.6; }
.figure-sub { font-size: 0.9rem; font-weight: 600; color: var(--pl-muted); }
.figure-note { font-size: 0.78rem; color: var(--pl-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.figure .progress-wrap { min-width: 0; margin: 0.15rem 0; }
@media (max-width: 575.98px) { .figure-wide { grid-column: auto; } }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; }
.section-head h5 { margin: 0; }
.side-box { padding: 0.8rem 0.9rem; margin-bottom: 0.9rem; border: 1px solid var(--pl-border); border-radius: 0.5rem; }
.side-box h5 { margin-top: 0; }

.compact-list li { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--pl-border); }
.compact-list li:last-child { border-bottom: 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; }
.facts dt { font-weight: 600; color: var(--pl-muted); font-size: 0.85rem; }
.facts dd { margin: 0; }
@media (min-width: 992px) { .facts-inline { grid-template-columns: max-content 1fr max-content 1fr; } }

.mini-stat { padding: 0.4rem; border: 1px solid var(--pl-border); border-radius: 0.4rem; }
.mini-stat-value { font-size: 1.15rem; font-weight: 700; }
.mini-stat-label { font-size: 0.75rem; color: var(--pl-muted); }

/* Health: the dot carries the colour; the word stays in body text colour so it reads in both themes */
.health-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--pl-border);
    border-radius: 50rem;
    background: var(--pl-surface);
    color: var(--ct-body-color);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
button.health-badge { cursor: pointer; }
button.health-badge:hover { border-color: var(--ct-primary, #4f46e5); }
.health-badge.dot-only { padding: 0.2rem; border: 0; background: transparent; }
.health-dot { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--pl-grey); }
.health-green .health-dot { background: var(--pl-green); }
.health-amber .health-dot { background: var(--pl-amber); box-shadow: inset 0 0 0 1px rgba(31, 41, 51, 0.35); }
.health-red .health-dot { background: var(--pl-red); }
.health-none { color: var(--pl-muted); }

/* Slide-in panel for quick views */
.side-panel-backdrop { position: fixed; inset: 0; z-index: 1054; background: rgba(15, 23, 42, 0.35); }
.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1055;
    display: flex;
    flex-direction: column;
    width: min(28rem, 100vw);
    background: var(--ct-card-bg, #ffffff);
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.2);
    animation: side-panel-in 0.18s ease-out;
}
@keyframes side-panel-in { from { transform: translateX(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .side-panel { animation: none; } }
.side-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--pl-border); }
.side-panel-body { flex: 1 1 auto; overflow-y: auto; padding: 1rem 1.15rem; }
.side-panel-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1.15rem; border-top: 1px solid var(--pl-border); }

/* Dashboard */
.attention-list li { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.55rem 0; border-bottom: 1px solid var(--pl-border); }
.attention-list li:last-child { border-bottom: 0; }
.attention-list .mdi { font-size: 1.2rem; line-height: 1.3; }
.attention-red { color: var(--pl-red); }
.attention-amber { color: #8a6100; }
.attention-info { color: var(--pl-blue); }
[data-bs-theme=dark] .attention-amber { color: var(--pl-amber); }
[data-bs-theme=dark] .attention-red { color: #f28b82; }
[data-bs-theme=dark] .attention-info { color: #8ab4f8; }

/* Portfolio list */
.portfolio-table td, .portfolio-table th { padding-left: 0.75rem; }
.portfolio-table .group-row td { background: var(--ct-light, #f3f5f8); font-size: 0.85rem; }
.sort-head { color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; text-decoration: none; }
.sort-head:hover { color: var(--ct-primary, #4f46e5); }

.gantt-readonly .gantt-bar, .gantt-readonly .gantt-milestone { cursor: pointer; }

/* ---- Calm palette: colour only where it carries meaning ----
   Status pills are neutral with a small coloured dot; Gantt bars keep their solid colours (they use .pill-* without .pill). */
.pill, .pill[class*="pill-"] {
    --dot: var(--pl-grey);
    min-width: 0;
    padding: 0.2rem 0.65rem 0.2rem 1.4rem;
    border: 1px solid var(--pl-border);
    background: radial-gradient(circle at 0.7rem 50%, var(--dot) 0 0.24rem, transparent 0.26rem), var(--pl-surface);
    color: var(--ct-body-color);
    font-weight: 600;
    text-align: left;
}
select.pill-select { text-align-last: left; padding-right: 0.65rem; }
.pill.pill-blue { --dot: var(--pl-blue); }
.pill.pill-orange, .pill.pill-purple { --dot: var(--pl-purple); }
.pill.pill-green { --dot: var(--pl-green); }
.pill.pill-red { --dot: var(--pl-red); }
.pill.pill-amber { --dot: var(--pl-amber); }

/* One avatar colour: initials identify people, colour does not need to */
.avatar[class*="avatar-"] { background: var(--pl-grey); }

/* Lists with a date or a dot on the left and text beside it */
.plain-list li { display: flex; align-items: baseline; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--pl-border); }
.plain-list li:last-child { border-bottom: 0; }
.date-col { flex: 0 0 5.5rem; font-size: 0.85rem; color: var(--pl-muted); white-space: nowrap; }
.sev-dot { flex: 0 0 auto; width: 0.55rem; height: 0.55rem; margin-top: 0.15rem; border-radius: 50%; background: var(--pl-grey); }
.sev-red { background: var(--pl-red); }
.sev-amber { background: var(--pl-amber); box-shadow: inset 0 0 0 1px rgba(31, 41, 51, 0.35); }

/* Sections in a side column, separated by a rule rather than a box */
.side-section { padding-bottom: 0.9rem; margin-bottom: 0.9rem; border-bottom: 1px solid var(--pl-border); }
.side-section:last-child { border-bottom: 0; margin-bottom: 0; }
.side-section h5 { margin: 0; }

/* Figures are all one size; numbers stay in body colour unless they flag a problem */
.figure { min-height: 4.6rem; }
.figure-strip { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
.section-head h5 { font-size: 0.95rem; font-weight: 700; }

/* Risk matrix: one red scale from low to critical instead of four unrelated colours.
   Text on each step meets AA (dark text on the pale steps, white on the deepest). */
:root {
    --pl-matrix-low: #f1f3f5;
    --pl-matrix-medium: #f6dcd8;
    --pl-matrix-high: #e8a59e;
    --pl-matrix-critical: #b42318;
    --pl-matrix-text: #1f2933;
}
[data-bs-theme=dark] {
    --pl-matrix-low: #2b3138;
    --pl-matrix-medium: #4a2c2a;
    --pl-matrix-high: #7a2e27;
    --pl-matrix-critical: #b42318;
    --pl-matrix-text: #e5e7eb;
}
.matrix-cell { color: var(--pl-matrix-text); font-weight: 700; }
.matrix-low { background: var(--pl-matrix-low); }
.matrix-medium { background: var(--pl-matrix-medium); color: var(--pl-matrix-text); }
.matrix-high { background: var(--pl-matrix-high); }
.matrix-critical { background: var(--pl-matrix-critical); color: #ffffff; }
.matrix-cell.has-items { box-shadow: inset 0 0 0 2px var(--ct-body-color); }
.matrix-critical.has-items { box-shadow: inset 0 0 0 2px #ffffff, inset 0 0 0 4px var(--pl-matrix-critical); }

/* Delivery dashboards */
.hero-line { margin: 0 0 1rem; font-size: 1rem; line-height: 1.55; max-width: 62rem; }
.bar-row { display: grid; grid-template-columns: 7.5rem 1fr 2rem; align-items: center; gap: 0.6rem; padding: 0.2rem 0; font-size: 0.875rem; }
.bar-track { height: 0.55rem; border-radius: 50rem; background: var(--ct-light, #f3f5f8); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 50rem; background: #2f4b8f; }
.bar-fill.bar-quiet { background: #a9b3c6; }
.bar-value { text-align: right; font-weight: 600; }
.timeline-compare { display: grid; grid-template-columns: 6.5rem 1fr; align-items: center; gap: 0.4rem 0.75rem; max-width: 40rem; }
.timeline-compare .progress-wrap { min-width: 0; }

/* Project summary cards (the portfolio dashboard) */
.project-summary {
    display: block;
    margin-bottom: 0.6rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--pl-border);
    border-radius: 0.5rem;
    background: var(--pl-surface);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.project-summary:hover, .project-summary:focus-visible { color: inherit; border-color: var(--ct-primary, #4f46e5); box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); }
.ps-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; margin-bottom: 0.6rem; }
.ps-name { font-size: 1.05rem; font-weight: 700; }
.ps-pm { color: var(--pl-muted); font-size: 0.85rem; }
.ps-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.5rem 1rem; }
.ps-metrics > div { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.ps-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--pl-muted); }
.ps-value { font-size: 1.15rem; font-weight: 700; line-height: 1.25; }
.ps-note { font-size: 0.78rem; color: var(--pl-muted); }
.ps-issues { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.6rem; margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px solid var(--pl-border); font-size: 0.875rem; }

/* Phases on the project page */
.phase-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.phase-card {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--pl-border);
    border-radius: 0.5rem;
    background: var(--pl-surface);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.phase-card:hover, .phase-card:focus-visible { border-color: var(--ct-primary, #4f46e5); box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); }
.phase-card.selected { border-color: var(--ct-primary, #4f46e5); box-shadow: inset 0 0 0 1px var(--ct-primary, #4f46e5); }
.phase-name { font-weight: 700; }
.phase-dates { font-size: 0.78rem; color: var(--pl-muted); }
.phase-value { font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.phase-note { font-size: 0.78rem; color: var(--pl-muted); }
.phase-status { font-size: 0.78rem; font-weight: 600; }
.phase-section { margin-bottom: 1.25rem; }
.phase-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(10rem, 16rem) auto; align-items: center; gap: 0.5rem 1rem; margin-bottom: 0.5rem; }
.phase-progress { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
@media (max-width: 767.98px) {
    .phase-head { grid-template-columns: 1fr; }
}

/* Page header: the breadcrumb above the title, and the page's filters beside it at the top */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.5rem 1rem; padding: 0.25rem 0 0.75rem; }
.page-head .breadcrumb { padding: 0; margin: 0; font-size: 0.8rem; }
.page-head .crumb-bar { padding: 0; }
.page-head .page-title { margin: 0; font-size: 1.15rem; font-weight: 600; line-height: 1.5; }
.page-head-main { min-width: 0; }
.page-filters { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 0.5rem 0.6rem; }
.page-filters:empty { display: none; }
.page-filters label:not(.form-check-label) { display: block; margin: 0 0 0.1rem; font-size: 0.72rem; font-weight: 600; color: var(--pl-muted); }
.page-filters .form-select, .page-filters .form-control { width: auto; min-width: 7.5rem; }

/* Portfolio, project list and project detail dashboards: Hyper cards and colours, laid out as in the Power BI report */
.pb-page { display: flex; flex-direction: column; gap: 1rem; }
.pb-page .card { margin-bottom: 0; }
.pb-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--pl-muted); }
.pb-value { font-size: 1.75rem; font-weight: 600; line-height: 1.2; color: var(--ct-body-color); }
.pb-value.is-alert { color: var(--pl-red); }
.pb-sub { font-size: 0.85rem; color: var(--pl-muted); }
.pb-muted { color: var(--pl-muted); }
.pb-gap { font-size: 0.85rem; font-style: italic; color: var(--pl-muted); }
.pb-delta { font-size: 0.85rem; color: var(--pl-muted); }
.pb-delta .is-up { color: var(--pl-green); }
.pb-delta .is-down { color: var(--pl-red); }

.pb-banner .card-body { padding: 1.15rem 1.4rem; }
.pb-banner .pb-eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: rgba(255, 255, 255, 0.75); }
.pb-banner p { max-width: 62rem; margin: 0.3rem 0 0; font-size: 1.2rem; line-height: 1.5; color: rgba(255, 255, 255, 0.9); }
.pb-banner b { font-weight: 700; color: #ffffff; }

.pb-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; }
.pb-kpi { color: inherit; text-decoration: none; }
.pb-kpi .card-body { display: flex; flex-direction: column; gap: 0.15rem; height: 100%; }
.pb-kpi .progress { margin-top: auto; }
a.pb-kpi:hover { color: inherit; border-color: var(--ct-primary); }

.pb-row-chart { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: 1rem; }
.pb-row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.pb-row-bottom { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; }
.pb-nav-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }

.pb-attention { margin: 0; padding: 0; list-style: none; }
.pb-attention li { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--pl-border); }
.pb-attention li:first-child { padding-top: 0; }
.pb-attention li:last-child { border-bottom: 0; padding-bottom: 0; }
.pb-attention li > div { flex: 1; min-width: 0; }
.pb-attention a { font-weight: 600; }
.pb-attention .pb-why { font-size: 0.85rem; color: var(--pl-muted); }
.pb-attention .pb-why b { color: var(--ct-body-color); }

.pb-bars { display: flex; flex-direction: column; gap: 0.6rem; }
.pb-bar-row { display: grid; grid-template-columns: 6rem minmax(0, 1fr) 2rem; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
.pb-bar-row .pb-track { height: 0.7rem; border-radius: 50rem; background: var(--ct-tertiary-bg); overflow: hidden; }
.pb-bar-row .pb-fill { display: block; height: 100%; border-radius: 50rem; background: var(--ct-primary); }
.pb-bar-row .pb-count { text-align: right; font-weight: 600; }
.pb-fill-ahead { background: var(--ct-success) !important; }
.pb-fill-on-track { background: var(--ct-info) !important; }
.pb-fill-slipping { background: var(--ct-warning) !important; }
.pb-fill-at-risk { background: var(--ct-orange) !important; }
.pb-fill-behind { background: var(--ct-danger) !important; opacity: 0.65; }
.pb-fill-critical { background: var(--ct-danger) !important; }
.pb-fill-quiet { background: var(--ct-secondary-color) !important; opacity: 0.5; }

.pb-comments { margin: 0; padding: 0; list-style: none; }
.pb-comments li { padding: 0.6rem 0; border-bottom: 1px solid var(--pl-border); }
.pb-comments li:first-child { padding-top: 0; }
.pb-comments li:last-child { border-bottom: 0; padding-bottom: 0; }
.pb-comments a { font-weight: 600; }
.pb-comments .pb-when { margin-left: 0.4rem; font-size: 0.8rem; color: var(--pl-muted); }
.pb-comments p { margin: 0.1rem 0 0; font-size: 0.875rem; }

.pb-nav-tile { color: inherit; text-decoration: none; }
.pb-nav-tile .card-body { display: flex; flex-direction: column; justify-content: space-between; gap: 1.4rem; height: 100%; }
a.pb-nav-tile:hover { color: inherit; border-color: var(--ct-primary); }
.pb-nav-tile .pb-nav-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 1rem; font-weight: 600; }
.pb-nav-tile .pb-nav-go { display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--ct-primary-bg-subtle); color: var(--ct-primary); }
.pb-nav-tile.is-off { opacity: 0.7; }

.pb-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.pb-ring svg { transform: rotate(-90deg); }
.pb-ring circle { fill: none; stroke-width: 6; }
.pb-ring .pb-ring-track { stroke: var(--ct-border-color); }
.pb-ring .pb-ring-value { stroke: var(--ct-primary); stroke-linecap: round; }

/* Project list: one card per project */
.pb-project { --pb-accent: var(--ct-primary); display: block; border-left: 4px solid var(--pb-accent); color: inherit; text-decoration: none; }
.pb-project:hover { color: inherit; }
.pb-project.is-critical, .pb-project.is-behind { --pb-accent: var(--ct-danger); }
.pb-project.is-at-risk { --pb-accent: var(--ct-orange); }
.pb-project.is-slipping { --pb-accent: var(--ct-warning); }
.pb-project.is-on-track { --pb-accent: var(--ct-info); }
.pb-project.is-ahead { --pb-accent: var(--ct-success); }
.pb-project-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.75rem; }
.pb-project-name { font-size: 1.05rem; font-weight: 600; }
.pb-project-sub { font-size: 0.875rem; color: var(--pl-muted); }
.pb-project-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-left: auto; }
.pb-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.75rem; margin-top: 0.85rem; }
.pb-tile { display: flex; flex-direction: column; gap: 0.15rem; min-height: 6.4rem; min-width: 0; padding: 0.8rem 0.95rem; border-radius: var(--ct-border-radius); background: var(--ct-tertiary-bg); }
.pb-tile .progress { margin-top: 0.3rem; }
.pb-tile-ring { display: flex; align-items: center; gap: 0.6rem; }
.pb-project-foot { margin-top: 0.85rem; padding-top: 0.65rem; border-top: 1px solid var(--pl-border); font-size: 0.875rem; }
.pb-project-foot .pb-label { margin-right: 0.5rem; }

/* Project detail */
.pd-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.pd-stat .card-body { display: flex; align-items: center; gap: 0.9rem; }
.pd-icon, .pd-line-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: var(--ct-border-radius); background: var(--ct-primary-bg-subtle); color: var(--ct-primary); }
.pd-icon { width: 2.9rem; height: 2.9rem; font-size: 1.45rem; }
.pd-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.pd-lines { margin: 0; padding: 0; list-style: none; }
.pd-line { display: flex; align-items: center; gap: 0.8rem; padding: 0.65rem 0; border-bottom: 1px solid var(--pl-border); }
.pd-line:first-child { padding-top: 0; }
.pd-line:last-child { border-bottom: 0; padding-bottom: 0; }
.pd-line-icon { width: 2rem; height: 2rem; font-size: 1.05rem; }
.pd-line-text { flex: 1; min-width: 0; }
.pd-line-sub { display: block; font-size: 0.78rem; color: var(--pl-muted); }
.pd-line-value { font-size: 1.1rem; font-weight: 600; }
.pd-note { margin: 0.75rem 0 0; font-size: 0.78rem; color: var(--pl-muted); }
.pd-dot { display: inline-block; width: 0.55rem; height: 0.55rem; margin-right: 0.5rem; border-radius: 50%; background: var(--ct-success); }
.pd-pct { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 50rem; background: rgba(16, 196, 105, 0.15); color: var(--pl-green); font-weight: 600; }
.pd-gauge { display: flex; flex-direction: column; align-items: center; }
.pd-gauge svg { width: 100%; max-width: 15rem; }
.pd-gauge .pd-gauge-value { font-size: 1.75rem; font-weight: 600; fill: var(--ct-body-color); }
.pd-gauge .pd-gauge-note { font-size: 0.78rem; fill: var(--pl-muted); }
.pd-timeline { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--pl-border); }
.pd-timeline-head { display: flex; justify-content: space-between; margin-bottom: 0.4rem; }
.pd-timeline-head b { font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--pl-green); }
.pd-timeline-dates { display: flex; justify-content: space-between; margin-top: 0.4rem; font-size: 0.8rem; color: var(--pl-muted); }

@media (max-width: 1399.98px) {
    .pb-kpis, .pb-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .pd-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
    .pb-row-chart, .pb-row-bottom, .pb-row-3, .pd-top, .pd-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
    .pb-kpis, .pb-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pb-nav-grid { grid-template-columns: 1fr; }
}

/* A project still missing required Key information shows its detail (Key information first) above the dashboard */
.project-body { display: flex; flex-direction: column; }
.project-body.is-setup > #project-detail { order: -1; }

/* Text colours that read on the dark theme */
[data-bs-theme=dark] .pb-value.is-alert, [data-bs-theme=dark] .pb-delta .is-down { color: #f28b82; }
[data-bs-theme=dark] .pb-delta .is-up, [data-bs-theme=dark] .pd-pct, [data-bs-theme=dark] .pd-timeline-head b { color: #6fd49a; }
