/* Bookant — this app's own CSS. Loaded last, after Bootstrap, techwork-theme.css,
   techwork-components.css and techwork-shell.css, so it can override any of them.

   Keep it small: the family look, the tokens and the pattern classes come from the package
   (docs/design-system in TechWork.Components). Put screen-specific rules here, not copies of
   package rules — if a component needs a change, change the package. */

/* ── Re-brand (optional) ──
   Redefine the accent family once for light and once for dark; nothing else need change.
   Re-check 4.5:1 text contrast in both themes. Example (teal):

:root {
    --twc-color-primary: #0f766e;
    --twc-color-primary-hover: #115e59;
    --twc-color-primary-tint: rgba(15, 118, 110, 0.12);
    --twc-color-primary-tint-strong: rgba(15, 118, 110, 0.22);
    --twc-color-link: #0f766e;
}
[data-bs-theme="dark"] {
    --twc-color-primary: #2dd4bf;
    --twc-color-primary-hover: #5eead4;
    --twc-color-primary-tint: rgba(45, 212, 191, 0.14);
    --twc-color-primary-tint-strong: rgba(45, 212, 191, 0.24);
    --twc-color-link: #2dd4bf;
}
*/

/* ── Material Icons, self-hosted (the native shell may be offline) ── */
@font-face {
    font-family: "Material Icons";
    font-style: normal;
    font-weight: 400;
    src: url("../fonts/MaterialIcons-Regular.woff2") format("woff2");
    font-display: block;
}

.material-icons {
    font-family: "Material Icons";
    font-weight: normal;
    font-style: normal;
    font-size: 1.25rem;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    vertical-align: middle;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: "liga";
}

/* ── Brand in the rail ── */
.brand-logo {
    border-radius: 0.4rem;
}

.brand-name {
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Start-up splash, shown while the WebAssembly app downloads ── */
.app-loading {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--twc-color-muted);
    background: var(--twc-color-bg);
}

/* ── Items list ── */
.items-search {
    width: 16rem;
    max-width: 100%;
}

/* ── Item detail: the back link above the title ── */
.detail-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-bottom: 0.25rem;
    text-decoration: none;
}

/* ── Item detail: a reference and its copy button stay together ── */
.item-ref {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* ── Unhandled-error bar ── */
#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom) + var(--shell-tab-height, 0px));
    background: var(--twc-color-warning-bg);
    color: var(--twc-color-warning);
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
}

#blazor-error-ui .reload {
    margin-left: 0.5rem;
}

#blazor-error-ui .blazor-error-support {
    display: block;
    margin-top: 0.25rem;
    padding-right: 2.5rem;
}

#blazor-error-ui .blazor-error-support a {
    color: inherit;
}

/* ── Support line with a trace id (features/20 §6): ServerErrorBanner and ErrorPage. A trace id is ~55 characters
   with no break opportunity, so it may break anywhere rather than widen a 375px page; the copy button stays beside it. ── */
.support-trace-id {
    max-width: 100%;
    vertical-align: middle;
}

.support-trace-id code {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* The topbar's end holds the name, ThemeToggle, help "?" and Sign out; at phone widths a long name ("Platform Admin")
   pushed it 9px past 375px once the "?" joined (L-386). The name is on Profile, so phones drop it here. */
@media (max-width: 479.98px) {
    .topbar-username {
        display: none !important;
    }
}

.error-page {
    padding: 1rem 0;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 0.5rem;
    top: 0.25rem;
    min-width: 44px;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1.25rem;
}

/* ── Signed-out pages (AuthLayout, VerifyEmailWall): the package's .auth-layout / .auth-card frame ── */
.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.auth-brand-name {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.auth-card .twc-page-header {
    margin-bottom: 1rem;
}

.auth-card .btn,
.auth-card .form-control {
    min-height: 44px;
}

.auth-inline-link {
    padding-left: 0;
    padding-right: 0;
    text-decoration: none;
}

.auth-switch {
    margin: 1rem 0 0;
    text-align: center;
    color: var(--twc-color-muted);
}

.auth-footer {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    color: var(--twc-color-muted);
    font-size: 0.875rem;
}

.auth-footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.auth-retry {
    margin-top: 0.5rem;
}

/* ── Choose a company: one full-width row per company ── */
.select-tenant-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-align: start;
}

.select-tenant-name {
    flex: 1;
    font-weight: 600;
}

/* ── Profile → Security: the authenticator key stays with its copy button (R7) ── */
.two-factor-key {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.two-factor-key code {
    font-size: 1rem;
    word-break: break-all;
}

.two-factor-code {
    max-width: 12rem;
}

/* ── Profile → Security: the App lock switch, an iOS-sized toggle with a 44 px tap target (Stayant's) ── */
.app-lock-switch {
    width: 2.5rem;
    height: 1.5rem;
    margin-top: 0;
}

.app-lock-label {
    min-height: 44px;
    cursor: pointer;
}

/* ── Settings → Business: one Save for the page in a footer that stays in view (features/03 §6.1) ── */
.settings-form-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    display: flex;
    justify-content: flex-end;
    margin: 1.25rem -1.25rem -1.25rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--twc-color-border);
    border-radius: 0 0 var(--twc-radius-card) var(--twc-radius-card);
    background: var(--twc-color-card-bg);
}

