/* ==========================================================================
   Life — main content area and page patterns
   Covers the shapes that recur across every entity page:
   the page shell, forms, definition rows, record lists and action bars.
   ========================================================================== */

#main {
    padding: calc(var(--lf-header-h) + 1.75rem) 1.75rem 3rem;
    min-height: 100vh;
    transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1199.98px) {
    #main {
        padding: calc(var(--lf-header-h) + 1.25rem) 1.25rem 3rem;
    }
}

@media (max-width: 575.98px) {
    #main {
        padding: calc(var(--lf-header-h) + 1rem) 1rem 2.5rem;
    }
}

#main .container {
    max-width: 1180px;
}

@media (min-width: 1400px) {
    #main .container {
        max-width: 1320px;
    }
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
#main form.row {
    row-gap: 0;
}

    #main form .row.mb-3 {
        margin-top: 0;
        margin-bottom: 1.125rem;
    }

/* Required marker — a small dot rather than bolding the whole label */
#main form .required-field::after {
    content: "*";
    color: var(--lf-danger);
    margin-left: 0.25rem;
    font-weight: 600;
}

/* The hint above the fields */
#main form > .row > small.text-muted,
#main form > .row > .col-12 > small.text-muted {
    color: var(--lf-ink-subtle) !important;
    font-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
   Grouped form layout

   Labels sit above their control, related fields pair up side by side, and
   the actions stay on screen so a long form never has to be scrolled to the
   bottom just to save it.

   The layout is Bootstrap's own grid: a section is a .row and each field is a
   col-* that stacks to the full width below md. None of the rules below
   decides where a field sits - only what a field is made of.
   -------------------------------------------------------------------------- */

/* Flex item, so it has to be allowed to shrink below the intrinsic width of
   what it holds: an <input type="date"> is wider than a sixth of a card, and
   the column widths are percentages, not content-driven. */
.form-field,
.detail-item {
    min-width: 0;
}

/* Label, control and validation message, stacked in that order */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

/* The label sits on its control through the flex gap, not a margin of its own */
.form-field .form-label {
    margin-bottom: 0;
}

/* The validation span is always rendered, even when empty, and the flex gap
   would reserve room for it under every field */
.form-field .text-danger:empty {
    display: none;
}

/* --------------------------------------------------------------------------
   Detail layout

   Read-only counterpart to the grouped form. Facts sit in the same columns as
   the form's fields, so a page and its create form line up field for field.
   -------------------------------------------------------------------------- */
.detail-item__label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--lf-ink-subtle);
    margin-bottom: 0.25rem;
}

.detail-item__value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--lf-ink);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

/* An unset value reads as a quiet dash rather than the word "Not Set" */
.detail-item__value--empty {
    color: var(--lf-ink-subtle);
    font-weight: 400;
}

.detail-item__sub {
    font-size: 0.8125rem;
    color: var(--lf-ink-muted);
    margin-top: 0.125rem;
}

/* Urgency on a detail line, matching the chip colours so an index row and its
   details page read the same. Weight carries it as well as colour - the sub is
   the line people actually scan for. */
    .detail-item__sub--soon {
        color: var(--lf-warning-ink);
        font-weight: 600;
    }

        .detail-item__sub--today {
            color: var(--lf-danger-ink);
            font-weight: 600;
        }

.detail-note {
    white-space: pre-wrap;
    background-color: var(--lf-surface-alt);
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius-sm);
    padding: 0.75rem 0.875rem;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--lf-ink);
}

/* Linked items ------------------------------------------------------------ */
/*
   The tile layout is Bootstrap's grid - one col-* per category - so the
   widths are percentages and a narrow screen stacks rather than overflowing.

   The col-* is a wrapper and the tile sits inside it, not the other way
   round. Bootstrap spaces columns by giving .row > * a padding, and a tile
   that is itself the column would have to set its own padding for the
   content - at the same specificity, and later in the cascade, so its padding
   would silently replace the gutter and leave the tiles flush against each
   other. The wrapper keeps the two paddings independent: the column owns the
   gutter, the tile owns its content spacing. h-100 then lets the tile fill
   the column so a row of tiles stays level.
*/
.linked-tile {
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius);
    background-color: var(--lf-surface);
    padding: 0.875rem 1rem;
    min-width: 0;
}

