/*
 * Project styles layered on top of EasyAdmin's own stylesheet.
 *
 * Injected into the admin by DashboardController::configureAssets() via
 * addAssetMapperEntry('app'), which pulls this file in through assets/app.js.
 */

/*
 * A datagrid row that needs a second look.
 *
 * Bootstrap's `.table-warning` cannot be used for this: it hardcodes
 * `--bs-table-color: #000` on `--bs-table-bg: #fff3cd`, literal hex values that EasyAdmin's
 * `.ea-dark-scheme` never overrides, so a flagged row came out black-on-pale-yellow in the
 * middle of a dark page. Same trap as `.content-panel-body`, which hardcodes
 * `background: var(--white)` — several Bootstrap and EA 4 rules survive in that stylesheet
 * with no dark-mode counterpart.
 *
 * This sets the same custom properties `.table-warning` does, so Bootstrap paints the row
 * exactly the way it paints its own variants (the cell background is an inset box-shadow,
 * not a plain background-color — setting one would be overridden). The values come from
 * EasyAdmin's `--alert-warning-*` tokens, which *are* defined twice: once in `@layer ea` and
 * once under `.ea-dark-scheme`, so both the tint and the text colour follow the theme.
 *
 * Used by the contract run and booking screens for a period whose issue date has already
 * passed, and by the contract detail page for a period that is earned but not yet raised.
 */
/*
 * The current step of the contract wizard.
 *
 * Bootstrap's `.nav-pills` hardcodes `--bs-nav-pills-link-active-bg: #0d6efd` and
 * `--bs-nav-pills-link-active-color: #fff` — literal hex, raw Bootstrap primary rather than
 * anything from EasyAdmin's palette, and identical in both themes. The result was a pill far
 * bluer than the rest of the admin and no better in dark mode. Same trap as
 * `.content-panel-body` and `.table-warning`: this stylesheet carries several Bootstrap and
 * EA 4 rules with hardcoded light-mode colours and no dark counterpart.
 *
 * Retargeted at the tokens EasyAdmin's own sidebar uses to mark the section you are in. They
 * are defined once in `@layer ea` and again under `.ea-dark-scheme`, and reusing them means
 * the step header says "you are here" in the language the application already speaks rather
 * than inventing a second one.
 *
 * The contents must inherit: a `text-muted` hint or a `badge-secondary` number sets its own
 * colour and wins over the pill's, which is how the active step ended up grey-on-blue and
 * unreadable whatever the background did.
 */
.wizard-steps .nav-link.active {
    background-color: var(--sidebar-menu-active-item-bg);
    color: var(--sidebar-menu-active-item-color);
}

.wizard-steps .nav-link .step-hint {
    opacity: 0.75;
}

/*
 * The invoice archive's period navigator.
 *
 * Reuses the sidebar menu's own palette variables rather than inventing colours, for the reason
 * the wizard pills do: those are the two tokens EasyAdmin's dark scheme actually redefines, so
 * anything built from them follows the theme without a second set of rules. A hardcoded
 * background here would come out white in dark mode, which is exactly what `.content-panel-body`
 * still does.
 *
 * The counts sit hard right so the ratios line up as a column and an incomplete period is
 * findable by scanning rather than by reading.
 */
.archive-period {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
    text-decoration: none;
}


/*
 * Invoices › By period: the bar under the view switch (cycle, pager, stats), the period popover,
 * the status line and the row menu column. Built from EasyAdmin's tokens only, which its dark
 * scheme redefines, so nothing here needs a dark block of its own. docs/invoice-archive.md.
 */
.archive-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 2rem;
    margin-bottom: 1rem;
}

.archive-bar-nav,
.period-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.archive-cycle-form .form-select {
    width: auto;
}

.period-picker {
    position: relative;
}

.period-picker > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-size: var(--font-size-xl);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.period-picker > summary::-webkit-details-marker {
    display: none;
}

.period-picker > summary:hover,
.period-picker[open] > summary {
    border-color: var(--border-color);
}

.period-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: transparent;
}

[data-state="due"] > .period-dot,
[data-state="drafted"] > .period-dot { background: var(--color-warning); }
[data-state="done"] > .period-dot { background: var(--color-success); }
[data-state="running"] > .period-dot { background: var(--border-color); }

