/*
 * Phone layout for MudTable rows.
 * Applies to every table that stacks on small screens (MudTable Breakpoint="Breakpoint.Sm" -> .mud-sm-table):
 * each record becomes a card with alternating backgrounds and a coloured accent bar, label on the left, value on the right.
 */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table {
        background: transparent;
        box-shadow: none;
    }

    .mud-table.mud-sm-table .mud-table-container {
        overflow: visible;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row {
        background: var(--mud-palette-surface);
        border-left: 5px solid var(--mud-palette-primary);
        border-radius: 14px;
        box-shadow: 0 1px 5px rgba(0, 0, 0, .14);
        display: block;
        margin: 0 0 12px;
        overflow: hidden;
    }

    /* strip colours: odd = surface + primary bar, even = tinted + teal bar */
    .mud-table.mud-sm-table tbody tr.mud-table-row:nth-child(odd) {
        background: var(--mud-palette-surface);
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row:nth-child(even) {
        background: rgba(89, 74, 226, .09);
        border-left-color: #14b8c4;
    }

    /* Cells with a caption (MudTd DataLabel="...") become a label/value row. */
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label]:not([data-label=""]) {
        align-items: center;
        border-bottom: 1px solid rgba(128, 128, 128, .15);
        display: flex;
        gap: 12px;
        justify-content: space-between;
        padding: 9px 14px;
        text-align: right !important;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label]:not([data-label=""]):last-child {
        border-bottom: 0;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label]:not([data-label=""])::before {
        color: var(--mud-palette-text-secondary);
        content: attr(data-label);
        flex: 0 0 38%;
        font-size: .75rem;
        font-weight: 500;
        text-align: left;
    }

    /* No caption set (MudTd has no DataLabel): keep the plain default MudBlazor stacked layout,
       just block-level and left-aligned, so cells don't collapse to nothing or show a blank label. */
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell:not([data-label]:not([data-label=""])) {
        border-bottom: 1px solid rgba(128, 128, 128, .15);
        display: block;
        padding: 6px 14px;
        text-align: left !important;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell:not([data-label]:not([data-label=""])):last-child {
        border-bottom: 0;
    }
}

/*
 * Compact rows: show only the first 3 fields (plus any action buttons) at a glance;
 * tap the card (js/mobile-rows.js toggles .br-open) to see everything.
 */
@media (max-width: 959.95px) {
    /* Everything below (expand/collapse, chevron) only makes sense once cells have captions to summarize. */
    .mud-table.mud-sm-table tbody tr.mud-table-row:has(td.mud-table-cell[data-label]:not([data-label=""])) {
        cursor: pointer;
        position: relative;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label]:not([data-label=""]) {
        padding: 6px 40px 6px 14px;
    }

    /* hide detail fields until the card is opened; keep summary fields and cells holding buttons */
    .mud-table.mud-sm-table tbody tr.mud-table-row:not(.br-open) td.mud-table-cell[data-label]:not([data-label=""]):nth-child(n+4):not(:has(button.mud-button-root, a.mud-button-root)) {
        display: none;
    }

    /* the last visible cell must not show a divider when the rest is collapsed */
    .mud-table.mud-sm-table tbody tr.mud-table-row:not(.br-open) td.mud-table-cell[data-label]:not([data-label=""]):nth-child(3) {
        border-bottom: 0;
    }

    /* details chevron */
    .mud-table.mud-sm-table tbody tr.mud-table-row:has(td.mud-table-cell[data-label]:not([data-label=""]))::after {
        border-bottom: 2px solid var(--mud-palette-text-secondary);
        border-right: 2px solid var(--mud-palette-text-secondary);
        content: "";
        height: 8px;
        pointer-events: none;
        position: absolute;
        right: 16px;
        top: 16px;
        transform: rotate(45deg);
        transition: transform .15s;
        width: 8px;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-open::after {
        transform: rotate(225deg);
    }

    /* buttons inside a cell must stay tappable and not toggle the card visually */
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell .mud-button-root {
        cursor: pointer;
    }
}

/* row-number columns are noise on a phone card; show one more field in the summary instead */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="No"],
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Id"],
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="#"],
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="S/N"] {
        display: none;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row:not(.br-open):has(> td:is([data-label="No"],[data-label="Id"],[data-label="#"],[data-label="S/N"]):first-child) td.mud-table-cell:nth-child(4):not(:has(button.mud-button-root, a.mud-button-root)) {
        display: flex;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row:not(.br-open):has(> td:is([data-label="No"],[data-label="Id"],[data-label="#"],[data-label="S/N"]):first-child) td.mud-table-cell:nth-child(3) {
        border-bottom: 1px solid rgba(128, 128, 128, .15);
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row:not(.br-open):has(> td:is([data-label="No"],[data-label="Id"],[data-label="#"],[data-label="S/N"]):first-child) td.mud-table-cell:nth-child(4) {
        border-bottom: 0;
    }
}

/* Collapsible filter area (Shared/MobileCollapse.razor): desktop shows the body only, phones get a collapsed bar */
.br-collapse-toggle {
    display: none;
}

@media (max-width: 959.95px) {
    .br-collapse {
        margin-bottom: 12px;
    }

    .br-collapse-toggle {
        align-items: center;
        background: var(--mud-palette-surface);
        border: 1px solid rgba(128, 128, 128, .3);
        border-radius: 12px;
        color: var(--mud-palette-text-primary);
        cursor: pointer;
        display: flex;
        font: inherit;
        font-weight: 500;
        gap: 8px;
        justify-content: space-between;
        padding: 10px 14px;
        width: 100%;
    }

    .br-collapse-toggle > span {
        flex: 1;
        text-align: left;
    }

    .br-collapse:not(.br-open) > .br-collapse-body {
        display: none;
    }

    .br-collapse.br-open > .br-collapse-body {
        margin-top: 8px;
    }

    /* the filter card inside already carries its own bottom margin */
    .br-collapse > .br-collapse-body > .mud-paper {
        margin-bottom: 0 !important;
    }

    /* Reload is not needed on a phone */
    button[title="Reload"],
    .mud-icon-button[title="Reload"] {
        display: none !important;
    }
}

/* Native-style bottom tab bar (Shared/MobileBottomNav.razor) */
.br-bottom-nav,
.br-bottom-nav-spacer {
    display: none;
}

@media (max-width: 959.95px) {
    .br-bottom-nav {
        background: var(--mud-palette-surface);
        border-top: 1px solid rgba(128, 128, 128, .25);
        bottom: 0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, .12);
        display: flex;
        justify-content: space-around;
        left: 0;
        padding-bottom: env(safe-area-inset-bottom);
        position: fixed;
        right: 0;
        z-index: 1200;
    }

    .br-bottom-nav-spacer {
        display: block;
        height: calc(68px + env(safe-area-inset-bottom));
    }

    .br-bottom-nav .br-tab {
        align-items: center;
        background: none;
        border: 0;
        color: var(--mud-palette-text-secondary);
        cursor: pointer;
        display: flex;
        flex: 1;
        flex-direction: column;
        font: inherit;
        font-size: .68rem;
        gap: 2px;
        justify-content: center;
        min-height: 60px;
        padding: 6px 2px;
        text-decoration: none;
    }

    .br-bottom-nav .br-tab.active {
        color: var(--mud-palette-primary);
        font-weight: 600;
    }

    .br-bottom-nav .br-tab-primary .mud-icon-root {
        color: var(--mud-palette-primary);
        font-size: 2.1rem;
    }
}

/* Comfortable touch targets: small icon buttons/buttons get a 40px hit area on phones */
@media (max-width: 959.95px) {
    .mud-icon-button.mud-icon-button-size-small {
        min-height: 40px;
        min-width: 40px;
    }

    .mud-button-root.mud-button-size-small {
        min-height: 36px;
    }
}

/* List/card view switch: pointless where the table already stacks into cards, so hide it only on those pages */
@media (max-width: 959.95px) {
    .mud-main-content:has(.mud-sm-table) .mud-icon-button[title="Card view" i],
    .mud-main-content:has(.mud-sm-table) .mud-icon-button[title="List view" i] {
        display: none !important;
    }
}

/*
 * Sessions calendar (Pages/Features/Session/SessionCalendarGrid.razor): on phones the 7-column week grid becomes a
 * vertical day-by-day agenda; the Month toggle is hidden (a 7-column month grid does not fit a phone).
 * Selectors are deliberately specific to win over the component's own <style>.
 */
@media (max-width: 959.95px) {
    .sess-mode-switch {
        display: none !important;
    }

    .sess-calendar-table-wrap table.sess-week-table,
    .sess-calendar-table-wrap table.sess-week-table tbody,
    .sess-calendar-table-wrap table.sess-week-table tr {
        display: block;
        min-width: 0;
        width: 100%;
    }

    .sess-calendar-table-wrap table.sess-week-table thead {
        display: none;
    }

    .sess-calendar-table-wrap table.sess-week-table td {
        border: 0;
        border-bottom: 1px solid rgba(128, 128, 128, .2);
        display: block;
        min-width: 0 !important;
        padding: 12px 14px;
        text-align: left;
        width: 100%;
    }

    .sess-calendar-table-wrap table.sess-week-table td:last-child {
        border-bottom: 0;
    }

    .sess-calendar-table-wrap table.sess-week-table td::before {
        color: var(--mud-palette-primary);
        content: attr(data-day);
        display: block;
        font-size: .85rem;
        font-weight: 700;
        margin-bottom: 8px;
    }

    .sess-calendar-table-wrap table.sess-week-table td:not(:has(.sess-block))::after {
        color: var(--mud-palette-text-secondary);
        content: "No sessions";
        font-size: .8rem;
    }

    .sess-calendar-table-wrap table.sess-week-table .sess-day-cell-inner {
        align-items: stretch;
        min-height: 0;
    }

    .sess-calendar-table-wrap table.sess-week-table .sess-block {
        align-items: center;
        display: flex;
        font-size: .85rem;
        gap: 10px;
        justify-content: space-between;
        padding: 10px 12px;
    }

    .sess-calendar-table-wrap table.sess-week-table .sess-block-patient {
        text-align: right;
    }
}

/* Calendar header on phones: [<]  date range  [>] on one row, "This week" pill centred below */
@media (max-width: 959.95px) {
    .sess-nav {
        align-items: center;
        display: grid !important;
        gap: 6px 4px !important;
        grid-template-columns: auto 1fr auto;
        width: 100%;
    }

    .sess-nav > :nth-child(1) { grid-column: 1; grid-row: 1; }
    .sess-nav > :nth-child(3) { grid-column: 2; grid-row: 1; justify-content: center; }
    .sess-nav > :nth-child(4) { grid-column: 3; grid-row: 1; }
    .sess-nav > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
}

/* Forms on phones: bigger fields, and chip sets (e.g. booking time slots) as a 3-column grid of 40px chips */
@media (max-width: 959.95px) {
    .mud-main-content .mud-input > .mud-input-slot.mud-input-root {
        padding-bottom: 11px;
        padding-top: 11px;
    }

    .mud-main-content .mud-chipset {
        display: grid !important;
        gap: 8px;
        grid-template-columns: repeat(3, 1fr);
    }

    .mud-main-content .mud-chipset .mud-chip {
        justify-content: center;
        margin: 0;
        min-height: 40px;
    }
}

/* Money fields are what people look for: always show them in the collapsed card; buttons in cards get a real tap size */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Balance Due"],
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Balance"],
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Amount"],
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Amount To Pay"] {
        display: flex !important;
        font-weight: 600;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell .mud-button-root {
        min-height: 38px;
    }
}