.settings-form-footer .btn {
    min-height: 44px;
    min-width: 6rem;
}

/* The three "Where you work" options do not fit side by side at 375px: stack them, full width. */
@media (max-width: 575.98px) {
    .settings-business .segmented {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .settings-business .segmented-option {
        text-align: start;
    }

    .settings-business .segmented-option + .segmented-option {
        border-left: 0;
        border-top: 1px solid var(--twc-color-border-input);
    }
}

/* ── Settings → Team (features/03 §6.2) ── */
.settings-team-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

/* A member's Avatar beside their name and email. */
.team-person {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.team-person .twc-avatar {
    flex: none;
}

.rtable-primary-line .team-person {
    gap: 0.5rem;
}

.team-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.team-row-inactive .team-name .fw-medium {
    color: var(--twc-color-muted);
}

/* The invitations still waiting: one summary row each (R6), the actions beside the text. */
.team-invitation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--twc-color-border);
}

.team-invitation-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.team-invitation-actions {
    display: flex;
    gap: 0.5rem;
}

.team-invitation-actions .btn {
    min-height: 44px;
}

/* A dialog's own Save / Cancel row, and the quiet destructive action in a row of its own below it. */
.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.dialog-actions .btn,
.dialog-secondary-actions .btn {
    min-height: 44px;
    min-width: 6rem;
}

.dialog-secondary-actions {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--twc-color-border);
}

.team-colours .segmented-option {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* The category colour itself, big enough to tell the four apart. techwork-components.css (loaded after
   the theme) repaints every .status-dot muted at the same specificity, so the theme's
   .status-dot-category-N needs restating here. */
.team-colours .status-dot {
    width: 0.875rem;
    height: 0.875rem;
}

.team-colours .status-dot-category-1 { background: var(--twc-color-category-1); }
.team-colours .status-dot-category-2 { background: var(--twc-color-category-2); }
.team-colours .status-dot-category-3 { background: var(--twc-color-category-3); }
.team-colours .status-dot-category-4 { background: var(--twc-color-category-4); }

/* Four colours do not fit side by side at 375px: two by two. */
@media (max-width: 575.98px) {
    .team-colours {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .team-colours .segmented-option + .segmented-option {
        border-left: 0;
    }
}

/* The photo in TeamMemberDialog (features/03 §6.2): the member's Avatar beside PhotoPicker's buttons. */
.team-photo-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

/* ── Profile → Calendar's calendar link (features/17 §6.1): the address with its copy button (R7), the subscribe row
   and each team member's actions, all 44 px targets that wrap on a phone ── */
.calendar-feed-url {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calendar-feed-url .form-control {
    min-width: 0;
}

.calendar-feed-subscribe,
.calendar-team-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.calendar-feed-subscribe .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.calendar-team-actions {
    justify-content: flex-end;
}

@media (max-width: 575.98px) {
    .calendar-feed-subscribe .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .calendar-team-actions {
        justify-content: flex-start;
    }
}

/* ── Profile → Calendar (features/23 §6): one R6 row per calendar, its account and last sync muted under the name ── */
.calendar-sync-row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    text-align: start;
}

/* The status sits beside the name and wraps under it when Connect leaves no room (375). */
.calendar-sync-row-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.5rem;
}

.calendar-sync-row-status {
    font-weight: 400;
}

/* A calendar that isn't connected has nothing to open: full contrast, no chevron, just Connect beside it. */
.calendar-sync .twc-disclosure-toggle:disabled {
    opacity: 1;
    cursor: default;
}

.calendar-sync .twc-disclosure-toggle:disabled .twc-disclosure-chevron {
    visibility: hidden;
}

.calendar-sync-row-summary {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--twc-color-muted);
    overflow-wrap: break-word;
}

