/*
 * Modern theme for the SASO app.
 *
 * The app ships only as a compiled bundle, so this is a layer on top of it,
 * loaded from index.html. Remove that <link> line to go back to the old look.
 *
 * - Joy UI tokens (colors, radius, font) are overridden on `:root:root` so they
 *   win over the theme variables Joy injects at runtime.
 * - Layout pieces (header, sidebar, cards, tables) are targeted by the class
 *   names the app already uses. Several of them carry inline styles or
 *   `!important` rules in the original CSS, hence the `!important`s here.
 */

/* ── Tokens ───────────────────────────────────────────────────────────────── */

:root:root {
    --mt-bg: #f4f6fb;
    --mt-surface: #ffffff;
    --mt-border: #e6e9f0;
    --mt-border-strong: #d5dae3;
    --mt-text: #0f172a;
    --mt-text-2: #475569;
    --mt-text-3: #94a3b8;
    --mt-side: #0f172a;
    --mt-side-text: #cbd5e1;
    --mt-side-muted: #64748b;
    --mt-accent: #2563eb;
    --mt-radius: 12px;
    --mt-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .04);
    --mt-shadow-lg: 0 10px 30px rgba(15, 23, 42, .10);
    --mt-font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

    --joy-palette-primary-50: #eff6ff;
    --joy-palette-primary-100: #dbeafe;
    --joy-palette-primary-200: #bfdbfe;
    --joy-palette-primary-300: #93c5fd;
    --joy-palette-primary-400: #60a5fa;
    --joy-palette-primary-500: #2563eb;
    --joy-palette-primary-600: #1d4ed8;
    --joy-palette-primary-700: #1e40af;
    --joy-palette-primary-800: #1e3a8a;
    --joy-palette-primary-900: #172554;
    --joy-palette-primary-mainChannel: 37 99 235;
    --joy-palette-primary-lightChannel: 191 219 254;
    --joy-palette-primary-darkChannel: 30 64 175;

    --joy-palette-success-500: #16a34a;
    --joy-palette-success-600: #15803d;
    --joy-palette-success-700: #166534;
    --joy-palette-success-mainChannel: 22 163 74;

    --joy-palette-neutral-50: #f8fafc;
    --joy-palette-neutral-100: #f1f5f9;
    --joy-palette-neutral-200: #e2e8f0;
    --joy-palette-neutral-300: #cbd5e1;
    --joy-palette-neutral-400: #94a3b8;
    --joy-palette-neutral-500: #64748b;
    --joy-palette-neutral-600: #475569;
    --joy-palette-neutral-700: #334155;
    --joy-palette-neutral-800: #1e293b;
    --joy-palette-neutral-900: #0f172a;

    --joy-palette-text-primary: var(--mt-text);
    --joy-palette-text-secondary: var(--mt-text-2);
    --joy-palette-text-tertiary: var(--mt-text-3);
    --joy-palette-background-body: var(--mt-bg);
    --joy-palette-background-surface: var(--mt-surface);
    --joy-palette-divider: var(--mt-border);

    --joy-radius-xs: 6px;
    --joy-radius-sm: 8px;
    --joy-radius-md: 10px;
    --joy-radius-lg: 14px;
    --joy-fontFamily-body: var(--mt-font);
    --joy-fontFamily-display: var(--mt-font);
}

/* ── Base ─────────────────────────────────────────────────────────────────── */

html body {
    font-family: var(--mt-font) !important;
    color: var(--mt-text) !important;
    background: var(--mt-bg);
    -webkit-font-smoothing: antialiased;
}

.main-layout__content,
.main-wrapper {
    background: var(--mt-bg);
}

* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

