/* =============================================================================
 * FILE: public/assets/css/styles.css
 * All P3A styling on top of Bootstrap 5. Light + dark themes via
 * [data-bs-theme] scoped CSS variables (the sidebar stays dark in both). Shell
 * layout, cards, badges, heatmap cells. Feature phases extend this file.
 * ========================================================================== */

:root {
    /* Sizes + accents shared by both themes. */
    --p3a-sidebar-w: 236px;
    --p3a-topbar-h: 56px;
    --p3a-sidebar-active: #32a3a1;
    --p3a-sidebar-fg-active: #ffffff;

    /* Brand palette — pulled directly from the org logo (Administration ->
       Organisation). Teal is the primary UI accent; the other four are a
       ready-made categorical set for charts/badges so those tie back to the
       same identity instead of generic red/green/blue. */
    --p3a-brand-slate: #3c6d79;
    --p3a-brand-teal: #32a3a1;
    --p3a-brand-gold: #fcc800;
    --p3a-brand-orange: #ea6f14;
    --p3a-brand-olive: #acb000;
    /* The sidebar stays dark in BOTH themes (dark sidebar + light content is a
       deliberate pattern), so its internal colors live here, not per-theme. */
    --p3a-sidebar-bg: #10151c;
    --p3a-sidebar-fg: #aeb7c4;
}

/* Dark theme (default) — surfaces, borders, muted text. */
[data-bs-theme="dark"] {
    --p3a-content-bg: #171b22;
    --p3a-surface: #1b2028;
    --p3a-border: rgba(255, 255, 255, .08);
    --p3a-border-soft: rgba(255, 255, 255, .06);
    --p3a-connector: rgba(255, 255, 255, .25);
    --p3a-muted: #8b93a0;
    --p3a-soft-fg: #cbd3dd;
}

/* Light theme. */
[data-bs-theme="light"] {
    --p3a-content-bg: #f4f6f9;
    --p3a-surface: #ffffff;
    --p3a-border: rgba(0, 0, 0, .12);
    --p3a-border-soft: rgba(0, 0, 0, .08);
    --p3a-connector: rgba(0, 0, 0, .2);
    --p3a-muted: #6c757d;
    --p3a-soft-fg: #4a5560;
}

body {
    background: var(--p3a-content-bg);
    min-height: 100vh;
}

/* --- Shell layout -------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-content {
    flex: 1 1 auto;
    min-width: 0; /* allow inner content to shrink/scroll */
    display: flex;
    flex-direction: column;
}

.view-root {
    flex: 1 1 auto;
    padding: 1.25rem;
    overflow-x: auto;
}

/* --- Sidebar ------------------------------------------------------------- */
.app-sidebar {
    flex: 0 0 var(--p3a-sidebar-w);
    width: var(--p3a-sidebar-w);
    background: var(--p3a-sidebar-bg);
    color: var(--p3a-sidebar-fg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: margin-left .2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-nav {
    margin: .5rem 0;
    flex: 1 1 auto;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.15rem;
    color: var(--p3a-sidebar-fg);
    text-decoration: none;
    font-size: .93rem;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, .04);
    color: var(--p3a-sidebar-fg-active);
}

.sidebar-nav a.active {
    background: rgba(29, 111, 224, .14);
    border-left-color: var(--p3a-sidebar-active);
    color: var(--p3a-sidebar-fg-active);
}

.sidebar-nav a i {
    width: 1.1rem;
    text-align: center;
}

.sidebar-nav li.nav-hidden {
    display: none;
}

/* Group labels — the flat 18-item list is now organised into scannable
   sections (Overview / Projects / People / Insights); Administration stays
   pinned last behind a plain divider rather than a labelled group, since
   it's a single item, not a category. */
.sidebar-section {
    padding: .85rem 1.15rem .3rem;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--p3a-sidebar-fg);
    opacity: .55;
}
.sidebar-section:first-child { padding-top: .4rem; }
.sidebar-divider {
    height: 1px;
    margin: .6rem 1.15rem;
    background: rgba(255, 255, 255, .08);
}