.calendar-sync-detail {
    max-width: 22rem;
}

/* The Team member dialog's Calendar card: one row per calendar, a quiet Disconnect beside a connected one. */
.team-member-calendar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.5rem 0;
}

.team-member-calendar + .team-member-calendar {
    border-top: 1px solid var(--twc-color-border);
}

.team-member-calendar-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.team-member-calendar .btn {
    min-height: 44px;
}

/* ── Settings → Services (features/04 §6.1): R6 rows with up / down buttons, one editor open ── */
.services-list {
    margin-top: 0.5rem;
}

.service-row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    text-align: start;
}

/* The toggle sets its own weight and colour; the summary line is muted body text (R6). */
.service-row-summary {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--twc-color-muted);
}

.service-row-moves {
    display: inline-flex;
    gap: 0.125rem;
}

.services-empty-template {
    display: flex;
    justify-content: center;
    margin-top: 0.75rem;
}

.services-empty-template .btn {
    min-height: 44px;
}

.service-deposit-value {
    max-width: 12rem;
}

.services-archived-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--twc-color-border);
}

.services-archived-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.services-archived-row .btn {
    min-height: 44px;
}

/* Four deposit choices and three places do not fit side by side at 375px: two by two, full width. */
@media (max-width: 575.98px) {
    .service-segmented {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .service-segmented .segmented-option + .segmented-option {
        border-left: 0;
    }
}

/* ── Customers (features/08 §6.1) ── */
.customers-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}

.customers-search {
    flex: 2 1 18rem;
}

.customers-team-filter {
    flex: 1 1 12rem;
    max-width: 18rem;
}

/* The booking form (features/07 §6.3): fields, then the summary beside them on a wide screen (sticky) or under them,
   right above Create, on a phone. */
.booking-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
}

@media (min-width: 992px) {
    .booking-form-grid {
        grid-template-columns: minmax(0, 1fr) 17rem;
        align-items: start;
    }

    .booking-form-summary {
        position: sticky;
        top: 1rem;
    }
}

.booking-form-section {
    margin-bottom: 1.5rem;
}

.booking-form-section:last-child {
    margin-bottom: 0;
}

