:root {
    /* Orange — the "In progress" badge colour, reused as a general accent. */
    --colour-primary-highlight: #ed7522;
    /* Blue — the title bar's colour, also used to mark the current user's own comments and tasks. */
    --colour-title-bar: #073777;
}

body {
    min-height: 100vh;
}

.navbar-brand {
    font-weight: 600;
}

.navbar-custom {
    background-color: var(--colour-title-bar);
}

.navbar-custom .navbar-brand,
.navbar-custom .nav-link {
    color: #fff;
}

.client-group-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
}

.client-group-toggle[aria-expanded="false"] .client-group-chevron {
    transform: rotate(-90deg);
}

/*
 * Projects are split into one <table> per client, each sized independently by
 * the browser — without fixed widths, e.g. a longer project name in one
 * client's table pushes its Status/PO/Budget/Tasks columns out of line with
 * every other client's table. table-layout: fixed plus explicit widths on
 * those columns keeps them at the same x-position in every table; the Name
 * column (no width set) absorbs whatever space is left, which is the same
 * amount in every table since they all span the same container width.
 */
.project-table {
    table-layout: fixed;
}

.project-table .col-status {
    width: 8rem;
}

/* Task status badges are coloured by the status's category (Planning/
 * Implementing/Complete — see TaskStatusCategory) via
 * task_status_badge_class() in TaskStatusExtension, rather than the
 * project-status pattern above (an if/elseif chain per template) — this
 * class is shared by several task tables plus the admin status list, so one
 * function avoids repeating the same conditional four times. An
 * uncategorised status falls back to the plain text-bg-light/border style
 * instead of one of these classes.
 *
 * Compounded with .badge (app.css loads before bootstrap.min.css — see
 * assets/app.js — so a bare .badge-status-* would lose the colour cascade
 * to Bootstrap's own same-specificity `.badge { color: ... }` rule, which
 * comes later in the stylesheet). */
.badge.badge-status-planning {
    background-color: #95dcb7;
    color: #000;
}

.badge.badge-status-implementing {
    background-color: var(--colour-primary-highlight);
    color: #fff;
}

.badge.badge-status-complete {
    background-color: #073777;
    color: #fff;
}

.project-table .col-po-number {
    width: 10rem;
}

.project-table .col-budget {
    width: 8rem;
}

.project-table .col-tasks {
    width: 6rem;
}

.project-table td,
.project-table th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* On a phone-sized viewport the fixed column widths above leave no room for
 * the name column (the only link into a project), so drop the tasks/PO
 * number/budget columns. table-layout stays fixed: the unsized Name column
 * then absorbs the rest of the table's width (100% minus col-status), so a
 * long name truncates with the ellipsis above instead of forcing a
 * horizontal scrollbar the way table-layout: auto did. */