.linked-tile__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--lf-ink-subtle);
    margin-bottom: 0.75rem;
}

    .linked-tile__head i {
        font-size: 0.875rem;
        color: var(--lf-navy-500);
    }

.linked-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    margin-left: auto;
    border-radius: var(--lf-radius-pill);
    background-color: var(--lf-navy-050);
    color: var(--lf-navy-700);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0;
}

.linked-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4375rem;
}

    .linked-list li {
        display: flex;
        align-items: baseline;
        gap: 0.4375rem;
        font-size: 0.875rem;
        line-height: 1.4;
        min-width: 0;
    }

        .linked-list li::before {
            content: "";
            flex-shrink: 0;
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background-color: var(--lf-emerald-500);
            transform: translateY(-2px);
        }

    .linked-list a {
        overflow-wrap: anywhere;
    }

        /* The overflow control on a linked tile - the way out to a category's
           own index for the entries the tile has no room for.

           Set apart with a rule rather than a colour change, so it reads as the
           tile's foot rather than as another entry in the list above it. */
        .linked-tile__more {
            margin-top: 0.625rem;
            padding-top: 0.5rem;
            border-top: 1px solid var(--lf-border);
            font-size: 0.8125rem;
        }

        .linked-tile__more a {
            display: inline-flex;
            align-items: center;
            gap: 0.3125rem;
        }

/* Prescriptions ----------------------------------------------------------- */
    /* Six figures in a fixed two-by-three shape - an eye each way, sphere,
       cylinder and axis - which is how they are written on a prescription and
       how they are read. Set out as a grid of label/value pairs the six of them
       read as a list and you have to hold which eye you are on; as a table with
       the eye down the side, it reads across the way an optometrist writes it
       and two tests can be compared without effort. */

.prescription {
    overflow-x: auto;
}

    .prescription__table {
        width: 100%;
        max-width: 28rem;
        border-collapse: collapse;
        font-variant-numeric: tabular-nums;
    }

        .prescription__table th,
        .prescription__table td {
            padding: 0.5rem 0.75rem;
            text-align: right;
            border-bottom: 1px solid var(--lf-border);
        }

        /* Header cells share the cells' right alignment rather than sitting on the
           left of their own column. SPH, CYL and AXIS are numbers, so each label
           lines up with the figures it names and the decimal points stack down
           the page - which is the only reason to right-align figures at all. */
        .prescription__table th {
            font-weight: 600;
            font-size: 0.8125rem;
            letter-spacing: 0.02em;
            text-transform: uppercase;
            color: var(--lf-ink-muted);
            white-space: nowrap;
        }

            /* The exception. RIGHT and LEFT label the rows rather than the
               figures, so they stay left-aligned and form their own column -
               right-aligning them would break the eye's eye-line and leave the
               labels floating away from the row they belong to. */
            .prescription__table tbody th {
                text-align: left;
            }

            .prescription__table thead th {
                border-bottom-color: var(--lf-border-strong);
            }

        /* An em dash for a figure that was never recorded. Not muted, and not
           zero - it is a gap in the record, and sitting at the same weight as the
           numbers keeps the row aligned without implying a measurement. */
        .prescription__table tbody td {
            color: var(--lf-ink);
            font-size: 0.9375rem;
        }

        .prescription__table tbody tr:last-child th,
        .prescription__table tbody tr:last-child td {
            border-bottom: 0;
        }

/* Sections ---------------------------------------------------------------- */
.form-section {
    margin-bottom: 1.75rem;
}

    .form-section:last-of-type {
        margin-bottom: 0;
    }

.form-section__hint {
    font-size: 0.8125rem;
    color: var(--lf-ink-muted);
    margin: -0.5rem 0 1rem;
}

/* Actions ----------------------------------------------------------------- */
.form-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.625rem;
    margin-top: 1.75rem;
    padding: 0.875rem 1.5rem;
    background-color: var(--lf-surface);
    border-top: 1px solid var(--lf-border);
    border-radius: 0 0 var(--lf-radius-lg) var(--lf-radius-lg);
}