.period-popover {
    position: absolute;
    z-index: 1050;
    top: calc(100% + 0.35rem);
    left: 0;
    width: 22rem;
    max-width: calc(100vw - 2rem);
    padding: 0.75rem;
    background: var(--dropdown-bg);
    border: 1px solid var(--dropdown-border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
}

.archive-years {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.archive-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin: 0.6rem 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.archive-legend li {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem;
}

/* A month cell: body text, not a link colour; the selected one is ringed and tinted in the
   primary colour, the current one bold. Counts stay muted, amber where work waits. */
.archive-grid .archive-period {
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    padding: 0.35rem 0.5rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
}

.archive-grid .archive-period:hover {
    background-color: color-mix(in srgb, var(--text-color) 4%, var(--body-bg));
}

.archive-grid .archive-period.is-selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
    background-color: color-mix(in srgb, var(--color-primary) 10%, var(--body-bg));
    color: color-mix(in srgb, var(--color-primary) 55%, var(--text-color));
}

.archive-period-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.archive-period-counts {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.archive-period-counts .text-warning {
    color: color-mix(in srgb, var(--color-warning) 70%, var(--text-color)) !important;
    font-weight: 600;
}

.archive-period-bar {
    display: block;
    height: 4px;
    margin-top: 0.2rem;
    border-radius: 2px;
    background: var(--border-color);
    overflow: hidden;
}

.archive-period-bar > span {
    display: block;
    height: 100%;
    background: var(--color-success);
}

.archive-period:is([data-state="due"], [data-state="drafted"]) .archive-period-bar > span {
    background: var(--color-warning);
}

.archive-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 2rem;
    margin: 0;
}

.archive-stat dt {
    font-size: var(--font-size-xs);
    font-weight: normal;
    color: var(--text-muted);
}

.archive-stat dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Clear of the table: flush, the alert's bottom border read as the table's top border. */
.archive-status {
    margin-bottom: 1rem;
}

.archive-status .alert .btn {
    margin-inline-start: 0.75rem;
}

.archive-table .datagrid th,
.archive-table .datagrid td.text-nowrap {
    white-space: nowrap;
}

/* Every column keeps its own gutter, so a right-aligned amount never runs into the next column.
   Headers take EasyAdmin's own padding, from the <span> inside each <th>. */
.archive-table .datagrid td,
.wizard-table td {
    padding-inline: 0.6rem;
}

/* The row menu stays on screen when the table scrolls sideways. */
.archive-table .datagrid td.actions,
.archive-table .datagrid th.actions {
    position: sticky;
    right: 0;
    background: var(--body-bg);
}

/*
 * Invoices › Wizard: the bar above the table, a row per invoice with its periods under it, the
 * Owed badge and planned dates. EasyAdmin tokens only. docs/contract-billing-engine.md.
 */
.wizard-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1rem;
}

.wizard-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}