.sidebar-footer {
    padding-bottom: 1rem;
}

/* Collapsed state (toggled by core.js). */
.app-shell.sidebar-collapsed .app-sidebar {
    margin-left: calc(-1 * var(--p3a-sidebar-w));
}

/* --- Top bar ------------------------------------------------------------- */
.app-topbar {
    height: var(--p3a-topbar-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1rem;
    background: var(--p3a-surface);
    border-bottom: 1px solid var(--p3a-border-soft);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-search {
    max-width: 320px;
    width: 100%;
    min-width: 0; /* flex children don't shrink a text input below its content size by default */
}

.topbar-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile top bar: the search box was packed in unconditionally alongside 4
   icon buttons with no room to shrink — overflowed/crushed below ~768px.
   Hide it behind an icon toggle instead; tapping wraps it onto its own row. */
@media (max-width: 767.98px) {
    .topbar-search { display: none; }
    .app-topbar.search-open {
        flex-wrap: wrap;
        height: auto;
        min-height: var(--p3a-topbar-h);
        padding-bottom: .6rem;
    }
    .app-topbar.search-open .topbar-search {
        display: flex;
        order: 10;
        flex: 1 1 100%;
        max-width: none;
        margin-left: 0 !important;
    }
}

/* --- Cards / metrics ----------------------------------------------------- */
.metric-card {
    border: 1px solid var(--p3a-border);
    border-radius: .6rem;
    background: var(--p3a-surface);
}

.metric-card .metric-value {
    font-size: 1.6rem;
    font-weight: 700;
}

.metric-card .metric-label {
    color: var(--p3a-muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.perf-note {
    font-size: .75rem;
    color: var(--p3a-muted);
}

/* --- Capacity heatmap (used from Phase 8; defined here centrally) -------- */
.heat-cell {
    display: inline-block;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    text-align: center;
    line-height: 26px;
    font-size: .7rem;
}

.heat-green { background: #1f7a3d; color: #fff; }
.heat-amber { background: #b8860b; color: #fff; }
.heat-red   { background: #a12d2d; color: #fff; }

/* --- Auth (login) screen ------------------------------------------------- */
/* When signed out, hide the app chrome and center the login card. */
body.unauthed .app-sidebar,
body.unauthed .app-topbar {
    display: none;
}

/* Split-screen shell shared by every signed-out screen (login, forgot/reset
   password, 2FA). The illustration panel carries the org's own brand colors;
   only the form panel content differs per screen. */
.auth-split {
    min-height: 100vh;
    display: flex;
}

.auth-illustration {
    flex: 1 1 46%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 3rem 2rem;
    color: #fff;
    background: linear-gradient(145deg, var(--p3a-brand-slate) 0%, var(--p3a-brand-teal) 100%);
    position: relative;
    overflow: hidden;
}

.auth-illustration-graphic { width: 100%; max-width: 320px; }

.auth-illustration-caption { text-align: center; max-width: 320px; }
.auth-illustration-caption .h4 { font-weight: 700; }

.auth-form-panel {
    flex: 1 1 54%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background: var(--p3a-content-bg);
}

.auth-card {
    width: 100%;
    max-width: 360px;
    background: var(--p3a-surface);
    border: 1px solid var(--p3a-border);
}

/* Below tablet width there's no room for both panels — keep only the form,
   full-width, same as the old centered-card layout. */
@media (max-width: 767.98px) {
    .auth-illustration { display: none; }
    .auth-form-panel { min-height: 100vh; }
    .pm-login { min-height: 100vh; }
}

/* =============================================================================
 * LOGIN SCREEN — split brand illustration + "Project Management Timeline"
 * -----------------------------------------------------------------------------
 * The LEFT side is the same .auth-illustration every signed-out screen uses
 * (real brand colors, untouched). The RIGHT side (.pm-login) is a deliberately
 * distinct dark/indigo panel per an explicit design brief, containing the
 * timeline reveal — contained to this column rather than taking the whole
 * viewport, so the org's actual brand stays visible alongside it. Below
 * ~768px .auth-illustration hides (existing rule) and .pm-login goes full
 * width/height, same fallback pattern as .auth-form-panel. forgot/reset/2FA
 * keep the plain .auth-split + .auth-form-panel shell, untouched.
 * ========================================================================== */
.pm-login {
    --pm-bg: #121417;
    --pm-bg-active: #1c1f24;
    --pm-accent: #6366f1;
    --pm-accent-hover: #4f52d8;
    --pm-accent-glow: rgba(99, 102, 241, .55);
    --pm-track: #2a2e35;
    --pm-text: #e6e8ec;
    --pm-muted: #9096a3;
    --pm-duration: .8s;
    --pm-ease: cubic-bezier(.22, 1, .36, 1);

    flex: 1 1 54%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--pm-bg);
    color: var(--pm-text);
    padding: 2rem 1.25rem 9rem;
    position: relative;
    overflow: hidden;
    transition: background-color var(--pm-duration) ease;
}
.pm-login.running,
.pm-login.active { background: var(--pm-bg-active); }

.pm-login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    margin-bottom: 2.25rem;
    text-align: center;
}
.pm-login-brand img { max-height: 44px; max-width: 160px; object-fit: contain; }
.pm-login-brand .h4 { color: var(--pm-text); margin: 0; font-weight: 700; }
.pm-login-brand .small { color: var(--pm-muted); }

/* --- The gated login form (same <form id="login-form"> as ever) -------- */
.pm-login-formwrap {
    width: 100%;
    max-width: 360px;
    opacity: 0;
    transform: translateY(24px);
    pointer-events: none;
    transition: opacity var(--pm-duration) var(--pm-ease), transform var(--pm-duration) var(--pm-ease);
}
.pm-login.active .pm-login-formwrap {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.pm-login-formwrap .auth-card {
    background: #191c21;
    border: 1px solid #2a2e35;
    color: var(--pm-text);
}
.pm-login-formwrap .form-control {
    background: #14171b;
    border-color: #2a2e35;
    color: var(--pm-text);
}
.pm-login-formwrap .form-control:focus {
    background: #14171b;
    color: var(--pm-text);
    border-color: var(--pm-accent);
    box-shadow: 0 0 0 .2rem var(--pm-accent-glow);
}
.pm-login-formwrap .form-label { color: var(--pm-muted); }
.pm-login-formwrap a.small { color: var(--pm-muted); }
.pm-login-formwrap .btn-primary {
    --bs-btn-bg: var(--pm-accent);
    --bs-btn-border-color: var(--pm-accent);
    --bs-btn-hover-bg: var(--pm-accent-hover);
    --bs-btn-hover-border-color: var(--pm-accent-hover);
    --bs-btn-active-bg: var(--pm-accent-hover);
}
/* Password show/hide toggle button, styled to match the dark input group. */
.pm-login-formwrap .input-group .btn-outline-secondary {
    background: #14171b;
    border-color: #2a2e35;
    color: var(--pm-muted);
}
.pm-login-formwrap .input-group .btn-outline-secondary:hover,
.pm-login-formwrap .input-group .btn-outline-secondary:focus {
    background: #1c2027;
    border-color: var(--pm-accent);
    color: var(--pm-text);
}

/* --- The timeline gate, pinned to the bottom of THIS panel (.pm-login is
   position:relative) rather than the whole viewport ----------------------- */
.pm-timeline-gate {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    padding: 1.75rem 1.25rem 2rem;
    z-index: 5;
}
.pm-timeline { width: 100%; max-width: 420px; }
.pm-timeline-track {
    position: relative;
    height: 4px;
    background: var(--pm-track);
    border-radius: 999px;
    margin: 1.2rem 0;
}
.pm-timeline-progress {
    position: absolute;
    top: 0; left: 0; height: 100%;
    width: 0%;
    background: var(--pm-accent);
    border-radius: 999px;
    transition: width var(--pm-duration) var(--pm-ease);
}
.pm-login.active .pm-timeline-progress,
.pm-login.running .pm-timeline-progress { width: 100%; }

.pm-timeline-playhead {
    position: absolute;
    top: 50%; left: 0%;
    width: 12px; height: 12px;
    background: var(--pm-accent);
    border: 2px solid var(--pm-bg-active);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--pm-accent-glow);
    transform: translate(-50%, -50%);
    transition: left var(--pm-duration) var(--pm-ease);
}
.pm-login.active .pm-timeline-playhead,
.pm-login.running .pm-timeline-playhead { left: 100%; }

.pm-milestone {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.pm-milestone-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--pm-track);
    border: 2px solid #3a3f47;
    transition: background-color .35s ease, border-color .35s ease, box-shadow .35s ease;
}
.pm-milestone.lit .pm-milestone-dot {
    background: var(--pm-accent);
    border-color: var(--pm-accent);
    box-shadow: 0 0 12px var(--pm-accent-glow);
}
.pm-milestone-label {
    position: absolute;
    top: 1.1rem;
    white-space: nowrap;
    font-size: .72rem;
    color: var(--pm-muted);
    transition: color .35s ease;
}
.pm-milestone.lit .pm-milestone-label { color: var(--pm-text); }

.pm-start-btn {
    border: none;
    border-radius: .6rem;
    padding: .6rem 1.7rem;
    font-weight: 600;
    font-size: .9rem;
    color: #fff;
    background: var(--pm-accent);
    box-shadow: 0 6px 18px var(--pm-accent-glow);
    transition: background-color .2s ease, transform .15s ease, opacity .2s ease;
}
.pm-start-btn:hover:not(:disabled) { background: var(--pm-accent-hover); }
.pm-start-btn:active:not(:disabled) { transform: translateY(1px); }
.pm-start-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 .2rem var(--pm-accent-glow);
}
.pm-start-btn:disabled { opacity: .55; cursor: default; }

@media (max-width: 480px) {
    .pm-login { padding-bottom: 10rem; }
    .pm-milestone-label { font-size: .65rem; }
}

@media (prefers-reduced-motion: reduce) {
    .pm-login,
    .pm-login-formwrap,
    .pm-timeline-progress,
    .pm-timeline-playhead,
    .pm-milestone-dot,
    .pm-milestone-label {
        transition-duration: .001ms !important;
    }
}

/* --- Org chart (organogram: top-down boxes + connector lines) ----------- */
.orgchart-scroll {
    overflow-x: auto;
    padding-bottom: .5rem;
}
.orgchart {
    display: inline-block;
    min-width: 100%;
    text-align: center;
}
.orgchart ul {
    padding-top: 20px;
    position: relative;
    display: flex;
    justify-content: center;
    margin: 0;
    list-style: none;
}
.orgchart li {
    list-style: none;
    position: relative;
    padding: 20px 8px 0;
    text-align: center;
}
/* down + across connector lines */
.orgchart li::before,
.orgchart li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 1px solid var(--p3a-connector);
    width: 50%;
    height: 20px;
}
.orgchart li::after {
    right: auto;
    left: 50%;
    border-left: 1px solid var(--p3a-connector);
}
.orgchart li:only-child::before,
.orgchart li:only-child::after {
    display: none;
}
.orgchart li:only-child {
    padding-top: 0;
}
.orgchart li:first-child::before,
.orgchart li:last-child::after {
    border: 0 none;
}
.orgchart li:last-child::before {
    border-right: 1px solid var(--p3a-connector);
    border-radius: 0 5px 0 0;
}
.orgchart li:first-child::after {
    border-radius: 5px 0 0 0;
}
.orgchart ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 1px solid var(--p3a-connector);
    width: 0;
    height: 20px;
}
.org-box {
    display: inline-block;
    border: 1px solid var(--p3a-border);
    background: var(--p3a-surface);
    border-radius: var(--p3a-radius-sm);
    box-shadow: var(--p3a-shadow-sm);
    padding: .4rem .6rem;
    min-width: 130px;
    transition: box-shadow var(--p3a-t), transform var(--p3a-t);
}
.org-box:hover { box-shadow: var(--p3a-shadow); transform: translateY(-1px); }
.org-box.org-director {
    border-color: var(--p3a-brand-gold);
    border-width: 2px;
}
.org-title {
    font-weight: 600;
    font-size: .85rem;
}
.org-people {
    font-size: .78rem;
    color: var(--p3a-soft-fg);
}
.org-dept {
    font-size: .7rem;
    color: var(--p3a-muted);
}

/* --- Leave / holiday month calendar -------------------------------------- */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.cal-dow {
    text-align: center;
    font-size: .7rem;
    text-transform: uppercase;
    color: var(--p3a-muted);
    padding-bottom: 2px;
}
.cal-cell {
    min-height: 62px;
    border: 1px solid var(--p3a-border);
    border-radius: .35rem;
    padding: 3px 4px;
    background: var(--p3a-surface);
    overflow: hidden;
}
.cal-cell.cal-empty {
    border: none;
    background: transparent;
}
.cal-cell.cal-today {
    outline: 2px solid var(--p3a-sidebar-active);
    outline-offset: -2px;
}
.cal-cell.cal-holiday {
    background: color-mix(in srgb, var(--p3a-sidebar-active) 12%, var(--p3a-surface));
}
.cal-day {
    font-size: .75rem;
    font-weight: 600;
}
.cal-tag {
    font-size: .62rem;
    line-height: 1.2;
    border-radius: 3px;
    padding: 1px 3px;
    margin-top: 2px;
}
.cal-hol-tag {
    background: var(--p3a-sidebar-active);
    color: #fff;
}
.cal-leave-tag {
    background: var(--p3a-content-bg);
    border: 1px solid var(--p3a-border);
    color: var(--p3a-muted);
}

/* --- Org calendar (milestones + events) ---------------------------------- */
.cal-cell.cal-has-items {
    cursor: pointer;
}
.cal-milestone-tag {
    background: #6f42c1;
    color: #fff;
}
.cal-event-tag {
    background: var(--p3a-sidebar-active);
    color: #fff;
    opacity: .75;
}

/* --- Activity timeline --------------------------------------------------- */
.activity-item {
    border-bottom: 1px solid var(--p3a-border-soft);
}
.activity-item:last-child {
    border-bottom: none;
}

/* --- Dashboard / report bar charts --------------------------------------- */
.dash-bar {
    height: 12px;
    border-radius: 6px;
    background: var(--p3a-sidebar-active);
    min-width: 2px;
}

/* Small color swatch beside a chart legend label. */
.dot {
    display: inline-block;
    width: .6rem;
    height: .6rem;
    border-radius: 50%;
    flex: 0 0 auto;
}

/* --- Kanban board -------------------------------------------------------- */
.kanban {
    display: flex;
    gap: .75rem;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: .5rem;
}
.kanban-col {
    flex: 1 0 240px;
    min-width: 240px;
    background: var(--p3a-surface);
    border: 1px solid var(--p3a-border);
    border-radius: .5rem;
    padding: .5rem;
}
.kanban-head {
    font-weight: 600;
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--p3a-muted);
    padding: .1rem .25rem .4rem;
}
.kanban-cards {
    min-height: 40px;
    border-radius: .35rem;
}
.kanban-cards.drop-hover {
    outline: 2px dashed var(--p3a-sidebar-active);
    outline-offset: -2px;
}
.kanban-card {
    background: var(--p3a-content-bg);
    border: 1px solid var(--p3a-border);
    border-radius: .4rem;
    padding: .45rem .55rem;
    margin-bottom: .5rem;
    cursor: grab;
}
.kanban-card.dragging {
    opacity: .5;
}
.kanban-card a {
    text-decoration: none;
}
/* Horizontal scroll instead of squeezing the whole timeline into whatever
   width is left after the fixed label column — a Gantt chart needs real
   width to be readable, so on a narrow screen it scrolls sideways rather
   than rendering illegibly thin bars. */