/* Expandable cards (e.g. client packages): summary always, details on tap. Desktop shows everything, no summary line. */
.br-pkg-summary {
    display: none;
}

@media (max-width: 959.95px) {
    .br-expandable {
        cursor: pointer;
        position: relative;
    }

    .br-expandable .br-pkg-summary {
        display: block;
        margin-bottom: 4px;
    }

    .br-expandable:not(.br-open) .br-details {
        display: none;
    }

    .br-expandable::after {
        border-bottom: 2px solid var(--mud-palette-text-secondary);
        border-right: 2px solid var(--mud-palette-text-secondary);
        bottom: 12px;
        content: "";
        height: 8px;
        pointer-events: none;
        position: absolute;
        right: 16px;
        transform: rotate(45deg);
        transition: transform .15s;
        width: 8px;
    }

    .br-expandable.br-open::after {
        transform: rotate(225deg);
    }
}

/*
 * Working Hours / shifts calendar (Pages/Features/TherapistAvailability/ShiftCalendar.razor): same day-by-day agenda
 * treatment as the sessions calendar. The therapist/summary label cell becomes a heading row above each therapist's days.
 */
@media (max-width: 959.95px) {
    .shift-calendar-table-wrap table.shift-week-table,
    .shift-calendar-table-wrap table.shift-week-table tbody,
    .shift-calendar-table-wrap table.shift-week-table tr {
        display: block;
        min-width: 0;
        width: 100%;
    }

    .shift-calendar-table-wrap table.shift-week-table colgroup,
    .shift-calendar-table-wrap table.shift-week-table thead {
        display: none;
    }

    .shift-calendar-table-wrap table.shift-week-table td {
        border: 0;
        border-bottom: 1px solid rgba(128, 128, 128, .2);
        display: block;
        min-width: 0 !important;
        padding: 12px 14px;
        text-align: left;
        width: 100%;
    }

    .shift-calendar-table-wrap table.shift-week-table td.shift-label-col {
        background: rgba(89, 74, 226, .08);
        font-weight: 600;
        padding: 10px 14px;
    }

    .shift-calendar-table-wrap table.shift-week-table td[data-day]::before {
        color: var(--mud-palette-primary);
        content: attr(data-day);
        display: block;
        font-size: .85rem;
        font-weight: 700;
        margin-bottom: 8px;
    }

    .shift-calendar-table-wrap table.shift-week-table td[data-day]:not(:has(.shift-block))::after {
        color: var(--mud-palette-text-secondary);
        content: "No shift";
        font-size: .8rem;
    }

    .shift-calendar-table-wrap table.shift-week-table .shift-day-cell-inner {
        align-items: stretch;
        min-height: 0;
    }

    .shift-calendar-table-wrap table.shift-week-table .shift-block {
        padding: 10px 12px;
    }

    .shift-calendar-table-wrap table.shift-week-table .shift-block-time,
    .shift-calendar-table-wrap table.shift-week-table .shift-block-break-label,
    .shift-calendar-table-wrap table.shift-week-table .shift-block-break-time {
        text-align: left;
    }
}

/* Nested cards/panels each add their own padding; on a phone that leaves ~60% of the width. Tighten the layers. */
@media (max-width: 959.95px) {
    .mud-main-content > .mud-container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .mud-main-content .mud-expand-panel-content.mud-expand-panel-gutters {
        padding: 8px 12px;
    }

    .mud-main-content .mud-paper.pa-4 {
        padding: 12px !important;
    }
}

/* Numeric field spinner arrows are tiny; people type numbers on a phone */
@media (max-width: 959.95px) {
    .mud-main-content .mud-input-numeric-spin,
    .mud-dialog .mud-input-numeric-spin {
        display: none;
    }
}

/* Dialog action buttons (Cancel / Save / Update) get a comfortable tap size */
@media (max-width: 959.95px) {
    .mud-dialog .mud-dialog-actions .mud-button-root {
        min-height: 42px;
    }
}

/* Table pager ("Rows per page", range, arrows) wraps and centres instead of running off the screen */
@media (max-width: 959.95px) {
    .mud-table-pagination-toolbar {
        flex-wrap: wrap;
        height: auto;
        justify-content: center;
        min-height: 52px;
        row-gap: 4px;
    }

    .mud-table.mud-sm-table td.mud-table-cell a.mud-link {
        align-items: center;
        display: inline-flex;
        min-height: 32px;
    }
}