.booking-form-legend {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.booking-form-extras {
    margin-top: 0.75rem;
}

.booking-form-extra {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.booking-form-time {
    max-width: 12rem;
}

/* Reschedule's "Keep the price" / "Use the new price": the words, then that total right-aligned (both totals shown). */
.booking-form-price-option {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    width: 100%;
}

.booking-form-price-option .ledger-figure {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.booking-form-summary {
    border: 1px solid var(--twc-color-border);
    border-radius: var(--twc-radius-card);
    padding: 1rem;
}

.booking-form-summary-list {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.25rem 0.75rem;
    margin-bottom: 1rem;
}

.booking-form-summary-list dt {
    font-weight: 500;
    color: var(--twc-color-text-muted, #6c757d);
}

.booking-form-summary-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* A reload dims the rows in place rather than swapping them for a spinner (the page keeps its height). */
.customers-grid-wrap.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.customer-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.customers-card .tabular-nums {
    font-variant-numeric: tabular-nums;
}

.customer-flag + .customer-flag {
    margin-left: 0.5rem;
}

.rtable-phone-row .customer-flag {
    margin-left: 0.5rem;
}

.customers-pager {
    margin-top: 1rem;
}

/* On phones the PhoneSearchBar above the card is the search, so the card's own row is only the team filter. */
@media (max-width: 767.98px) {
    .customers-filters:not(:has(.customers-team-filter)) {
        display: none;
    }

    .customers-team-filter {
        max-width: none;
    }
}

/* ── Bookings (features/07 §6.1) ── */
.bookings-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.bookings-search {
    flex: 2 1 18rem;
}

.bookings-team-filter {
    flex: 1 1 12rem;
    max-width: 18rem;
}

/* "Waiting for an earlier time" (features/25 §6): sits on the inputs' baseline. */
.bookings-waiting-filter {
    flex: 0 0 auto;
    margin-bottom: 0.375rem;
}

.bookings-filters .bookings-dates {
    flex: 1 1 100%;
}

.bookings-tabs {
    margin-bottom: 0.5rem;
}

/* A reload dims the rows in place rather than swapping them for a spinner (the page keeps its height). */
.bookings-grid-wrap.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* When: the first column fits its content (R9). */
.bookings-card td.bookings-when,
.booking-history td.bookings-when {
    width: 1%;
    white-space: nowrap;
}

.booking-when,
.booking-stack,
.booking-total {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.booking-total {
    align-items: flex-end;
}

.bookings-card .tabular-nums {
    font-variant-numeric: tabular-nums;
}

.booking-phone-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
}

.bookings-pager {
    margin-top: 1rem;
}

/* A customer's bookings on their detail (features/08 §6.2): "Coming up", then "Past". */
.booking-history-section + .booking-history-section {
    margin-top: 1.5rem;
}

.booking-history-title {
    margin-bottom: 0.5rem;
}

@media (max-width: 767.98px) {
    .bookings-team-filter {
        max-width: none;
    }
}

/* ── Booking detail (features/07 §6.2): head with the state action and More, then a card grid, customer first ── */
.booking-detail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.booking-detail-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.booking-detail-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.booking-detail-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 1rem;
}

/* R7: the reference and its copy button stay together when the line wraps. */
.booking-detail-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.booking-detail-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.booking-detail-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
    gap: 1rem;
    align-items: start;
}

.booking-detail .page-card {
    margin-bottom: 0;
}

.booking-detail .tabular-nums {
    font-variant-numeric: tabular-nums;
}

.booking-contact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.booking-contact-actions .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.booking-customer-notes {
    white-space: pre-line;
}

.booking-notes-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

@media (max-width: 575.98px) {
    .booking-detail-actions {
        width: 100%;
    }

    .booking-detail-actions .btn-tinted {
        flex: 1 1 auto;
        min-height: 44px;
    }
}

/* ── Customer detail (features/08 §6.2): head, summary card, Addresses and Notes tabs ── */
.customer-detail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.customer-detail-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.customer-detail-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.customer-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.customer-detail .page-card {
    margin-bottom: 0;
}

.customer-detail .tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* R7: the number and its copy button stay together when the value wraps. */
.customer-detail-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

/* features/22 §6: "Usually every 3 weeks · last visit 12 Oct · nothing booked" beside Book again; stacked on a phone. */
.customer-rebook {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.customer-rebook-text {
    min-width: 0;
}

.customer-address-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    text-align: start;
}

.customer-address-summary {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--twc-color-muted);
}

.customer-address-actions,
.customer-notes-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.customer-notes-actions {
    margin-top: 0.75rem;
}

/* Merge (§6.2): what stays beside what disappears; stacked on a phone. */
.merge-preview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.merge-preview .page-card {
    margin-bottom: 0;
}

@media (max-width: 575.98px) {
    .merge-preview {
        grid-template-columns: minmax(0, 1fr);
    }

    .customer-detail-actions {
        width: 100%;
    }

    .customer-detail-actions .btn {
        flex: 1 1 auto;
        min-height: 44px;
    }

    .customer-rebook .btn {
        flex: 1 1 100%;
        min-height: 44px;
    }
}

/* ── Settings → Travel pricing (features/05 §6.2): the "Try it" card's customer preview under a rule ── */
.travel-try-it-customer {
    border-top: 1px solid var(--twc-color-border);
}

/* ── Settings → Service area map (features/05 §6.1, §7.6): Leaflet + Geoman, vendored under lib/ ──
   Full width of its card and at most 60% of the screen tall, so the page always scrolls outside it; the card's
   own inset keeps it more than 16 px from the screen edges on a phone, so the iOS back pan and the Android back
   gesture never start inside the map. Every map control is a 44 px target. */
/* ── Settings → Service area (features/05 §6.1): the postcode field and its Check button on one line ── */
.service-area-check-row {
    display: flex;
    gap: 0.5rem;
    max-width: 24rem;
}

.service-area-check-row .btn {
    min-height: 44px;
}

.service-area-target .form-select {
    max-width: 24rem;
}

.service-area-map {
    height: min(60vh, 480px);
    width: 100%;
    border: 1px solid var(--twc-color-border);
    border-radius: var(--twc-radius-card);
    overflow: hidden;
    background: var(--twc-color-bg);
}

/* The demand card's read-only map (features/25 §6): shorter than the editor's, markers only. */
.area-demand-map .service-area-map {
    height: min(40vh, 320px);
}

/* .leaflet-container on the same element: leaflet.css is added after this file and sizes .leaflet-touch .leaflet-bar a. */
.service-area-map.leaflet-container .leaflet-bar a,
.service-area-map.leaflet-container .leaflet-pm-toolbar .leaflet-buttons-control-button {
    width: 44px;
    height: 44px;
    line-height: 44px;
}

.service-area-map.leaflet-container .leaflet-pm-toolbar .leaflet-buttons-control-button {
    padding: 9px;
}

.service-area-map.leaflet-container .button-container .leaflet-pm-actions-container .leaflet-pm-action {
    height: 44px;
    line-height: 44px;
}

/* Dark theme: the controls and the credit line on the app's own surfaces; the tiles stay as the provider draws them. */
[data-bs-theme="dark"] .service-area-map .leaflet-bar a,
[data-bs-theme="dark"] .service-area-map .leaflet-pm-toolbar .leaflet-buttons-control-button,
[data-bs-theme="dark"] .service-area-map .leaflet-control-attribution {
    background-color: var(--twc-color-card-bg);
    color: var(--bs-body-color);
    border-color: var(--twc-color-border);
}

[data-bs-theme="dark"] .service-area-map .leaflet-pm-toolbar .control-icon {
    filter: invert(1) brightness(1.6);
}

[data-bs-theme="dark"] .service-area-map .leaflet-control-attribution a {
    color: var(--bs-link-color);
}

/* ── Settings → Availability (features/06 §6.1): the working hours rows ──
   Desktop: one row a day (name, Open, start "to" end, Add break) with its breaks indented under it, rows ruled
   apart. Phones: each day is a Disclosure row and its editor stacks; the times stay side by side. */
.availability-target .form-select {
    max-width: 24rem;
}

.hours-day {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--twc-color-border);
}