/*
   Inside a card body the bar bleeds out to the card edges to cancel the body
   padding, so it reads as a footer of the card rather than a row of buttons
   floating inside it. Scoped to that position on purpose: as a direct child
   of .card there is no padding to cancel, and the same negative margins would
   push the bar outside the card entirely.

   The form case is listed separately because a create or edit form has to
   wrap its bar in a <form>, which puts the bar one level deeper than on a
   read-only page. Without the second selector the bar keeps the body padding
   as an inset and its rounded bottom corners no longer line up with the
   card's, so a pinned bar reads as a floating panel instead of a card footer.
*/
.card-body > .form-actions,
.card-body > form > .form-actions {
    margin: 1.75rem -1.5rem -1.5rem;
}

.form-actions .btn {
    --bs-btn-border-radius: var(--lf-radius-pill);
    padding-left: 1.375rem;
    padding-right: 1.375rem;
}

/* A confirmation is a short centred card, so its actions centre with the text
   above rather than sitting under it on the right as they do on a form. */
.form-actions--center {
    justify-content: center;
}

/* Three pill buttons need about 281px between them, and the bar's content box
   is narrower than that below roughly a 400px viewport. Because the bar is
   right-aligned with nowrap, that overflow runs off the LEFT edge - the first
   button is clipped against the card rather than spilling visibly, which is
   easy to miss.

   The tighter pill padding applies across all of sm: it is what buys the
   one-row layout from 400px up to 576px in the first place, saving 40px over
   the default. */
@media (max-width: 575.98px) {
    .form-actions {
        flex-wrap: wrap;
    }

        .form-actions .btn {
            padding-left: 0.75rem;
            padding-right: 0.75rem;
        }
}

/* Below ~400px the three cannot share a row, so the bar becomes a two-row grid:
   the lead action - "View all" - centred on a row of its own, and Delete and
   Edit centred as a pair beneath it. Below this the bar is back to a single
   right-aligned row.

   Grid rather than wrapped flex because the two requirements pull against each
   other in flex: a full-width basis forces the button onto its own line but also
   makes it fill that line, so it can no longer be its natural width. Flex has no
   way to say "own line, then centre within it". Grid separates the two - a
   1 / -1 column span puts it on its own row, justify-self centres it at its
   natural width.

   :has() scopes this to bars that actually have a lead action. The rule would
   otherwise restyle every form action bar too, and those have two buttons that
   are better off staying in their existing wrapped-flex layout. */
@media (max-width: 399.98px) {
    .form-actions:has(.form-actions__lead) {
        display: grid;
        grid-template-columns: repeat(2, auto);
        justify-content: center;
        gap: 0.5rem 0.625rem;
    }

        .form-actions__lead {
            grid-column: 1 / -1;
            justify-self: center;
        }
}

/* Optional read-only pair, e.g. showing when a record was last touched */
.form-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.75rem;
    color: var(--lf-ink-subtle);
}

    .form-meta strong {
        color: var(--lf-ink-muted);
        font-weight: 600;
    }

/* --------------------------------------------------------------------------
   Definition rows (Details / Account pages)
   The markup is a two column row: a <strong> label then the value.
   -------------------------------------------------------------------------- */
#main .col-sm-4 > strong {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--lf-ink-subtle);
    line-height: 1.4;
}

#main .row.mb-3 > .col-sm-8,
#main .row.mb-4 > .col-sm-8 {
    color: var(--lf-ink);
    font-size: 0.9375rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--lf-border);
}

#main .row.mb-3 > .col-sm-4,
#main .row.mb-4 > .col-sm-4 {
    padding-bottom: 0.875rem;
    border-bottom: 1px solid transparent;
}

/* Keep the divider aligned when the row is the last one in a group */
#main .row.mb-3:last-of-type > .col-sm-8,
#main .row.mb-4:last-of-type > .col-sm-8 {
    border-bottom-color: transparent;
}

/* --------------------------------------------------------------------------
   Record lists (Index pages)
   -------------------------------------------------------------------------- */

/* The card header on an Index page: title and subtitle on the left, the
   primary action on the right.

   The gap is load-bearing rather than cosmetic. `justify-content: space-between`
   hands the action whatever room is left over, and on a narrow screen that
   turns out to be nothing at all - the subtitle runs at three lines, the action
   keeps its full width, and the two end up flush against each other with no air
   between them. Stating a gap puts a floor under that separation at every size.
   That matters most just above sm, where the one-row layout still applies but
   the room has not yet grown enough to relieve the pressure on its own.

   Only below sm does the action move under the text and take the full width.
   Between sm and md the row still fits comfortably once the gap is there, and
   keeping the action beside the title preserves the header height instead of
   spending another 30px of a small screen on it. Below sm there is no width
   left to win, so the action gets a row of its own - and grows to a comfortable
   tap target at the same time, since at btn-sm's 31px it was well short of one.

   This mirrors what .record-row already does below sm with its own actions. */