.gantt-scroll {
    overflow-x: auto;
    padding-bottom: .25rem;
}
.gantt-row {
    gap: .5rem;
    min-width: 480px;
}
.gantt-label {
    flex: 0 0 220px;
    max-width: 220px;
}
.gantt-track {
    height: 20px;
    background: var(--p3a-surface);
    border: 1px solid var(--p3a-border);
    border-radius: .25rem;
}
.gantt-bar {
    position: absolute;
    top: 2px;
    bottom: 2px;
    border-radius: .2rem;
    min-width: 4px;
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        z-index: 1040;
        height: 100vh;
        transition: margin-left .2s ease;
    }
    .app-shell:not(.sidebar-open) .app-sidebar {
        margin-left: calc(-1 * var(--p3a-sidebar-w));
    }
    /* Dimmed backdrop behind the open overlay sidebar (tap the toggle to close). */
    .app-shell.sidebar-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .5);
        z-index: 1039;
    }
}

/* =============================================================================
 * UI/UX ENHANCEMENT LAYER
 * -----------------------------------------------------------------------------
 * Pure-CSS polish on top of everything above — no JS, no new dependencies, no
 * runtime cost (this file is parsed once and cached). Only cheap, GPU-friendly
 * properties are transitioned (transform / opacity / colour / shadow); no blur
 * and no layout animation, so it does not affect scrolling or speed.
 * ========================================================================== */