.hours-day-row,
.hours-break {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem 1rem;
}

.hours-day-row > .hours-day-name {
    width: 7rem;
    padding-top: 0.5rem;
}

.hours-day-row > .hours-open,
.hours-day-row > .hours-closed {
    padding-top: 0.5rem;
}

.hours-open {
    min-width: 5rem;
}

.hours-closed {
    color: var(--twc-color-subtle);
}

.hours-times {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.hours-time .form-control {
    width: 8rem;
    min-height: 44px;
}

.hours-to {
    padding-top: 0.6rem;
    color: var(--twc-color-muted);
}

.hours-break {
    margin-top: 0.5rem;
    padding-left: 8rem;
}

.hours-break-label {
    min-width: 5rem;
    padding-top: 0.6rem;
    color: var(--twc-color-muted);
}

.hours-add-break,
.hours-remove-break {
    min-height: 44px;
}

.hours-day-editor {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}

.hours-day-editor .hours-break {
    margin-top: 0;
    padding-left: 0;
}

@media (max-width: 900px) {
    .hours-time .form-control {
        width: 7.5rem;
    }
}

/* ── Settings → Availability: the time off card ──
   The heading with "Add time off" beside it (wrapping under it on a phone); the When cell with the reason folded
   under (R9); Edit and Delete side by side at the row's end, and under the reason in a phone row. The form's
   two dates or two times sit side by side. */
.settings-availability > .page-card + .page-card,
.settings-payments > .page-card + .page-card,
.settings-reviews > .page-card + .page-card {
    margin-top: 1.5rem;
}

.timeoff-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.timeoff-calendar-filter {
    margin-bottom: 0.75rem;
}

.timeoff-when {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.timeoff-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem;
}

.timeoff-actions .btn {
    min-height: 44px;
}

.timeoff-phone-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timeoff-phone-row > .tag-quiet {
    align-self: flex-start;
    margin-bottom: 0.5rem;
}

.timeoff-phone-row .timeoff-actions {
    justify-content: flex-start;
    margin-left: -0.5rem;
}

.timeoff-pager {
    margin-top: 1rem;
}

.timeoff-range {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1rem;
}

/* ── Booking payments card (features/14 §6.2): summary line, payment rows, pay link field ── */
.booking-payments-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.booking-payments-actions,
.booking-payment-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* On a phone a row's Remove and Refund drop under it, so the description keeps the width. */
@media (max-width: 575.98px) {
    .booking-payment {
        flex-wrap: wrap;
    }

    .booking-payment-actions {
        flex-basis: 100%;
        justify-content: flex-end;
    }
}

.booking-payments-head .btn,
.booking-payment-refund,
.booking-payment-remove {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.booking-payments-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    margin-bottom: 0.75rem;
}

.booking-payments-dot {
    color: var(--bs-secondary-color);
}

.booking-payments-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.booking-payment {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--bs-border-color);
}