#main .list-header {
    gap: 0.75rem 1rem;
}

    @media (max-width: 575.98px) {
        /* align-items and justify-content need !important here: the markup
           carries Bootstrap's .align-items-center and .justify-content-between,
           and the alignment utilities are emitted as !important, so an ordinary
           rule here loses to them however specific it is. */
        #main .list-header {
            flex-direction: column;
            align-items: stretch !important;
            justify-content: flex-start !important;
            gap: 0.875rem;
            padding: 0.875rem 1rem;
        }

        #main .list-header__action {
            align-self: stretch;
            justify-content: center;
            min-height: 2.75rem;
        }
    }

#main .list-group {
    gap: 0.75rem;
}

/* Bootstrap's list-group is built for a JOINED list - items sharing edges - so
   it strips the top border from every item after the first and rounds only the
   outer corners. Neither applies here: .list-group carries a 12px gap, so the
   items never touch, and each one is drawn as a standalone card with its own
   border, radius, shadow and hover lift. Left alone, the first item renders
   with 6px top corners, the last with 6px bottom corners, and every item after
   the first with no top edge at all.

   The radius is restored with the shorthand so all four corners are set; the
   alternative - naming just the two outer corners - would leave the other two
   relying on the base rule and the pair could drift apart again.

   These have to sit at #main. The rules being countered are :first-child,
   :last-child and adjacent-sibling selectors, each 0,2,0. A plain
   .list-group-item rule is 0,1,0 and loses to them on specificity regardless of
   which file it is declared in, which is why the base border-radius in
   bootstrapoverrides.css never took effect on those corners. */
#main .list-group-item + .list-group-item {
    border-top-width: 1px;
}

    #main .list-group-item:first-child,
    #main .list-group-item:last-child {
        border-radius: var(--lf-radius);
    }

#main .list-group-item {
    padding: 1.125rem 1.25rem;
}

    #main .list-group-item .d-flex > div > h5,
    #main .list-group-item h5.mb-2 {
        font-size: 1rem;
        font-weight: 600;
        color: var(--lf-ink);
        margin-bottom: 0.375rem;
    }

    #main .list-group-item h6 {
        font-size: 0.8125rem;
        color: var(--lf-ink-muted);
        font-weight: 500;
    }

    #main .list-group-item .mt-2 {
        margin-top: 0.875rem !important;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

        #main .list-group-item .mt-2 .btn {
            --bs-btn-border-radius: var(--lf-radius-pill);
        }

    /* Centred records, e.g. the reminders list */
    #main .list-group-item .text-center h5 {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--lf-ink);
    }

        #main .list-group-item .text-center h5 + h5 {
            font-size: 0.9375rem;
            font-weight: 500;
            color: var(--lf-ink-muted);
            margin-bottom: 0.5rem !important;
        }

/* --------------------------------------------------------------------------
   Record rows

   The list layout used by Index pages that need more than a name per record:
   a lead icon, the record itself, a supporting line, and a row of facts.

   Laid out as its own grid inside the list item rather than by nesting more
   Bootstrap rows, so the icon and the body stay on the same two vertical lines
   down the whole list.

   The whole row is the target and the name is the only link. The link is
   stretched over the row by a positioned pseudo-element rather than the row
   being wrapped in its own anchor, because that would put one link inside
   another - invalid markup, and the inner one stops working.

   Nothing else in the row is interactive, so nothing has to be lifted above
   that overlay. If that changes, whatever is added needs position:relative and
   a z-index, or the stretched link will sit on top of it and swallow the taps.
   -------------------------------------------------------------------------- */