/* --- Shared design tokens ------------------------------------------------ */
:root {
    --p3a-accent: #32a3a1;
    /* A deliberately darker teal, not just a hover-darken of --p3a-accent:
       pure #32a3a1 only hits ~3:1 contrast against white, enough for large UI
       (buttons, borders) but short of the 4.5:1 normal-text needs — this one
       clears 5:1, so it's what text/links actually use against a light
       surface (see .btn-primary / a below). */
    --p3a-accent-strong: #1e7a78;
    --p3a-radius: .7rem;
    --p3a-radius-sm: .5rem;
    --p3a-t: .15s ease;
}
[data-bs-theme="dark"] {
    --p3a-shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --p3a-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    --p3a-ring: rgba(50, 163, 161, .45);
    --p3a-hover: rgba(255, 255, 255, .04);
    --p3a-accent-soft: rgba(50, 163, 161, .18);
}
[data-bs-theme="light"] {
    --p3a-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --p3a-shadow: 0 10px 28px rgba(16, 24, 40, .1);
    --p3a-ring: rgba(50, 163, 161, .3);
    --p3a-hover: rgba(16, 24, 40, .03);
    --p3a-accent-soft: rgba(50, 163, 161, .1);
}

/* --- Typography ---------------------------------------------------------- */
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { letter-spacing: -.01em; }
.text-secondary, .small { letter-spacing: 0; }