.booking-payment-icon {
    color: var(--bs-secondary-color);
    margin-top: 0.125rem;
}

.booking-payment-main {
    flex: 1 1 auto;
    min-width: 0;
}

.booking-payment-line {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.booking-payment-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
}

/* features/22 §6: the repeat dialog. The visits' count or last date sits under its radio; each date row keeps its
   status dot and reason beside the date and wraps under it on a phone. */
.repeat-ends-field {
    margin: 0.25rem 0 0.75rem 1.75rem;
    max-width: 16rem;
}

.repeat-date-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    min-width: 0;
}

.booking-paylink-url {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.booking-paylink-url .form-control {
    min-width: 0;
    font-size: 0.875rem;
}

/* ── Global admin → Tenants (features/18 §6): the filter card, the detail's reference, actions and Members card ── */
.admin-tenants-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}

.admin-tenants-search {
    flex: 2 1 18rem;
}

.admin-tenants-filter {
    flex: 1 1 10rem;
    max-width: 16rem;
}

.admin-tenants-grid-wrap.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.admin-tenants-pager {
    margin-top: 1rem;
}

.admin-tenant-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Scheduled tasks: how many days back Run now goes, for a task that backfills (features/24 §7). */
.admin-task-days {
    width: 5.5rem;
    flex: 0 0 auto;
}

.admin-tenant-reference {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: -0.5rem 0 1rem;
}

.admin-tenant-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.admin-member-role {
    min-width: 9rem;
    max-width: 12rem;
}

.admin-member-phone-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-top: 0.5rem;
}

@media (max-width: 767.98px) {
    .admin-tenants-filter {
        max-width: none;
    }
}

/* A global admin inside an entered tenant (features/18 §6): above every page, the way back on the right. */
.entered-tenant-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.entered-tenant-banner-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* A company whose deletion is pending (features/19 §6): every member sees the date; an owner can cancel. */
.tenant-deletion-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.tenant-deletion-banner-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Updated terms to accept (features/19 §4.5, §6): above every page until the person accepts them. */
.legal-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.legal-banner-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* A legal document in the viewer: the server's HTML, readable at any width. */
.legal-accept-doc + .legal-accept-doc {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--bs-border-color);
}

.legal-doc-body {
    overflow-wrap: anywhere;
}

.legal-doc-body h1 {
    display: none;
}

.legal-doc-body h2 {
    font-size: 1.05rem;
    margin-top: 1.5rem;
}

.legal-doc-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.legal-doc-body th,
.legal-doc-body td {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--bs-border-color);
    vertical-align: top;
}

.legal-doc-body blockquote {
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--bs-warning);
    background: var(--bs-tertiary-bg);
}

.legal-doc-body blockquote p:last-child {
    margin-bottom: 0;
}

/* Global admin → Activity (features/18 §6): the person and tenant pickers take the search's room; dates on their own line. */
.admin-activity-pick {
    flex: 2 1 14rem;
    max-width: 20rem;
}

.admin-tenants-filters .admin-activity-dates {
    flex: 1 1 100%;
}

@media (max-width: 767.98px) {
    .admin-activity-pick {
        max-width: none;
    }
}

/* Global admin → Dashboard, the sign-up funnel (features/18 §6): the source select beside the heading, the share under
   each count, and the cell shaded in the accent's one hue by its share (R4). */
.signup-funnel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
}

.signup-funnel-filter {
    min-width: 12rem;
}

/* Eight columns: a narrow desktop scrolls the table inside the card, not the page. */
.signup-funnel-grid {
    overflow-x: auto;
}

.signup-funnel-grid.is-loading {
    opacity: 0.55;
    transition: opacity 0.1s ease-in;
}