.record-row {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.875rem 1rem;
    align-items: start;
}

    .record-row__lead {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2.5rem;
        height: 2.5rem;
        border-radius: var(--lf-radius-sm);
        background-color: var(--lf-navy-050);
        color: var(--lf-navy-600);
        font-size: 1.125rem;
        line-height: 1;
        flex-shrink: 0;
    }

    .record-row--reminder {
        /* The date block is taller than the icon lead the rows elsewhere in the
           app use, so the row centres its two columns against each other rather
           than top-aligning as .record-row does by default. Declared here rather
           than as Bootstrap's .align-items-center on the markup, because that
           utility is emitted as !important and would then beat this rule from
           anywhere else in the cascade. */
        align-items: center;
    }

/* Calendar date block used on Reminders to make the date prominent. Sits in the
   grid's auto column where .record-row__lead would sit, so the two share a role:
   the date can be read without reading the line beside it. */
    .reminder-date-block {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 3.5rem;
        min-width: 3.5rem;
        height: 3.75rem;
        border-radius: var(--lf-radius-sm);
        background-color: var(--lf-surface-alt);
        border: 1px solid var(--lf-border);
        text-align: center;
        line-height: 1;
        padding: 0.375rem 0.25rem;
    }

        .reminder-date-block__month {
            font-size: 0.6875rem;
            font-weight: 700;
            letter-spacing: 0.05em;
            text-transform: uppercase;
            color: var(--lf-navy-700);
            margin-bottom: 0.125rem;
        }

        .reminder-date-block__day {
            font-size: 1.375rem;
            font-weight: 700;
            color: var(--lf-ink);
            line-height: 1.1;
        }

        .reminder-date-block__year {
            font-size: 0.625rem;
            font-weight: 500;
            color: var(--lf-ink-muted);
            margin-top: 0.125rem;
        }

        .reminder-date-block--today {
            background-color: var(--lf-danger-bg);
            border-color: var(--lf-danger-border);
        }

            .reminder-date-block--today .reminder-date-block__month,
            .reminder-date-block--today .reminder-date-block__day {
                color: var(--lf-danger-ink);
            }

        .reminder-date-block--soon {
            background-color: var(--lf-warning-bg);
            border-color: var(--lf-warning-border);
        }

            .reminder-date-block--soon .reminder-date-block__month,
            .reminder-date-block--soon .reminder-date-block__day {
                color: var(--lf-warning-ink);
            }

    /* An expired reminder keeps the plain block. It sits in its own tab where the
       whole row is already past, so the block only has to say when - the red
       carries "this has been" and nothing more. Re-stating the background and
       border here was a no-op anyway: identical declarations to the base. */
        .reminder-date-block--expired .reminder-date-block__month,
        .reminder-date-block--expired .reminder-date-block__day {
            color: var(--lf-danger-ink);
        }

/* Where the row leads. These are colour modifiers on .record-fact rather than
   shapes of their own, so the chip's geometry - border, radius, padding, font
   size - comes from the one place that owns it and only the colour says what
   kind of link this is.

   A custom reminder is deliberately neutral rather than green: nothing is
   linked to it, and a green chip would imply something that is not there. */
    .reminder-pill--linked {
        background-color: var(--lf-navy-050);
        border-color: var(--lf-navy-200);
    }

        .reminder-pill--linked .record-fact__value {
            color: var(--lf-navy-700);
        }

    .reminder-pill--custom {
        background-color: var(--lf-surface-alt);
        border-color: var(--lf-border);
    }

        .reminder-pill--custom .record-fact__value {
            color: var(--lf-ink-muted);
            font-weight: 500;
        }

    /* An automatic reminder whose parent record is gone. Amber is the system's
       standing "needs a look" colour, the same as a missing reminder elsewhere. */
    .reminder-pill--orphan {
        background-color: var(--lf-warning-bg);
        border-color: var(--lf-warning-border);
    }

        .reminder-pill--orphan .record-fact__value {
            color: var(--lf-warning-ink);
        }

.record-row__body {
    min-width: 0;
}

.record-row__title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--lf-ink);
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
}

    /* No colour or decoration rule here on purpose. The name used to be ink
   until hover, which made it the only link in the app that did not look like a
   link at rest - on a touch screen it looked like plain heading text. The
   base `a` rule in bootstrapoverrides.css already gives it navy and a hover
   shift, the same as the address and linked-item links on a Details page, so
   restating that here would only be a second place for the two to drift. */

    /* Stretches the link across the row. The text on its own measured 112x25px,
       which only just clears the 24px minimum a pointer target needs; the row is
       far more forgiving to hit. */
    .record-row__title a::after {
        content: "";
        position: absolute;
        inset: 0;
    }

    /* The focus ring goes on the overlay rather than the text, so it traces the
       row - which is the size of the actual target - instead of implying that
       only the words are clickable. Same 2px navy at 2px offset as the global
       a:focus-visible rule, so it is only the extent that differs. */
        .record-row__title a:focus-visible {
            outline: none;
        }

            .record-row__title a:focus-visible::after {
                outline: 2px solid var(--lf-navy-600);
                outline-offset: 2px;
                border-radius: var(--lf-radius-sm);
            }