@media (max-width: 575.98px) {
    /* Every data table in the app (project list, task list, time entries,
     * admin listings, …) sits inside the standard .container and inherits
     * the same unwanted side gutter on mobile. Bleed all of them out of the
     * container's own side padding (calc(--bs-gutter-x * .5), 0.75rem by
     * default) so they reach the screen edges instead.
     * `table.table` (not just `.table`) to outrank Bootstrap's own
     * unqualified `.table{width:100%}`, which app.css is loaded before and
     * would otherwise win the width tie-break. A table with its own inline
     * width/max-width (e.g. admin/client_organisation/task_statuses) is
     * unaffected, since an inline style always wins over a stylesheet rule. */
    table.table {
        width: calc(100% + var(--bs-gutter-x, 1.5rem));
        margin-left: calc(var(--bs-gutter-x, 1.5rem) * -.5);
        margin-right: calc(var(--bs-gutter-x, 1.5rem) * -.5);
    }

    /* 8rem (desktop) is wider than any status badge needs; "Completed", the
     * widest, only needs ~6.1rem including cell padding. Narrowing it here
     * gives the Name column the room back. */
    .project-table .col-status {
        width: 6.5rem;
    }

    .project-table .col-tasks,
    .project-table .col-po-number,
    .project-table .col-budget {
        display: none;
    }

    /* Task Status is free text (per-client custom labels, e.g. "Deployed to
     * staging" — see TaskStatusDefinition), so unlike col-status above it
     * isn't narrowed or truncated here; only the less essential Due/Assigned
     * to columns are dropped, giving Name and Status the rest of the width. */
    .task-table .col-due,
    .task-table .col-assigned {
        display: none;
    }

    /* Bootstrap's .badge is white-space: nowrap, which is fine for the
     * project list's fixed-wording status badges (col-status above narrows
     * around them deliberately) but here forces one unbreakably wide column
     * whenever a client's custom task status is a longer phrase (e.g.
     * "Deployed to staging") — let it wrap instead of dictating the table's
     * width. */
    .task-table .badge {
        white-space: normal;
        /* Bootstrap's .badge is inline-block, which sizes itself from its
         * own content regardless of a fixed-width ancestor <td> — without
         * this it still renders at its un-wrapped shrink-to-fit width
         * rather than actually wrapping to fit the cell. */
        max-width: 100%;
    }

    /* The dashboard's own task table (Task/Project, plus the hidden Due
     * above) has more columns than the project page's task table and,
     * unlike it, needs table-layout: fixed + overflow-wrap here — without it
     * a single long unbreakable word in Project (e.g. a client named
     * "Hammersmith and Fulham Council") still forces its column wide even
     * though the rest of the cell can wrap, and the table overflows. Scoped
     * to .dashboard-task-table rather than .task-table generally, since
     * forcing fixed layout on the project page's task table (which relies
     * on auto-layout to size Name generously against a short Status) would
     * squeeze its Name column. */
    .dashboard-task-table {
        table-layout: fixed;
    }

    .dashboard-task-table td,
    .dashboard-task-table th {
        overflow-wrap: break-word;
    }

    /* Project now also carries the "Client > " prefix that used to be its
     * own column, so it keeps roughly the two columns' combined share of
     * the table rather than just Project's old 24%. */
    .dashboard-task-table .col-project {
        width: 52%;
    }

    .dashboard-task-table .col-status {
        width: 20%;
    }

    /* The per-client project groups wrap their table in this panel. Bootstrap's
     * .collapsing class (applied only while the collapse animation is
     * running) sets overflow: hidden on it; since the table.table rule above
     * bleeds the table itself past this panel's own box via a negative
     * margin, that overflow:hidden clipped off the bled edge for the
     * animation's duration, showing a thin sliver of the page's plain
     * background where the table should have reached the screen edge.
     * Bleed the panel instead, and cancel the table's own bleed inside one
     * so the two don't stack. */
    .project-group-panel {
        width: calc(100% + var(--bs-gutter-x, 1.5rem));
        margin-left: calc(var(--bs-gutter-x, 1.5rem) * -.5);
        margin-right: calc(var(--bs-gutter-x, 1.5rem) * -.5);
    }

    .project-group-panel table.table {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}

/* Comment bodies and task descriptions are sanitised HTML (see
 * App\Service\Html\HtmlSanitizer) — drop the trailing margin on their last
 * element so they don't add extra whitespace inside their container. */
.rich-text > :last-child {
    margin-bottom: 0;
}

/* Bootstrap resets blockquote to a bare margin; restyle it to match what
 * CKEditor shows while editing (.ck-content blockquote: italic, left rule)
 * so a quote looks the same rendered as it did in the editor. */
.rich-text blockquote {
    border-left: 0.25rem solid var(--colour-primary-highlight);
    padding: 0.25rem 1rem;
    margin: 0 0 1rem;
    font-style: italic;
    color: var(--bs-secondary-color);
}

.rich-text blockquote > :last-child {
    margin-bottom: 0;
}

.rich-text span[data-mention] {
    background-color: #e7f1ff;
    color: #0d6efd;
    font-weight: 600;
    border-radius: 0.25rem;
    padding: 0 0.2rem;
}

/* Sized against the viewport, not Bootstrap's fixed breakpoints (even
 * modal-xl tops out at 1140px), so a comment attachment's full image gets as
 * much room as the screen allows. Compound selector needed to outrank
 * Bootstrap's own same-specificity `.modal-dialog { max-width: 500px }` rule,
 * which loads after this stylesheet (see app.js's import order). */
.modal-dialog.modal-dialog-attachment {
    max-width: 90vw;
}

.modal-dialog-attachment .modal-body img {
    max-height: 80vh;
}

/*
 * An outline overlaid on the card's own 1px border rather than a
 * border-color: app.css loads before bootstrap.min.css (see app.js), so
 * Bootstrap's own same-specificity .card border rule would win.
 */
.comment-mine {
    outline: 1px solid var(--colour-title-bar);
    outline-offset: -1px;
}

/*
 * Cashflow forecast balance chart (balance_chart_controller.js). Colours are
 * the dataviz reference palette's first two categorical slots, validated as
 * a pair against a light surface; the app has no dark mode.
 */
.balance-chart {
    --chart-series-1: #2a78d6;
    --chart-series-2: #eb6834;
    --chart-grid: #e9e8e4;
    --chart-text-muted: #6c6b66;
    position: relative;
}

.balance-chart-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--bs-secondary-color);
}

.balance-chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.balance-chart-line-key {
    display: inline-block;
    width: 14px;
    height: 2px;
    border-radius: 1px;
}

.balance-chart-grid {
    stroke: var(--chart-grid);
    stroke-width: 1;
}

.balance-chart-zero {
    stroke: var(--chart-text-muted);
    stroke-width: 1;
}

.balance-chart-tick {
    font-size: 11px;
    fill: var(--chart-text-muted);
    font-variant-numeric: tabular-nums;
}

.balance-chart-end-value {
    font-size: 12px;
    font-weight: 600;
    fill: var(--bs-body-color);
}

.balance-chart-dot {
    stroke: var(--bs-body-bg);
    stroke-width: 2;
}

.balance-chart-crosshair {
    stroke: var(--chart-text-muted);
    stroke-width: 1;
}

.balance-chart-hit:focus {
    outline: none;
}

.balance-chart-hit:focus-visible {
    outline: 2px solid var(--chart-series-1);
    outline-offset: 2px;
}

.balance-chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--bs-body-bg);
    border: 1px solid var(--chart-grid);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 0.4rem 0.6rem;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.balance-chart-tooltip-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.balance-chart-tooltip-label {
    color: var(--bs-secondary-color);
}

/*
 * Estimated figures on the cashflow forecast: italic with a dotted underline
 * (not colour alone), and a hover/focus title saying how each was worked
 * out. Estimated dates get a "~" prefix and the dotted underline only.
 */
.estimate {
    font-style: italic;
    text-decoration: underline dotted;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    cursor: help;
}

.estimate-date {
    text-decoration: underline dotted;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    cursor: help;
}

.estimate:focus-visible,
.estimate-date:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
    border-radius: 2px;
}