/* Table toolbar (search + filter selects + buttons) wraps: each control takes a full row instead of overflowing */
@media (max-width: 959.95px) {
    .mud-table-toolbar {
        flex-wrap: wrap;
        gap: 8px;
        height: auto;
        min-height: 56px;
        padding-bottom: 8px;
        padding-top: 8px;
    }

    .mud-table-toolbar > .mud-input-control,
    .mud-table-toolbar > .mud-select {
        flex: 1 1 100%;
        margin: 0;
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .mud-table-toolbar > .mud-toolbar-spacer,
    .mud-table-toolbar > .mud-spacer {
        display: none;
    }
}

/* MobileCollapse wrappers are invisible on desktop (their children lay out as if the wrapper were not there) */
.br-collapse,
.br-collapse-body {
    display: contents;
}

@media (max-width: 959.95px) {
    .br-collapse {
        display: block;
        width: 100%;
    }

    .br-collapse-body {
        display: block;
    }

    .br-collapse:not(.br-open) > .br-collapse-body {
        display: none;
    }

    .br-collapse-body > .mud-input-control,
    .br-collapse-body > .mud-select {
        margin: 0 0 8px;
        max-width: 100%;
        width: 100%;
    }
}

/*
 * Tenant / Branch admin dashboards. The scoped component CSS hard-codes widths that add up to more than a phone screen;
 * these !important rules only apply on phones.
 */
@media (max-width: 959.95px) {
    /* branch selector: was a fixed 280px on every part of the control */
    body .mud-main-content .tenant-admin-dashboard-branch,
    body .mud-main-content .tenant-admin-dashboard-branch .mud-input-control,
    body .mud-main-content .tenant-admin-dashboard-branch .mud-input-control-input-container,
    body .mud-main-content .tenant-admin-dashboard-branch .mud-select,
    body .mud-main-content .tenant-admin-dashboard-branch .mud-input-root,
    body .mud-main-content .tenant-admin-dashboard-branch .mud-input-slot,
    body .mud-main-content .tenant-admin-dashboard-branch .mud-select-input {
        flex: 1 1 auto !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    body .mud-main-content .tenant-admin-dashboard-branch .mud-input-adornment {
        flex: 0 0 auto !important;
        width: auto !important;
    }

    /* chart legend wraps */
    .branch-stats__legend {
        flex-wrap: wrap !important;
        gap: 6px 14px !important;
        padding: 8px 12px 12px !important;
    }

    /* week day strip: seven equal columns instead of fixed 40px tiles + a 74px selected pill */
    .branch-appt__days {
        gap: 4px !important;
        grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    }

    .branch-appt__day {
        max-width: 44px;
        width: 100% !important;
    }

    .branch-appt__day.is-selected {
        justify-content: center !important;
        padding-left: 0 !important;
        width: 100% !important;
    }

    .branch-appt__day.is-selected::after {
        display: none !important;
    }
}

/* Admin dashboards on phones: date-range / branch filter row wraps; KPI cards are compact 2x2 tiles (no chart/range text) */
@media (max-width: 959.95px) {
    .dash-filter-row {
        flex-wrap: wrap;
    }

    .dash-filter-controls {
        flex: 1 1 100%;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .branch-kpi-card {
        padding: 12px !important;
    }

    .branch-kpi-card__content {
        align-items: flex-start !important;
        flex-direction: column !important;
        gap: 6px !important;
    }

    .branch-kpi-card__right {
        align-items: flex-start !important;
        width: 100%;
    }

    .branch-kpi-card__chart,
    .branch-kpi-card__range {
        display: none !important;
    }

    .branch-kpi-card__value {
        font-size: 1.35rem !important;
    }
}

/* 404 page illustration is a fixed 550px SVG */
@media (max-width: 959.95px) {
    svg[viewBox="0 0 569 384.7"] {
        height: auto;
        max-width: 100%;
    }
}

/* Expand-arrow cells: no caption, control on the right */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Expand"]::before {
        display: none;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Expand"] {
        justify-content: flex-end;
    }
}

/* Therapist dashboard KPI cards (Therapist/Components/KpiCard.razor): 2x2 compact tiles, no mini chart */
@media (max-width: 959.95px) {
    .br-kpi-card {
        flex-direction: column;
        height: auto !important;
        min-height: 0;
        padding: 12px !important;
    }

    .br-kpi-card > div {
        margin: 6px 0 0 !important;
        text-align: left !important;
        width: 100%;
    }

    .br-kpi-card .mud-typography-h3 {
        font-size: 1.6rem !important;
    }

    .br-kpi-card .br-kpi-chart {
        display: none !important;
    }

    .br-kpi-avatar {
        height: 40px !important;
        width: 40px !important;
    }
}

/* Admin KPI tiles: keep long values (e.g. "RM200.00") inside the tile */
@media (max-width: 959.95px) {
    .branch-kpi-card__icon {
        height: 36px !important;
        width: 36px !important;
    }

    .branch-kpi-card__left {
        gap: 8px !important;
    }

    .branch-kpi-card__value {
        font-size: 1.15rem !important;
        white-space: nowrap;
    }
}

/*
 * KPI tiles as native-app pastel tiles (supersedes the earlier compact-card rules above):
 * a horizontally scrolling row; each tile = coloured icon, big number, small label underneath.
 * Applies to the therapist, tenant and branch dashboards (.br-kpi-row is on their KPI grid).
 */
@media (max-width: 959.95px) {
    .br-kpi-row {
        flex-wrap: nowrap !important;
        gap: 10px;
        margin: 0 !important;
        overflow-x: auto;
        padding: 2px 2px 8px;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        width: 100% !important;
    }

    .br-kpi-row::-webkit-scrollbar {
        display: none;
    }

    .br-kpi-row > .mud-grid-item {
        flex: 0 0 auto !important;
        max-width: none !important;
        padding: 0 !important;
        scroll-snap-align: start;
        width: 128px !important;
    }

    .br-kpi-row > .mud-grid-item:nth-child(1) { --kpi: #16a34a; --kpi-bg: #e6f7ee; }
    .br-kpi-row > .mud-grid-item:nth-child(2) { --kpi: #2563eb; --kpi-bg: #e6f0ff; }
    .br-kpi-row > .mud-grid-item:nth-child(3) { --kpi: #ea580c; --kpi-bg: #fff0e2; }
    .br-kpi-row > .mud-grid-item:nth-child(4) { --kpi: #9333ea; --kpi-bg: #f3e8ff; }

    /* therapist dashboard tile */
    .br-kpi-row .br-kpi-card {
        align-items: flex-start !important;
        background: var(--kpi-bg) !important;
        border-radius: 16px !important;
        box-shadow: none !important;
        color: #111827 !important;
        height: auto !important;
        padding: 14px 12px !important;
    }

    .br-kpi-row .br-kpi-avatar {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        color: var(--kpi) !important;
        height: auto !important;
        width: auto !important;
    }

    .br-kpi-row .br-kpi-card > div {
        display: flex;
        flex-direction: column;
    }

    .br-kpi-row .br-kpi-card .mud-typography-h3 {
        color: #111827;
        font-size: 1.7rem !important;
        order: 1;
    }

    .br-kpi-row .br-kpi-card .mud-typography-subtitle2 {
        color: #4b5563;
        font-size: .78rem !important;
        font-weight: 500 !important;
        opacity: 1 !important;
        order: 2;
    }

    /* tenant / branch dashboard tile */
    .br-kpi-row .branch-kpi-card {
        background: var(--kpi-bg) !important;
        border-radius: 16px !important;
        box-shadow: none !important;
        height: 100%;
        padding: 14px 12px !important;
    }

    .br-kpi-row .branch-kpi-card__left {
        align-items: flex-start !important;
        flex-direction: column !important;
        gap: 4px !important;
    }

    .br-kpi-row .branch-kpi-card__icon {
        background: transparent !important;
        box-shadow: none !important;
        color: var(--kpi) !important;
        height: auto !important;
        width: auto !important;
    }

    .br-kpi-row .branch-kpi-card__icon .mud-icon-root {
        color: var(--kpi) !important;
    }

    .br-kpi-row .branch-kpi-card__meta {
        display: flex;
        flex-direction: column;
    }

    .br-kpi-row .branch-kpi-card__value {
        color: #111827 !important;
        font-size: 1.35rem !important;
        order: 1;
    }

    .br-kpi-row .branch-kpi-card__title {
        color: #4b5563 !important;
        font-size: .78rem !important;
        order: 2;
    }

    .br-kpi-row .branch-kpi-card__pill {
        font-size: .68rem !important;
        padding: 2px 8px !important;
    }
}

/* KPI tile labels wrap inside the tile instead of being clipped */
@media (max-width: 959.95px) {
    .br-kpi-row .br-kpi-card .mud-typography-subtitle2,
    .br-kpi-row .branch-kpi-card__title {
        overflow-wrap: anywhere;
        white-space: normal !important;
    }

    .br-kpi-row .branch-kpi-card__meta,
    .br-kpi-row .br-kpi-card > div {
        min-width: 0;
        width: 100%;
    }
}

/*
 * Dashboard page background + cards (therapist / tenant / branch): soft primary-tinted gradient behind white rounded cards,
 * like native dashboard apps. Tinted from theme variables so it also works in dark mode.
 */
@media (max-width: 959.95px) {
    .mud-main-content:has(.br-kpi-row) {
        background: linear-gradient(180deg,
            color-mix(in srgb, var(--mud-palette-primary) 12%, var(--mud-palette-background)) 0%,
            color-mix(in srgb, var(--mud-palette-primary) 5%, var(--mud-palette-background)) 40%,
            var(--mud-palette-background) 100%);
        min-height: 100vh;
    }

    .mud-main-content:has(.br-kpi-row) .mud-paper:not(.br-kpi-card):not(.branch-kpi-card) {
        border-radius: 16px !important;
        box-shadow: 0 2px 12px rgba(37, 99, 235, .08) !important;
    }
}

/* slightly deeper pastels so the tiles stay distinct on the tinted dashboard background */
@media (max-width: 959.95px) {
    .br-kpi-row > .mud-grid-item:nth-child(1) { --kpi-bg: #d9f4e3; }
    .br-kpi-row > .mud-grid-item:nth-child(2) { --kpi-bg: #d6e6ff; }
    .br-kpi-row > .mud-grid-item:nth-child(3) { --kpi-bg: #ffe6cf; }
    .br-kpi-row > .mud-grid-item:nth-child(4) { --kpi-bg: #ecdcff; }
}

/*
 * Tenant/Branch admin KPI row: 3 equal tiles per row (not a scroller like the therapist row), short labels.
 * Overrides the earlier .br-kpi-row rules for this component only (branch-kpi-card, not br-kpi-card).
 */
@media (max-width: 959.95px) {
    .br-kpi-row:has(.branch-kpi-card) {
        display: grid !important;
        flex-wrap: unset !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow-x: visible;
    }

    .br-kpi-row:has(.branch-kpi-card) > .mud-grid-item {
        min-width: 0 !important;
        width: auto !important;
    }

    .br-kpi-row:has(.branch-kpi-card) > .mud-grid-item:nth-child(4) {
        grid-column: 1 / -1;
    }

    .br-kpi-row .branch-kpi-card .br-title-full {
        display: none;
    }

    .br-kpi-row .branch-kpi-card .br-title-short {
        display: inline;
    }

    .br-kpi-row .branch-kpi-card__value {
        overflow-wrap: anywhere;
    }
}

/* Desktop: the mobile-only short label stays hidden */
.br-title-short {
    display: none;
}

/* KPI tile right column (pill/range) must not force the tile — or the page — wider than its grid track */
@media (max-width: 959.95px) {
    .branch-kpi-card__right {
        flex-shrink: 1;
        max-width: 100%;
        min-width: 0 !important;
    }
}

/* Therapist dashboard KPI tiles (Therapist/Components/KpiCard.razor): short one-word label instead of the full title */
@media (max-width: 959.95px) {
    .br-kpi-row .br-kpi-card .br-title-full {
        display: none;
    }

    .br-kpi-row .br-kpi-card .br-title-short {
        display: inline;
    }
}

/*
 * MudExpansionPanel's collapse container sometimes gets stuck at max-height:0 (a MudBlazor JS
 * measurement race) when its content re-renders after the panel opens — e.g. our own
 * Breakpoint="Sm" MudTable swapping row layout. Once expanded, force it visible on phones.
 */
@media (max-width: 959.95px) {
    .mud-expand-panel.mud-panel-expanded .mud-collapse-container.mud-collapse-entered {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

/*
 * Native-style icon-only action buttons on phones (js/mobile-rows.js finds "Create"/"Add"/"Search"
 * MudButtons with a leading icon and wraps their text in .br-btn-hidden-text so we can hide it here).
 */
@media (max-width: 959.95px) {
    .br-btn-icon-only.mud-button-root {
        border-radius: 50% !important;
        min-width: 0 !important;
        padding: 10px !important;
    }

    .br-btn-icon-only .mud-button-label {
        gap: 0 !important;
        justify-content: center !important;
    }

    /* MudBlazor reserves a gap between the icon and the (now hidden) label text; without
       resetting it the icon sits off-centre inside the circle. */
    .br-btn-icon-only .mud-button-icon-start {
        margin: 0 !important;
    }

    .br-btn-icon-only .br-btn-hidden-text {
        display: none;
    }
}

/* "Reload" buttons (js/mobile-rows.js flags any MudButton whose text is exactly "Reload") aren't
   needed on a phone — pull-to-refresh / re-navigating covers it. */
@media (max-width: 959.95px) {
    .br-btn-hide {
        display: none !important;
    }
}

/* Calendar toolbar on phones (Pages/Features/Schedule/Calendar.razor): one compact card instead of a stack of wrapped controls.
 *   [<]   Sat, 31 Oct 2026   [>]  [Today]
 *   [ Day | Week | Month ]        [Add]
 *   [Mon Tue Wed Thu Fri Sat Sun]   (scrolls sideways if needed)
 *   [ All Therapists          v ]   (i)
 * The Razor stacks are flattened with display: contents so every control can be placed on this grid. */
@media (max-width: 959.95px) {
    .cal-toolbar {
        align-items: center;
        border-radius: 14px !important;
        display: grid !important;
        gap: 0 6px;
        grid-template-areas:
            "branch branch branch branch"
            "prev   title  next   today"
            "view   view   view   add"
            "days   days   days   days"
            "ther   ther   ther   info";
        grid-template-columns: auto 1fr auto auto;
        padding: 10px !important;
    }

    .cal-toolbar .cal-tb-row,
    .cal-toolbar .cal-tb-filters,
    .cal-toolbar .cal-tb-nav,
    .cal-toolbar .cal-nav-compact,
    .cal-toolbar .cal-tb-actions {
        display: contents !important;
    }

    .cal-toolbar .cal-m-branch { grid-area: branch; margin-bottom: 8px; min-width: 0 !important; }
    .cal-toolbar .cal-m-prev { grid-area: prev; }
    .cal-toolbar .cal-m-next { grid-area: next; }
    .cal-toolbar .cal-m-today { grid-area: today; }

    .cal-toolbar .cal-m-title {
        font-size: .95rem !important;
        grid-area: title;
        text-align: center;
    }

    .cal-toolbar .cal-m-view {
        display: flex;
        grid-area: view;
        margin-top: 10px;
        width: 100%;
    }

    .cal-toolbar .cal-m-view .mud-toggle-item {
        flex: 1;
        justify-content: center;
    }

    .cal-toolbar .cal-m-add { grid-area: add; margin-top: 10px; }

    .cal-toolbar .cal-m-days {
        display: flex;
        gap: 2px;
        grid-area: days;
        margin-top: 10px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .cal-toolbar .cal-m-days::-webkit-scrollbar { display: none; }
    .cal-toolbar .cal-m-days:not(:has(*)) { display: none; }

    /* seven day chips always fit the card width, so the selected day is never scrolled out of sight */
    .cal-toolbar .cal-m-days .cal-day-btn {
        flex: 1 1 0;
        font-size: .75rem;
        min-width: 0 !important;
        padding-left: 0;
        padding-right: 0;
    }

    .cal-toolbar .cal-m-ther {
        display: block;
        grid-area: ther;
        margin: 10px 0 0 !important;
        width: 100%;
    }

    .cal-toolbar .cal-m-ther .mud-menu-activator,
    .cal-toolbar .cal-m-ther .cal-ther-trigger {
        width: 100%;
    }

    .cal-toolbar .cal-m-ther .cal-ther-trigger {
        display: flex;
        min-height: 40px;
    }

    .cal-toolbar .cal-m-ther .cal-ther-trigger > span { flex: 1; }
    .cal-toolbar .cal-m-info { grid-area: info; margin-top: 10px; }
}

/* Phones: slim page-title bar (no subtitle) and no hamburger beside the logo
 * (the bottom bar's "More" opens the menu). Page action buttons next to a title stay, right-aligned. */
@media (max-width: 959.95px) {
    /* page title: a full-width bar attached under the top bar (title only, no subtitle); stays in view while the page scrolls */
    .bitrehab-title-row {
        align-items: center;
        background: #0a1531; /* the top bar's own navy (bottom of its gradient), so the two read as one header */
        border-top: 1px solid rgba(255, 255, 255, .08);
        display: flex !important;
        justify-content: space-between;
        margin: -16px -12px 12px;
        min-height: 28px;
        padding: 3px 14px;
        position: sticky;
        top: 56px;
        z-index: 5;
    }

    .bitrehab-title-block { display: block; }
    .mud-main-content .bitrehab-title-row .bitrehab-title-block .mud-typography { color: #fff !important; font-size: .72rem !important; font-weight: 600; line-height: 1.4; margin: 0 !important; }
    .bitrehab-title-subtitle-wrap { display: none; }
    .br-drawer-toggle { display: none !important; }
}

/* Dashboards on phones: the date range reads fine without the leading "Showing:" */
@media (max-width: 959.95px) {
    .dash-showing-label { display: none; }
}

/* Branch dashboard on phones: one standard 12px gap between every tile and card (nested grids had an extra 16px) */
@media (max-width: 959.95px) {
    .br-kpi-row:has(.branch-kpi-card) {
        gap: 12px;
        padding: 0;
    }

    .dash-nested {
        margin-top: -12px !important;
    }
}

/* Phones: smaller avatars on every page (list photos, person cards), floating Add button and compact person cards */
@media (max-width: 959.95px) {
    .mud-main-content .mud-avatar.mud-avatar-large:not(.branch-kpi-card__icon):not(.br-kpi-avatar):not(.profile-picture__img) {
        font-size: .95rem;
        height: 40px;
        width: 40px;
    }

    .mud-main-content .mud-avatar.mud-avatar-medium {
        font-size: .85rem;
        height: 32px;
        width: 32px;
    }

    /* Add button floats bottom-right above the tab bar (same 40px circle as the Calendar's) */
    .br-fab-mobile.mud-button-root {
        border-radius: 50% !important;
        bottom: 84px;
        box-shadow: 0 4px 10px rgba(0,0,0,.25);
        height: 40px;
        min-width: 0 !important;
        padding: 10px !important;
        position: fixed !important;
        right: 16px;
        width: 40px;
        z-index: 1100;
    }

    /* compact person card (client list card view): less padding, smaller text, actions tucked in the bottom-right corner */
    .br-person-card { position: relative; }
    .br-person-card .mud-card-content { padding: 10px 12px !important; }
    .br-person-card .mud-divider { margin: 8px 0 !important; }
    .br-person-card .mud-typography-body2 { font-size: .8rem; }
    .br-person-card .mud-typography-subtitle1 { font-size: .9rem; }
    .br-person-card .mud-chip { font-size: .7rem; height: 20px; }
    .br-person-card .mud-card-actions { bottom: 2px; padding: 0 !important; position: absolute; right: 4px; }
}

/* Phones: the package chip on the person card is icon-only (the text does not fit next to the name) */
@media (max-width: 959.95px) {
    .br-person-card .mud-chip .mud-chip-content { display: none; }
    .br-person-card .mud-chip { border-radius: 50%; height: 24px; justify-content: center; padding: 0 !important; width: 24px; }
    .br-person-card .mud-chip .mud-chip-icon { margin: 0 !important; }
}

/* Phones, list cards: no "Actions" caption; the row menu is an orange "..." circle */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Actions"]::before {
        display: none;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Actions"] {
        gap: 12px !important;
        justify-content: flex-end !important;
    }

    .mud-table.mud-sm-table td.mud-table-cell[data-label="Actions"] .mud-menu .mud-icon-button,
    .br-person-card .mud-menu .mud-icon-button {
        align-items: center;
        background-color: #fb8c00;
        border-radius: 50%;
        color: #fff;
        display: inline-flex;
        height: 30px !important;
        justify-content: center;
        line-height: 1;
        min-height: 0 !important;
        min-width: 0 !important;
        padding: 0 !important;
        width: 30px !important;
    }

    .mud-table.mud-sm-table td.mud-table-cell[data-label="Actions"] .mud-menu .mud-icon-button svg,
    .br-person-card .mud-menu .mud-icon-button svg {
        height: 20px;
        width: 20px;
    }
}

/* Phones: no "N records" counter above the list cards */
@media (max-width: 959.95px) {
    .br-record-count { display: none; }
}

/* Phone list cards: the expand chevron is centred vertically on the first row, and the Actions button reaches the right edge */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row:has(td.mud-table-cell[data-label]:not([data-label=""]))::after {
        top: 16px;
        transform: translateY(-50%) rotate(45deg);
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-open::after {
        transform: translateY(-50%) rotate(225deg);
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell[data-label="Actions"] {
        padding-right: 10px !important;
    }
}

/*
 * Tabs on phones look like a native top tab bar: no scroll arrows, tabs share the width (icon above the label),
 * the active tab is coloured with a thick rounded underline; with many tabs the bar scrolls sideways by swiping.
 */
@media (max-width: 959.95px) {
    .mud-main-content .mud-tabs > .mud-tabs-tabbar .mud-tabs-scroll-button {
        display: none;
    }

    .mud-main-content .mud-tabs > .mud-tabs-tabbar .mud-tabs-tabbar-content {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .mud-main-content .mud-tabs > .mud-tabs-tabbar .mud-tabs-tabbar-content::-webkit-scrollbar {
        display: none;
    }

    .mud-main-content .mud-tabs > .mud-tabs-tabbar .mud-tabs-tabbar-wrapper {
        min-width: 100%;
    }

    .mud-main-content .mud-tabs > .mud-tabs-tabbar .mud-tabs-tabbar-wrapper > .mud-tooltip-root {
        display: flex;
        flex: 1 0 auto;
    }

    .mud-main-content .mud-tabs > .mud-tabs-tabbar .mud-tab {
        flex: 1 0 auto;
        flex-direction: column;
        font-size: .75rem;
        font-weight: 600;
        gap: 2px;
        letter-spacing: 0;
        min-height: 56px;
        min-width: 84px;
        padding: 8px 10px;
        text-transform: none;
    }

    .mud-main-content .mud-tabs > .mud-tabs-tabbar .mud-tab .mud-icon-root {
        font-size: 1.35rem;
        margin: 0;
    }

    .mud-main-content .mud-tabs > .mud-tabs-tabbar .mud-tab-slider {
        border-radius: 3px 3px 0 0;
        height: 3px;
    }
}

/* ---- Phone polish: back arrow, smaller headings/dialogs, tighter list top, compact pager ---- */
@media (max-width: 959.95px) {
    /* "Back" / "Back to X" buttons show only a back arrow */
    .br-btn-back.mud-button-root {
        align-items: center;
        border-radius: 50% !important;
        font-size: 0 !important;
        height: 36px;
        justify-content: center;
        min-width: 0 !important;
        padding: 0 !important;
        width: 36px;
    }

    .br-btn-back.mud-button-root::before {
        background-color: currentColor;
        content: "";
        display: inline-block;
        height: 22px;
        -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'/%3E%3C/svg%3E") center / contain no-repeat;
        width: 22px;
    }

    .br-btn-back.mud-button-root:has(.mud-button-icon-start)::before { display: none; }
    .br-btn-back .mud-button-icon-start { margin: 0 !important; }
    .br-btn-back .mud-button-icon-start svg { height: 22px; width: 22px; }

    /* page headings */
    .mud-main-content .mud-typography-h4 { font-size: 1.3rem !important; }
    .mud-main-content .mud-typography-h5 { font-size: 1.05rem !important; }
    .mud-main-content .mud-typography-h6 { font-size: .95rem !important; }
    .mud-main-content .mud-typography-subtitle1 { font-size: .9rem !important; }

    /* dialogs: one small, consistent size for title, text, fields and buttons */
    .mud-dialog .mud-dialog-title,
    .mud-dialog .mud-dialog-title .mud-typography { font-size: 1rem !important; line-height: 1.3; }
    .mud-dialog .mud-dialog-title { padding: 14px 16px 6px; }
    .mud-dialog .mud-dialog-content { font-size: .85rem; }
    .mud-dialog .mud-dialog-content .mud-typography-body1,
    .mud-dialog .mud-alert-message { font-size: .8rem !important; }
    .mud-dialog .mud-input-slot,
    .mud-dialog .mud-select-input { font-size: .85rem; }
    .mud-dialog .mud-input-label { font-size: .85rem; }
    .mud-dialog .mud-input-outlined .mud-input-slot.mud-input-root-outlined { padding-bottom: 10px; padding-top: 10px; }
    .mud-dialog .mud-dialog-actions .mud-button-root {
        font-size: .75rem;
        line-height: 1.4;
        min-height: 32px;
        padding: 4px 12px;
    }

    /* the list starts right under the filter bar: the table's now-empty toolbar (its Create button floats) takes no space */
    .mud-table .mud-toolbar { min-height: 0 !important; padding: 0 !important; }

    /* pager: only "1-4 of 4" and the arrows, centred; no rows-per-page picker */
    .mud-table-pagination-toolbar { justify-content: center; min-height: 40px; padding: 0; }
    .mud-table-pagination-toolbar .mud-table-pagination-display,
    .mud-table-pagination-toolbar .mud-table-pagination-spacer { display: none; }
    .mud-table-pagination-toolbar .mud-table-pagination-caption { display: none; }
}

/* Card-view pager (Shared/Components/MobileTablePager.razor): "<  1-10 of 25  >", centred and quiet */
.br-mpager {
    align-items: center;
    color: var(--mud-palette-text-secondary);
    display: flex;
    font-size: .85rem;
    gap: 14px;
    justify-content: center;
    margin: 14px 0 4px;
}

.br-mpager .mud-icon-button {
    border: 1px solid rgba(128, 128, 128, .35);
    height: 34px;
    width: 34px;
}

/* pager arrows must not push the page wider than the screen */
@media (max-width: 959.95px) {
    .mud-table-pagination-toolbar { box-sizing: border-box; max-width: 100%; overflow: hidden; }
    .mud-table-pagination-toolbar .mud-table-pagination-actions { display: flex; flex: none; width: auto; }
    .mud-table-pagination-toolbar .mud-table-pagination-actions .mud-icon-button { padding: 8px; }
}

/* Booking time slots: two columns everywhere on phones (drawer, dialog or page) */
@media (max-width: 959.95px) {
    .mud-chipset.br-slot-grid {
        display: grid !important;
        gap: 8px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mud-chipset.br-slot-grid .mud-chip {
        font-size: .8rem;
        justify-content: center;
        margin: 0;
        min-height: 38px;
        padding: 0 6px;
    }

    .mud-chipset.br-slot-grid .mud-chip .mud-icon-root { display: none; }

    /* side-drawer forms: same small buttons as dialogs, no wrapping inside a button */
    .mud-drawer .mud-button-root:not(.mud-icon-button) {
        font-size: .75rem;
        min-height: 32px;
        padding: 4px 12px;
        white-space: nowrap;
    }
}

/* Form panels (side drawer / dialog) on phones: the action row inside the form becomes full-width stacked buttons
   (primary first, Cancel last) */
@media (max-width: 959.95px) {
    :is(.mud-dialog, .mud-drawer) .d-flex.flex-row.justify-end:has(> .mud-button-root, > .mud-tooltip-root > .mud-button-root) {
        align-items: stretch;
        flex-direction: column-reverse !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        margin-top: 8px;
    }

    :is(.mud-dialog, .mud-drawer) .d-flex.flex-row.justify-end > .mud-tooltip-root { display: flex; width: 100%; }

    :is(.mud-dialog, .mud-drawer) .d-flex.flex-row.justify-end > .mud-button-root,
    :is(.mud-dialog, .mud-drawer) .d-flex.flex-row.justify-end > .mud-tooltip-root > .mud-button-root {
        border-radius: 10px;
        font-size: .85rem;
        font-weight: 600;
        justify-content: center;
        min-height: 44px;
        width: 100%;
    }

    :is(.mud-dialog, .mud-drawer) .d-flex.flex-row.justify-end > .mud-button-root.mud-button-text { font-weight: 500; min-height: 40px; }
}

/* Therapist dashboard: the four KPI tiles form a 2x2 grid (they used to scroll sideways, so "Pending" was cut off) */
@media (max-width: 959.95px) {
    .br-kpi-row:has(.br-kpi-card) {
        display: grid !important;
        flex-wrap: unset !important;
        gap: 12px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow-x: visible;
        padding: 0;
    }

    .br-kpi-row:has(.br-kpi-card) > .mud-grid-item {
        min-width: 0 !important;
        width: auto !important;
    }
}

/* Phone agenda (Calendar page and the session calendars): greeting band, rounded sheet with week strip and hourly cards */
/* Phone agenda: tinted greeting header, rounded sheet with week strip + hourly timeline of pastel cards */
.cal-ag { padding-bottom: 96px; position: relative; }
.cal-ag-hero { background: color-mix(in srgb, var(--mud-palette-primary) 14%, var(--mud-palette-surface)); border-radius: 20px; padding: 12px 16px 44px; }
.cal-ag-top { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
.cal-ag-month { align-items: center; background: none; border: 0; color: var(--mud-palette-text-primary); display: inline-flex; font: inherit; font-size: .88rem; font-weight: 700; gap: 2px; padding: 4px 0; white-space: nowrap; }
.cal-ag-therbtn { align-items: center; background: var(--mud-palette-surface); border-radius: 999px; box-shadow: 0 1px 3px rgba(0,0,0,.12); cursor: pointer; display: inline-flex; font-size: .75rem; gap: 5px; max-width: 150px; min-height: 32px; padding: 3px 8px 3px 9px; }
.cal-ag-therbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ag-therbtn .mud-avatar { font-size: .62rem; height: 20px; width: 20px; }
.cal-ag-therpop .mud-list-item { font-size: .8rem; min-height: 36px; }
.cal-ag-therpop .mud-avatar { font-size: .62rem; height: 20px; width: 20px; }
.cal-ag-headline { font-size: .82rem; font-weight: 500; line-height: 1.25; margin-top: 14px; }
.cal-ag-headline b { color: var(--mud-palette-primary); font-weight: 700; }
.cal-ag-picker { height: 1px; opacity: 0; overflow: hidden; pointer-events: none; position: absolute; width: 1px; }
.cal-ag-sheet { background: var(--mud-palette-surface); border-radius: 24px 24px 12px 12px; box-shadow: 0 -4px 16px rgba(0,0,0,.08); margin-top: -28px; padding: 10px 10px 4px; position: relative; }
.cal-ag-sheet::before { background: rgba(128,128,128,.35); border-radius: 4px; content: ""; display: block; height: 4px; margin: 0 auto 8px; width: 36px; }
.cal-ag-strip { align-items: center; display: flex; gap: 2px; }
.cal-ag-nav { background: none; border: 0; color: var(--mud-palette-text-secondary); display: grid; flex: none; padding: 2px; place-items: center; }
.cal-ag-day { align-items: center; background: none; border: 0; border-radius: 14px; color: var(--mud-palette-text-primary); display: flex; flex: 1; flex-direction: column; font: inherit; gap: 2px; padding: 8px 0; }
.cal-ag-day .num { font-size: 1.05rem; font-weight: 700; }
.cal-ag-day .dow { color: var(--mud-palette-text-secondary); font-size: .68rem; }
.cal-ag-day.today .num { color: var(--mud-palette-primary); }
.cal-ag-day.sel { background: var(--mud-palette-primary); }
.cal-ag-day.sel .num, .cal-ag-day.sel .dow { color: #fff; }
.cal-ag-dayrow { align-items: center; border-bottom: 1px solid rgba(128,128,128,.2); border-top: 1px solid rgba(128,128,128,.2); display: flex; font-size: .78rem; gap: 8px; justify-content: space-between; margin: 8px 0 12px; padding: 8px 2px; }
.cal-ag-dayrow b, .cal-ag-gotoday { white-space: nowrap; background: none; border: 0; color: var(--mud-palette-primary); font: inherit; font-weight: 700; padding: 0; }
.cal-ag-empty { color: var(--mud-palette-text-secondary); padding: 36px 0 44px; text-align: center; }
.cal-ag-empty .mud-icon-root { font-size: 2.5rem; }
.cal-ag-row { align-items: flex-start; display: flex; gap: 8px; margin-bottom: 10px; }
.cal-ag-hour { color: var(--mud-palette-text-secondary); flex: none; font-size: .75rem; padding-top: 2px; width: 40px; }
.cal-ag-menu { display: block; flex: 1; min-width: 0; }
.cal-ag-card { background: color-mix(in srgb, var(--ag) 30%, var(--mud-palette-surface)); border: 1.5px solid transparent; border-radius: 16px; cursor: pointer; padding: 10px 12px; text-align: left; width: 100%; }
.cal-ag-card.dashed { border: 1.5px dashed var(--ag); }
.cal-ag-card.cancelled { opacity: .55; }
.cal-ag-card.cancelled .cal-ag-title { text-decoration: line-through; }
.cal-ag-cardtop { align-items: center; display: flex; gap: 8px; }
.cal-ag-icon { color: color-mix(in srgb, var(--ag) 55%, #000); display: inline-flex; }
.cal-ag-status { background: rgba(255,255,255,.65); border-radius: 999px; color: #333; font-size: .68rem; font-weight: 600; padding: 1px 8px; }
.cal-ag-av { align-items: center; border: 2px solid var(--mud-palette-surface); border-radius: 50%; display: inline-flex; font-size: .6rem; font-weight: 700; height: 22px; justify-content: center; margin-left: auto; width: 22px; }
.cal-ag-title { font-size: .85rem; font-weight: 700; line-height: 1.25; margin-top: 6px; overflow-wrap: anywhere; }
.cal-ag-when { color: var(--mud-palette-text-secondary); font-size: .78rem; margin-top: 2px; }
.cal-ag-who { color: var(--mud-palette-text-secondary); font-size: .7rem; margin-top: 2px; }
.cal-ag-tags { align-items: center; display: flex; font-size: .74rem; gap: 10px; margin-top: 6px; }
.cal-ag-bill .cal-dot { margin-right: 4px; }
.cal-ag-price { font-weight: 700; margin-left: auto; }
.cal-ag-now { align-items: center; display: flex; gap: 6px; margin: 2px 0 10px; }
.cal-ag-now span { background: var(--mud-palette-primary); border-radius: 999px; color: #fff; flex: none; font-size: .68rem; font-weight: 600; padding: 2px 8px; }
.cal-ag-now i { background: var(--mud-palette-primary); flex: 1; height: 1.5px; }
.cal-fab { bottom: 84px; position: fixed; right: 16px; z-index: 1100; }
/* same 40px circle as the Add button on list pages (Clients etc.) */
.cal-fab .mud-button-root { border-radius: 50%; box-shadow: 0 4px 10px rgba(0,0,0,.25); height: 40px; min-width: 0; padding: 10px; width: 40px; }
.cal-fab .mud-icon-root { font-size: 1.25rem; height: 20px; width: 20px; }

/* the session agenda sits directly on the page on phones (no outlined box around it) */
@media (max-width: 959.95px) {
    .br-agenda-wrap { background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; }
}

/* Phones: no pager when there is nothing to page (no records, or everything fits on one page) */
@media (max-width: 959.95px) {
    .mud-table:has(.mud-table-empty-row) .mud-table-pagination,
    .mud-table-pagination:not(:has(.mud-table-pagination-actions .mud-icon-button:not([disabled]):not(.mud-disabled))) {
        display: none;
    }
}

/* Filters as a native-style bottom sheet: the bar opens a sheet that slides up over a dimmed page; Search closes it */
.br-sheet-head,
.br-sheet-backdrop { display: none; }

@media (max-width: 959.95px) {
    .br-collapse.br-open > .br-collapse-body {
        animation: br-sheet-up .2s ease-out;
        background: var(--mud-palette-surface);
        border-radius: 18px 18px 0 0;
        bottom: 0;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, .28);
        left: 0;
        margin-top: 0;
        max-height: 78vh;
        overflow-y: auto;
        padding: 0 14px 18px;
        position: fixed;
        right: 0;
        z-index: 1205;
    }

    .br-collapse.br-open > .br-sheet-backdrop {
        background: rgba(0, 0, 0, .42);
        display: block;
        inset: 0;
        position: fixed;
        z-index: 1204;
    }

    .br-collapse.br-open > .br-collapse-body > .br-sheet-head {
        background: var(--mud-palette-surface);
        display: block;
        margin: 0 -14px 6px;
        padding: 8px 14px 4px;
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .br-sheet-handle { background: rgba(128, 128, 128, .4); border-radius: 4px; display: block; height: 4px; margin: 0 auto 8px; width: 36px; }
    .br-sheet-title { align-items: center; display: flex; justify-content: space-between; }
    .br-sheet-title b { font-size: .95rem; }
    .br-sheet-close { background: none; border: 0; color: var(--mud-palette-text-secondary); display: grid; padding: 6px; place-items: center; }

    .br-collapse.br-open > .br-collapse-body > .mud-paper { box-shadow: none !important; padding-left: 0 !important; padding-right: 0 !important; }
}

@keyframes br-sheet-up {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Title-bar icons (Therapist Sessions): small white icons that fit the 28px bar */
@media (max-width: 959.95px) {
    .bitrehab-title-row { align-items: center !important; }
    .br-title-actions { align-items: center; display: flex; gap: 2px; }
    .mud-main-content .br-title-actions .mud-icon-button { color: #fff; height: 22px !important; min-height: 0 !important; min-width: 0 !important; padding: 2px !important; width: 22px !important; }
    .mud-main-content .br-title-actions .mud-icon-button .mud-icon-root { font-size: 1rem; height: 1rem; width: 1rem; }
    .br-collapse-toggle.br-bar-hidden { display: none !important; }
    .br-collapse.br-no-bar { margin-bottom: 0; }
}

/* Filters from the title bar: the "Filters" bar is hidden when the title bar has the filter icon; icon-only Reset/Reload buttons
   inside the filter sheet are dropped (Search closes the sheet and the list can be refreshed by searching again) */
@media (max-width: 959.95px) {
    body.br-title-filter .br-collapse-toggle { display: none !important; }
    body.br-title-filter .br-collapse { margin-bottom: 0; }
    .br-title-filter-btn { align-items: center; background: none; border: 0; color: #fff; display: inline-flex; height: 22px; justify-content: center; padding: 2px; width: 22px; }
    .br-title-filter-btn svg { fill: currentColor; height: 1rem; width: 1rem; }
    .br-collapse-body .mud-icon-button[title="Reset"],
    .br-collapse-body .mud-icon-button[title="Reload"],
    .br-collapse-body .mud-icon-button[title="Refresh"],
    .br-collapse-body .mud-button-root:has(.mud-icon-root path[d^="M17.65 6.35"]),
    .br-collapse-body .mud-icon-button[title="Clear"] { display: none !important; }
}

/* Status legend popup on phones: full width, hanging directly below the title bar (not over it) */
@media (max-width: 959.95px) {
    .mud-popover.br-legend-pop {
        border-radius: 0 0 14px 14px !important;
        left: 0 !important;
        max-width: none !important;
        right: 0 !important;
        top: 86px !important;
        transform: none !important;
        width: 100% !important;
    }
}

/* Cells that carry no caption (the value says what it is, e.g. the client's name): full width, left aligned, no label */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell.br-no-caption::before { display: none; }
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell.br-no-caption { justify-content: flex-start; text-align: left !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell.br-no-caption .mud-typography-body2 { font-size: .8rem; font-weight: 600; }
    .mud-table.mud-sm-table .br-amount { font-weight: 700; }
    .mud-table.mud-sm-table td.br-no-caption .d-flex, .mud-table.mud-sm-table td.br-no-caption .mud-stack { align-items: flex-start !important; width: 100%; }
}

/* Pending payments card: client name on the left and the amount on the same row at the right edge (no "Amount" caption) */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row > td:nth-child(-n+3) { grid-column: 1 / -1; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row > td.br-amount-cell {
        align-self: stretch;
        align-items: center;
        border-bottom: 0;
        grid-column: 2;
        justify-content: flex-end !important;
        padding-right: 14px !important;
        text-align: right !important;
        white-space: nowrap;
    }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row > td.br-amount-cell .br-amount { font-size: .8rem; }
    /* date and slot values are as small as their captions */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row > td[data-label="Session Date"],
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row > td[data-label="Slot"] { font-size: .75rem; }
    /* ...and end at the same right edge as the amount (only the "No" row needs room for the chevron) */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row > td[data-label="Session Date"],
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row > td[data-label="Slot"] { padding-right: 14px !important; }
}

/* Filter sheet polish: filters sit directly on the sheet (no inner outlined box) */
@media (max-width: 959.95px) {
    .br-collapse.br-open > .br-collapse-body > .mud-paper,
    .br-collapse.br-open > .br-collapse-body > .mud-paper-outlined {
        background: transparent !important;
        border: 0 !important;
        padding: 4px 0 0 !important;
    }

    .br-collapse.br-open > .br-collapse-body { padding-bottom: 20px; }
}

/* Phones: every page sits on the same white (surface) background, whether or not its list is wrapped in a panel */
@media (max-width: 959.95px) {
    body,
    .mud-main-content { background-color: var(--mud-palette-surface); }
}

/* Week strip: a small dot marks days that have a shift */
.cal-ag-day .dot { background: transparent; border-radius: 50%; height: 5px; width: 5px; }
.cal-ag-day .dot.on { background: var(--mud-palette-primary); }
.cal-ag-day.sel .dot.on { background: #fff; }

/* Time Off cards (Branch Admin > Time Off tabs): name on top, date/day and time with small icons, reason underneath; no captions */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row {
        column-gap: 12px;
        display: grid;
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
        padding: 12px 14px;
        row-gap: 6px;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row::after { display: none; }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td.mud-table-cell {
        align-items: center;
        border: 0 !important;
        display: flex !important;
        font-size: .8rem;
        gap: 6px !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        text-align: left !important;
        white-space: nowrap;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td.mud-table-cell::before { display: none; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="No"] { display: none !important; }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Name"] { font-size: .8rem; font-weight: 600; grid-column: 1 / -1; grid-row: 1; white-space: normal; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Active"] { grid-column: 2; grid-row: 1; justify-self: end; margin-top: -2px; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row:has(> td[data-label="Active"]) > td[data-label="Name"] { grid-column: 1; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Date"],
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Day"] { grid-column: 1; grid-row: 2; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Time"] { grid-column: 2; grid-row: 2; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Reason"] { color: var(--mud-palette-text-secondary); font-size: .75rem; grid-column: 1 / -1; grid-row: 3; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Reason"]:empty { display: none !important; }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Date"]::before,
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Day"]::before,
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Time"]::before {
        background-color: var(--mud-palette-text-secondary);
        content: "" !important;
        display: inline-block !important;
        flex: 0 0 15px !important;
        font-size: 0 !important;
        height: 15px;
        width: 15px;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Date"]::before,
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Day"]::before { -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z'/%3E%3C/svg%3E") center / contain no-repeat; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-block-row > td[data-label="Time"]::before { -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z'/%3E%3C/svg%3E") center / contain no-repeat; }
}

/* Add / Edit drawers on phones: full-screen panel; fields stack one per row at full width */
@media (max-width: 959.95px) {
    .mud-dialog-centerright:has(.drawer-dialog) {
        justify-content: stretch !important;
        padding: 0 !important;
    }

    .drawer-dialog {
        height: 100dvh !important;
        max-height: 100dvh !important;
        max-width: 100vw !important;
        width: 100vw !important;
    }

    .drawer-dialog .mud-dialog-content { overflow-y: auto; padding: 4px 14px 14px; }
    .drawer-dialog .mud-dialog-title { padding: 14px 14px 6px; }

    /* one column: every grid item takes a full row unless the form explicitly asked for narrow columns (xs 3/4/6) */
    .drawer-dialog .mud-grid-item:not(.mud-grid-item-xs-6):not(.mud-grid-item-xs-4):not(.mud-grid-item-xs-3) {
        flex-basis: 100%;
        max-width: 100%;
    }

    .drawer-dialog .mud-input-control,
    .drawer-dialog .mud-select { max-width: 100%; width: 100%; }
}

/* drawer footer: Cancel and Save share the width as a pinned bottom bar */
@media (max-width: 959.95px) {
    .drawer-dialog .mud-dialog-actions {
        background: var(--mud-palette-surface);
        border-top: 1px solid rgba(128, 128, 128, .2);
        display: flex;
        gap: 10px;
        justify-content: stretch;
        padding: 10px 14px;
    }

    .drawer-dialog .mud-dialog-actions .mud-button-root {
        border-radius: 10px;
        flex: 1;
        font-size: .85rem;
        font-weight: 600;
        min-height: 44px;
    }
}

/* Phones: a table (with its toolbar button) that follows an inline filter card inside a tab panel needs breathing room */
@media (max-width: 959.95px) {
    .mud-tabs-panels .mud-paper + .mud-table { margin-top: 14px; }
}

/* Invoice cards on phones: the status chip sits at the left of the action icons instead of having its own row */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell.br-desktop-only { display: none !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell .br-inv-chip { margin: 0 auto 0 0 !important; order: -1; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell:has(.br-inv-chip) > div { gap: 12px; justify-content: flex-end; width: 100%; }
}
@media (max-width: 959.95px) {
    /* even spacing between the invoice action icons (the icon buttons carry their own padding) */
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell:has(.br-inv-chip) > div { gap: 16px !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell:has(.br-inv-chip) > div > .mud-icon-button { height: 24px !important; min-width: 0 !important; padding: 2px !important; width: 24px !important; }
}

/* Pending invoices on phones: full-width "Issue selected" button with space around it; the row checkbox sits in the card header next to "No" */
@media (max-width: 959.95px) {
    .mud-table:has(.br-issue-btn) { margin-top: 12px; }
    .mud-table:has(.br-issue-btn) > .mud-toolbar { min-height: 0; padding: 0 12px 10px !important; }
    .br-issue-btn { border-radius: 10px; height: 42px; width: 100%; }
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell.br-pend-select { border: 0 !important; display: flex !important; left: 38px; padding: 0 !important; position: absolute; top: 0; width: auto !important; z-index: 1; }
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell.br-pend-select::before { display: none !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row td.mud-table-cell.br-pend-select .mud-checkbox { margin: 0; }
}

/*
 * Pending invoices on phones: one grouped card per session.
 *   [ ] checkbox                            #1
 *   05/10/2026 · 09:00 AM – 10:00 AM
 *   Client name                    IC number
 *   [ Charge ] [ Paid ] [ Balance ]
 *   [        Issue Invoice          ]
 */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row {
        column-gap: 8px;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding: 12px 14px 14px;
        row-gap: 8px;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row::after { display: none; }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.mud-table-cell {
        align-items: center;
        border: 0 !important;
        display: flex !important;
        font-size: .8rem;
        min-width: 0;
        padding: 0 !important;
        text-align: left !important;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.mud-table-cell::before { display: none !important; }

    /* header: checkbox left, running number right */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-select { grid-column: 1 / 3; grid-row: 1; left: auto; position: static; width: auto !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-no { color: var(--mud-palette-text-secondary); font-size: .72rem; grid-column: 3; grid-row: 1; justify-content: flex-end; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-no::before { content: "#" !important; display: inline !important; flex: none !important; font-size: .72rem; padding-right: 1px; width: auto !important; }
    .br-pend-row .br-pend-select .mud-checkbox { margin: -6px 0 -6px -8px; }
    .br-pend-row .br-pend-select .mud-checkbox .mud-button-root { padding: 6px; }
    .br-pend-row .br-pend-select .mud-checkbox svg { height: 26px; width: 26px; }

    /* session: date and time on one line */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td[data-label="Session Date"] { font-weight: 600; gap: 8px; grid-column: 1 / -1; grid-row: 2; }
    .br-pend-row .br-pend-time { color: var(--mud-palette-text-secondary); font-weight: 400; }
    .br-pend-row .br-pend-time::before { content: "·"; padding-right: 8px; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td[data-label="Start Time"],
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td[data-label="End Time"] { display: none !important; }

    /* client: name left, IC number right, same line */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td:not([data-label]):not(.br-pend-select):first-of-type,
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td[data-label=""]:not(.br-pend-select):not(:last-child) { gap: 8px; grid-column: 1 / -1; grid-row: 3; justify-content: space-between; }
    .br-pend-row td[data-label=""] .mud-typography { margin: 0; }

    /* money: three small tiles */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt { align-items: flex-start; background: var(--mud-palette-background-gray, #f5f5f5); border-radius: 10px; flex-direction: column; font-size: .9rem; font-weight: 600; grid-row: 4; padding: 8px 10px !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt::before { color: var(--mud-palette-text-secondary); content: attr(data-label) !important; display: block !important; flex: none !important; font-size: .66rem; font-weight: 400; letter-spacing: .04em; text-transform: uppercase; width: auto !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-bal { background: rgba(33, 150, 243, .1); color: var(--mud-palette-primary); }

    /* action: a real full-width button */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td:last-child { grid-column: 1 / -1; grid-row: 5; }
    .br-pend-row .br-pend-issue { border-radius: 10px; font-size: .82rem; font-weight: 600; height: 38px; justify-content: center; margin: 0; width: 100%; }
}
@media (max-width: 959.95px) {
    .mud-tabs-panels:has(.br-issue-btn) { padding-top: 8px !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-no { gap: 0 !important; justify-content: flex-end !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td[data-label="Session Date"] { justify-content: flex-start !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt { gap: 2px !important; justify-content: flex-start !important; text-align: left !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt::before { margin: 0 !important; text-align: left; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt[data-label="Charge"] { background: #fff3e0; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt[data-label="Paid"] { background: #e8f5e9; }
}

/*
 * Invoice cards on phones (grouped like the pending ones):
 *   INV-001                               #1
 *   Client name
 *   [ Invoice date ] [ Issued date ] [ Amount ]
 *   (Status)                      eye bell ...
 */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row {
        column-gap: 8px;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding: 12px 14px;
        row-gap: 8px;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row::after { display: none; }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.mud-table-cell {
        align-items: center;
        border: 0 !important;
        display: flex !important;
        font-size: .8rem;
        min-width: 0;
        padding: 0 !important;
        text-align: left !important;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.mud-table-cell::before { display: none !important; }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-num { font-size: .9rem; font-weight: 600; grid-column: 1 / 3; grid-row: 1; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-no { color: var(--mud-palette-text-secondary); font-size: .72rem; gap: 0 !important; grid-column: 3; grid-row: 1; justify-content: flex-end !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-no::before { content: "#" !important; display: inline !important; flex: none !important; font-size: .72rem; width: auto !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-client { grid-column: 1 / -1; grid-row: 2; }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-tile { align-items: flex-start; border-radius: 10px; flex-direction: column; gap: 2px !important; grid-row: 3; justify-content: flex-start !important; padding: 8px 10px !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-tile::before { color: var(--mud-palette-text-secondary); content: attr(data-label) !important; display: block !important; flex: none !important; font-size: .66rem; letter-spacing: .04em; margin: 0 !important; text-transform: uppercase; width: auto !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-t1 { background: #e3f2fd; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-t2 { background: #f3e5f5; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-t3 { background: #e8f5e9; font-weight: 600; }

    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td[data-label="Actions"] { grid-column: 1 / -1; grid-row: 4; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.mud-table-cell.br-desktop-only { display: none !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-tile::before { font-size: .6rem; letter-spacing: 0; white-space: nowrap; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-no::before { margin: 0 1px 0 0 !important; padding: 0 !important; }
}

/* Pending invoices on phones: a ticked card is tinted until it is unticked */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row.br-pend-sel { background: #dcedc8 !important; }
}

@media (max-width: 959.95px) {
    /* pending: IC number in the same colour and size as the client name */
    .br-pend-row td[data-label=""] .mud-typography { color: var(--mud-palette-text-primary) !important; font-size: .8rem !important; }
    /* invoices: name left, IC number right; tiles centred and a little smaller */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-client { justify-content: space-between; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-tile { align-items: center; font-size: .72rem; text-align: center !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-tile::before { font-size: .55rem; text-align: center; }
}
@media (max-width: 959.95px) {
    /* tile labels and values centred (pending: Charge/Paid/Balance, invoices: Date/Issued/Amount) */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt,
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-tile { align-items: center !important; text-align: center !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt::before,
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-tile::before { text-align: center !important; width: 100% !important; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.br-pend-amt::before,
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-tile::before { box-sizing: border-box; padding: 0 !important; }
}
@media (max-width: 959.95px) {
    /* pending cards: client name and IC number use exactly the invoice card's text style */
    .br-pend-row td[data-label=""] .mud-typography { font-family: inherit !important; font-size: .8rem !important; font-weight: 400 !important; letter-spacing: normal !important; line-height: inherit !important; }
}
@media (max-width: 959.95px) {
    /* several status chips: they sit together on the left, only the last one takes the free space */
    .br-inv-row td .mud-chip-container:has(~ .mud-chip-container) .br-inv-chip { margin-right: 0 !important; }
}

/* KPI tiles on phones: icon, number, label and change pill all centred */
@media (max-width: 959.95px) {
    .br-kpi-row .branch-kpi-card,
    .br-kpi-row .br-kpi-card { text-align: center; }
    .br-kpi-row .branch-kpi-card__content,
    .br-kpi-row .branch-kpi-card__right { align-items: center !important; text-align: center; }
    .br-kpi-row .branch-kpi-card__left { align-items: center !important; }
    .br-kpi-row .branch-kpi-card__meta { align-items: center; text-align: center; }
    .br-kpi-row .br-kpi-card { align-items: center !important; }
    .br-kpi-row .br-kpi-card > div { align-items: center; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-num { gap: 0 !important; justify-content: flex-start !important; }
}

/* Therapist payouts on phones: cards with fewer rows than the invoice ones */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-2row > td.br-inv-tile { grid-row: 2; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-2row > td[data-label="Actions"] { grid-row: 3; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-wide { grid-column: 2 / 4; }
}
@media (max-width: 959.95px) {
    /* single view button on the pending payout card: same round orange button as the "..." menus */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-2row > td[data-label="Actions"] .mud-icon-button { align-items: center; background-color: #fb8c00; border-radius: 50%; color: #fff; display: inline-flex; height: 30px !important; justify-content: center; padding: 0 !important; width: 30px !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-2row > td[data-label="Actions"] .mud-icon-button svg { height: 18px; width: 18px; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-2row > td[data-label="Actions"] .mud-icon-button { flex: 0 0 30px; min-width: 30px !important; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-2row > td[data-label="Actions"] .mud-icon-button { min-height: 30px !important; }
}

/* Pending payment sessions (select sessions to pay) on phones */
@media (max-width: 959.95px) {
    .br-pay-sel-bar { flex-wrap: wrap; }
    .br-pay-sel-bar .mud-button-filled.mud-button-filled-primary { border-radius: 10px; flex: 1 1 100%; height: 42px; order: 3; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row { position: relative; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-select { padding: 0 !important; position: absolute; right: 8px; top: 6px; width: auto !important; }
    .br-inv-row .br-inv-select .mud-checkbox { margin: 0; }
    .br-inv-row .br-inv-select .mud-checkbox .mud-button-root { padding: 6px; }
    .br-inv-row .br-inv-select .mud-checkbox svg { height: 26px; width: 26px; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row.br-pend-sel { background: #dcedc8 !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-t3:not(.br-inv-wide):nth-last-child(1) { grid-column: 2 / 4; }
}

/* Back arrow: soft primary-tinted round button with a clear arrow (no grey shadowed blob) */
@media (max-width: 959.95px) {
    .br-btn-back.mud-button-root {
        background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent) !important;
        box-shadow: none !important;
        color: var(--mud-palette-primary) !important;
        height: 38px;
        width: 38px;
    }

    .br-btn-back.mud-button-root::before { height: 22px; width: 22px; }
    .br-btn-back.mud-button-root:active { background: color-mix(in srgb, var(--mud-palette-primary) 22%, transparent) !important; }
}
@media (max-width: 959.95px) {
    .br-btn-back.mud-button-root::before { height: 28px; width: 28px; }
}
@media (max-width: 959.95px) {
    .br-btn-back.mud-button-root::before { flex: none; }
}
@media (max-width: 959.95px) {
    .br-btn-back.mud-button-root { align-items: center; display: inline-flex; justify-content: center; }
    .br-btn-back.mud-button-root::before { height: 20px; margin: 0; width: 20px; }
    .br-btn-back .mud-button-label { display: none; }
}

/* pending payment sessions: the last tile is not an action button, so it keeps its tile place */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row.br-pend-nobtn > td.br-pend-amt:last-child { grid-column: 2 / 4; grid-row: 4; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row.br-pend-nobtn > td.br-pend-amt:first-of-type { grid-column: 1; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row > td.mud-table-cell.br-desktop-only { display: none !important; }
}
@media (max-width: 959.95px) {
    /* pending payout card: plain eye icon, no circle */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-2row > td[data-label="Actions"] .mud-icon-button { background: none !important; border-radius: 50%; color: var(--mud-palette-primary) !important; height: 34px !important; min-height: 34px !important; min-width: 34px !important; width: 34px !important; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-2row > td[data-label="Actions"] .mud-icon-button svg { height: 22px; width: 22px; }
}

/* Expense cards on phones (same grouped design as invoices/payments) + cards that do not expand are not "clickable" */
@media (max-width: 959.95px) {
    .br-exp-left { align-items: baseline; display: inline-flex; flex-wrap: wrap; gap: 0 8px; min-width: 0; }
    .br-exp-left { font-weight: 600; }
    .br-exp-sub { color: var(--mud-palette-text-secondary); font-weight: 400; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-num { white-space: normal; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row td[data-label="Actions"] > div { gap: 8px; }
    /* these cards show everything at once, so no hand cursor */
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row,
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pend-row { cursor: default; }
    /* the sort-by picker above the cards has a single "Date" entry here and just adds noise */
    .mud-table:has(tr.br-inv-row) .mud-table-smalldevices-sortselect { display: none; }
}
@media (max-width: 959.95px) {
    .br-exp-left { align-items: flex-start; display: flex; flex-direction: column; gap: 2px; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-client:has(.br-exp-left) { align-items: flex-start; }
    .br-inv-client .br-inv-ic { flex: none; white-space: nowrap; }
}

/* Document cards on phones */
@media (max-width: 959.95px) {
    .br-doc-file { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-doc-meta { color: var(--mud-palette-text-secondary); font-size: .74rem; grid-column: 1 / -1; grid-row: 3; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-doc-meta span { padding-right: 4px; }
}
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-doc-meta { gap: 0 !important; justify-content: flex-start !important; }
}

/* Row number on phone cards (setup screens etc.): "#1" instead of a "No ... 1" row */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row:not(.br-inv-row):not(.br-pend-row):not(.br-block-row) td.mud-table-cell[data-label="No"] {
        color: var(--mud-palette-text-secondary);
        gap: 0 !important;
        justify-content: flex-start !important;
        text-align: left !important;
    }

    .mud-table.mud-sm-table tbody tr.mud-table-row:not(.br-inv-row):not(.br-pend-row):not(.br-block-row) td.mud-table-cell[data-label="No"]::before {
        content: "#" !important;
        display: inline !important;
        flex: none !important;
        padding: 0 !important;
        width: auto !important;
    }
}

/* Business hours on phones: summary card + one card per day */
@media (max-width: 959.95px) {
    .br-bh-hero { background: linear-gradient(135deg, var(--mud-palette-primary), color-mix(in srgb, var(--mud-palette-primary) 70%, #000)); border-radius: 16px; color: #fff; margin-bottom: 12px; padding: 14px; }
    .br-bh-nav { align-items: center; display: flex; justify-content: space-between; }
    .br-bh-navbtn { align-items: center; background: rgba(255, 255, 255, .18); border: 0; border-radius: 50%; color: #fff; display: inline-flex; height: 32px; justify-content: center; width: 32px; }
    .br-bh-range { font-size: 1rem; font-weight: 700; }
    .br-bh-sum { display: flex; font-size: .78rem; gap: 14px; justify-content: center; margin-top: 8px; opacity: .92; }
    .br-bh-inh { font-size: .7rem; font-style: italic; margin-top: 4px; opacity: .85; text-align: center; }
    .br-bh-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
    .br-bh-pill { background: transparent; border: 1px solid rgba(255, 255, 255, .7); border-radius: 999px; color: #fff; font-size: .78rem; font-weight: 600; padding: 5px 16px; }
    .br-bh-pill--solid { background: #fff; border-color: #fff; color: var(--mud-palette-primary); }

    .br-bh-day { align-items: center; background: var(--mud-palette-surface); border-left: 4px solid var(--mud-palette-primary); border-radius: 14px; box-shadow: 0 1px 4px rgba(0, 0, 0, .1); cursor: pointer; display: flex; gap: 14px; margin-bottom: 10px; padding: 10px 12px; }
    .br-bh-day.closed { border-left-color: #e57373; }
    .br-bh-day.today { background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface)); }
    .br-bh-date { align-items: center; background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent); border-radius: 12px; color: var(--mud-palette-primary); display: flex; flex: 0 0 52px; flex-direction: column; height: 52px; justify-content: center; }
    .br-bh-day.closed .br-bh-date { background: #fdecea; color: #c62828; }
    .br-bh-date .num { font-size: 1.15rem; font-weight: 700; line-height: 1; }
    .br-bh-date .dow { font-size: .68rem; letter-spacing: .04em; margin-top: 3px; text-transform: uppercase; }
    .br-bh-info { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
    .br-bh-hours { font-size: .95rem; font-weight: 600; }
    .br-bh-closed { color: #c62828; font-size: .9rem; font-weight: 600; }
    .br-bh-break { color: var(--mud-palette-text-secondary); font-size: .75rem; }
    .br-bh-go { color: var(--mud-palette-text-secondary); }
}

/* Business hours dialogs on phones: smaller type */
@media (max-width: 959.95px) {
    .bh-dlg .mud-dialog-title .mud-typography-h6 { font-size: 1rem !important; }
    .bh-dlg .mud-dialog-title .mud-typography-body2 { font-size: .75rem !important; }
    .bh-dlg .bh-open-row { font-size: .88rem; }
    .bh-dlg .mud-input-label { font-size: .8rem; }
    .bh-dlg .mud-input-slot, .bh-dlg .mud-input { font-size: .85rem; }
    .bh-dlg .mud-button-root { font-size: .78rem; }
}
@media (max-width: 959.95px) {
    .bh-dlg .mud-dialog-content { overflow-x: hidden; }
    .bh-dlg .mud-dialog-content > .bh-open-row,
    .bh-dlg .bh-time-row,
    .bh-dlg .bh-break-card { box-sizing: border-box; width: 100%; }
    .bh-dlg .bh-open-row span { white-space: nowrap; }
}
@media (max-width: 959.95px) {
    .bh-dlg .bh-open-row .mud-input-control { flex: 0 0 auto; width: auto !important; }
    .bh-dlg .bh-open-row .mud-switch { margin: 0; width: auto !important; }
}

/* The sort-by picker MudBlazor puts above card lists is confusing (often blank until opened): hidden on every phone list */
@media (max-width: 959.95px) {
    .mud-table-smalldevices-sortselect { display: none !important; }
}

/* a fourth tile colour (amount still due) */
@media (max-width: 959.95px) {
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-inv-row > td.br-inv-t4 { background: #fff3e0; }
}

/* Client dashboard KPI boxes on phones: compact */
@media (max-width: 959.95px) {
    .br-cli-kpi { margin-top: -8px !important; width: calc(100% + 12px); }
    .br-cli-kpi > .mud-grid-item { padding-top: 8px !important; }
    .br-cli-kpi .mud-card { border-radius: 12px; }
    .br-cli-kpi .mud-card-content { padding: 10px 8px !important; }
    .br-cli-kpi .mud-stack { gap: 2px !important; }
    .br-cli-kpi .mud-icon-root { font-size: 1.4rem !important; height: 1.4rem; width: 1.4rem; }
    .br-cli-kpi .mud-typography-h4 { font-size: 1.15rem !important; line-height: 1.3; }
    .br-cli-kpi .mud-typography-body2 { font-size: .7rem !important; line-height: 1.2; text-align: center; }
    .br-cli-kpi .mud-typography-caption { font-size: .62rem !important; }
}

/* Account > Profile / Security on phones: profile hero, compact fields, full-width save */
@media (max-width: 959.95px) {
    .br-prof { margin: 0 !important; width: 100% !important; }
    .br-prof > .mud-grid-item { padding: 0 0 12px !important; }

    .br-prof-card { border-radius: 16px; overflow: hidden; }
    .br-prof-card::before { background: linear-gradient(135deg, var(--mud-palette-primary), color-mix(in srgb, var(--mud-palette-primary) 65%, #000)); content: ""; display: block; height: 64px; }
    .br-prof-card .mud-card-content { padding: 0 16px 4px !important; text-align: center; }
    .br-prof-card .mud-card-content > .d-flex { margin: -40px 0 8px !important; }
    .br-prof-card .mud-avatar { border: 3px solid var(--mud-palette-surface); font-size: 2rem !important; height: 84px !important; width: 84px !important; }
    .br-prof-card .mud-typography-h6 { font-size: 1rem !important; }
    .br-prof-card .mud-typography-body1 { color: var(--mud-palette-text-secondary); font-size: .8rem !important; }
    .br-prof-card .mud-card-actions { gap: 4px; padding: 4px 8px 12px; }
    .br-prof-card .mud-card-actions .mud-button-root { font-size: .75rem; }

    .br-prof-form, .br-sec-card { border-radius: 16px; }
    .br-prof-form .mud-card-header, .br-sec-card .mud-card-header { padding: 14px 16px 0; }
    .br-prof-form .mud-card-header .mud-typography, .br-sec-card .mud-card-header .mud-typography { font-size: .95rem; font-weight: 600; }
    .br-prof-form .mud-card-content, .br-sec-card .mud-card-content { padding: 8px 16px 4px; }
    .br-prof-form .mud-grid, .br-sec-card .mud-grid { margin: 0 !important; width: 100% !important; }
    .br-prof-form .mud-grid > .mud-grid-item, .br-sec-card .mud-grid > .mud-grid-item { padding: 6px 0 !important; }
    .br-prof-form .mud-input, .br-sec-card .mud-input { font-size: .85rem; }
    .br-prof-form .mud-input-outlined .mud-input-slot, .br-sec-card .mud-input-outlined .mud-input-slot { padding-bottom: 11px; padding-top: 11px; }
    .br-prof-form .mud-input-label, .br-sec-card .mud-input-label { font-size: .85rem; }

    .br-prof-form .mud-card-actions, .br-sec-card .mud-card-actions { padding: 8px 16px 16px !important; }
    .br-prof-save.mud-button-root { border-radius: 10px; height: 42px; margin-left: 0 !important; width: 100%; }
}

/* Client payments on phones: summary banner, bolder tiles, compact Pay Now */
@media (max-width: 959.95px) {
    .br-pay-hero { border-radius: 0; color: #fff; display: flex; flex-direction: column; gap: 2px; margin: 12px 0; padding: 14px 16px; }
    .br-pay-hero--due { background: linear-gradient(135deg, #fb8c00, #e65100); }
    .br-pay-hero--paid { background: linear-gradient(135deg, #43a047, #1b5e20); }
    .br-pay-hero .lbl { font-size: .72rem; letter-spacing: .06em; opacity: .9; text-transform: uppercase; }
    .br-pay-hero .amt { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
    .br-pay-hero .sub { font-size: .78rem; opacity: .9; }
    .mud-table.mud-sm-table tbody tr.mud-table-row.br-pay-row > td.br-inv-tile { font-weight: 600; }
}

/* Client payments: the tabs' outer card has no border/shadow on phones, content sits straight on the page */
@media (max-width: 959.95px) {
    .br-pay-tabs, .br-pay-tabs.mud-elevation-2, .br-pay-tabs .mud-tabs-tabbar, .br-pay-tabs .mud-tabs-panels { background: transparent !important; border: 0 !important; box-shadow: none !important; }
    .br-pay-tabs .mud-tabs-panels { padding: 0 !important; }
}

/* helpers: something that is hidden on phones; card lists with alternating row colours + the same left accent as other lists */
@media (max-width: 959.95px) {
    .br-hide-phone { display: none !important; }
    .br-alt-cards > .mud-grid-item > .mud-card { border-left: 4px solid #1e88e5; }
    .br-alt-cards > .mud-grid-item:nth-child(even) > .mud-card { background: rgba(89, 74, 226, .09); border-left-color: #14b8c4; }
}

/* Client appointment cards */
.br-appt-head { align-items: center; display: flex; gap: 8px; justify-content: space-between; }
.br-appt-title { font-size: .95rem; font-weight: 700; }
.br-appt-who { align-items: baseline; color: var(--mud-palette-text-secondary); display: flex; font-size: .8rem; gap: 8px; justify-content: space-between; margin: 4px 0 10px; }
.br-appt-ther { text-align: right; }
.br-appt-tiles { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.br-appt-tile { align-items: center; border-radius: 10px; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; text-align: center; }
.br-appt-tile .lbl { color: var(--mud-palette-text-secondary); font-size: .6rem; letter-spacing: .04em; text-transform: uppercase; }
.br-appt-tile .val { font-size: .8rem; font-weight: 600; }
.br-appt-tile--date { background: #e3f2fd; }
.br-appt-tile--time { background: #f3e5f5; }

/* "Buy a Package" cards */
.br-buy-card { border-radius: 14px !important; }
.br-buy-head { align-items: flex-start; display: flex; gap: 10px; justify-content: space-between; }
.br-buy-name { font-size: .85rem; font-weight: 700; line-height: 1.3; }
.br-buy-price { background: color-mix(in srgb, var(--mud-palette-primary) 12%, transparent); border-radius: 999px; color: var(--mud-palette-primary); flex: none; font-size: .85rem; font-weight: 700; padding: 4px 12px; white-space: nowrap; }
.br-buy-desc { color: var(--mud-palette-text-secondary); font-size: .8rem; margin-top: 6px; }
.br-buy-lines { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.br-buy-line { align-items: center; background: rgba(0, 0, 0, .04); border-radius: 10px; display: flex; font-size: .7rem; gap: 8px; padding: 7px 10px; }
.br-buy-line .nm { flex: 1; min-width: 0; }
.br-buy-line .ct { color: var(--mud-palette-text-secondary); flex: none; font-size: .66rem; font-weight: 600; }
.br-buy-valid { align-items: center; color: var(--mud-palette-text-secondary); display: flex; font-size: .75rem; gap: 4px; margin-top: 10px; }
.br-buy-line .mud-icon-root { font-size: 1rem; height: 1rem; width: 1rem; }

/* Phones: same height for Pay Now as the other primary buttons; smaller text in info alerts ("No ... found.") */
@media (max-width: 959.95px) {
    .br-pay-row .mud-button-filled { height: 35px; }
    .mud-main-content .mud-alert .mud-alert-message { font-size: .8rem; }
}

/* New booking form on phones: smaller controls */
@media (max-width: 959.95px) {
    .br-bk-form .mud-input, .br-bk-form .mud-input-slot, .br-bk-form .mud-select-input { font-size: .8rem; }
    .br-bk-form .mud-input-label { font-size: .75rem; }
    .br-bk-form .mud-input-helper-text, .br-bk-form .mud-input-control-helper-container { font-size: .65rem; }
    .br-bk-form .mud-input-adornment .mud-icon-root, .br-bk-form .mud-select-input .mud-icon-root { font-size: 1.2rem; }
    .br-bk-form .mud-typography-subtitle1, .br-bk-form .mud-typography-subtitle2 { font-size: .82rem !important; }
    .br-bk-form .mud-typography-body1, .br-bk-form .mud-typography-body2 { font-size: .78rem !important; }
    .br-bk-form .mud-typography-caption { font-size: .68rem !important; }
    .br-bk-form .mud-chip { font-size: .72rem; }
}