/* --- Accessible keyboard focus (harmonised accent ring) ------------------ */
.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.page-link:focus,
a.nav-link:focus-visible {
    box-shadow: 0 0 0 .2rem var(--p3a-ring) !important;
    outline: none;
}

/* --- Cards --------------------------------------------------------------- */
.card {
    border-color: var(--p3a-border);
    border-radius: var(--p3a-radius);
    box-shadow: var(--p3a-shadow-sm);
}
.card .card-body { border-radius: inherit; }

.metric-card {
    border-radius: var(--p3a-radius);
    box-shadow: var(--p3a-shadow-sm);
    transition: box-shadow var(--p3a-t), transform var(--p3a-t);
}
/* Metric cards that link somewhere lift slightly on hover. */
a.metric-card:hover,
.metric-card[role="button"]:hover {
    box-shadow: var(--p3a-shadow);
    transform: translateY(-2px);
    text-decoration: none;
}

/* --- Buttons ------------------------------------------------------------- */
.btn {
    border-radius: var(--p3a-radius-sm);
    font-weight: 500;
    transition: transform var(--p3a-t), box-shadow var(--p3a-t),
                background-color var(--p3a-t), border-color var(--p3a-t), color var(--p3a-t);
}
.btn:active { transform: translateY(1px); }
.btn-primary,
.btn-success,
.btn-danger,
.btn-outline-primary:hover {
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.btn-primary {
    /* Default fill uses --p3a-accent-strong (not the raw brand teal): white
       button-label text on the raw teal only clears ~3:1 contrast, short of
       the 4.5:1 normal-text needs. The darker strong tone clears ~5:1. */
    --bs-btn-bg: var(--p3a-accent-strong);
    --bs-btn-border-color: var(--p3a-accent-strong);
    --bs-btn-hover-bg: #175f5d;
    --bs-btn-hover-border-color: #175f5d;
    --bs-btn-active-bg: #175f5d;
}
.btn-sm { border-radius: .4rem; }

/* --- Touch target sizing for icon-only action buttons --------------------
   WCAG 2.5.8 (AA) sets a 24 CSS-px minimum target size, with 8px minimum
   spacing between adjacent small targets as the alternative to enlarging
   them (ui-ux-pro-max: "Touch Target Size" / "Touch Spacing"). Most row
   actions here (edit/delete/remove/etc.) are `.btn-sm` buttons whose only
   content is a Font Awesome <i> — this widens their hit area past the
   Bootstrap-default ~29px and adds a little breathing room where several
   sit back-to-back in a table cell with no flex `gap-*` utility already
   doing that job. `:only-child` matches on ELEMENT siblings only, so an
   icon immediately followed by a text node ("<i></i>New project") also
   matches — harmless here: Bootstrap's `.btn` already centers that content
   by default, and a 2rem floor is a no-op on a button already wider/taller
   than that. Relies on :has(), which every browser this app already
   assumes (fetch, CSS custom properties, native drag-and-drop) supports. */
.btn-sm:has(> i:only-child) {
    min-width: 2rem;
    min-height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: .4rem;
    padding-right: .4rem;
}
.btn-sm:has(> i:only-child) + .btn-sm:has(> i:only-child) {
    margin-left: .25rem;
}

/* --- Forms --------------------------------------------------------------- */
.form-control, .form-select {
    border-radius: var(--p3a-radius-sm);
    border-color: var(--p3a-border);
    transition: border-color var(--p3a-t), box-shadow var(--p3a-t);
}
.form-control:focus, .form-select:focus { border-color: var(--p3a-accent); }
.form-label { font-weight: 500; }
.form-switch .form-check-input:checked { background-color: var(--p3a-accent); border-color: var(--p3a-accent); }

/* --- Tables -------------------------------------------------------------- */
.table { --bs-table-bg: transparent; }
.table > thead > tr > th {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    font-weight: 600;
    color: var(--p3a-muted);
    border-bottom: 1px solid var(--p3a-border);
    white-space: nowrap;
}
.table > tbody > tr > td { border-color: var(--p3a-border-soft); }
.table-hover > tbody > tr { transition: background-color var(--p3a-t); }
.table-hover > tbody > tr:hover > * {
    background-color: var(--p3a-accent-soft);
    --bs-table-accent-bg: transparent;
}

/* --- Tabs (Administration / Directory / Performance hubs, project tabs) --- */
.nav-tabs {
    border-bottom: 1px solid var(--p3a-border);
    gap: .15rem;
}
.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--p3a-muted);
    font-weight: 500;
    padding: .5rem .9rem;
    transition: color var(--p3a-t), border-color var(--p3a-t);
}
.nav-tabs .nav-link:hover {
    color: var(--bs-body-color);
    border-bottom-color: var(--p3a-border);
    background: transparent;
}
.nav-tabs .nav-link.active {
    color: var(--p3a-accent);
    background: transparent;
    border-bottom-color: var(--p3a-accent);
    font-weight: 600;
}