.record-row__meta {
    font-size: 0.8125rem;
    color: var(--lf-ink-muted);
    margin-bottom: 0.625rem;
}

/* Facts sit as small labelled pairs. Label above value would double the row
   height, and these are read in a scan rather than compared column to column,
   so the label stays inline in its quieter colour. */
.record-row__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 0.5rem;
    margin: 0;
}

.record-fact {
    display: inline-flex;
    align-items: baseline;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius-sm);
    background-color: var(--lf-surface-alt);
    font-size: 0.75rem;
    line-height: 1.35;
    min-width: 0;
}

    .record-fact__label {
        color: var(--lf-ink-subtle);
        font-weight: 500;
    }

    .record-fact__value {
        color: var(--lf-ink);
        font-weight: 600;
    }

    /* A fact with nothing recorded reads as a quiet placeholder rather than a
       row of dashes the eye has to skip past */
        .record-fact--empty .record-fact__value {
            color: var(--lf-ink-subtle);
            font-weight: 400;
        }

    /* A fact with a real value that simply is not urgent - "due in 3 years",
       "expired 2 years ago". Distinct from --empty above, and the distinction
       matters: --empty means nothing was recorded, so being faint is honest,
       whereas this one is information and has to stay readable. --lf-ink-subtle
       measures 2.96:1 on this chip's own background and fails AA; --lf-ink-muted
       measures 5.21:1 and passes. */
        .record-fact--quiet .record-fact__value {
            color: var(--lf-ink-muted);
            font-weight: 500;
        }

    /* The one chip that marks a state rather than a value - which address is the
       current one. Colour is the only thing that sets it apart.

       Nothing else is overridden on purpose. An earlier version shrank the text
       and set it in caps, which made the chip shorter than the chips beside it
       and the row visibly ragged. A unitless line-height is resolved against
       each element's own font size, so shrinking the text inside a chip pulls
       its line box in and the padding no longer lines up with its neighbours. */
        .record-fact--current {
            background-color: var(--lf-emerald-100);
            border-color: var(--lf-emerald-500);
        }

            .record-fact--current .record-fact__value {
                color: var(--lf-emerald-700);
            }

/* The two urgency chips. An expiry date is a spectrum rather than a yes/no, so
   "current" needs cousins: amber once it is close enough to act on, and red on
   the day itself or for a linked date still needing action after it has passed.

   A card that has already expired gets no red chip. It sits in the expired group
   where the whole row is already red, and a red chip inside a red row is noise.
   Something expiring today still lands in the current group and would
   otherwise look like any other card.

   Text uses the -ink tokens rather than --lf-warning / --lf-danger, because this
   value is 12px and has to clear 4.5:1, not the 3:1 those manage. */
        .record-fact--soon {
            background-color: var(--lf-warning-bg);
            border-color: var(--lf-warning-border);
        }

            .record-fact--soon .record-fact__value {
                color: var(--lf-warning-ink);
            }

        .record-fact--today {
            background-color: var(--lf-danger-bg);
            border-color: var(--lf-danger-border);
        }

            .record-fact--today .record-fact__value {
                color: var(--lf-danger-ink);
            }

    /* Same amber as --soon, for something that is not an expiry at all - a
       missing reminder, say. Amber means "needs a look" throughout; the class
       name is what says which thing is asking. */
        .record-fact--attention {
            background-color: var(--lf-warning-bg);
            border-color: var(--lf-warning-border);
        }

            .record-fact--attention .record-fact__value {
                color: var(--lf-warning-ink);
            }