::selection {
    background: #bfdbfe;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

html .main-layout__header {
    background: var(--mt-surface) !important;
    height: 56px;
    flex: 0 0 56px;
    border-bottom: 1px solid var(--mt-border);
}

html .main-layout__header > div {
    box-shadow: none !important;
}

/* Brand block above the sidebar (covers the header's bottom border). Desktop
   header only (.w-100) - on phones the first slot is the menu button. */
html .main-layout__header.w-100 > div > div:first-child {
    background: var(--mt-side);
    border-bottom: 0 !important;
    height: calc(100% + 1px) !important;
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
    gap: 1px; /* icon B is the first letter of the name */
    justify-content: flex-start !important;
    padding-left: 22px;
}

html .main-layout__header > div > .flex-grow-0 {
    align-self: center;
}

html .main-layout__header.w-100 > div > div:first-child::before {
    content: "B"; /* app icon */
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #38bdf8 0%, #6366f1 55%, #8b5cf6 100%);
    box-shadow: 0 4px 14px rgba(99, 102, 241, .45), inset 0 1px 0 rgba(255, 255, 255, .25);
    color: #fff;
    font: 800 20px/1 var(--mt-font);
    letter-spacing: -.02em;
}

html .main-layout__header.w-100 > div > div:first-child::after {
    content: "RISMA"; /* with the B icon: "BRISMA" */
    font: 700 22px/1 var(--mt-font);
    letter-spacing: .02em;
    color: #fff;
    background: linear-gradient(90deg, #ffffff 0%, #c7d2fe 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Temple name (header): large, deep blue gradient, with an accent bar before it */
html .main-layout__header p.MuiTypography-root {
    color: #1e3a8a !important;
    font: 800 23px/1.15 var(--mt-font) !important;
    letter-spacing: -.015em;
    margin-left: 24px !important;
    white-space: nowrap;
    background: linear-gradient(90deg, #1e3a8a 0%, #4338ca 60%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

html .main-layout__header p.MuiTypography-root::before {
    content: "";
    flex: none;
    width: 5px;
    height: 26px;
    margin-right: 12px;
    border-radius: 3px;
    background: linear-gradient(180deg, #f59e0b 0%, #ea580c 100%);
}

@media (max-width: 1100px) {
    html .main-layout__header p.MuiTypography-root {
        font-size: 19px !important;
    }
}

/* Phones: the app's header has no name - show it between the menu and user buttons
   (written here, so update it if the temple name changes) */
html .main-layout__header:not(.w-100) > div > div:nth-child(2) {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 10px;
}

html .main-layout__header:not(.w-100) > div > div:nth-child(2)::before {
    content: "";
    flex: none;
    width: 4px;
    height: 20px;
    margin-right: 8px;
    border-radius: 2px;
    background: linear-gradient(180deg, #f59e0b 0%, #ea580c 100%);
}

html .main-layout__header:not(.w-100) > div > div:nth-child(2)::after {
    content: "Sri Ayyppa Samajam Of Ontario";
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font: 800 16px/1.2 var(--mt-font);
    letter-spacing: -.01em;
    color: #1e3a8a;
    background: linear-gradient(90deg, #1e3a8a 0%, #4338ca 60%, #7c3aed 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

html .main-layout__header:not(.w-100) > div > .me-auto,
html .main-layout__header:not(.w-100) > div > .ms-auto {
    margin: 0 !important;
    flex: none;
}

/* Global search */
html .main-layout__header .MuiAutocomplete-root {
    background: var(--joy-palette-neutral-100);
    border-color: transparent;
    min-width: 260px !important;
    min-height: 38px;
    border-radius: 10px;
}

html .main-layout__header .MuiAutocomplete-root:focus-within {
    background: var(--mt-surface);
}

/* Greeting + date */
html body .main-layout__header > div > div.ms-auto {
    align-items: center;
}

html body .main-layout__header > div > div.ms-auto > div:first-child > div {
    color: var(--mt-text) !important;
    font-weight: 600;
    margin-top: 0 !important;
}

html body .main-layout__header > div > div.ms-auto > div:first-child span.text-muted {
    color: var(--mt-text-2) !important;
    font-weight: 400 !important;
    margin-top: 2px !important;
    margin-bottom: 0 !important;
}

html body .main-layout__header > div > div.ms-auto svg {
    color: var(--mt-text-2) !important;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

html .main-layout__side-bar {
    background: var(--mt-side) !important;
}

html .main-sidebar .links {
    padding: 14px 10px 0 !important;
}

html .main-sidebar .sc-link {
    border-bottom: 0 !important;
    border-radius: 10px;
    padding: 10px 12px !important;
    margin-bottom: 4px;
    transition: background-color .15s ease;
}

html .main-sidebar .sc-link:hover {
    background-color: rgba(255, 255, 255, .06) !important;
}

html .main-sidebar .sc-link .poppins-font {
    color: var(--mt-side-text) !important;
    font: 500 14px/1.2 var(--mt-font) !important;
    margin-top: 0 !important;
}

html .main-sidebar .sc-link svg {
    color: var(--mt-side-muted) !important;
    width: 20px;
    height: 20px;
}

/* Active link (the app marks it with an inline primary-800 background) */
html .main-sidebar .sc-link[style*="primary-800"] {
    background: rgba(59, 130, 246, .16) !important;
    box-shadow: inset 3px 0 0 #60a5fa;
}

html .main-sidebar .sc-link[style*="primary-800"] .poppins-font {
    color: #fff !important;
    font-weight: 600 !important;
}

html .main-sidebar .sc-link[style*="primary-800"] svg {
    color: #93c5fd !important;
}

/* Missing business logo above Logout shows as a broken image */
html .main-sidebar .mt-auto > img {
    display: none;
}

/* Ayyappan image above Logout (sidebar-ayyappan.jpg); its edges fade into the sidebar */
html .main-sidebar > .mt-auto::before {
    content: "";
    display: block;
    width: 100%;
    max-width: 170px;
    aspect-ratio: 360 / 396;
    margin: 0 auto 16px;
    background: url("/sidebar-ayyappan.jpg") center / contain no-repeat;
    -webkit-mask-image: radial-gradient(farthest-side, #000 80%, transparent 100%);
    mask-image: radial-gradient(farthest-side, #000 80%, transparent 100%);
}

/* short windows: smaller, so the menu keeps its room */
@media (max-height: 760px) {
    html .main-sidebar > .mt-auto::before {
        max-width: 110px;
        margin-bottom: 10px;
    }
}

@media (max-height: 600px) {
    html .main-sidebar > .mt-auto::before {
        display: none;
    }
}

/* App version under Logout (same version as on the login page) */
html .main-sidebar > .mt-auto::after {
    content: "Ver 5.5.0";
    display: block;
    margin-top: 10px;
    text-align: center;
    font: 500 11px/1.2 var(--mt-font);
    letter-spacing: .06em;
    color: #64748b;
}

html .main-sidebar .mt-auto .MuiButton-root {
    background: rgba(255, 255, 255, .07);
    color: #e2e8f0;
    font-weight: 600;
}

html .main-sidebar .mt-auto .MuiButton-root:hover {
    background: rgba(239, 68, 68, .85);
    color: #fff;
}

/* ── Content: cards & sections ────────────────────────────────────────────── */

html .main-content {
    padding: 20px 24px !important;
}

/* Form sections (e.g. "Member Information" on /cust/new) */
html .main-content .bg-white.rounded-1 {
    background: var(--mt-surface) !important;
    border: 1px solid var(--mt-border);
    border-radius: var(--mt-radius) !important;
    box-shadow: var(--mt-shadow);
    padding: 0 0 20px !important;
    overflow: hidden;
}

html .main-content .bg-white.rounded-1 > div > .mt-2 {
    margin-top: 0 !important;
}

html .main-content .bg-white.rounded-1 .MuiTypography-variantSoft {
    background: transparent !important;
    border-bottom: 1px solid var(--mt-border);
    padding: 14px 20px !important;
    margin-bottom: 20px !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--mt-text) !important;
}

html .main-content .bg-white.rounded-1 .MuiTypography-variantSoft .MuiTypography-startDecorator svg {
    color: var(--mt-accent) !important;
}

html .main-content .bg-white.rounded-1 .thing {
    padding: 0 20px !important;
}

/* Cards (member view, etc.) */
html .main-content .MuiCard-root {
    background: var(--mt-surface) !important;
    border-color: var(--mt-border) !important;
    border-radius: var(--mt-radius);
    box-shadow: var(--mt-shadow);
}

/* Member view: keep the card within the page instead of pushing the
   photo and "Additional Members" off-screen */
html .main-content .d-flex.w-100 > .MuiCard-root {
    min-width: 0;
    flex: 1 1 auto;
}

html .main-content .MuiCard-root > .mt-2 > .d-flex {
    flex-wrap: wrap;
    gap: 16px 24px;
}

/* Member view card, compact: details | address & note | actions | photo in one row */
html .main-content .MuiCard-root.nowhite > .mt-2 {
    margin-top: 4px !important;
}

/* Don't stretch the card to the height of the "Additional Members" list */
html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) {
    align-items: flex-start;
    position: relative;
    gap: 16px;
}

/* Member Info fills the row; Additional Members is a narrow column on the right */
html .main-content .d-flex.w-100 > .MuiCard-root.nowhite {
    flex: 1 1 850px !important; /* fills the row up to the Additional Members list */
}

/* Additional Members: names one under another in a list that scrolls up/down,
   no taller than the Member Info card. The heading sits above the list, outside
   the scrolling area, so it stays put. */
html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 {
    flex: 0 1 300px; /* narrow column; long names still fit on one line */
    min-width: 220px;
    margin-left: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* the scrolling area starts below the heading, so names never slide under it */
    margin-top: 36px;
    max-height: 286px; /* + 36px heading = the Member Info card height */
    padding: 0 6px 4px 0; /* right: room for the scrollbar */
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--joy-palette-neutral-300) transparent;
    container-type: inline-size;
}

/* Out of the list: positioned against the member row (not the scroller), so it doesn't scroll */
html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 > h4 {
    position: absolute;
    top: 0;
    width: max-content;
    max-width: 100cqw;
    pointer-events: none;
    margin: 0 !important;
    font: 700 18px/1.3 var(--mt-font);
    color: var(--mt-text);
}

html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 > div {
    flex: 0 0 auto;
    min-width: 0;
}

html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 > div > .MuiCard-root {
    margin: 0 !important;
    padding: 10px 12px !important;
    border-radius: 12px;
}

/* "More below" hint on the list's bottom edge (member-view.js) */
html .mv-more {
    position: absolute;
    height: 56px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
    background: linear-gradient(to bottom, rgba(244, 246, 251, 0), var(--mt-bg) 75%);
    pointer-events: none;
    z-index: 2;
}

html .mv-more[hidden] {
    display: none;
}

html .mv-more button {
    pointer-events: auto;
    border: 1px solid var(--joy-palette-primary-200);
    border-radius: 999px;
    background: var(--joy-palette-primary-100); /* light blue */
    color: var(--joy-palette-primary-700);
    font: 600 12.5px/1 var(--mt-font);
    padding: 6px 12px;
    cursor: pointer;
    box-shadow: var(--mt-shadow);
}

html .mv-more button:hover {
    background: var(--joy-palette-primary-200);
}

/* Delete Photo in the enlarged photo view (member-view.js) */
html .mv-del-photo {
    margin-left: 16px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font: 600 13px/1 var(--mt-font);
    padding: 7px 12px;
    cursor: pointer;
}

html .mv-del-photo:hover,
html .mv-del-photo.is-armed {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

html .mv-del-photo:disabled {
    opacity: .6;
    cursor: default;
}

html .MuiDialogContent-root > .d-flex.justify-content-between:has(> .mv-del-photo) {
    align-items: center;
    justify-content: flex-start !important;
}

/* keep Download next to Delete Photo on the right */
html .MuiDialogContent-root > .d-flex.justify-content-between:has(> .mv-del-photo) > div:nth-child(2) {
    margin-left: auto;
}

html .mv-toast {
    position: fixed;
    left: 50%;
    top: 24px;
    transform: translateX(-50%);
    z-index: 20001;
    background: #166534;
    color: #fff;
    font: 500 14px var(--mt-font);
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}

html .mv-toast.is-error {
    background: #b91c1c;
}

/* "No Linked Members" text */
html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 > .opacity-50 {
    grid-column: 1 / span 2;
    font-size: 15px;
}

@media (max-width: 1000px) {
    html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) {
        flex-wrap: wrap;
    }

    html .main-content .d-flex.w-100 > .MuiCard-root.nowhite,
    html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 {
        flex: 1 1 100% !important;
    }

    /* Additional Members under the card: heading sits with its list, list not height-limited */
    html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 {
        margin-top: 0 !important;
        max-height: none;
        overflow: visible;
    }

    html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 > h4 {
        position: static;
        margin-bottom: 4px !important;
    }

    html .mv-more {
        display: none !important;
    }

    html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > .mv-title[data-name]:not([data-name=""])::after {
        font-size: 20px;
    }
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex {
    column-gap: 16px;
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > .field-group:first-child {
    flex: 0 1 auto; /* as wide as its content */
    min-width: 0;
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) {
    flex: 1 1 200px;
    min-width: 0;
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) > .field-group {
    margin-left: 0 !important;
}

/* Created / Updated: under the address instead of floating far below */
html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) > .d-flex.justify-content-end {
    justify-content: flex-start !important;
    margin: 4px 0 0 !important;
    font-size: 12px;
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) > .d-flex.justify-content-end td {
    padding: 1px 4px 1px 0;
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > .text-end.w-75 {
    order: 2; /* buttons after the photo */
    flex: 0 0 auto;
    width: auto !important;
    justify-content: flex-start !important;
    gap: 8px;
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > .text-end.w-75 > .MuiButton-root {
    width: 118px !important;
    margin: 0 !important;
    white-space: nowrap;
    padding: 0 10px !important;
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > .d-inline-block.ms-4 {
    order: 1; /* photo before the buttons */
    flex: 0 0 auto;
    margin-left: 0 !important;
    width: var(--mv-photo);
}

/* Photo box: fixed square (never grows with the picture); a photo fills it, cropped */
html .main-content .MuiCard-root.nowhite {
    --mv-photo: 140px;
}

@media (max-width: 1599px) {
    html .main-content .MuiCard-root.nowhite {
        --mv-photo: 110px;
    }
}

html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .wrapper,
html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .wrapper > .btn-1,
html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .wrapper > .btn-1 > div,
html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .wrapper > input,
html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .d-inline-block:first-child /* box when a photo is set */ {
    width: var(--mv-photo) !important;
    height: var(--mv-photo) !important;
    min-width: var(--mv-photo);
    max-width: var(--mv-photo);
    max-height: var(--mv-photo);
    flex: 0 0 auto;
    border-radius: 10px;
    overflow: hidden;
}

html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .wrapper img,
html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .d-inline-block:first-child > img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .wrapper > .btn-1 > div {
    background-color: var(--joy-palette-neutral-100) !important;
    color: var(--mt-text-3);
    font-size: 13px;
}

html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .mt-1.d-flex {
    width: var(--mv-photo);
    margin-top: 6px !important;
}

html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .mt-1.d-flex .MuiButton-root {
    min-height: 30px;
    min-width: 0;
    flex: 1 1 auto;
    padding: 0 4px;
    font-size: 12px;
    white-space: nowrap;
    --Button-gap: 4px;
}

/* Upload-from-file icon next to Camera: removed (Camera only) */
html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .mt-1.d-flex > .wrapper {
    display: none !important;
}

/* Tighter field rows */
html .main-content .MuiCard-root.nowhite .field-group > .mb-3 {
    margin-bottom: 6px !important;
}

html .main-content .MuiCard-root.nowhite .field-group .MuiFormControl-root > div > div:first-child {
    min-width: 0 !important;
    width: 128px !important;
    flex: 0 0 128px;
    margin-right: 12px !important;
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) .MuiFormControl-root > div > div:first-child {
    width: 76px !important;
    flex-basis: 76px;
}

html .main-content .MuiCard-root.nowhite .field-group .MuiFormLabel-root {
    min-height: 24px;
    padding: 2px 8px !important;
    margin-bottom: 0 !important;
}

html .main-content .MuiCard-root.nowhite .field-group .MuiFormControl-root > div > div:last-child {
    font-size: 15px;
    line-height: 24px;
    min-width: 0;
    overflow-wrap: break-word; /* break long words only if they cannot fit */
}

html .main-content .MuiCard-root.nowhite .field-group .MuiFormControl-root > div > div:last-child > span {
    display: inline-block;
    padding-top: 0 !important;
}

/* Values (incl. N/A) and Created / Updated in black */
html .main-content .MuiCard-root.nowhite .field-group .MuiFormControl-root > div > div:last-child,
html .main-content .MuiCard-root.nowhite .field-group .MuiFormControl-root > div > div:last-child *,
html .main-content .MuiCard-root.nowhite table td,
html .main-content .MuiCard-root.nowhite table td * {
    color: #000 !important;
    opacity: 1 !important;
}

/* Created / Updated: small print */
html .main-content .MuiCard-root.nowhite table td,
html .main-content .MuiCard-root.nowhite table td * {
    font-size: 11.5px !important;
    line-height: 1.5 !important;
}

/* Label pills on view pages */
html .main-content .MuiCard-root .MuiFormLabel-root {
    background: var(--joy-palette-primary-50) !important;
    color: var(--joy-palette-primary-700) !important;
    font-size: 12.5px;
    font-weight: 600;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 8px !important;
}

/* ── Member Info card: profile-card styling ──────────────────────────────── */

/* Header: title + member ID as a quiet badge */
html .main-content .MuiCard-root.nowhite > p.MuiTypography-root {
    font: 700 17px/1.3 var(--mt-font) !important;
}

html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > div:last-child {
    font: 600 13px/1 var(--mt-font);
    color: var(--mt-text-2);
    background: var(--joy-palette-neutral-100);
    border: 1px solid var(--mt-border);
    border-radius: 999px;
    padding: 5px 12px;
    letter-spacing: .02em;
}

/* Name + ACC ID, prominent (mv-title / mv-id + data-name / data-id set by member-view.js) */
html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex {
    align-items: center;
    gap: 18px;
    justify-content: flex-start !important;
}

/* ACC ID badge first, then a divider, then MEMBER INFO + name */
html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > .mv-id {
    order: -1;
}

html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > .mv-title {
    padding-left: 18px;
    border-left: 1px solid var(--mt-border-strong);
}

html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > .mv-title {
    font: 600 11px/1.2 var(--mt-font);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--joy-palette-primary-600); /* same as the ACC ID label */
    min-width: 0;
}

html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > .mv-title[data-name]:not([data-name=""])::after {
    content: attr(data-name);
    display: block;
    margin-top: 3px;
    font: 700 24px/1.2 var(--mt-font);
    letter-spacing: -.01em;
    text-transform: none;
    color: var(--joy-palette-primary-800); /* same as the ACC ID number */
    overflow-wrap: anywhere;
}

html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > .mv-id[data-id]:not([data-id=""]) {
    font-size: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    padding: 6px 16px;
    border-radius: 12px;
    background: var(--joy-palette-primary-50);
    border: 1px solid var(--joy-palette-primary-200);
}

html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > .mv-id[data-id]:not([data-id=""])::before {
    content: "ACC ID";
    font: 700 10.5px/1.2 var(--mt-font);
    letter-spacing: .1em;
    color: var(--joy-palette-primary-600);
}

html .main-content .MuiCard-root.nowhite > p.MuiTypography-root > .d-flex > .mv-id[data-id]:not([data-id=""])::after {
    content: attr(data-id);
    font: 800 22px/1.15 var(--mt-font);
    color: var(--joy-palette-primary-800);
    font-variant-numeric: tabular-nums;
}

/* Labels: small grey caps instead of blue pills */
html .main-content .MuiCard-root.nowhite .field-group .MuiFormLabel-root {
    background: transparent !important;
    color: var(--joy-palette-neutral-500) !important;
    padding: 0 !important;
    min-height: 0;
    font: 600 11px/24px var(--mt-font) !important;
    letter-spacing: .06em;
    text-transform: uppercase;
    justify-content: flex-start;
}

/* Rows: even spacing with faint dividers */
html .main-content .MuiCard-root.nowhite .field-group > .mb-3 {
    margin: 0 !important;
    padding: 7px 0;
    border-bottom: 1px solid #eef1f6;
}

/* last row of each column (the hidden width-measuring div comes after it) */
html .main-content .MuiCard-root.nowhite .field-group > .mb-3:nth-last-child(2) {
    border-bottom: 0;
}

html .main-content .MuiCard-root.nowhite .field-group .MuiFormControl-root > div > div:last-child {
    font-weight: 500;
}

/* No data: leave the value blank instead of "N/A" (data-empty set by member-view.js) */
html .main-content .MuiCard-root.nowhite .field-group .MuiFormControl-root > div > div:last-child[data-empty] > *,
html .main-content .MuiCard-root.nowhite table td[data-empty] > * {
    visibility: hidden;
}

/* Address/Note column: a little air from the details column */
html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) {
    padding-left: 20px;
    border-left: 1px solid #eef1f6;
}

/* Created / Updated: footer under the address */
html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) > .d-flex.justify-content-end {
    margin-top: 8px !important;
    padding-top: 8px;
    border-top: 1px dashed var(--mt-border);
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) > .d-flex.justify-content-end table td:first-child * {
    font-weight: 600 !important;
}

/* Photo: framed, with a full-width Camera button underneath */
html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .wrapper {
    border: 1px dashed var(--mt-border-strong);
    border-radius: 12px !important;
}

/* With a photo: solid frame, same rounded square */
html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .d-inline-block:first-child {
    border: 1px solid var(--mt-border-strong) !important;
    border-radius: 12px !important;
    background: var(--joy-palette-neutral-50) !important;
}

html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .wrapper > .btn-1 > div {
    background: var(--joy-palette-neutral-50) !important;
    font-size: 12px !important;
}

html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .mt-1.d-flex .MuiButton-root {
    border-color: var(--mt-border-strong);
    color: var(--joy-palette-neutral-700);
    background: var(--mt-surface);
}

html .main-content .MuiCard-root.nowhite .d-inline-block.ms-4 > .mt-1.d-flex .MuiButton-root:hover {
    background: var(--joy-palette-neutral-100);
}

/* Actions: equal-width buttons, aligned to the top of the photo */
html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > .text-end.w-75 {
    align-self: flex-start;
    gap: 10px;
}

/* Extra space between the photo and the buttons where the screen has room */
@media (min-width: 1600px) {
    html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > .text-end.w-75 {
        margin-left: 20px !important;
    }
}

/* Smaller screens: slightly narrower buttons/address so the card stays on one row */
@media (max-width: 1599px) {
    html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > .text-end.w-75 > .MuiButton-root {
        width: 112px !important;
    }

    html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > div:nth-child(2) {
        flex-basis: 180px;
    }

    /* give the card room: narrower Additional Members column */
    html .main-content .d-flex.w-100:has(> .MuiCard-root.nowhite) > .ms-3 {
        flex-basis: 240px;
    }
}

html .main-content .MuiCard-root.nowhite > .mt-2 > .d-flex > .text-end.w-75 > .MuiButton-root {
    width: 128px !important;
    min-height: 40px;
    border-radius: 10px;
}

/* ── Receipt form (/invoice/new) ──────────────────────────────────────────── */

html .main-content > div:has(> .thy) {
    max-width: 840px;
    margin: 8px auto 24px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
    border-radius: 16px;
    box-shadow: var(--mt-shadow);
    padding: 24px 36px 8px;
}

/* Title reads "Reciept - NAME"; show a clean "Receipt" heading with the name below */
html .main-content > div:has(> .thy) > h3 {
    font-size: 0 !important;
    color: var(--mt-text);
    padding-bottom: 16px;
    margin-bottom: 20px !important;
    border-bottom: 1px solid var(--mt-border);
}

html .main-content > div:has(> .thy) > h3::before {
    content: "Receipt";
    display: block;
    font: 700 26px/1.25 var(--mt-font);
    letter-spacing: -.01em;
}

/* member name under the title: not shown - the member card (receipt-member.js) has it */
html .main-content > div:has(> .thy) > h3 > span {
    display: none !important;
    margin-top: 4px;
    font: 500 18px/1.3 var(--mt-font) !important;
    color: var(--mt-accent);
}

html .main-content .thy {
    max-width: none !important;
    width: 100%;
}

html .main-content .thy .field {
    margin-bottom: 18px !important;
}

/* Amount Paid | Balance side by side, Note full width */
html .main-content .thy > .field-group:last-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
}

html .main-content .thy > .field-group:last-child > .field {
    width: auto !important;
    margin-right: 0 !important;
    min-width: 0;
}

/* Balance on the left, Amount Paid on the right (Balance isn't focusable, so tab order is unaffected) */
html .main-content .thy > .field-group:last-child > .field:nth-child(1) {
    grid-row: 1;
    grid-column: 2;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(2) {
    grid-row: 1;
    grid-column: 1;
    align-self: start;
    margin-top: 31px;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(n+3) {
    grid-column: 1 / -1;
}

html .main-content .thy .MuiFormLabel-root {
    font: 600 15px/1.3 var(--mt-font) !important;
    color: var(--joy-palette-neutral-700) !important;
    margin-bottom: 8px;
}

html .main-content .thy .MuiInput-root,
html .main-content .thy .MuiSelect-root,
html .main-content .thy .MuiAutocomplete-root {
    min-height: 48px;
    font-size: 17px !important;
    border-radius: 10px;
}

html .main-content .thy .MuiInput-root input,
html .main-content .thy .MuiSelect-button,
html .main-content .thy .MuiAutocomplete-input {
    font-size: 17px !important;
}

html .main-content .thy .MuiSelect-root .MuiSelect-button {
    padding: 0 4px;
}

html .main-content .thy .MuiTextarea-root {
    font-size: 16px;
    border-radius: 10px;
    min-height: 96px;
}

/* Amount Paid: the number people type and check — the most prominent field */
html .main-content .thy > .field-group:last-child > .field:nth-child(1) .MuiFormLabel-root {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--mt-text) !important;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(1) .MuiInput-root {
    min-height: 64px;
    font-size: 28px !important;
    background: var(--joy-palette-primary-50);
    border: 2px solid var(--joy-palette-primary-400);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .10);
}

html .main-content .thy > .field-group:last-child > .field:nth-child(1) .MuiInput-root:hover {
    border-color: var(--joy-palette-primary-500);
}

html .main-content .thy > .field-group:last-child > .field:nth-child(1) .MuiInput-root:focus-within {
    background: var(--mt-surface);
    border-color: var(--mt-accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .18);
}

html .main-content .thy > .field-group:last-child > .field:nth-child(1) .MuiInput-root input {
    font: 700 28px/1 var(--mt-font) !important;
    color: var(--mt-text);
    letter-spacing: .01em;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(1) .MuiInput-startDecorator {
    font: 700 28px/1 var(--mt-font);
    color: var(--joy-palette-primary-600);
}

/* Service: same highlight as Amount Paid (field tagged .mt-svc-field by service-menu.js) */
html .main-content .thy .field.mt-svc-field .MuiFormLabel-root {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--mt-text) !important;
}

html .main-content .thy .field.mt-svc-field .MuiSelect-root {
    background: var(--joy-palette-primary-50);
    border: 2px solid var(--joy-palette-primary-400);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .10);
    --Select-focusedHighlight: transparent;
}

html .main-content .thy .field.mt-svc-field .MuiSelect-root::before {
    box-shadow: none !important; /* Joy's own focus ring; the border below is used instead */
}

html .main-content .thy .field.mt-svc-field .MuiSelect-root:hover {
    border-color: var(--joy-palette-primary-500);
}

html .main-content .thy .field.mt-svc-field .MuiSelect-root:focus-within {
    background: var(--mt-surface);
    border-color: var(--mt-accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .18);
}

html .main-content .thy .field.mt-svc-field .MuiSelect-button {
    font-weight: 600 !important;
    color: var(--mt-text);
}

/* Balance: plain read-only figure (no highlight); turns red while money is owed */
html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div {
    background: transparent;
    border: 1px solid var(--mt-border);
    border-radius: 12px;
    min-height: 64px;
    padding: 6px 18px;
    gap: 12px;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div > div:first-child {
    width: auto !important;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormLabel-root {
    margin: 0 !important;
    color: var(--mt-text-2) !important;
    font-size: 15px !important;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div > div:last-child {
    font: 600 22px/1.1 var(--mt-font);
    color: var(--mt-text-2);
    font-variant-numeric: tabular-nums;
}

/* Balance still owed (flag set by receipt-balance.js) */
html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div[data-balance="due"] {
    border-color: #fecaca;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div[data-balance="due"] > div:last-child {
    font-weight: 700;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div[data-balance="due"] .MuiFormLabel-root,
html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div[data-balance="due"] > div:last-child {
    color: #dc2626 !important;
}

/* Paid in full: balance $0.00 after an amount was received (flag set by receipt-balance.js) */
html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div[data-balance="paid"] {
    border-color: #bbf7d0;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div[data-balance="paid"] .MuiFormLabel-root,
html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div[data-balance="paid"] > div:last-child {
    color: #16a34a !important;
}

html .main-content .thy > .field-group:last-child > .field:nth-child(2) .MuiFormControl-root > div[data-balance="paid"] > div:last-child {
    font-weight: 700;
}

html .main-content .thy .MuiFormHelperText-root {
    font-size: 14px;
}

/* Cancel / Submit directly below Note, as the card's footer.
   The buttons live in the app's bottom bar (a sibling of the content area), so
   the content area is no longer stretched and the bar is styled as the card's
   bottom edge. On short screens the whole column (card + footer) scrolls together. */
html .main-wrapper:has(.thy) {
    overflow-y: auto !important;
}

html .main-wrapper:has(.thy) > .main-layout__content {
    flex: 0 0 auto !important;
    overflow: visible !important;
}

html .main-wrapper:has(.thy) .main-content {
    padding-bottom: 0 !important;
}

html .main-content > div:has(> .thy) {
    margin-bottom: 0;
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: none;
    padding-bottom: 0;
}

html .main-wrapper:has(.thy) > .border-top.mt-auto {
    margin-top: 0 !important;
    border-top: 0 !important;
    box-shadow: none !important;
    background: transparent;
}

html .main-wrapper:has(.thy) > .border-top.mt-auto > div {
    max-width: 840px;
    margin: 0 auto 24px;
    background: var(--mt-surface) !important;
    backdrop-filter: none !important;
    border: 1px solid var(--mt-border);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    padding: 4px 36px 24px !important;
}

html .main-wrapper:has(.thy) > .border-top.mt-auto .MuiButton-root {
    min-height: 46px;
    padding: 0 28px;
    font-size: 16px;
}

/* ── Receipt view (/invoice/:id/view) — same card as the new-receipt form ── */
/* .receipt-view is added by receipt-balance.js (the app gives this block no class). */

html .main-content > .receipt-view {
    max-width: 840px;
    margin: 8px auto 24px;
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
    border-radius: 16px;
    box-shadow: var(--mt-shadow);
    padding: 24px 36px 22px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-flow: row dense;
    column-gap: 16px;
}

html .main-content > .receipt-view > * {
    grid-column: 1 / -1;
}

html .main-content > .receipt-view > h3 {
    font-size: 0 !important;
    padding-bottom: 16px;
    margin-bottom: 20px !important;
    border-bottom: 1px solid var(--mt-border);
}

html .main-content > .receipt-view > h3::before {
    content: "Receipt";
    display: block;
    font: 700 26px/1.25 var(--mt-font);
    letter-spacing: -.01em;
    color: var(--mt-text);
}

html .main-content > .receipt-view > h3::after {
    content: none; /* member name: shown on the member card instead */
    display: none;
    margin-top: 4px;
    font: 500 18px/1.3 var(--mt-font);
    color: var(--mt-accent);
}

/* Fields become grid items */
html .main-content > .receipt-view > .field-group {
    display: contents;
}

html .main-content > .receipt-view .field,
html .main-content > .receipt-view > .MuiFormControl-root {
    grid-column: 1 / -1;
    width: auto !important;
    margin: 0 0 18px !important;
}

html .main-content > .receipt-view > div.mb-3:empty,
html .main-content > .receipt-view > br,
html .main-content > .receipt-view > .mt-6:empty {
    display: none;
}

/* Date | Receipt No */
html .main-content > .receipt-view > h3 + .field-group > .field:nth-child(1) {
    grid-column: 1 / 4;
}

html .main-content > .receipt-view > h3 + .field-group > .field:nth-child(2) {
    grid-column: 4 / 7;
}

/* Balance | Amount Received (second group: Payment, Amount, Balance, Note) */
html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(2) {
    grid-column: 4 / 7;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) {
    grid-column: 1 / 4;
    align-self: end;
}

/* Labels: plain, like the form */
html .main-content > .receipt-view .MuiFormControl-root > div > div:first-child {
    min-height: 0 !important;
}

html .main-content > .receipt-view .MuiFormLabel-root {
    background: transparent !important;
    padding: 0 !important;
    margin-bottom: 8px !important;
    font: 600 15px/1.3 var(--mt-font) !important;
    color: var(--joy-palette-neutral-700) !important;
}

/* Values: read-only boxes the same size as the form inputs */
html .main-content > .receipt-view .MuiFormControl-root > div > div:last-child {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 4px 14px;
    background: var(--joy-palette-neutral-50);
    border: 1px solid var(--mt-border-strong);
    border-radius: 10px;
    font: 400 17px/1.4 var(--mt-font);
    color: var(--mt-text);
}

html .main-content > .receipt-view .MuiFormControl-root > div > div:last-child br {
    display: none;
}

/* Amount Received: prominent */
html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(2) .MuiFormLabel-root {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--mt-text) !important;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(2) .MuiFormControl-root > div > div:last-child {
    min-height: 64px;
    background: var(--joy-palette-primary-50);
    border: 2px solid var(--joy-palette-primary-400);
    border-radius: 12px;
    font: 700 28px/1 var(--mt-font);
}

/* Balance: label and value in one plain panel */
html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div {
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
    padding: 6px 18px;
    border: 1px solid var(--mt-border);
    border-radius: 12px;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div > div:first-child {
    width: auto !important;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormLabel-root {
    margin: 0 !important;
    color: var(--mt-text-2) !important;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div > div:last-child {
    min-height: 0;
    padding: 0;
    background: none;
    border: 0;
    font: 600 22px/1.1 var(--mt-font);
    color: var(--mt-text-2);
    font-variant-numeric: tabular-nums;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div[data-balance="due"] {
    border-color: #fecaca !important;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div[data-balance="paid"] {
    border-color: #bbf7d0 !important;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div[data-balance="due"] .MuiFormLabel-root,
html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div[data-balance="due"] > div:last-child {
    color: #dc2626 !important;
    font-weight: 700 !important;
}

html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div[data-balance="paid"] .MuiFormLabel-root,
html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) .MuiFormControl-root > div[data-balance="paid"] > div:last-child {
    color: #16a34a !important;
    font-weight: 700 !important;
}

/* Footer: Update | Print | Cancel */
html .main-content > .receipt-view > .MuiButton-root {
    grid-column: span 2;
    width: auto !important;
    min-height: 46px;
    margin: 6px 0 0 !important;
    font-size: 16px;
    border-radius: 10px;
}

html .main-content > .receipt-view > .MuiButton-root:nth-of-type(1) {
    background: var(--mt-accent) !important;
    color: #fff;
}

html .main-content > .receipt-view > .MuiButton-root:nth-of-type(2) {
    background: var(--joy-palette-primary-50) !important;
    color: var(--joy-palette-primary-700);
    border: 1px solid var(--joy-palette-primary-200);
    box-shadow: none;
}

html .main-content > .receipt-view > .MuiButton-root:nth-of-type(3) {
    background: var(--mt-surface) !important;
    color: var(--joy-palette-neutral-700);
    border: 1px solid var(--mt-border-strong);
    box-shadow: none;
}

html .main-content > .receipt-view > .MuiButton-root:nth-of-type(3):hover {
    background: var(--joy-palette-neutral-100) !important;
}

/* Created / Updated */
html .main-content > .receipt-view > .d-inline-block:not(.rp-panel) {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--mt-border);
    font-size: 12px;
}

@media (max-width: 600px) {
    html .main-content > .receipt-view {
        padding: 20px 20px 18px;
        margin-top: 0;
    }

    html .main-content > .receipt-view > h3 + .field-group > .field:nth-child(n),
    html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(n) {
        grid-column: 1 / -1;
    }

    html .main-content > .receipt-view > div.mb-3 + .field-group > .field:nth-child(3) {
        grid-row: auto;
    }
}

/* "Previous balance" badge, top right of the new-receipt card (receipt-balance.js) */
html .main-content > div:has(> .thy) {
    position: relative;
}

html .main-content > div:has(> .thy) > .rb-prev {
    position: absolute;
    top: 24px;
    right: 36px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding: 8px 14px;
    border: 1px solid #fecaca;
    border-radius: 12px;
    background: #fef2f2;
    color: #b91c1c;
    text-decoration: none;
}

html .main-content > div:has(> .thy) > .rb-prev:hover {
    background: #fee2e2;
}

html .main-content > div:has(> .thy) > .rb-prev span {
    font: 600 11px/1.2 var(--mt-font);
    letter-spacing: .05em;
    text-transform: uppercase;
}

html .main-content > div:has(> .thy) > .rb-prev strong {
    font: 700 20px/1.1 var(--mt-font);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
    html .main-content > div:has(> .thy) > .rb-prev {
        top: 18px;
        right: 20px;
        padding: 6px 10px;
    }

    html .main-content > div:has(> .thy) > .rb-prev strong {
        font-size: 17px;
    }
}

/* Receipt edit lock (data-locked / .receipt-locked-btn set by receipt-balance.js) */
html .main-content > .receipt-view[data-locked]::after,
html .main-content > div:has(> .thy)[data-locked]::after {
    content: "\1F512\00A0\00A0" attr(data-locked);
    display: block;
    grid-column: 1 / -1;
    order: 3;
    margin: 14px 0 0;
    padding: 10px 14px;
    border: 1px solid #fde68a;
    border-radius: 10px;
    background: #fffbeb;
    color: #92400e;
    font: 500 14px/1.45 var(--mt-font);
}

html .main-content > div:has(> .thy)[data-locked]::after {
    margin: 0 0 16px;
}

/* Member card on receipt pages (receipt-member.js): top left beside the receipt
   when there is room, above it otherwise */
html .main-content:has(> .rm-card) {
    position: relative;
}

html .rm-card {
    position: absolute;
    top: 24px;
    left: 24px;
    width: calc((100% - 840px) / 2 - 48px);
    max-width: 320px;
    background: var(--mt-surface, #fff);
    border: 1px solid var(--mt-border);
    border-radius: 16px;
    box-shadow: var(--mt-shadow);
    padding: 20px 22px;
    font-family: var(--mt-font);
    color: var(--mt-text);
    z-index: 1;
}

html .rm-label {
    font: 600 11px/1.2 var(--mt-font);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--mt-text-2);
}

html .rm-name {
    display: block;
    margin-top: 6px;
    font: 700 19px/1.25 var(--mt-font);
    color: var(--joy-palette-primary-700, #1d4ed8);
    text-decoration: none;
    overflow-wrap: anywhere;
}

html .rm-name:hover {
    text-decoration: underline;
}

html .rm-id {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--joy-palette-primary-50, #eff6ff);
    color: var(--joy-palette-primary-700, #1d4ed8);
    font: 600 12px/1.6 var(--mt-font);
}

html .rm-list {
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--mt-border);
}

html .rm-list dt {
    margin-top: 12px;
    font: 600 11px/1.2 var(--mt-font);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--mt-text-3, #94a3b8);
}

html .rm-list dt:first-child {
    margin-top: 0;
}

html .rm-list dd {
    margin: 4px 0 0;
    font: 500 15px/1.45 var(--mt-font);
    color: var(--mt-text);
    overflow-wrap: anywhere;
}

html .rm-list dd a {
    color: inherit;
    text-decoration: none;
}

html .rm-list dd a:hover {
    color: var(--joy-palette-primary-600, #2563eb);
    text-decoration: underline;
}

html .rm-none {
    color: var(--mt-text-3, #94a3b8);
}

/* not enough room beside the receipt: above it, as wide as the receipt */
@media (max-width: 1620px) {
    html .rm-card {
        position: static;
        width: auto;
        max-width: 840px;
        margin: 8px auto 14px;
        box-shadow: none;
    }

    html .rm-list {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        column-gap: 18px;
        border-top: 1px solid var(--mt-border);
    }

    html .rm-list dt {
        grid-row: 1;
        margin-top: 0;
    }

    html .rm-list dd {
        grid-row: 2;
    }
}

@media (max-width: 600px) {
    html .rm-card {
        margin: 0 0 12px;
        padding: 16px 18px;
    }

    html .rm-list {
        grid-template-columns: minmax(0, 1fr);
    }

    html .rm-list dt,
    html .rm-list dd {
        grid-row: auto;
    }

    html .rm-list dt {
        margin-top: 10px;
    }

    html .rm-list dt:first-child {
        margin-top: 0;
    }
}

/* Receipt items (receipt-items.js) */
html .main-content .field.ri-hidden {
    display: none !important;
}

html .ri-panel {
    grid-column: 1 / -1;
    margin: -4px 0 18px;
}

html .ri-open,
html .ri-add {
    border: 1px dashed var(--joy-palette-primary-300, #93c5fd);
    background: var(--joy-palette-primary-50, #eff6ff);
    color: var(--joy-palette-primary-700, #1d4ed8);
    border-radius: 10px;
    min-height: 40px;
    padding: 0 16px;
    font: 600 14px var(--mt-font);
    cursor: pointer;
}

html .ri-open:hover,
html .ri-add:hover {
    background: var(--joy-palette-primary-100, #dbeafe);
}

html .ri-panel.is-open {
    border: 1px solid var(--mt-border);
    border-radius: 12px;
    padding: 14px;
    background: var(--joy-palette-neutral-50, #f8fafc);
}

html .ri-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 10px;
    font: 700 15px var(--mt-font);
    color: var(--mt-text);
}

html .ri-hint {
    font: 500 12px var(--mt-font);
    color: var(--mt-text-2);
}

html .ri-cols,
html .ri-row {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr) 64px 92px 84px 28px;
    gap: 8px;
    align-items: center;
}

html .ri-cols {
    padding: 0 2px 6px;
    font: 600 11px var(--mt-font);
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--mt-text-2);
}

html .ri-cols span:nth-child(n+3) {
    text-align: right;
}

html .ri-row {
    padding: 6px 0;
    border-top: 1px solid var(--mt-border);
}

html .ri-row input,
html .ri-row select {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--mt-border-strong, #d5dae3);
    border-radius: 8px;
    background: #fff;
    font: 400 15px var(--mt-font);
    color: var(--mt-text);
}

/* member receipt history: the date text uses the row's 14px like the other columns (cell tagged in the bundle, m30) */
html td.berlin-data[style*="--mt-plain"] .MuiTypography-root {
    font-size: inherit;
    font-weight: inherit;
}

/* member receipt history: bold column headings */
html table:has(td.berlin-data[style*="--mt-plain"]) th,
html table:has(td.berlin-data[style*="--mt-plain"]) th * {
    font-weight: 700 !important;
    color: var(--mt-text, #0f172a) !important;
}

/* item picker: service parents stand out as tinted, bold headers */
html .ri-row select optgroup {
    background: #dbe6fb;
    color: #1e3a8a;
    font-weight: 700;
    font-style: normal;
}

html .ri-row select optgroup option {
    background: #fff;
    color: var(--mt-text, #111827);
    font-weight: 400;
}

html .ri-row input:focus,
html .ri-row select:focus {
    outline: none;
    border-color: var(--mt-accent, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

html .ri-qty,
html .ri-price {
    text-align: right;
}

html .ri-main {
    font: 600 15px var(--mt-font);
    color: var(--mt-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html .ri-total {
    text-align: right;
    font: 600 15px var(--mt-font);
    font-variant-numeric: tabular-nums;
}

html .ri-del {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--mt-text-2);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

html .ri-del:hover {
    background: #fee2e2;
    color: #b91c1c;
}

html .ri-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--mt-border);
}

html .ri-sum {
    font: 500 15px var(--mt-font);
    color: var(--mt-text-2);
}

html .ri-sum b {
    margin-left: 8px;
    font-size: 18px;
    color: var(--mt-text);
}

@media (max-width: 600px) {
    html .ri-cols {
        display: none;
    }

    html .ri-row {
        grid-template-columns: minmax(0, 1fr) 70px 90px 28px;
        grid-template-areas: "svc svc svc del" "desc desc desc desc" "qty price total total";
    }

    html .ri-row > :nth-child(1) { grid-area: svc; }
    html .ri-row > :nth-child(2) { grid-area: desc; }
    html .ri-row > :nth-child(3) { grid-area: qty; }
    html .ri-row > :nth-child(4) { grid-area: price; }
    html .ri-row > :nth-child(5) { grid-area: total; }
    html .ri-row > :nth-child(6) { grid-area: del; }
}

/* view page: the lines */
html .main-content > .receipt-view > .ri-view {
    grid-column: 1 / -1;
    order: 0; /* after the fields, before the buttons */
    margin: 4px 0 8px;
    border: 1px solid var(--mt-border);
    border-radius: 12px;
    padding: 14px 16px;
}

html .ri-view table {
    width: 100%;
    border-collapse: collapse;
    font: 400 15px var(--mt-font);
}

html .ri-view th {
    text-align: left;
    font: 600 11px var(--mt-font);
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--mt-text-2);
    padding: 6px 8px;
    border-bottom: 1px solid var(--mt-border);
}

html .ri-view td {
    padding: 8px;
    border-bottom: 1px solid var(--mt-border);
}

html .ri-view .r {
    text-align: right;
    white-space: nowrap;
}

html .ri-view tfoot td {
    font-weight: 700;
    border-bottom: 0;
}

/* Payment Method as pills (receipt-pills.js); the drop-down stays, hidden */
html .main-content .field.rp-has-pills .MuiSelect-root {
    display: none !important;
}

html .rp-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

html .rp-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--mt-border-strong, #d5dae3);
    border-radius: 999px;
    background: var(--mt-surface, #fff);
    color: var(--mt-text, #0f172a);
    font: 600 15px/1 var(--mt-font);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

html .rp-pill:hover:not([disabled]) {
    border-color: var(--joy-palette-primary-300, #93c5fd);
    background: var(--joy-palette-primary-50, #eff6ff);
}

html .rp-pill:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .25);
}

html .rp-pill.is-on {
    border-color: var(--joy-palette-primary-600, #2563eb);
    background: var(--joy-palette-primary-600, #2563eb);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .25);
}

html .rp-pill-check {
    display: none;
    font-size: 13px;
}

html .rp-pill.is-on .rp-pill-check {
    display: inline;
}

/* Submit without a payment method (receipt-pills.js) */
html .rp-pills.rp-missing .rp-pill {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

html .rp-missing-note {
    margin-top: 6px;
    font: 600 13px var(--mt-font);
    color: #dc2626;
}

html .rp-pill[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

/* wider screens: one even row */
@media (min-width: 601px) {
    html .rp-pills {
        flex-wrap: nowrap;
        gap: 8px;
    }

    html .rp-pill {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
        padding: 0 10px;
        white-space: nowrap;
    }
}

@media (max-width: 600px) {
    html .rp-pills {
        gap: 8px;
    }

    html .rp-pill {
        min-height: 42px;
        padding: 0 14px;
        font-size: 14px;
    }
}

/* VOID banner under the title (receipt-balance.js) */
html .main-content > .receipt-view > h3 {
    order: -2;
}

html .main-content > .receipt-view > .rv-void {
    order: -1;
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    margin: -6px 0 18px;
    padding: 12px 16px;
    border: 1px solid #fecaca;
    border-radius: 12px;
    background: #fef2f2;
    color: #991b1b;
    font: 500 15px/1.4 var(--mt-font);
}

html .main-content > .receipt-view > .rv-void strong {
    font-weight: 800;
    letter-spacing: .08em;
    color: #dc2626;
}

html .main-content > .receipt-view > .rv-void .rv-void-by {
    margin-left: auto;
    font-size: 13px;
    color: #b91c1c;
}

/* Card order: fields, buttons, Payments (receipt-payments.js), lock notice, Created/Updated */
html .main-content > .receipt-view > .MuiButton-root {
    order: 1;
}

html .main-content > .receipt-view > .rp-panel {
    order: 2;
    margin-top: 14px !important;
}

html .main-content > .receipt-view > .d-inline-block:not(.rp-panel) {
    order: 4;
}

html .MuiButton-root.receipt-locked-btn,
html .main-content > .receipt-view > .MuiButton-root.receipt-locked-btn {
    opacity: .45;
    cursor: not-allowed;
    box-shadow: none;
}

/* ── New / Edit Member form — same card format as the receipt ──────────────── */
/* .bg-white.rounded-1 is the app's FormSection, used only by the member form. */

html .main-content .mt-2.ms-2:has(> div > .bg-white.rounded-1) {
    margin: 0 !important;
}

html .main-content .bg-white.rounded-1 {
    max-width: 760px;
    margin: 8px auto 0;
    border-radius: 16px 16px 0 0 !important;
    border-bottom: 0;
    box-shadow: none;
    padding: 0 0 4px !important;
}

/* Title bar */
html .main-content .bg-white.rounded-1 .MuiTypography-variantSoft {
    font-size: 22px !important;
    padding: 20px 32px 16px !important;
    margin-bottom: 22px !important;
}

html .main-content .bg-white.rounded-1 .thing {
    padding: 0 32px !important;
}

/* Two even columns: personal details | address */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 {
    width: 100% !important;
    max-width: none !important;
    gap: 24px;
}

html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300 {
    flex: 1 1 0;
    width: auto !important;
    min-width: 0;
    margin-left: 0 !important;
}

html .main-content .bg-white.rounded-1 .thing > .wp-600 {
    width: 100% !important;
    max-width: none !important;
}

html .main-content .bg-white.rounded-1 .field {
    margin-bottom: 18px !important;
}

/* DOB | Gender */
html .main-content .bg-white.rounded-1 .wp-300 > .d-flex {
    gap: 12px;
}

html .main-content .bg-white.rounded-1 .wp-300 > .d-flex > .w-50 {
    flex: 1 1 0;
    width: auto !important;
    min-width: 0;
    margin-left: 0 !important;
}

/* let the date picker and select shrink to share the row */
html .main-content .bg-white.rounded-1 .wp-300 > .d-flex > .w-50 *:not(svg):not(path) {
    min-width: 0 !important;
}

html .main-content .bg-white.rounded-1 .wp-300 > .d-flex > .w-50 input {
    width: 100%;
}

/* Labels and inputs: same size as the receipt */
html .main-content .bg-white.rounded-1 .MuiFormLabel-root {
    font: 600 15px/1.3 var(--mt-font) !important;
    color: var(--joy-palette-neutral-700) !important;
    margin-bottom: 8px;
}

html .main-content .bg-white.rounded-1 .MuiInput-root,
html .main-content .bg-white.rounded-1 .MuiSelect-root,
html .main-content .bg-white.rounded-1 .MuiAutocomplete-root {
    min-height: 48px;
    font-size: 17px !important;
    border-radius: 10px;
}

html .main-content .bg-white.rounded-1 .MuiInput-root input,
html .main-content .bg-white.rounded-1 .MuiSelect-button,
html .main-content .bg-white.rounded-1 .MuiAutocomplete-input {
    font-size: 17px !important;
}

html .main-content .bg-white.rounded-1 .MuiTextarea-root {
    min-height: 0 !important;
    font-size: 16px;
    border-radius: 10px;
}

/* Note: about two lines tall, grows with the text (up to ~8 lines) */
html .main-content .bg-white.rounded-1 .MuiTextarea-root textarea:not([aria-hidden="true"]):not([tabindex="-1"]) {
    height: auto !important;
    min-height: calc(2 * 1.5em) !important;
    max-height: calc(8 * 1.5em);
    line-height: 1.5;
    field-sizing: content;
    overflow-y: auto !important;
}

html .main-content .bg-white.rounded-1 .thing > .wp-600 > hr {
    margin: 4px 0 18px;
}

/* Cancel / Submit as the card's footer, right under Note (desktop) */
html .main-wrapper:has(.main-content .bg-white.rounded-1) {
    overflow-y: auto !important;
}

html .main-wrapper:has(.main-content .bg-white.rounded-1) > .main-layout__content {
    flex: 0 0 auto !important;
    overflow: visible !important;
}

html .main-wrapper:has(.main-content .bg-white.rounded-1) .main-content {
    padding-bottom: 0 !important;
}

html .main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto {
    margin-top: 0 !important;
    border-top: 0 !important;
    box-shadow: none !important;
    background: transparent;
}

html .main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto > div {
    max-width: 760px;
    margin: 0 auto 24px;
    background: var(--mt-surface) !important;
    backdrop-filter: none !important;
    border: 1px solid var(--mt-border);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    padding: 6px 32px 24px !important;
}

html .main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto > div > .d-flex {
    flex-wrap: wrap;
    gap: 10px;
}

html .main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto .MuiButton-root {
    min-height: 46px;
    padding: 0 22px;
    font-size: 16px;
    border-radius: 10px;
}

html .main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto .ms-auto .MuiButton-root {
    margin: 0 !important;
}

html .main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto .ms-auto {
    gap: 48px; /* space between Cancel and Submit */
}

/* Member form buttons, one tidy layout (desktop and phone):
     Cancel ........................ Submit & Create Invoice   Submit
     ───────────────────────────────────────────────────────────────
     Delete Member   Deactivate              (edit only, smaller)
   The two groups the app renders are flattened (display: contents) and
   the buttons placed by their label. */
html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .d-flex.justify-content-between {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px !important;
}

html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .d-flex.justify-content-between > .d-flex {
    display: contents !important;
}

html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root {
    margin: 0 !important;
}

html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root[text="Cancel"] {
    order: 1;
    margin-right: auto !important;
}

html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root[text^="Submit &"] {
    order: 2;
}

html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root[text="Submit"] {
    order: 3;
    min-width: 120px;
}

/* divider + second row, only when Deactivate / Delete Member are there */
html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .d-flex.justify-content-between:has(.MuiButton-root[text="Deactivate"], .MuiButton-root[text="ReActivate"], .MuiButton-root[text="Delete Member"])::after {
    content: "";
    order: 4;
    flex: 0 0 100%;
    height: 0;
    margin: 8px 0 4px;
    border-top: 1px solid var(--mt-border);
}

html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root:is([text="Deactivate"], [text="ReActivate"], [text="Delete Member"]) {
    order: 6;
    min-height: 38px !important;
    padding: 0 16px !important;
    font-size: 14px !important;
    background: transparent !important;
    border: 1px solid currentColor !important;
}

html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root[text="Delete Member"] {
    order: 5;
}

html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root:is([text="Deactivate"], [text="ReActivate"], [text="Delete Member"]):hover {
    background: color-mix(in srgb, currentColor 8%, transparent) !important;
}

/* Phones: Submit & Create Invoice full width, then Cancel | Submit, then
   Delete Member | Deactivate - each pair splits the row */
@media (max-width: 600px) {
    html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root[text^="Submit &"] {
        order: 0;
        flex: 1 1 100%;
    }

    html :is(.main-wrapper:has(.main-content .bg-white.rounded-1) > .border-top.mt-auto, .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom) .MuiButton-root:is([text="Cancel"], [text="Submit"], [text="Deactivate"], [text="ReActivate"], [text="Delete Member"]) {
        flex: 1 1 0;
        min-width: 0;
        margin-right: 0 !important;
    }
}

/* Fields on a grid, laid out as:
   row 1 First Name | Last Name, 2 DOB+Gender | Email, 3 Address | City,
   4 Postal Code | Country & State, 5 Primary Phone | Secondary Phone */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 24px;
    align-items: start;
}

html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300,
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300 > .field-group {
    display: contents;
}

html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(1) > .field { grid-area: 1 / 1; } /* First Name */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(2) > .field { grid-area: 1 / 2; } /* Last Name */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .d-flex { grid-area: 2 / 1; } /* DOB + Gender */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(5) > .field:nth-child(2) { grid-area: 2 / 2; } /* Email */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300.ms-4 > .field-group > .field:nth-child(1) { grid-area: 3 / 1; } /* Address */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300.ms-4 > .field-group > .field:nth-child(2) { grid-area: 3 / 2; } /* City */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300.ms-4 > .field-group > .field:nth-child(3) { grid-area: 4 / 1; } /* Postal Code */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300.ms-4 > .field-group > .field:nth-child(4) { grid-area: 4 / 2; } /* Country & State */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(4) > .field { grid-area: 5 / 1; } /* Primary Phone */
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(5) > .field:nth-child(1) { grid-area: 5 / 2; } /* Secondary Phone */

html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 .field {
    width: auto !important;
    margin: 0 !important; /* spacing comes from the grid row gap */
}

html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 {
    row-gap: 18px;
    margin-bottom: 18px;
}

html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 .field .MuiFormControl-root,
html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300 > .d-flex .field {
    margin: 0 !important;
}

html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .d-flex {
    margin-bottom: 0;
}

/* Small screens: one column */
@media (max-width: 700px) {
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 {
        flex-direction: column;
        gap: 18px 0;
        grid-template-columns: minmax(0, 1fr);
    }

    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 .field,
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300 > .d-flex {
        grid-area: auto !important;
    }

    /* same order as the desktop layout */
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(1) > .field { order: 1; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(2) > .field { order: 2; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .d-flex { order: 3; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(5) > .field:nth-child(2) { order: 4; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300.ms-4 > .field-group > .field:nth-child(1) { order: 5; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300.ms-4 > .field-group > .field:nth-child(2) { order: 6; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300.ms-4 > .field-group > .field:nth-child(3) { order: 7; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300.ms-4 > .field-group > .field:nth-child(4) { order: 8; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(4) > .field { order: 9; }
    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300:not(.ms-4) > .field-group:nth-child(5) > .field:nth-child(1) { order: 10; }

    html .main-content .bg-white.rounded-1 .thing > .d-flex.wp-600 > .wp-300 {
        flex: none;
        width: 100% !important;
    }

    html .main-content .bg-white.rounded-1 .thing {
        padding: 0 20px !important;
    }

    html .main-content .bg-white.rounded-1 .MuiTypography-variantSoft {
        padding: 16px 20px 14px !important;
        font-size: 19px !important;
    }
}

/* Phones: footer under the card too */
html .main-layout:has(.main-content .bg-white.rounded-1) .main-content {
    padding-bottom: 0 !important;
}

html .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom {
    position: static;
    background: transparent;
    border-top: 0;
    box-shadow: none;
    padding: 0 16px 24px;
}

html .main-layout:has(.main-content .bg-white.rounded-1) > .main-layout__mobile-bottom > div {
    max-width: 760px;
    margin: 0 auto;
    background: var(--mt-surface) !important;
    border: 1px solid var(--mt-border);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    padding: 4px 20px 20px !important;
}

/* ── New / Edit Service — same card format as the receipt and member forms ── */
/* .main-content > .mwp-400 is the service form (the receipt's .mwp-400 is nested deeper). */

html .main-content > .mwp-400 {
    max-width: 640px !important;
    margin: 8px auto 0;
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    padding: 24px 36px 4px;
}

html .main-content > .mwp-400::before {
    content: "Service";
    display: block;
    font: 700 26px/1.25 var(--mt-font);
    letter-spacing: -.01em;
    color: var(--mt-text);
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--mt-border);
}

/* fields one per row; the three checkboxes together on the last row */
html .main-content > .mwp-400 > .field-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 18px;
}

html .main-content > .mwp-400 > .field-group > .field {
    grid-column: 1 / -1;
    width: auto !important;
    margin: 0 !important;
}

html .main-content > .mwp-400 > .field-group > .field:has(.MuiCheckbox-root) {
    grid-column: span 1;
    order: 10;
}

html .main-content > .mwp-400 .MuiFormLabel-root {
    font: 600 15px/1.3 var(--mt-font) !important;
    color: var(--joy-palette-neutral-700) !important;
    margin-bottom: 8px;
}

html .main-content > .mwp-400 .MuiInput-root,
html .main-content > .mwp-400 .MuiSelect-root,
html .main-content > .mwp-400 .MuiAutocomplete-root {
    min-height: 48px;
    font-size: 17px !important;
    border-radius: 10px;
}

html .main-content > .mwp-400 .MuiInput-root input,
html .main-content > .mwp-400 .MuiSelect-button {
    font-size: 17px !important;
}

html .main-content > .mwp-400 .MuiCheckbox-root {
    font: 500 16px/1.3 var(--mt-font);
    color: var(--mt-text);
    gap: 10px;
}

html .main-content > .mwp-400 .MuiCheckbox-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 6px;
}

/* Submit as the card's footer (desktop) */
html .main-wrapper:has(.main-content > .mwp-400) {
    overflow-y: auto !important;
}

html .main-wrapper:has(.main-content > .mwp-400) > .main-layout__content {
    flex: 0 0 auto !important;
    overflow: visible !important;
}

html .main-wrapper:has(.main-content > .mwp-400) .main-content {
    padding-bottom: 0 !important;
}

html .main-wrapper:has(.main-content > .mwp-400) > .border-top.mt-auto {
    margin-top: 0 !important;
    border-top: 0 !important;
    box-shadow: none !important;
    background: transparent;
}

html .main-wrapper:has(.main-content > .mwp-400) > .border-top.mt-auto > div {
    max-width: 640px;
    margin: 0 auto 24px;
    background: var(--mt-surface) !important;
    backdrop-filter: none !important;
    border: 1px solid var(--mt-border);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    padding: 14px 36px 24px !important;
}

html .main-wrapper:has(.main-content > .mwp-400) > .border-top.mt-auto .MuiButton-root {
    min-height: 46px;
    padding: 0 28px;
    font-size: 16px;
    border-radius: 10px;
}

/* Phones */
html .main-layout:has(.main-content > .mwp-400) .main-content {
    padding-bottom: 0 !important;
}

html .main-layout:has(.main-content > .mwp-400) > .main-layout__mobile-bottom {
    position: static;
    background: transparent;
    border-top: 0;
    box-shadow: none;
    padding: 0 16px 24px;
}

html .main-layout:has(.main-content > .mwp-400) > .main-layout__mobile-bottom > div {
    max-width: 640px;
    margin: 0 auto;
    background: var(--mt-surface) !important;
    border: 1px solid var(--mt-border);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    padding: 12px 20px 20px !important;
}

@media (max-width: 600px) {
    html .main-content > .mwp-400 {
        padding: 20px 20px 4px;
    }

    html .main-content > .mwp-400 > .field-group > .field:has(.MuiCheckbox-root) {
        grid-column: 1 / -1;
    }
}

/* Services list: drag handle in the Order column (service-order.js) */

html table.so-table .so-grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: -4px 10px -4px -6px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--joy-palette-neutral-400, #94a3b8);
    font-size: 18px;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    vertical-align: middle;
}

html table.so-table .so-grip:hover {
    background: var(--joy-palette-primary-50, #eff6ff);
    color: var(--joy-palette-primary-600, #2563eb);
}

html table.so-table.so-off .so-grip {
    display: none;
}

html table.so-table.so-dragging,
html table.so-table.so-dragging * {
    cursor: grabbing !important;
    user-select: none;
}

html table.so-table.so-dragging > tbody > tr {
    transition: transform 150ms ease;
}

html table.so-table.so-dragging > tbody > tr.so-moving {
    transition: none;
    position: relative;
    z-index: 2;
    background: var(--mt-surface, #fff);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
}

/* Services list: Hide in Receipt checkbox (the Yes / No text stays, hidden) */

html table.so-table td.so-hide-cell {
    font-size: 0 !important;
    cursor: pointer;
}

html table.so-table td.so-hide-cell > .so-hide {
    width: 20px;
    height: 20px;
    margin: 0;
    vertical-align: middle;
    accent-color: var(--joy-palette-primary-500, #2563eb);
    cursor: pointer;
}

/* View Service: each value in a read-only box, the flags as ticked / unticked
   checkboxes on the last row (service-view.js adds data-label / data-on). */

html .main-content > .service-view > .field-group > .field .MuiFormControl-root > div > div:last-child {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 14px;
    background: var(--joy-palette-neutral-50, #f8fafc);
    border: 1px solid var(--mt-border);
    border-radius: 10px;
    font: 400 17px/1.3 var(--mt-font);
    color: var(--mt-text);
}

html .main-content > .service-view > .field-group > .field[data-empty] .MuiFormControl-root > div > div:last-child > * {
    display: none;
}

html .main-content > .service-view > .field-group > .field.sv-flag {
    grid-column: span 1;
    order: 10;
}

html .main-content > .service-view > .field-group > .field.sv-flag .MuiFormControl-root {
    display: none;
}

html .main-content > .service-view > .field-group > .field.sv-flag::before {
    content: attr(data-label);
    display: flex;
    align-items: center;
    gap: 10px;
    font: 500 16px/1.3 var(--mt-font);
    color: var(--mt-text);
}

html .main-content > .service-view > .field-group > .field.sv-flag::after {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 22px;
    height: 22px;
    margin-top: -11px;
    box-sizing: border-box;
    border: 1px solid var(--mt-border-strong, #d5dae3);
    border-radius: 6px;
    background: var(--joy-palette-neutral-50, #f8fafc) center / 14px no-repeat;
}

html .main-content > .service-view > .field-group > .field.sv-flag {
    position: relative;
    padding-left: 32px;
    min-height: 24px;
    display: flex;
    align-items: center;
}

html .main-content > .service-view > .field-group > .field.sv-flag[data-on]::after {
    border-color: var(--joy-palette-primary-500, #2563eb);
    background-color: var(--joy-palette-primary-500, #2563eb);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

/* ── Phones (mobile layout)───────────────────────────────────────────────── */

/* The original mobile layout never rendered the Cancel/Submit bar; the patched
   bundle (index-CPxavLUM-m1.js) adds it as .main-layout__mobile-bottom.
   Let the page grow so the bar follows the content, and keep it on screen. */
html .main-layout:has(> .main-layout__mobile-bottom) {
    height: auto !important;
    min-height: 100%;
}

html .main-layout:has(> .main-layout__mobile-bottom) > .main-layout__wrapper {
    height: auto !important;
    flex: 1 0 auto;
}

html .main-layout__mobile-bottom {
    position: sticky;
    bottom: 0;
    z-index: 900;
    background: rgba(255, 255, 255, .96);
    border-top: 1px solid var(--mt-border);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
}

html .main-layout__mobile-bottom > div {
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)) !important;
    background: transparent !important;
    backdrop-filter: none !important;
}

html .main-layout__mobile-bottom > div > .d-flex {
    flex-wrap: wrap;
    gap: 8px;
}

html .main-layout__mobile-bottom .MuiButton-root {
    min-height: 44px;
    margin: 0 !important;
}

html .main-layout__mobile-bottom > div > .d-flex > .ms-auto {
    gap: 28px; /* space between Cancel and Submit */
}

/* Receipt on phones: buttons right below Note, as the card's footer */
html .main-layout:has(.thy) .main-content {
    padding-bottom: 0 !important;
}

html .main-layout:has(.thy) > .main-layout__mobile-bottom {
    position: static;
    background: transparent;
    border-top: 0;
    box-shadow: none;
    padding: 0 16px 24px;
}

html .main-layout:has(.thy) > .main-layout__mobile-bottom > div {
    max-width: 840px;
    margin: 0 auto;
    background: var(--mt-surface) !important;
    border: 1px solid var(--mt-border);
    border-top: 0;
    border-radius: 0 0 16px 16px;
    padding: 4px 20px 20px !important;
}

html .main-layout:has(.thy) > .main-layout__mobile-bottom .MuiButton-root {
    min-height: 48px;
    padding: 0 24px;
    font-size: 16px;
}

@media (max-width: 600px) {
    html .main-content {
        padding: 12px 16px !important;
    }

    html .main-content > div:has(> .thy) {
        padding: 20px 20px 0;
        margin-top: 0;
    }

    /* Amount Received first, Balance under it, full width */
    html .main-content .thy > .field-group:last-child {
        grid-template-columns: 1fr;
    }

    html .main-content .thy > .field-group:last-child > .field:nth-child(1) {
        grid-row: 1;
        grid-column: 1;
    }

    html .main-content .thy > .field-group:last-child > .field:nth-child(2) {
        grid-row: 2;
        grid-column: 1;
        margin-top: 0;
    }

    html .main-content .thy .MuiFormLabel-root {
        flex-wrap: wrap;
    }

    /* New Member / Edit Member: the two fixed 300px columns stack instead of overflowing */
    html .main-content .bg-white.rounded-1 .wp-600 {
        width: 100% !important;
        max-width: 100% !important;
        flex-wrap: wrap;
    }

    html .main-content .bg-white.rounded-1 .wp-600 > .wp-300 {
        width: 100% !important;
        margin-left: 0 !important;
    }

    html .main-content .bg-white.rounded-1 .MuiTypography-variantSoft {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ── Forms ────────────────────────────────────────────────────────────────── */

html .MuiFormLabel-root {
    color: var(--joy-palette-neutral-700);
    font-size: 13px;
    font-weight: 600;
}

html .MuiInput-root,
html .MuiSelect-root,
html .MuiAutocomplete-root,
html .MuiTextarea-root {
    background: var(--mt-surface);
    border-color: var(--mt-border-strong);
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

html .MuiInput-root:hover,
html .MuiSelect-root:hover,
html .MuiAutocomplete-root:hover,
html .MuiTextarea-root:hover {
    border-color: var(--joy-palette-neutral-400);
}

html .MuiInput-root:focus-within,
html .MuiAutocomplete-root:focus-within,
html .MuiTextarea-root:focus-within,
html .MuiSelect-root.Mui-expanded,
html .MuiSelect-root:focus-within {
    border-color: var(--mt-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

html .MuiInput-root.MuiInput-sizeMd,
html .MuiSelect-root.MuiSelect-sizeMd {
    min-height: 38px;
}

html .main-content hr {
    border-color: var(--mt-border);
    opacity: 1 !important;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

html .MuiButton-root {
    font-weight: 600;
    letter-spacing: .01em;
    box-shadow: none;
    transition: background-color .15s ease, box-shadow .15s ease, transform .05s ease;
}

html .MuiButton-root.MuiButton-variantSolid {
    box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}

html .MuiButton-root:active {
    transform: translateY(1px);
}

/* Sticky bottom action bar on forms */
html .main-wrapper > .border-top.mt-auto {
    border-top: 1px solid var(--mt-border) !important;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .05) !important;
    background: rgba(255, 255, 255, .85);
}

html .main-wrapper > .border-top.mt-auto > div {
    background: transparent !important;
    padding: 10px 24px !important;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */

html .berlin-table {
    background: var(--mt-surface);
    border: 1px solid var(--mt-border);
    border-radius: var(--mt-radius);
    box-shadow: var(--mt-shadow);
    overflow: hidden;
}

html .berlin-table table {
    background: var(--mt-surface) !important;
    border: 0 !important;
    margin-bottom: 0;
}

html .berlin-table table th,
html .berlin-table table th.berlin-head {
    background: var(--joy-palette-neutral-50) !important;
    color: var(--mt-text-2) !important;
    font: 600 12px/1.3 var(--mt-font) !important;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--mt-border) !important;
    border-left: 0 !important;
    border-right: 0 !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

/* No !important on color: the app colours some cells inline (balance owing and
   Void in red), and those must win */
html .berlin-table table td {
    font-family: var(--mt-font) !important;
    font-size: 14px;
    color: var(--mt-text);
    border-color: #eef1f6 !important;
    border-left: 0 !important;
    border-right: 0 !important;
}

html .berlin-table table td a {
    color: var(--mt-accent);
    font-weight: 600;
    text-decoration: none;
}

html .berlin-table table tbody tr:hover,
html .berlin-table table tr.has-row-click:hover {
    background-color: #f8faff !important;
}

/* Search filter bar */
html .medina-filters {
    gap: 8px;
}

/* Report totals are pulled up into the filter row (-45px), where they overlap
   the Search/Reset/Export buttons on normal screen widths. Give them their own row. */
html .main-content > .overflow-hidden > div > .d-flex.justify-content-end.pb-4[style*="-45px"] {
    margin-top: 4px !important;
    padding-bottom: 14px !important;
}

html .main-content > .overflow-hidden > div > .d-flex.justify-content-end.pb-4 > .h4 {
    gap: 20px;
    font-size: 18px;
}

/* ── Modals & menus ───────────────────────────────────────────────────────── */

/* Edit / Add User pop-up in the New Member / Receipt card format
   (user-active.js adds .mt-user-modal). Two fields per row - Username | Password,
   First | Last Name, Email | Expire - then Notes, then a "Permissions" section
   with the checkboxes as tiles; Submit in the card footer. */
html .MuiModalDialog-root.mt-user-modal {
    width: 720px !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 40px) !important;
    padding: 0 !important;
    border: 1px solid var(--mt-border) !important;
    border-radius: 16px !important;
    overflow: hidden;
}

/* the app gives this wrapper min-width: 400px and a fixed height (too wide for phones) */
html .mt-user-modal > div {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0 !important;
    height: auto !important;
    max-height: calc(100vh - 40px) !important;
}

html .mt-user-modal .flex-grow-1 {
    min-height: 0;
}

html .mt-user-modal .MuiModalClose-root {
    top: 22px;
    right: 22px;
}

html .mt-user-modal .border-bottom {
    padding: 26px 36px 16px !important;
    margin: 0 36px 0 0;
    border-color: var(--mt-border) !important;
}

html .mt-user-modal .border-bottom .MuiTypography-title-lg {
    font: 700 26px/1.25 var(--mt-font) !important;
    letter-spacing: -.01em;
    color: var(--mt-text);
}

html .mt-user-modal .border-bottom .MuiTypography-body-sm:empty {
    display: none;
}

html .mt-user-modal .flex-grow-1 {
    padding: 22px 36px 26px !important;
    overflow-y: auto;
}

html .mt-user-modal .field-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 20px;
    row-gap: 16px;
}

html .mt-user-modal .field-group > .field {
    margin: 0 !important;
    order: 1;
    min-width: 0;
}

html .mt-user-modal .field-group > .field:has(textarea) {
    grid-column: 1 / -1;
    order: 2;
}

html .mt-user-modal .field-group::after {
    content: "Permissions";
    order: 3;
    grid-column: 1 / -1;
    margin-top: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--mt-border);
    font: 600 12px/1.2 var(--mt-font);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--mt-text-2);
}

html .mt-user-modal .field-group > .field:has(.MuiCheckbox-root) {
    order: 4;
}

html .mt-user-modal .field-group > .field:has(.MuiCheckbox-root) .MuiFormControl-root > div > div:first-child {
    display: none;
}

html .mt-user-modal .field-group > .field:has(.MuiCheckbox-root) .MuiFormControl-root {
    height: 100%;
    padding: 11px 14px;
    border: 1px solid var(--mt-border);
    border-radius: 10px;
    background: var(--joy-palette-neutral-50, #f8fafc);
    transition: border-color .15s ease, background-color .15s ease;
}

html .mt-user-modal .field-group > .field:has(.MuiCheckbox-root.Mui-checked) .MuiFormControl-root {
    border-color: var(--joy-palette-primary-200, #bfdbfe);
    background: var(--joy-palette-primary-50, #eff6ff);
}

html .mt-user-modal .MuiCheckbox-root {
    font: 500 15px/1.3 var(--mt-font);
    color: var(--mt-text);
    gap: 10px;
}

html .mt-user-modal .MuiCheckbox-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
}

html .mt-user-modal .MuiFormLabel-root {
    font: 600 15px/1.3 var(--mt-font) !important;
    color: var(--joy-palette-neutral-700) !important;
    margin-bottom: 8px;
}

html .mt-user-modal .MuiInput-root {
    min-height: 48px;
    font-size: 17px !important;
    border-radius: 10px;
}

html .mt-user-modal .MuiInput-root input {
    font-size: 17px !important;
}

/* Show / Hide on the password (user-active.js) */
html .mt-user-modal .MuiInput-root:has(> .mt-pw-toggle) {
    position: relative;
    padding-right: 70px;
}

html .mt-user-modal .mt-pw-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: var(--joy-palette-neutral-100, #f1f5f9);
    color: var(--mt-text-2, #475569);
    font: 600 13px var(--mt-font);
    cursor: pointer;
}

html .mt-user-modal .mt-pw-toggle:hover {
    background: var(--joy-palette-neutral-200, #e2e8f0);
    color: var(--mt-text, #0f172a);
}

html .mt-user-modal .MuiTextarea-root {
    font-size: 16px !important;
    border-radius: 10px;
}

/* footer: a plain divider (no shadow falling over the last row of tiles) */
html .mt-user-modal .mt-auto,
html .mt-user-modal .mt-auto > .d-flex {
    box-shadow: none !important;
    background: var(--mt-surface, #fff) !important;
}

html .mt-user-modal .mt-auto {
    border-top: 1px solid var(--mt-border);
}

html .mt-user-modal .mt-auto > .d-flex {
    justify-content: flex-end !important;
    padding: 14px 36px 22px !important;
}

html .mt-user-modal .mt-auto .MuiButton-root {
    min-height: 46px;
    padding: 0 30px;
    font-size: 16px;
    border-radius: 10px;
}

@media (max-width: 600px) {
    html .mt-user-modal .border-bottom {
        padding: 20px 20px 14px !important;
        margin-right: 40px;
    }

    html .mt-user-modal .border-bottom .MuiTypography-title-lg {
        font-size: 22px !important;
    }

    html .mt-user-modal .MuiModalClose-root {
        top: 16px;
        right: 14px;
    }

    html .mt-user-modal .flex-grow-1 {
        padding: 16px 20px 22px !important;
    }

    html .mt-user-modal .field-group {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 14px;
    }

    html .mt-user-modal .field-group > .field:has(.MuiCheckbox-root) .MuiFormControl-root {
        padding: 10px 12px;
    }

    html .mt-user-modal .mt-auto > .d-flex {
        padding: 12px 20px 18px !important;
    }

    html .mt-user-modal .mt-auto .MuiButton-root {
        width: 100%;
    }
}

/* Print Preview: receipt text in black (the dialog's content is grey) */
html .MuiDialogContent-root:has(> div[style*="max-width: 330px"]),
html .MuiDialogContent-root > div[style*="max-width: 330px"] * {
    color: #000 !important;
}

html .MuiModalDialog-root {
    border: 0;
    border-radius: 16px;
    box-shadow: var(--mt-shadow-lg);
}

html .MuiMenu-root,
html .MuiAutocomplete-listbox,
html .MuiSelect-listbox {
    border-color: var(--mt-border) !important;
    border-radius: 10px !important;
    box-shadow: var(--mt-shadow-lg) !important;
}

/* dropdown choices (e.g. Service on a receipt): black and a little larger */
html .MuiSelect-listbox .MuiOption-root {
    color: #000 !important;
    font-size: 16px !important;
}

/* ── Login ────────────────────────────────────────────────────────────────── */

/* Same background as the BBI (GL Management) login: low-poly blue pattern
   (login-bg.svg, copied from C:\BBI\client\public) over blue */
html .page:has(> div > .con) {
    background: #2563eb url("/login-bg.svg") center / cover no-repeat !important;
}

html .con {
    width: 380px;
    max-width: calc(100vw - 32px);
    background: rgba(255, 255, 255, .95) !important;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 16px !important;
    box-shadow: 0 25px 50px -12px rgba(30, 58, 138, .35) !important;
    backdrop-filter: blur(8px) !important;
    padding: 36px 32px 56px !important;
}

html .con form {
    width: 100% !important;
}

html .con form > div:first-child span {
    color: var(--mt-text) !important;
    font: 700 22px/1.2 var(--mt-font) !important;
    letter-spacing: -.01em !important;
    text-transform: none !important;
    font-size: 0 !important; /* hide "BMS System"; app logo + name shown instead */
    width: auto !important;
    display: inline-flex !important;
    align-items: center;
    gap: 1px; /* icon B is the first letter of the name */
}

/* The temple logo printed on receipts (business "print" logo, Settings) above the app name */
html .con form > div:first-child {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}
html .con form > div:first-child::before {
    content: "";
    display: block;
    width: 150px;
    height: 150px;
    margin: -10px auto 14px;
    /* login-logo.png = the receipt logo (ayyappan.jpg, 2160 px) resized to 480 px with high-quality
       resampling - the browser shrinking the full picture 18x made the lettering muddy */
    background: #fff url("/login-logo.png") center / 100% no-repeat;
    border-radius: 50%; /* the seal is round - no white square corners on the card */
    box-shadow: 0 0 0 3px #fff, 0 6px 18px rgba(30, 58, 138, .18);
}

/* Same app logo as the sidebar: gradient icon + "BRISMA" wordmark */
html .con form > div:first-child span::before {
    content: "B";
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #38bdf8 0%, #6366f1 55%, #8b5cf6 100%);
    box-shadow: 0 6px 18px rgba(99, 102, 241, .35), inset 0 1px 0 rgba(255, 255, 255, .25);
    color: #fff;
    font: 800 26px/1 var(--mt-font);
    letter-spacing: -.02em;
}

html .con form > div:first-child span::after {
    content: "RISMA"; /* with the B icon: "BRISMA" */
    font: 700 32px/1.1 var(--mt-font);
    letter-spacing: .02em;
    white-space: nowrap;
    color: #1e3a8a;
    background: linear-gradient(90deg, #1e3a8a 0%, #4f46e5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

html .con label {
    color: var(--mt-text-2) !important;
    font: 600 13px/1.4 var(--mt-font) !important;
    margin-bottom: 6px;
}

html .con input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--mt-border-strong) !important;
    border-radius: 10px;
    font: 400 15px var(--mt-font);
    color: var(--mt-text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

html .con input:focus {
    border-color: var(--mt-accent) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

html .con button {
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: var(--mt-accent) !important;
    color: #fff;
    font: 600 15px var(--mt-font);
    margin-top: 12px !important;
    cursor: pointer;
    transition: background-color .15s ease;
}

html .con button:hover {
    background: #1d4ed8 !important;
}

html .con form .position-relative > div {
    color: var(--mt-text-3) !important;
    font: 600 12px var(--mt-font) !important;
    letter-spacing: .2em;
}

/* App version on the same line as SASO, after a thin divider */
html .con form .position-relative > div::after {
    content: "Ver 5.5.0";
    display: inline-block;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--joy-palette-neutral-300);
    font: 500 11px/1.2 var(--mt-font);
    letter-spacing: .04em;
    color: var(--joy-palette-neutral-400);
}

/* ── Member page (/cust/:id/view): compact, so it fits one screen ─────────── */
/* member details: shorter field rows */
html .main-content:has(.mv-title) .field-group > .mb-3 {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
}
html .main-content:has(.mv-title) .field-group .MuiFormLabel-root {
    min-height: 0 !important;
}
/* receipt history: shorter rows, smaller filter bar gap */
html .main-content:has(.mv-title) table.vline td.berlin-data,
html .main-content:has(.mv-title) table.vline td.berlin-menu {
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}
html .main-content:has(.mv-title) table.vline th {
    padding-top: 7px !important;
    padding-bottom: 7px !important;
}
html .main-content:has(.mv-title) .medina-filters {
    margin-bottom: 8px !important;
}
/* the row's ⋮ menu button set the row height (46px) */
html .main-content:has(.mv-title) table.vline td.berlin-menu .MuiMenuButton-root {
    min-height: 26px !important;
    height: 26px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
/* receipt history scrolls inside its own box (height set by member-view.js); headings stay on top */
html .main-content .mv-hist {
    overflow-y: auto !important;
}
html .main-content .mv-hist table.vline > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--joy-palette-neutral-50, #f8fafc);
}

/* sidebar sub-items (e.g. Services inside Settings; icon tagged mt-subitem in the bundle, m40) */
html .main-sidebar .links .sc-link:has(svg.mt-subitem) {
    padding-left: 30px !important;
}
html .main-sidebar .links .sc-link:has(svg.mt-subitem) .poppins-font {
    font-size: 14px !important;
}