.wizard-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.wizard-header-date {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-inline-start: 1rem;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.wizard-header-date .form-control {
    width: auto;
}

.wizard-bar .wizard-stats {
    margin-inline-start: auto;
}

.wizard-table .chip,
.archive-table .chip {
    display: inline-block;
    padding: 0 0.35rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

.wizard-table .wizard-chips {
    white-space: nowrap;
}

.wizard-table tr.wizard-line td {
    font-size: var(--font-size-sm);
}

/* By period: a grouped invoice's periods, under it as in the wizard. */
.archive-table .datagrid tr.archive-line > td {
    font-size: var(--font-size-sm);
    background-color: color-mix(in srgb, var(--text-color) 3%, var(--body-bg));
}

.archive-table tr.archive-line .archive-line-name {
    padding-left: 2.25rem;
}

.wizard-table tr.wizard-line .wizard-line-name {
    padding-left: 1.75rem;
}

.wizard-table tr.wizard-line:has(input[name="rows[]"]:not(:checked)) .wizard-line-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

.wizard-expand > .icon,
.wizard-idle-toggle .btn > .icon,
.notice-more .btn > .icon {
    transition: transform 0.15s ease;
}

/* Only these chevrons turn when open -- a global rule also spun the top bar's gear. */
.wizard-expand[aria-expanded="true"] > .icon,
.wizard-idle-toggle .btn[aria-expanded="true"] > .icon,
.notice-more .btn[aria-expanded="true"] > .icon {
    transform: rotate(90deg);
}

.wizard-planned {
    font-style: italic;
    color: var(--text-muted);
}

.badge-owed {
    border-style: dashed;
}

.wizard-table td.actions,
.wizard-table th.actions {
    position: sticky;
    right: 0;
    background: var(--body-bg);
}

/* Each sticky cell is its own stacking context, so an open row menu must lift its cell above the rows below. */
:is(.archive-table .datagrid, .wizard-table) td.actions:has(.dropdown-menu.show) {
    z-index: 5;
}

/* An invoice's periods: indented under it, on a faint ground of their own. */
.wizard-table tr.wizard-line > td:first-child {
    padding-inline-start: 1.6rem;
}

.wizard-table tbody:not(.is-split) > tr.wizard-line > td {
    background-color: color-mix(in srgb, var(--text-color) 3%, var(--body-bg));
}

.wizard-table tbody.is-split > tr.wizard-line > td {
    background-color: color-mix(in srgb, var(--invoice-group) calc(var(--invoice-group-tint-amount) / 2), var(--body-bg));
}

.drag-grip {
    display: inline-block;
    margin-inline-end: 0.35rem;
    color: var(--text-muted);
    cursor: grab;
}

.drag-grip:hover {
    color: var(--text-color);
}

.datagrid tr.row-flagged {
    --bs-table-bg: var(--alert-warning-bg);
    --bs-table-color: var(--alert-warning-color);
    --bs-table-border-color: var(--alert-warning-border-color);
    --bs-table-hover-bg: var(--alert-warning-bg);
    --bs-table-hover-color: var(--alert-warning-color);
}

/*
 * The switchers. The company switcher renders twice -- in the sidebar header on desktop and
 * in the mobile bar -- because `.ea-sidebar-header` is hidden below 992px.
 * See docs/admin-forms.md, "The switchers".
 */
.ea-company-switcher-toggle {
    align-items: center;
    display: flex;
    gap: 0.5rem;
    padding: 0.25rem 0;
    text-decoration: none;
}

/*
 * At the compact sidebar width the column is 64px, so the name is hidden and the icon stands
 * alone -- the same swap EasyAdmin does for its own logo (`.logo-custom` / `.logo-compact`).
 * Bootstrap's caret is a `::after` with its own margin, so with the name hidden it took up
 * half the button and pushed the icon off the column's centre; it is hidden here only, since
 * at full width the caret is the affordance that says the button opens something.
 */
body.ea-sidebar-width-compact .ea-company-switcher-name {
    display: none;
}

body.ea-sidebar-width-compact .ea-company-switcher-toggle::after {
    display: none;
}

body.ea-sidebar-width-compact .ea-company-switcher-toggle {
    gap: 0;
}

/* The mobile bar gives the switcher the space the dashboard title had, and no more. */
.ea-company-switcher-responsive .ea-company-switcher-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The tenant's brand colour, so the switcher says which client's books these are. */
.ea-tenant-switcher .dropdown-item::before,
.ea-company-switcher-responsive .ea-tenant-chip {
    content: '';
    display: inline-block;
    width: .7rem;
    height: .7rem;
    margin-inline-end: .5rem;
    border-radius: 50%;
    background: var(--ea-tenant-chip, transparent);
    vertical-align: middle;
}

/*
 * Contact label badges.
 *
 * Five of the six reuse EasyAdmin's own badge token pairs, which are defined once in
 * `@layer ea` and again under `.ea-dark-scheme` -- the same reason the wizard pills and the
 * archive navigator borrow sidebar tokens rather than inventing colours. Purple has no
 * EasyAdmin equivalent, so its pair is defined here, twice, mirroring the danger formula
 * exactly with violet substituted.
 *
 * These are `badge-label-*` rather than `badge-*` so EasyAdmin treats them as unknown
 * variants and passes the class straight through. See docs/contact-labels.md.
 */
.badge.badge-label-red {
    background-color: var(--badge-danger-bg);
    box-shadow: var(--badge-danger-box-shadow);
    color: var(--badge-danger-color);
}

.badge.badge-label-amber {
    background-color: var(--badge-warning-bg);
    box-shadow: var(--badge-warning-box-shadow);
    color: var(--badge-warning-color);
}

.badge.badge-label-green {
    background-color: var(--badge-success-bg);
    box-shadow: var(--badge-success-box-shadow);
    color: var(--badge-success-color);
}

.badge.badge-label-blue {
    background-color: var(--badge-info-bg);
    box-shadow: var(--badge-info-box-shadow);
    color: var(--badge-info-color);
}

.badge.badge-label-grey {
    background-color: var(--badge-secondary-bg);
    box-shadow: var(--badge-secondary-box-shadow);
    color: var(--badge-secondary-color);
}

.badge.badge-label-purple {
    background-color: var(--badge-label-purple-bg);
    box-shadow: var(--badge-label-purple-box-shadow);
    color: var(--badge-label-purple-color);
}

:root,
.ea-dark-scheme {
    --badge-label-purple-bg: var(--purple-100);
    --badge-label-purple-box-shadow: none;
    --badge-label-purple-color: var(--violet-700);
}

.ea-dark-scheme {
    --badge-label-purple-bg: color-mix(in srgb, var(--violet-700) 18%, transparent);
    --badge-label-purple-box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--violet-200) 30%, transparent);
    --badge-label-purple-color: var(--violet-200);
}

/* These follow a contact's name inline on the dense pages, so they need their own gap --
   without it the run page reads "Customer OneFASSZOPO". Margin only: nothing to theme. */
.badge.contact-label-badge {
    margin-inline-start: 0.25rem;
}

/* The internal-note marker that sits beside the badges. Quieter than a badge on purpose. */
.contact-note-icon {
    color: var(--text-muted);
    cursor: help;
    margin-inline-start: 0.25rem;
}

/* The billing presets and the schedule preview on the contract form.

   Band colours are tokens defined under `:root, .ea-dark-scheme` and again under
   `.ea-dark-scheme`, for the reason the badge tints above give: EasyAdmin applies dark mode
   with a class on <body> that redefines the same tokens, so a `:root`-only value is silently
   ignored there. */
:root,
.ea-dark-scheme {
    --billing-band: var(--color-primary);
    --billing-band-alt: color-mix(in srgb, var(--color-primary) 65%, var(--body-bg));
    --billing-track-bg: var(--gray-100);
    --billing-track-line: var(--border-color);
    --billing-band-stripe: rgb(255 255 255 / 40%);
    --billing-tick-weekend: color-mix(in srgb, var(--color-primary) 70%, transparent);
    --billing-popup-stripe: rgb(255 255 255 / 13%);
}

.ea-dark-scheme {
    --billing-band-alt: color-mix(in srgb, var(--color-primary) 62%, var(--body-bg));
    --billing-popup-stripe: rgb(0 0 0 / 16%);
    --billing-track-bg: color-mix(in srgb, var(--gray-500) 16%, transparent);
    --billing-band-stripe: rgb(0 0 0 / 30%);
}