/* Totals strip above a list, where the sum is the reason to look at the list */
.record-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

    .record-summary__item {
        display: flex;
        align-items: baseline;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        border: 1px solid var(--lf-border);
        border-radius: var(--lf-radius-sm);
        background-color: var(--lf-surface-alt);
    }

        .record-summary__label {
            font-size: 0.75rem;
            color: var(--lf-ink-subtle);
        }

        .record-summary__value {
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--lf-ink);
        }

    /* A summary figure that is also a control, filtering the list beneath it.

       A button rather than a div with a click handler, so it is reachable by
       keyboard and announced as a control with no ARIA having to be added. The
       font and line-height resets are what a button brings that a div does not:
       without them the chips sit at the browser's default button size and stop
       lining up with the plain items beside them.

       Only the pressed state separates a control from a figure, so a strip of
       filters still reads as one row of numbers rather than a row of buttons. */
        .record-summary__item--filter {
            font: inherit;
            line-height: inherit;
            text-align: left;
            cursor: pointer;
        }

    /* On a plain chip the label is a caption under the figure, so it is the
       quieter half of the pair. Here it carries the thing being clicked - the
       year - so it cannot stay that faint: --lf-ink-subtle measures 2.96:1 on
       this background, --lf-ink-muted measures 5.21:1 and still reads as
       subordinate to the value beside it. */
            .record-summary__item--filter .record-summary__label {
                color: var(--lf-ink-muted);
            }

            .record-summary__item--filter:hover {
                background-color: var(--lf-navy-050);
                border-color: var(--lf-navy-200);
            }

            /* The "this is text you can activate" signal, given as colour rather
               than as an underline.

               An underline was here to begin with, and it was wrong twice over.
               On a label as short as "2026/27" a permanent underline reads as an
               underscore stuck to the text rather than as an affordance, and a
               strip of figures with lines under every one of them stops looking
               like a strip of figures.

               Dropping the underline altogether rather than moving it to hover
               is the better answer still: no link anywhere in this app is
               underlined. The convention set in bootstrapoverrides.css is that a
               link is identified by its colour - navy-600, going navy-800 on
               hover - and by nothing else. The only underline in the stylesheets
               is on .link-primary, which is a stock Bootstrap class this app
               never uses. So the cue here is the same one a link gets: the
               label takes the link colour, and the background and border move
               with it. */
            .record-summary__item--filter:hover .record-summary__label,
            .record-summary__item--filter:focus-visible .record-summary__label {
                color: var(--lf-navy-600);
            }

            .record-summary__item--filter[aria-pressed="true"] {
                background-color: var(--lf-navy-050);
                border-color: var(--lf-navy-600);
            }

                .record-summary__item--filter[aria-pressed="true"] .record-summary__label,
                .record-summary__item--filter[aria-pressed="true"] .record-summary__value {
                    color: var(--lf-navy-700);
                }

        /* The same ring the row links use, on the chip's own edge. */
            .record-summary__item--filter:focus-visible {
                outline: 2px solid var(--lf-navy-600);
                outline-offset: 2px;
            }

/* --------------------------------------------------------------------------
   Monthly outgoings on a Current Account Details page
   -------------------------------------------------------------------------- */
/* The one number worth reading first, with the per-category split underneath
   in the smaller pills the Index pages use for their totals. */
.outgoings-total {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.375rem;
}

    .outgoings-total__value {
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--lf-ink);
    }

.outgoings-label {
    font-family: var(--lf-font);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--lf-ink-subtle);
}

/* What the figures leave out, said plainly. Anything derived rather than
   recorded belongs on the page, not in a tooltip nobody finds. */
    .outgoings-note {
        display: flex;
        align-items: flex-start;
        gap: 0.375rem;
        margin: 0.875rem 0 0;
        font-size: 0.8125rem;
        color: var(--lf-ink-muted);
    }

        .outgoings-note i {
            flex-shrink: 0;
            margin-top: 0.1rem;
        }

.outgoings-schedule {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--lf-border);
}

    .outgoings-schedule__row {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.25rem 0.625rem;
        padding: 0.375rem 0;
    }

        .outgoings-schedule__row + .outgoings-schedule__row {
            border-top: 1px solid var(--lf-border);
        }

        .outgoings-schedule__date {
            min-width: 6rem;
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--lf-ink);
        }

        .outgoings-schedule__name {
            font-size: 0.875rem;
            font-weight: 600;
        }

        .outgoings-schedule__meta {
            font-size: 0.8125rem;
            color: var(--lf-ink-muted);
        }