.signup-funnel-cell {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 3.5rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--twc-radius-sm);
    line-height: 1.2;
}

.signup-funnel-pct {
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

.funnel-shade-1 { background: color-mix(in srgb, var(--twc-color-primary) 4%, transparent); }
.funnel-shade-2 { background: color-mix(in srgb, var(--twc-color-primary) 7%, transparent); }
.funnel-shade-3 { background: color-mix(in srgb, var(--twc-color-primary) 10%, transparent); }
.funnel-shade-4 { background: color-mix(in srgb, var(--twc-color-primary) 13%, transparent); }
.funnel-shade-5 { background: color-mix(in srgb, var(--twc-color-primary) 16%, transparent); }
.funnel-shade-6 { background: color-mix(in srgb, var(--twc-color-primary) 19%, transparent); }
.funnel-shade-7 { background: color-mix(in srgb, var(--twc-color-primary) 22%, transparent); }
.funnel-shade-8 { background: color-mix(in srgb, var(--twc-color-primary) 25%, transparent); }
.funnel-shade-9 { background: color-mix(in srgb, var(--twc-color-primary) 28%, transparent); }
.funnel-shade-10 { background: color-mix(in srgb, var(--twc-color-primary) 32%, transparent); }

@media (max-width: 767.98px) {
    .signup-funnel-filter {
        width: 100%;
    }

    /* A week on a phone: "Paid ........ 3  60%" per milestone. */
    .signup-funnel-phone-steps {
        display: grid;
        gap: 0.125rem;
        margin-top: 0.375rem;
        font-size: 0.875rem;
    }

    .signup-funnel-phone-step {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .signup-funnel-phone-step .signup-funnel-cell {
        flex-direction: row;
        align-items: baseline;
        gap: 0.5rem;
    }

    .signup-funnel-phone-step .signup-funnel-pct {
        min-width: 3rem;
        text-align: right;
    }
}

/* ── Global admin → Help feedback (features/20 §6): the article filter and the % helpful meter ── */
.admin-help-feedback-article {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
}

.admin-help-feedback-meter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 8rem;
}

.admin-help-feedback-meter .progress {
    flex: 1 1 auto;
    height: 0.5rem;
}

.admin-help-feedback-meter .tabular-nums {
    min-width: 2.75rem;
    text-align: end;
}

/* ── Activation checklist on Today (features/01 §6): one-hue meter (R4) and rows (R6) with 44 px targets ── */
.activation-card {
    margin-bottom: 1rem;
}

.activation-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.activation-hide {
    padding-inline: 0;
    color: var(--twc-color-subtle);
}

.activation-meter {
    height: 0.5rem;
    margin-top: 0.75rem;
}

.activation-rows {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.activation-rows > li + li {
    border-top: 1px solid var(--twc-color-border);
}

.activation-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
    padding: 0.5rem 0;
    color: inherit;
    text-decoration: none;
}

a.activation-row:hover .activation-row-title {
    text-decoration: underline;
}

.activation-row-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.activation-row-title {
    font-weight: 500;
}

.activation-row-hint {
    font-size: 0.845rem;
    color: var(--twc-color-subtle);
}

.activation-optional {
    margin-inline-start: 0.4rem;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--twc-color-subtle);
}

.activation-chevron {
    color: var(--twc-color-subtle);
}

/* A row without a link keeps its status in line with the linked rows' (the chevron's width). */
div.activation-row::after {
    content: "";
    flex: 0 0 24px;
}

/* ── Onboarding wizard (features/01 §6) on the package's WizardLayout ── */
.onboarding-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.onboarding-header-sub {
    font-size: 0.875rem;
}

.onboarding-step-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.onboarding-step .service-area-map {
    height: min(45vh, 360px);
}

/* "Your services": a starter row (tick, name, time, price) per service or extra, one line on desktop, two on phones. */
.onboarding-choice-heading {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.onboarding-choice-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--twc-color-border);
}

.onboarding-choice-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem 1rem;
    min-height: 44px;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--twc-color-border);
}

.onboarding-choice-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.onboarding-choice-name .form-check-input {
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
}