/* --- Badges -------------------------------------------------------------- */
.badge {
    font-weight: 600;
    letter-spacing: .01em;
    padding: .34em .62em;
    border-radius: .45rem;
}

/* --- Alerts / modals / toasts -------------------------------------------- */
.alert { border-radius: var(--p3a-radius-sm); }
.modal-content {
    border: 1px solid var(--p3a-border);
    border-radius: var(--p3a-radius);
    box-shadow: var(--p3a-shadow);
}
.toast {
    border: 1px solid var(--p3a-border);
    border-radius: var(--p3a-radius-sm);
    box-shadow: var(--p3a-shadow);
}

/* --- Sidebar polish ------------------------------------------------------ */
.sidebar-nav { padding: .35rem .5rem; }
.sidebar-nav a {
    margin: 1px 0;
    padding: .55rem .7rem;
    border-radius: .5rem;
    border-left: 3px solid transparent;
    transition: background-color var(--p3a-t), color var(--p3a-t), border-color var(--p3a-t);
}
.sidebar-nav a:hover { background: var(--p3a-hover); }
.sidebar-nav a.active {
    background: var(--p3a-accent-soft);
    border-left-color: var(--p3a-accent);
}
.sidebar-nav a.active i { color: #5ecfcd; }
.sidebar-brand { letter-spacing: .02em; }

/* --- Top bar ------------------------------------------------------------- */
.app-topbar { box-shadow: 0 1px 0 var(--p3a-border-soft); }
.topbar-search .form-control { border-radius: 999px; }

/* --- Login card ---------------------------------------------------------- */
.auth-card {
    border-radius: var(--p3a-radius);
    box-shadow: var(--p3a-shadow);
}

/* --- Kanban cards -------------------------------------------------------- */
.kanban-card {
    border-radius: var(--p3a-radius-sm);
    box-shadow: var(--p3a-shadow-sm);
    transition: box-shadow var(--p3a-t), transform var(--p3a-t);
}
.kanban-card:hover { box-shadow: var(--p3a-shadow); }

/* --- Dashboard bars ------------------------------------------------------ */
.dash-bar { transition: width .35s ease; }

/* --- Thin, themed scrollbars --------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--p3a-border) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--p3a-border);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--p3a-muted); }

/* --- Detail-page hero header, stage pills, mini progress, empty states ---
   .proj-hero/.proj-chip started on the Projects screen but are now the
   general "entity detail hero" pattern reused across screens (e.g. the
   Employee profile) — name kept as-is to avoid a pure-cosmetic rename churn. */
.proj-hero {
    background: linear-gradient(135deg, var(--p3a-accent-soft) 0%, transparent 60%);
    border: 1px solid var(--p3a-border);
    border-radius: var(--p3a-radius);
    padding: 1rem 1.1rem;
}
.proj-chip {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
}
.proj-chip i { color: var(--p3a-accent); width: 1rem; text-align: center; }
.stage-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--p3a-muted);
    background: var(--p3a-hover);
    border-radius: .45rem;
    padding: .3em .6em;
}
.stage-pill .dot { width: .5rem; height: .5rem; margin: 0; }
.mini-progress {
    height: .4rem;
    background: var(--p3a-border);
    border-radius: 999px;
    overflow: hidden;
}
.mini-progress-fill {
    height: 100%;
    background: var(--p3a-accent);
    border-radius: 999px;
    transition: width .35s ease;
}
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--p3a-muted);
}
.empty-state i {
    font-size: 1.8rem;
    color: var(--p3a-border);
    display: block;
    margin-bottom: .25rem;
}

.announce-card { border-left: 3px solid var(--p3a-accent); }

/* --- Initials avatar (Directory/People, task/comment authorship) -------- */
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .15);
}

/* --- Respect users who prefer less motion -------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .001ms !important;
        animation-duration: .001ms !important;
    }
}