/* --------------------------------------------------------------------------
   Action rail on Details pages
   -------------------------------------------------------------------------- */
#main .row > .col-md-4 > .d-flex.justify-content-between {
    position: sticky;
    top: calc(var(--lf-header-h) + 1.75rem);
    gap: 0.5rem;
}

    #main .row > .col-md-4 > .d-flex.justify-content-between .btn {
        flex: 1 1 auto;
        --bs-btn-border-radius: var(--lf-radius-pill);
        padding-left: 1rem;
        padding-right: 1rem;
    }

@media (max-width: 767.98px) {
    #main .row > .col-md-4 > .d-flex.justify-content-between {
        position: static;
        margin-top: 1.5rem !important;
    }
}

/* --------------------------------------------------------------------------
   Nested panels (Linked entities, histories)
   -------------------------------------------------------------------------- */
#main .row > .card.bg-light,
#main .row > div > .card.bg-light {
    width: 100%;
}

#main .card.bg-light + .card.bg-light,
#main .row + .row > .card.bg-light {
    margin-top: 1rem;
}

#main .card.bg-light h6 {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--lf-ink-subtle);
    margin-bottom: 0.5rem;
}

#main .card.bg-light .list-unstyled a {
    font-size: 0.875rem;
    font-weight: 500;
}

#main .card.bg-light .text-muted {
    color: var(--lf-ink-subtle) !important;
}

/* --------------------------------------------------------------------------
   Confirmation pages (Delete)
   -------------------------------------------------------------------------- */
/* Bare warning glyph on a confirmation.

   No badge, circle or tinted disc behind it - the red of the glyph is the whole
   signal, sitting straight on the card. Block plus auto margins so it centres
   and keeps its space below without the parent having to be laid out for it. */
#main .confirm-icon {
    display: block;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--lf-danger);
}

#main .card-body.text-center h5 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--lf-ink-muted);
}

#main .card-body.text-center h3 {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--lf-ink);
    margin-bottom: 1.5rem;
    overflow-wrap: anywhere;
}

/* What else a delete takes with it.

   Deleting an entity here cascades, and not always destructively - some linked
   records are removed outright, others only have their link cleared and survive.
   The difference matters, so it is spelled out rather than left implied.

   Sits inside the centred confirmation, so it keeps its own max-width and drops
   back to the centre rather than running the full card width. */
#main .confirm-impact {
    display: flex;
    gap: 0.75rem;
    max-width: 32rem;
    margin: 0 auto 1.5rem;
    padding: 0.875rem 1rem;
    border: 1px solid var(--lf-danger-border);
    border-radius: var(--lf-radius-sm);
    background-color: var(--lf-danger-bg);
    text-align: left;
}

    #main .confirm-impact__icon {
        color: var(--lf-danger);
        font-size: 1.0625rem;
        line-height: 1.4;
        flex-shrink: 0;
    }

    /* The same box in a neutral key, for a line on the confirmation that is
       information rather than a warning - "your address is kept", on a record
       whose parent survives the delete. Nothing is lost in that case, and the
       danger colours above would say the opposite of what the sentence says.
       One modifier rather than a parallel set of rules, so anything added to
       the box later keeps working in both keys. */
    #main .confirm-impact--neutral {
        border-color: var(--lf-border);
        background-color: var(--lf-surface-alt);
    }

        #main .confirm-impact--neutral .confirm-impact__icon {
            color: var(--lf-navy-600);
        }

    #main .confirm-impact__body {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    #main .confirm-impact__section:not(:first-child) {
        margin-top: 0.75rem;
    }

    #main .confirm-impact__title {
        font-size: 0.8125rem;
        font-weight: 600;
        color: var(--lf-ink);
        margin-bottom: 0.25rem;
    }

    #main .confirm-impact__list {
        margin: 0;
        padding-left: 1.125rem;
        font-size: 0.8125rem;
        line-height: 1.5;
        color: var(--lf-ink-muted);
    }

        #main .confirm-impact__list li + li {
            margin-top: 0.125rem;
        }

    /* Empty deletion state; kept and unlinked records can still follow it. */
    #main .confirm-impact__note {
        font-size: 0.75rem;
        line-height: 1.5;
        color: var(--lf-ink-subtle);
    }

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */
#main canvas {
    max-width: 100%;
}