.onboarding-choice-label {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.onboarding-choice-fields {
    display: grid;
    /* The price column fits MoneyInput's 6.5rem amount and its £. */
    grid-template-columns: 8.5rem 8.75rem;
    gap: 0.5rem;
}

.onboarding-choice-row.is-off .onboarding-choice-label {
    color: var(--twc-color-muted);
}

.onboarding-choice-error {
    grid-column: 1 / -1;
}

.onboarding-choice-error .invalid-feedback {
    margin-top: 0;
}

@media (max-width: 575.98px) {
    .onboarding-choice-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .onboarding-choice-fields {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        padding-left: 2rem;
    }
}

/* "Get the app" and "Done": store buttons, the booking link with its copy button, and the share row (44 px targets). */
.onboarding-store-links,
.onboarding-share-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.onboarding-store-links .btn,
.onboarding-share-row .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.onboarding-done-hero {
    font-size: 1.125rem;
    font-weight: 600;
}

.onboarding-done-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.onboarding-done-link .form-control {
    min-width: 0;
}

@media (max-width: 575.98px) {
    .onboarding-share-row .btn {
        flex: 1 1 0;
        justify-content: center;
    }
}

/* ── Settings → Reviews (features/22 §6): the Google review link with "Open link" beside it, and a private
   comment shown on at most two lines (R9; the whole comment is its title). ── */
.reviews-url-row {
    display: flex;
    gap: 0.5rem;
}

.reviews-url-row .btn {
    flex: none;
    min-height: 44px;
}

.reviews-comment {
    display: -webkit-box;
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* Insights (features/24 §6): the filter card's period buttons, dates and team member side by side, wrapping on a phone;
   Takings as the hero beside the strip of small figures (one column on a phone, where the strip is two figures a row);
   the Overview's ledger beside the series; the Services share as a one-hue bar with its percentage (R4). */
.insights-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.insights-period {
    flex-wrap: wrap;
}

.insights-filters .insights-dates {
    flex: 1 1 18rem;
}

.insights-member {
    flex: 0 1 14rem;
}

.insights-summary {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.insights-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.insights-body.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.insights-grid {
    display: grid;
    gap: 1rem;
}

.insights-share {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 8rem;
}

.insights-share .progress {
    flex: 1 1 auto;
    height: 0.5rem;
}

.insights-share-figure {
    min-width: 2.75rem;
    text-align: end;
}

@media (min-width: 768px) {
    .insights-strip {
        grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    }
}

@media (min-width: 1200px) {
    .insights-summary {
        grid-template-columns: minmax(14rem, 1fr) minmax(0, 3fr);
    }

    .insights-grid {
        grid-template-columns: minmax(16rem, 1fr) minmax(0, 2fr);
        align-items: start;
    }
}

.insights-strip > div > .kpi {
    height: 100%;
}

/* Today (features/16 §6.1): "Whose day" beside the title at its natural width; the totals' hero over its ledger; the
   now-line and stops come from DayAgenda's own block. */
.today-operator {
    width: auto;
    min-width: 10rem;
    max-width: 100%;
}

.today-totals .hero-figure {
    margin-bottom: 0.75rem;
}

/* Today's week (features/16 §6.2): one day under another on a phone; from 900px seven equal columns (minmax(0, 1fr), so
   a long name ellipsizes in the compact agenda instead of widening the page at 1024). Each day's heading is a link to
   that day, at least 44px tall; today's card carries the primary rule. */
.today-view-tabs > .twc-tab-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    padding-top: 1rem;
}

.today-week {
    display: grid;
    gap: 0.75rem;
}

.today-week-totals {
    color: var(--twc-color-muted);
}

.today-week-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
}

.today-week-day {
    padding: 0.75rem;
    min-width: 0;
    scroll-margin-top: calc(var(--shell-safe-top, 0px) + 1rem);
}

.today-week-day.is-today {
    border-top: 3px solid var(--twc-color-primary);
}

.today-week-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 0.5rem;
    min-height: 44px;
    margin-bottom: 0.5rem;
    color: var(--twc-color-text);
    text-decoration: none;
}

.today-week-heading:hover .today-week-date,
.today-week-heading:focus-visible .today-week-date {
    text-decoration: underline;
}

.today-week-date {
    font-weight: 600;
}

.today-week-sums {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0 0.5rem;
    font-size: 0.875rem;
    color: var(--twc-color-muted);
}

@media (min-width: 900px) {
    .today-week-grid {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 0.5rem;
    }

    .today-week-day {
        padding: 0.5rem;
    }

    .today-week-heading {
        flex-direction: column;
        align-items: flex-start;
    }
}