.billing-mode-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-block: 0.75rem;
}

.billing-mode-card {
    background: transparent;
    border: 1px solid var(--billing-track-line);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.75rem;
    text-align: start;
}

.billing-mode-card span {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.billing-mode-card[aria-pressed="true"] {
    border-color: var(--billing-band-0);
    box-shadow: 0 0 0 1px var(--billing-band-0);
}

.billing-preview-heading {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-block-end: 0.25rem;
}

/* Labels and ticks are positioned by day fraction like the bands, so both containers are
   their own positioning context and every child carries a percentage offset. */
.billing-preview-scale {
    color: var(--text-muted);
    font-size: 0.7rem;
    height: 1rem;
    position: relative;
}

/* Centred on the boundary tick it names, not over the span between boundaries: the label
   belongs to the mark where the month starts, which is where the eye goes to read a date off
   a ruler. Width is its own, so `left` can stay the boundary and the transform do the
   centring. */
.billing-preview-scale-label {
    position: absolute;
    text-align: center;
    transform: translateX(-50%);
    white-space: nowrap;
}

.billing-preview-scale-label.is-flush-start {
    transform: none;
}

.billing-preview-scale-label.is-flush-end {
    transform: translateX(-100%);
}

.billing-preview-ticks {
    height: 0.6rem;
    position: relative;
}

/* A day tick is a hairline half the height of the ruler; a calendar boundary -- the mark a
   month or year label names -- is full height and twice the weight. */
.billing-preview-tick {
    background-color: color-mix(in srgb, var(--text-muted) 55%, transparent);
    bottom: 0;
    height: 50%;
    position: absolute;
    width: 1px;
}

/* Saturdays and Sundays, so a period boundary landing on one is visible before the invoice
   date turns out to be a weekend. Only meaningful on a day grid; the template checks. */
.billing-preview-tick.is-weekend {
    background-color: var(--billing-tick-weekend);
}

.billing-preview-tick.is-calendar {
    background-color: var(--text-color);
    height: 100%;
    width: 2px;
}

/* The bands are absolutely positioned by day fraction, so the track is the positioning
   context and must keep its height even when empty. */
.billing-preview-track {
    background: var(--billing-track-bg);
    border: 1px solid var(--billing-track-line);
    border-radius: 4px;
    height: 2.25rem;
    overflow: hidden;
    position: relative;
}

.billing-preview-band {
    border: 0;
    border-radius: 3px;
    bottom: 4px;
    cursor: pointer;
    padding: 0;
    position: absolute;
    top: 4px;
}

/* Two shades of the one brand colour rather than a ramp of six: adjacent periods still
   separate, and the row reads as a calendar instead of a novelty stripe. */
.billing-preview-band { background-color: var(--billing-band); }
.billing-preview-band.is-alternate { background-color: var(--billing-band-alt); }

.billing-preview-band[aria-pressed="true"] {
    outline: 2px solid var(--text-color);
    outline-offset: -2px;
}

/* Clipped rather than hidden below a width threshold: a band too narrow for "#12" simply
   shows nothing, and the button keeps its aria-label either way. */
.billing-preview-band-number {
    color: var(--text-on-primary, #fff);
    display: block;
    font-size: 0.7rem;
    line-height: 1.6rem;
    overflow: hidden;
    text-align: center;
    white-space: nowrap;
}

.billing-preview-band.is-alternate .billing-preview-band-number {
    color: var(--text-on-primary, #fff);
}

/* A clipped period is shorter than its cycle and bills a full one anyway, so it is worth
   seeing before the contract is saved rather than after the first invoice. */
.billing-preview-band.is-partial {
    background-image: repeating-linear-gradient(
        45deg,
        transparent 0 4px,
        var(--billing-band-stripe) 4px 8px
    );
}

.billing-preview-continues {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-block: 0.15rem 0;
    text-align: end;
}

/* The popups are anchored to their band, so the plot is their positioning context -- the
   track itself clips its bands and would clip these too. */
.billing-preview-plot {
    position: relative;
}

.billing-preview-popup {
    background: var(--billing-band);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgb(0 0 0 / 25%);
    color: var(--text-on-primary, #fff);
    margin-block-start: 0.4rem;
    max-width: min(20rem, 100%);
    padding: 0.6rem 0.8rem;
    position: absolute;
    top: 100%;
    transform: translateX(-50%);
    width: max-content;
    z-index: 5;
}

.billing-preview-popup.is-alternate {
    background: var(--billing-band-alt);
}

/* The same stripe its band wears, so a part period is recognisable once the popup covers the
   band that said so. Wider and fainter than the band's: this one sits behind text. */
.billing-preview-popup.is-partial {
    background-image: repeating-linear-gradient(
        45deg,
        transparent 0 7px,
        var(--billing-popup-stripe) 7px 14px
    );
}

/* Near the ends the popup grows inwards from its anchor instead of straddling it, so it
   stays inside the plot whatever an ancestor does about overflow. */
.billing-preview-popup.is-flush-start {
    transform: none;
}

.billing-preview-popup.is-flush-end {
    transform: translateX(-100%);
}

/* The labels inside sit on a coloured ground now, so they step back from the text through
   transparency rather than through the muted grey, which would fall out of contrast. */
.billing-preview-popup .billing-preview-dates dt {
    color: color-mix(in srgb, currentcolor 72%, transparent);
}

/* Inherits the popup's own text colour: EasyAdmin's heading colour is picked for the page
   background and collides with the band shade behind it. */
.billing-preview-popup-title {
    color: inherit;
    font-size: 0.9rem;
    margin-block: 0 0.35rem;
}

.billing-preview-dates {
    display: grid;
    gap: 0.1rem 0.75rem;
    grid-template-columns: auto 1fr;
    margin: 0;
}

.billing-preview-dates dt {
    color: var(--text-muted);
    font-weight: 400;
}

.billing-preview-dates dd {
    margin: 0;
}

.billing-preview-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Which mode is showing. A tint rather than a fill: EasyAdmin's own .btn background beats a
   bare attribute selector, which left the pressed button white text on a white fill. */

/* Payment terms is sized for the row of four it shares under Advanced. Alone in Simple, a
   quarter-width box reads as a stray; half-width matches the dates above it. */
.billing-simple [class*="col-"]:has(> [data-billing-terms]) {
    flex: 0 0 50%;
    max-width: 50%;
}

/* The contract's Change menu: each choice's one-line explanation wraps instead of running off. */
.action-group[data-action-group-name="changeContract"] .dropdown-header {
    white-space: normal;
    max-width: 22rem;
}

/*
 * The wizard's split invoices: colour = invoice, as a tint over the invoice's rows and a numbered
 * tint. Five hues kept clear of warning, danger and success, which already mean Ahead, blocked
 * and paid on this page; the number is always shown beside the colour. Each tint mixes its hue
 * into the page background, so one rule serves both schemes. docs/admin-theming.md.
 */
:root,
.ea-dark-scheme {
    --invoice-group-1: var(--indigo-600);
    --invoice-group-2: var(--teal-600);
    --invoice-group-3: var(--violet-600);
    --invoice-group-4: var(--sky-600);
    --invoice-group-5: var(--pink-600);
    --invoice-group-tint-amount: 9%;
}

.ea-dark-scheme {
    --invoice-group-1: var(--indigo-300);
    --invoice-group-2: var(--teal-300);
    --invoice-group-3: var(--violet-300);
    --invoice-group-4: var(--sky-300);
    --invoice-group-5: var(--pink-300);
    --invoice-group-tint-amount: 14%;
}

.invoice-group-1 { --invoice-group: var(--invoice-group-1); }
.invoice-group-2 { --invoice-group: var(--invoice-group-2); }
.invoice-group-3 { --invoice-group: var(--invoice-group-3); }
.invoice-group-4 { --invoice-group: var(--invoice-group-4); }
.invoice-group-5 { --invoice-group: var(--invoice-group-5); }

.wizard-table tbody.is-split > tr > td {
    background-color: color-mix(in srgb, var(--invoice-group) var(--invoice-group-tint-amount), var(--body-bg));
}


.wizard-table [draggable="true"] {
    cursor: grab;
}

.wizard-table tbody.is-drop-target > tr > td {
    box-shadow: inset 0 2px 0 var(--invoice-group, var(--color-primary, currentColor)), inset 0 -2px 0 var(--invoice-group, var(--color-primary, currentColor));
}

.wizard-new-zone td {
    border: 2px dashed var(--border-color);
    color: var(--text-muted);
    text-align: center;
}

.wizard-new-zone.is-drop-target td {
    border-color: var(--text-color);
    color: var(--text-color);
}

.move-to {
    position: relative;
}

.move-to > summary {
    list-style: none;
}

.move-to > summary::-webkit-details-marker {
    display: none;
}

.move-to-menu {
    position: absolute;
    z-index: 1050;
    min-width: 12rem;
    padding: 0.25rem;
    background: var(--dropdown-bg);
    border: 1px solid var(--dropdown-border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
}

.move-to-menu a,
.move-to-menu .btn {
    display: block;
    padding: 0.3rem 0.6rem;
    text-align: start;
    white-space: nowrap;
}

/* An invoice or contract line: labels above their inputs, as in the rest of the form. EasyAdmin
   lays a complex collection item's fields out label-beside-input, which squeezed the labels. */
.form-group.field-collection .accordion-item .entity-picker .form-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.4rem 0;
}

.form-group.field-collection .accordion-item .entity-picker .form-group > .form-control-label {
    width: auto;
    margin: 0;
}

/* The drag grip line_order_controller puts before each line's header button. */
.form-group.field-collection .accordion-header:has(> .line-grip) {
    display: flex;
    align-items: center;
}

.form-group.field-collection .accordion-header > .accordion-button {
    flex: 1;
}

.line-grip {
    border: 0;
    background: none;
    padding: 0 0.25rem 0 0.75rem;
    align-self: stretch;
    color: var(--text-muted);
    cursor: grab;
}

.line-grip:hover,
.line-grip:focus-visible {
    color: var(--text-color);
}

.field-collection-item.is-dragging {
    opacity: 0.4;
}

/* A mode toggle -- Existing | New on the customer and signatory pickers, Product | Service on a
   new line: a segmented radio, not a button, so no `btn` classes
   (MarkupConventionTest). Coloured from EasyAdmin's button tokens -- secondary, primary when
   chosen -- which can be gradients, hence `background`. */
.mode-toggle {
    display: inline-flex;
    margin-bottom: 0.6rem;
}

.mode-toggle > input {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}

.mode-toggle > :is(label, button) {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.25rem 0.85rem;
    font-size: var(--font-size-sm);
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    background: var(--button-secondary-bg);
    color: var(--button-secondary-color);
    border: 1px solid var(--button-secondary-border-color);
    box-shadow: var(--button-secondary-box-shadow);
}

.mode-toggle > :is(label, button):first-of-type {
    border-start-start-radius: var(--border-radius);
    border-end-start-radius: var(--border-radius);
}

.mode-toggle > :is(label, button):last-of-type {
    border-start-end-radius: var(--border-radius);
    border-end-end-radius: var(--border-radius);
}

.mode-toggle > label + input + label,
.mode-toggle > button + button {
    margin-inline-start: -1px;
}

.mode-toggle > :is(label, button):hover {
    background: var(--button-secondary-hover-bg);
    color: var(--button-secondary-hover-color);
}

.mode-toggle > input:focus-visible + label,
.mode-toggle > button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.mode-toggle > input:checked + label,
.mode-toggle > button[aria-pressed="true"] {
    background: var(--button-primary-bg);
    border-color: var(--button-primary-border-color);
    color: var(--button-primary-color);
    box-shadow: var(--button-primary-box-shadow);
}

/* The date picker (date_picker_controller.js, Vanilla Calendar Pro) in EasyAdmin's colours. The
   library reads only --vc-* variables, with fallbacks of its own, so these theme both schemes;
   the selected day takes the company's primary colour, as the toggles do. */
[data-vc=calendar] {
    --vc-bg: var(--dropdown-bg);
    --vc-color: var(--text-color);
    --vc-title-color: var(--text-color);
    --vc-week-day-color: var(--text-muted);
    --vc-week-day-off-color: var(--text-muted);
    --vc-date-bg: transparent;
    --vc-date-color: var(--text-color);
    --vc-date-bg-hover: color-mix(in srgb, var(--text-color) 8%, var(--dropdown-bg));
    --vc-date-color-hover: var(--text-color);
    --vc-date-weekend-bg-hover: color-mix(in srgb, var(--text-color) 8%, var(--dropdown-bg));
    --vc-date-outside-color: color-mix(in srgb, var(--text-muted) 55%, var(--dropdown-bg));
    --vc-date-weekend-outside-bg: transparent;
    --vc-date-weekend-outside-color: color-mix(in srgb, var(--text-muted) 55%, var(--dropdown-bg));
    --vc-date-weekend-outside-bg-hover: color-mix(in srgb, var(--text-color) 8%, var(--dropdown-bg));
    --vc-date-weekend-outside-hover-bg: color-mix(in srgb, var(--text-color) 8%, var(--dropdown-bg));
    --vc-months-years-bg: transparent;
    --vc-months-years-color: var(--text-color);
    --vc-months-years-bg-hover: color-mix(in srgb, var(--text-color) 8%, var(--dropdown-bg));
    --vc-months-years-bg-selected: var(--color-primary);
    --vc-months-years-color-selected: var(--button-primary-color, #fff);
    --vc-date-today-bg: transparent;
    --vc-date-today-color: var(--color-primary);
    --vc-date-selected-bg: var(--color-primary);
    --vc-date-selected-color: var(--button-primary-color, #fff);
    --vc-date-weekend-color: var(--text-muted);
    --vc-date-weekend-selected-bg: var(--color-primary);
    --vc-date-weekend-selected-color: var(--button-primary-color, #fff);
    --vc-focus-outline-color: var(--color-primary);
    font-family: inherit;
}

[data-vc=calendar][data-vc-input] {
    z-index: 1060;
    border: 1px solid var(--dropdown-border-color);
    box-shadow: var(--box-shadow-lg);
}

/* dropdown_into_view_controller.js scrolls an opened dropdown into view. The margin keeps it off
   the window's bottom edge, and a form page keeps room below its last field, or a line added at
   the bottom opens a dropdown past the end of the page. Spacing only: nothing to theme. */
.ts-dropdown {
    scroll-margin-bottom: 3rem;
}

.ea-new .content-body,
.ea-edit .content-body {
    padding-bottom: 18rem;
}

/*
 * A column an action changed, on the History detail page. The alert tokens are defined in
 * `@layer ea` and again under `.ea-dark-scheme`, so the tint follows the theme.
 */
.history-changes tr.history-changed > td,
.history-changes tr.history-changed code {
    background: var(--alert-warning-bg);
    color: var(--alert-warning-color);
}

/*
 * The top bar's history menu: one round, neutral button beside the user menu, with a dot while
 * undo or redo is available. Colours come from theme tokens, so both schemes follow. Desktop
 * only: on phones it lives in the mobile header, and showing this row too duplicated it.
 */
@media (min-width: 992px) {
    .navbar-custom-menu:has(.history-top-bar) {
        display: flex;
        align-items: center;
    }
}

/* At phone width the search field would otherwise keep its full width and push the button out. */
.content-top:has(.history-top-bar) .content-search {
    min-width: 0;
}

.history-top-bar {
    display: flex;
    align-items: center;
    margin-inline-end: .75rem;
}

.history-top-bar .history-round {
    position: relative;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* The same grey as EasyAdmin's settings gear, no outline; open turns it the primary colour. */
.history-top-bar .history-toggle {
    color: var(--dropdown-settings-icon-color);
}

.history-top-bar .history-toggle:hover,
.history-top-bar .history-toggle[aria-expanded="true"] {
    color: var(--color-primary);
}

.history-top-bar .history-dot {
    position: absolute;
    top: 1px;
    right: 1px;
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 0 2px var(--body-bg);
}

.history-menu .dropdown-menu {
    min-width: 22rem;
    max-width: calc(100vw - 2rem);
}

.history-menu .history-menu-off {
    cursor: not-allowed;
}

.history-menu .history-menu-off .dropdown-item {
    opacity: .5;
}

.history-menu .history-item {
    display: flex;
    gap: .75rem;
    padding: .35rem 1rem;
}

.history-menu .history-item-time {
    color: var(--text-muted);
    white-space: nowrap;
}

.history-menu .history-item-undone .history-item-label {
    color: var(--text-muted);
    text-decoration: line-through;
}

.history-menu .history-item-note {
    padding: .35rem 1rem;
    color: var(--text-muted);
    font-size: .85em;
}

/*
 * Possible duplicates (templates/admin/pages/contact_duplicates.html.twig). Theme tokens only,
 * so both schemes follow without a dark block of their own.
 */
.duplicate-group {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    background: var(--body-bg);
}
.duplicate-group-header,
.duplicate-group-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
}
.duplicate-group-header {
    border-bottom: 1px solid var(--border-color);
    background-color: color-mix(in srgb, var(--text-color) 4%, var(--body-bg));
}
.duplicate-group-actions { justify-content: flex-end; border-top: 1px solid var(--border-color); }
.duplicate-count { margin-left: auto; font-size: var(--font-size-sm); color: var(--text-muted); }
.duplicate-hit {
    background-color: color-mix(in srgb, var(--color-success) 18%, var(--body-bg));
    border-radius: 3px;
    padding: 0 3px;
}
.merge-address-group {
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: .5rem .75rem;
    margin-bottom: .5rem;
}
.merge-address { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .25rem 0; }
.merge-join { width: auto; margin-left: auto; }

/* The contact list's labels button: a small plus or pencil over the tag's corner. */
.contact-labels-menu__icon { position: relative; display: inline-block; }
.contact-labels-menu__mark {
    position: absolute;
    right: -.45em;
    bottom: -.35em;
    font-size: .6em;
    line-height: 1;
    padding: .1em;
    border-radius: 50%;
    background: var(--body-bg);
}
.contact-labels-menu--empty,
.contact-labels-menu--empty:hover { color: var(--text-muted); }

/* The what's-new bell, beside the history menu. See docs/announcements.md. */
.whats-new-bell {
    display: flex;
    align-items: center;
    margin-inline-end: .5rem;
}

.whats-new-bell .whats-new-toggle {
    color: var(--dropdown-settings-icon-color);
}

.whats-new-bell .whats-new-toggle:hover,
.whats-new-bell .whats-new-toggle[aria-expanded="true"] {
    color: var(--color-primary);
}

/* The bell and history icons at the gear's size, and all four top-bar controls answering hover
   and an open menu the same way: the primary colour. */
.whats-new-bell .whats-new-toggle,
.history-top-bar .history-toggle {
    font-size: var(--icon-size-md);
}

.dropdown-settings .dropdown-settings-button:hover,
.dropdown-settings .dropdown-settings-button[aria-expanded="true"],
.user-menu-wrapper .user-details:hover,
.user-menu-wrapper .user-details[aria-expanded="true"],
.user-menu-wrapper .user-details:hover .user-avatar,
.user-menu-wrapper .user-details[aria-expanded="true"] .user-avatar {
    color: var(--color-primary);
}

.whats-new-badge {
    position: absolute;
    top: -.35rem;
    right: -.45rem;
    min-width: 1.1rem;
    padding: 0 .25rem;
    border-radius: .55rem;
    background: var(--color-primary);
    color: var(--body-bg);
    font-size: .65rem;
    font-weight: 600;
    line-height: 1.1rem;
    text-align: center;
    box-shadow: 0 0 0 2px var(--body-bg);
}

.whats-new-menu .dropdown-menu {
    min-width: 22rem;
    max-width: calc(100vw - 2rem);
}

/* A bell row: dot, title, date, then the eye that toggles read/unread. */
.whats-new-item {
    display: flex;
    align-items: center;
}

.whats-new-item .dropdown-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: 1;
    min-width: 0;
    white-space: normal;
}

.whats-new-dot {
    flex: none;
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
}

.whats-new-unread .whats-new-dot {
    background: var(--color-primary);
}

.whats-new-title {
    flex: 1;
}

.whats-new-date {
    flex: none;
    color: var(--text-muted);
    font-size: .8rem;
}

.whats-new-read-toggle {
    flex: none;
    margin-inline-end: .5rem;
    padding: .25rem .4rem;
    border: 0;
    border-radius: var(--border-radius);
    background: none;
    color: var(--dropdown-settings-icon-color);
}

.whats-new-read-toggle:hover {
    color: var(--color-primary);
    background: var(--dropdown-link-hover-bg);
}

/* On the page the eye carries its label. */
.whats-new-read-toggle-labelled {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    margin-inline-end: 0;
    font-size: .85rem;
}

.whats-new-unread .whats-new-title {
    font-weight: 600;
}

.whats-new-more,
.whats-new-empty {
    color: var(--text-muted);
    font-size: .85rem;
}

.whats-new-empty {
    margin: .5rem 1rem;
}

.whats-new-entry {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.whats-new-entry header {
    display: flex;
    align-items: baseline;
    gap: .75rem;
}

.whats-new-entry-title {
    margin: 0;
    font-size: 1.1rem;
}

/* Unread on the page: a primary bar at the start, until opened or marked. */
.whats-new-entry.whats-new-unread {
    padding-inline-start: .75rem;
    border-inline-start: 3px solid var(--color-primary);
}

.whats-new-entry-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: .5rem;
}

.whats-new-entry-actions:empty {
    display: none;
}

/* System notice banners, under the flash messages and on the login page. */
.notice-banners:empty {
    display: none;
}

.notice-banner {
    position: relative;
    padding-inline-end: 2.5rem;
}

.notice-banner .notice-dismiss {
    position: absolute;
    top: .75rem;
    inset-inline-end: .75rem;
}

.notice-banner .notice-event {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .25rem;
    font-weight: 600;
}

.notice-banner p:last-child {
    margin-bottom: 0;
}

.notice-more {
    margin-bottom: 1rem;
}

/* The notices page: like What's new, with dismissed notices dimmed. */
.notices-entry {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.notices-entry header {
    display: flex;
    align-items: baseline;
    gap: .75rem;
}

.notices-entry-title {
    margin: 0;
    font-size: 1.1rem;
}

.notices-entry-event {
    margin: .25rem 0 0;
    font-weight: 600;
}

.notices-entry-until {
    margin: .25rem 0 0;
    font-size: .85rem;
}

.notices-dismissed {
    opacity: .7;
}

/* The top bar's controls -- bell, history, settings, user menu -- are siblings in
   .navbar-custom-menu (see layout.html.twig); one gap spaces them evenly. Desktop only: below
   992px EasyAdmin hides this row and the mobile header carries them (further down). */
@media (min-width: 992px) {
    .content-top .navbar-custom-menu {
        display: flex;
        align-items: center;
        gap: 1.25rem;
    }

    .content-top .whats-new-bell,
    .content-top .history-top-bar {
        margin-inline-end: 0;
    }

    .content-top .dropdown-settings .dropdown-settings-button {
        padding-inline-start: 0;
    }
}

/* Every top-bar control is the same box: a 2rem-high flex row centring its glyph. Font Awesome
   glyphs (bell, history) and EasyAdmin's inline SVGs (gear, avatar) otherwise sit on different
   baselines and land up to 3px apart. */
@media (min-width: 992px) {
    .content-top .navbar-custom-menu > *,
    .content-top .navbar-custom-menu .dropdown-toggle,
    .content-top .navbar-custom-menu .icon,
    .content-top .navbar-custom-menu .user-avatar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .content-top .navbar-custom-menu > *,
    .content-top .navbar-custom-menu .dropdown-toggle {
        height: 2rem;
        padding-block: 0;
        line-height: 1;
    }

    .content-top .navbar-custom-menu .icon > svg,
    .content-top .navbar-custom-menu .icon > i {
        display: block;
    }
}

/* The mobile header: ☰, the title, then the same four controls in the desktop order. The bell
   and history arrive inside #responsive-header-logo (its block is the header's only slot), so
   that wrapper steps aside and flex order lines everything up. */
@media (max-width: 991.98px) {
    .responsive-header {
        gap: 1rem;
    }

    #responsive-header-logo {
        display: contents;
    }

    .responsive-header .responsive-logo,
    .responsive-header .ea-company-switcher-responsive {
        order: 1;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: center;
    }

    .responsive-header .whats-new-bell { order: 2; margin-inline-end: 0; }
    .responsive-header .history-top-bar { order: 3; margin-inline-end: 0; }
    .responsive-header .dropdown-settings { order: 4; }
    .responsive-header .user-menu-wrapper { order: 5; margin-inline-start: 0 !important; }

    .responsive-header .dropdown-settings .dropdown-settings-button {
        padding-inline-start: 0;
    }

    .responsive-header .whats-new-bell,
    .responsive-header .history-top-bar,
    .responsive-header .dropdown-settings,
    .responsive-header .user-menu-wrapper,
    .responsive-header .whats-new-bell .dropdown-toggle,
    .responsive-header .history-top-bar .dropdown-toggle,
    .responsive-header .dropdown-settings-button,
    .responsive-header .user-details,
    .responsive-header .whats-new-bell .icon,
    .responsive-header .history-top-bar .icon,
    .responsive-header .dropdown-settings-button .icon,
    .responsive-header .user-avatar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 2rem;
        padding-block: 0;
        line-height: 1;
    }
}
