/* =============================================================================
   Tennisflow mobile app layer
   Loaded after styles.css. Everything visual lives inside the max-width media
   queries below, so the desktop layout (> 900px) is unchanged.
   ============================================================================= */

:root {
    color-scheme: light only;
    --tf-tabbar-h: 66px;
    --tf-safe-t: env(safe-area-inset-top, 0px);
    --tf-safe-b: env(safe-area-inset-bottom, 0px);
    --tf-gutter: 14px;
    --tf-edge: rgba(33, 49, 61, 0.16);
    --tf-edge-strong: rgba(33, 49, 61, 0.24);
    --tf-glass: rgba(250, 247, 240, 0.78);
    --tf-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Mobile-only pieces stay out of the desktop layout entirely. */
.tf-mobile,
.tf-att-chips,
.tf-att-tools,
.tf-att-summary,
.tf-swipe-hint {
    display: none;
}

/* Icon tones (used by tiles and quick actions). */
.tf-tone-home { --tone: #56733d; }
.tf-tone-calendar { --tone: #3f7891; }
.tf-tone-attendance { --tone: #4f8a35; }
.tf-tone-ticket { --tone: #a8831f; }
.tf-tone-clients { --tone: #3d6aa8; }
.tf-tone-messages { --tone: #b65a31; }
.tf-tone-enroll { --tone: #2f8a6a; }
.tf-tone-programs { --tone: #7a9a1f; }
.tf-tone-billing { --tone: #a8831f; }
.tf-tone-reports { --tone: #5b4f9a; }
.tf-tone-account { --tone: #21313d; }
.tf-tone-payment { --tone: #4f8a35; }
.tf-tone-household { --tone: #b65a31; }
.tf-tone-player { --tone: #3d6aa8; }
.tf-tone-dot { --tone: #21313d; }

.tf-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@keyframes tf-pop {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

@keyframes tf-vt-out {
    to { opacity: 0; transform: translateY(-6px) scale(0.995); }
}

@keyframes tf-vt-in {
    from { opacity: 0; transform: translateY(14px); }
}

@keyframes tf-flash {
    0% { box-shadow: 0 0 0 0 rgba(141, 191, 77, 0.55); }
    100% { box-shadow: 0 0 0 14px rgba(141, 191, 77, 0); }
}

/* =============================================================================
   PHONE + SMALL TABLET (<= 900px): the app shell
   ============================================================================= */
@media (max-width: 900px) {
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        -webkit-tap-highlight-color: transparent;
        background: transparent;
    }

    html:has(.tf-toggle:checked) {
        overflow: hidden;
    }

    .app-frame {
        display: block;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .main-panel {
        min-width: 0;
        padding: 0 var(--tf-gutter) calc(28px + var(--tf-safe-b));
    }

    body.tf-has-tabbar .main-panel {
        padding-bottom: calc(var(--tf-tabbar-h) + 34px + var(--tf-safe-b));
    }

    .tf-mobile {
        display: contents;
    }

    .tf-toggle {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        border: 0;
        appearance: none;
        -webkit-appearance: none;
    }

    /* ---------------------------------------------------------------- top bar */
    .tf-topbar {
        position: sticky;
        top: 0;
        z-index: 90;
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        align-items: center;
        gap: 10px;
        margin: 0 calc(var(--tf-gutter) * -1) 14px;
        padding: calc(var(--tf-safe-t) + 10px) var(--tf-gutter) 10px;
        background: var(--tf-glass);
        -webkit-backdrop-filter: blur(18px) saturate(1.8);
        backdrop-filter: blur(18px) saturate(1.8);
        border-bottom: 1px solid transparent;
        transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    }

    .tf-scrolled .tf-topbar {
        background: rgba(251, 248, 242, 0.9);
        border-bottom-color: var(--tf-edge);
        box-shadow: 0 10px 28px rgba(27, 28, 24, 0.1);
    }

    .tf-topbar-mark .brand-mark {
        width: 42px;
        height: 42px;
        border-radius: 15px;
        box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.45), 0 6px 14px rgba(86, 115, 61, 0.28);
    }

    .tf-topbar-mark .brand-mark span {
        width: 15px;
        height: 15px;
    }

    .tf-topbar-btn {
        width: 42px;
        height: 42px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        border: 1px solid var(--tf-edge);
        background: rgba(255, 255, 255, 0.86);
        color: var(--ink);
        box-shadow: 0 4px 12px rgba(27, 28, 24, 0.08);
        transition: transform 0.15s ease;
    }

    .tf-topbar-btn:active {
        transform: scale(0.92);
    }

    .tf-topbar-btn .tf-icon {
        width: 22px;
        height: 22px;
        stroke-width: 2.2;
    }

    button.tf-topbar-titles {
        all: unset;
        display: grid;
        place-items: center;
        min-width: 0;
        min-height: 42px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    button.tf-topbar-titles:focus-visible {
        outline: 2px solid rgba(86, 115, 61, 0.45);
        outline-offset: 2px;
        border-radius: 12px;
    }

    .tf-topbar-titles > * {
        grid-area: 1 / 1;
        max-width: 100%;
        transition: opacity 0.28s ease, transform 0.32s var(--tf-ease);
    }

    .tf-topbar-brand {
        display: grid;
        justify-items: center;
        gap: 3px;
        line-height: 1;
    }

    .tf-topbar-brand small {
        font-size: 0.66rem;
        font-weight: 700;
        letter-spacing: 0.16em;
        text-transform: uppercase;
        color: var(--muted);
    }

    .tf-topbar-brand strong,
    .tf-topbar-page {
        font-family: "Iowan Old Style", "Baskerville", serif;
        font-size: 1.12rem;
        font-weight: 600;
        letter-spacing: -0.02em;
        color: var(--ink);
    }

    .tf-topbar-page {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        opacity: 0;
        transform: translateY(10px);
    }

    .tf-title-collapsed .tf-topbar-page {
        opacity: 1;
        transform: none;
    }

    .tf-title-collapsed .tf-topbar-brand {
        opacity: 0;
        transform: translateY(-10px);
    }

    .tf-avatar {
        width: 42px;
        height: 42px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        background: linear-gradient(135deg, #6f9f3f, #3f5a2c);
        color: #fbffe9;
        font-size: 0.86rem;
        font-weight: 800;
        letter-spacing: 0.04em;
        cursor: pointer;
        box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9), 0 6px 16px rgba(63, 90, 44, 0.32);
        transition: transform 0.15s ease;
        user-select: none;
        -webkit-user-select: none;
    }

    .tf-avatar:active {
        transform: scale(0.92);
    }

    .tf-topbar-login {
        justify-self: end;
        display: inline-flex;
        align-items: center;
        min-height: 38px;
        padding: 0 14px;
        border-radius: 999px;
        background: var(--ink);
        color: #fffaf0;
        font-size: 0.85rem;
        font-weight: 700;
        white-space: nowrap;
    }

    body.tf-public .tf-topbar {
        grid-template-columns: 44px minmax(0, 1fr) auto;
    }

    /* --------------------------------------------------------------- tab bar */
    .tf-tabbar {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(10px + var(--tf-safe-b));
        z-index: 95;
        height: var(--tf-tabbar-h);
        max-width: 560px;
        margin: 0 auto;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: center;
        padding: 0 4px;
        border-radius: 26px;
        border: 1px solid var(--tf-edge);
        background: rgba(255, 252, 246, 0.86);
        -webkit-backdrop-filter: blur(22px) saturate(1.9);
        backdrop-filter: blur(22px) saturate(1.9);
        box-shadow: 0 14px 36px rgba(27, 28, 24, 0.2), 0 2px 6px rgba(27, 28, 24, 0.08);
    }

    .tf-tab {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        height: 100%;
        min-width: 0;
        color: #4f5a53;
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.01em;
        cursor: pointer;
        user-select: none;
        -webkit-user-select: none;
    }

    .tf-tab span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tf-tab .tf-icon {
        box-sizing: content-box;
        padding: 4px 14px;
        border-radius: 14px;
        transition: background 0.25s ease, transform 0.2s var(--tf-ease);
    }

    .tf-tab:active .tf-icon {
        transform: scale(0.88);
    }

    .tf-tab-active {
        color: #3f5a2c;
    }

    .tf-tab-active .tf-icon {
        background: rgba(141, 191, 77, 0.3);
        stroke-width: 2.1;
    }

    .tf-tab-fab {
        overflow: visible;
    }

    .tf-fab {
        width: 58px;
        height: 58px;
        margin-top: -30px;
        display: grid;
        place-items: center;
        border-radius: 22px;
        background: linear-gradient(145deg, #8dbf4d, #4f7a33);
        color: #fff;
        box-shadow: 0 0 0 5px rgba(250, 247, 240, 0.95), 0 12px 26px rgba(63, 90, 44, 0.45);
        transition: transform 0.35s var(--tf-ease), border-radius 0.35s var(--tf-ease), background 0.3s ease;
    }

    .tf-fab .tf-icon {
        width: 28px;
        height: 28px;
        padding: 0;
        stroke-width: 2.6;
    }

    .tf-tab-fab:active .tf-fab {
        transform: scale(0.92);
    }

    #tf-quick-toggle:checked ~ .tf-tabbar .tf-fab {
        transform: rotate(135deg);
        border-radius: 999px;
        background: linear-gradient(145deg, #d17a50, #a9532d);
    }

    /* ------------------------------------------------------- sheets + backdrop */
    .tf-backdrop {
        position: fixed;
        inset: 0;
        z-index: 110;
        background: rgba(18, 23, 20, 0.42);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.35s ease;
    }

    #tf-more-toggle:checked ~ .tf-backdrop-more,
    #tf-quick-toggle:checked ~ .tf-backdrop-quick {
        opacity: 1;
        pointer-events: auto;
    }

    .tf-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 120;
        max-width: 640px;
        max-height: 88vh;
        max-height: 88dvh;
        margin: 0 auto;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 4px 18px calc(22px + var(--tf-safe-b));
        border-radius: 30px 30px 0 0;
        border: 1px solid var(--tf-edge);
        border-bottom: 0;
        background:
            radial-gradient(circle at 100% 0, rgba(141, 191, 77, 0.16), transparent 40%),
            radial-gradient(circle at 0 100%, rgba(201, 106, 61, 0.1), transparent 45%),
            linear-gradient(180deg, #fffdf8, #f5efe4);
        box-shadow: 0 -18px 50px rgba(27, 28, 24, 0.26);
        transform: translateY(105%);
        visibility: hidden;
        transition: transform 0.45s var(--tf-ease), visibility 0s linear 0.45s;
    }

    #tf-more-toggle:checked ~ .tf-sheet-more,
    #tf-quick-toggle:checked ~ .tf-sheet-quick {
        transform: translateY(0);
        visibility: visible;
        transition: transform 0.45s var(--tf-ease), visibility 0s;
    }

    .tf-sheet-grip {
        display: grid;
        place-items: center;
        height: 22px;
        touch-action: none;
    }

    .tf-sheet-grip span {
        width: 44px;
        height: 5px;
        border-radius: 999px;
        background: rgba(33, 49, 61, 0.26);
    }

    .tf-sheet-head {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        gap: 12px;
        margin: 4px 0 18px;
    }

    .tf-sheet-head .eyebrow {
        margin: 0 0 4px;
        color: var(--green-deep);
        font-weight: 700;
    }

    .tf-sheet-head h2 {
        margin: 0;
        font-family: "Iowan Old Style", "Baskerville", serif;
        font-size: 1.9rem;
        font-weight: 600;
        line-height: 1;
        letter-spacing: -0.02em;
        color: var(--ink);
    }

    .tf-sheet-close {
        width: 40px;
        height: 40px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        border: 1px solid var(--tf-edge);
        background: #fff;
        color: var(--ink);
        cursor: pointer;
    }

    .tf-sheet-close .tf-icon {
        width: 20px;
        height: 20px;
        stroke-width: 2.2;
    }

    .tf-tile-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
    }

    .tf-tile {
        display: grid;
        justify-items: center;
        align-content: center;
        gap: 8px;
        min-height: 98px;
        padding: 12px 6px;
        border-radius: 20px;
        border: 1px solid var(--tf-edge);
        background: rgba(255, 255, 255, 0.88);
        box-shadow: 0 6px 16px rgba(27, 28, 24, 0.07);
        text-align: center;
        transition: transform 0.15s ease, background 0.2s ease;
    }

    .tf-tile:active {
        transform: scale(0.95);
    }

    .tf-tile-icon,
    .tf-quick-icon {
        width: 46px;
        height: 46px;
        display: grid;
        place-items: center;
        border-radius: 15px;
        color: var(--tone);
        background: color-mix(in srgb, var(--tone) 15%, white);
        border: 1px solid color-mix(in srgb, var(--tone) 28%, white);
    }

    .tf-tile-label {
        font-size: 0.82rem;
        font-weight: 700;
        line-height: 1.15;
        color: var(--ink);
    }

    .tf-tile-active {
        border-color: rgba(86, 115, 61, 0.55);
        background: linear-gradient(160deg, rgba(141, 191, 77, 0.26), rgba(255, 255, 255, 0.92) 70%);
        box-shadow: 0 0 0 2px rgba(141, 191, 77, 0.35), 0 6px 16px rgba(27, 28, 24, 0.07);
    }

    button.tf-install {
        all: unset;
        box-sizing: border-box;
        width: 100%;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 12px;
        margin-top: 14px;
        padding: 12px 14px;
        border-radius: 20px;
        border: 1px solid rgba(86, 115, 61, 0.35);
        background: linear-gradient(135deg, rgba(141, 191, 77, 0.24), rgba(255, 255, 255, 0.9) 70%);
        cursor: pointer;
    }

    button.tf-install[hidden] {
        display: none;
    }

    .tf-install-icon img {
        display: block;
        width: 40px;
        height: 40px;
        border-radius: 11px;
        box-shadow: 0 4px 10px rgba(63, 90, 44, 0.3);
    }

    .tf-install-copy {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    .tf-install-copy strong {
        font-size: 0.92rem;
        color: var(--ink);
    }

    .tf-install-copy span {
        font-size: 0.8rem;
        line-height: 1.35;
        color: var(--muted);
    }

    .tf-install-cta {
        width: 36px;
        height: 36px;
        display: grid;
        place-items: center;
        border-radius: 999px;
        background: #4f7a33;
        color: #fff;
    }

    .tf-install-cta .tf-icon {
        width: 20px;
        height: 20px;
        stroke-width: 2.2;
    }

    .tf-sheet-user {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 12px;
        margin-top: 14px;
        padding: 12px 12px 12px 14px;
        border-radius: 20px;
        border: 1px solid var(--tf-edge);
        background: rgba(255, 255, 255, 0.82);
    }

    .tf-sheet-user > div {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    .tf-sheet-user strong {
        color: var(--ink);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .tf-sheet-user > div span {
        font-size: 0.8rem;
        color: var(--muted);
    }

    .tf-avatar-lg {
        box-shadow: none;
        cursor: default;
    }

    .tf-sheet-logout {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        min-height: 40px;
        padding: 0 12px;
        border-radius: 14px;
        border: 1px solid rgba(201, 106, 61, 0.35);
        background: rgba(201, 106, 61, 0.1);
        color: #8d4427;
        font-size: 0.85rem;
        font-weight: 700;
    }

    .tf-sheet-logout .tf-icon {
        width: 18px;
        height: 18px;
    }

    .tf-quick-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .tf-quick {
        display: grid;
        align-content: start;
        gap: 4px;
        min-height: 124px;
        padding: 14px;
        border-radius: 22px;
        border: 1px solid var(--tf-edge);
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 8px 20px rgba(27, 28, 24, 0.08);
        transition: transform 0.15s ease;
    }

    .tf-quick:active {
        transform: scale(0.96);
    }

    .tf-quick-icon {
        margin-bottom: 8px;
    }

    .tf-quick strong {
        color: var(--ink);
        font-size: 0.98rem;
        line-height: 1.15;
    }

    .tf-quick > span:last-child {
        color: var(--muted);
        font-size: 0.8rem;
        line-height: 1.3;
    }

    #tf-quick-toggle:checked ~ .tf-sheet-quick .tf-quick {
        animation: tf-pop 0.5s var(--tf-ease) both;
        animation-delay: calc(var(--tf-i, 0) * 40ms + 90ms);
    }

    /* ------------------------------------------------------- page content */
    .page-stack {
        gap: 16px;
    }

    .page-intro {
        gap: 6px;
        padding: 2px 2px 0;
    }

    .page-intro h2 {
        font-size: clamp(1.95rem, 8.6vw, 2.5rem);
        line-height: 1.02;
    }

    .page-intro p:last-child {
        font-size: 0.96rem;
        line-height: 1.5;
    }

    .panel,
    .stat-card {
        border-radius: 22px;
        border-color: rgba(46, 59, 54, 0.15);
        box-shadow: 0 10px 28px rgba(27, 28, 24, 0.09);
    }

    .panel {
        padding: 16px;
    }

    .panel .panel {
        padding: 14px;
        box-shadow: none;
    }

    .panel h3 {
        font-size: 1.28rem;
        line-height: 1.15;
    }

    .panel-header,
    .table-header {
        flex-wrap: wrap;
        align-items: center;
        margin-bottom: 14px;
    }

    .table-header > p {
        margin: 0;
        line-height: 1.5;
    }

    /* Stat tiles: a tight 2-up grid instead of one long column. */
    .stats-grid,
    .report-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stats-grid > :last-child:nth-child(odd),
    .report-summary-grid > :last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .stat-card {
        padding: 14px 14px 14px 18px;
    }

    .stat-card span {
        display: block;
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.02em;
    }

    .stat-card strong {
        margin: 6px 0 4px;
        font-size: 1.7rem;
        line-height: 1.05;
        color: var(--ink);
    }

    .stat-card p {
        margin: 0;
        font-size: 0.78rem;
        line-height: 1.35;
    }

    /* Buttons: thumb sized, with a press response. */
    .button,
    button {
        min-height: 44px;
        font-size: 0.95rem;
        font-weight: 600;
        transition: transform 0.12s ease, background 0.2s ease;
        touch-action: manipulation;
    }

    .button:active,
    button:active {
        transform: scale(0.97);
    }

    .button-secondary {
        border-color: var(--tf-edge);
        background: rgba(255, 255, 255, 0.92);
    }

    /* Page-level action rows become a swipeable chip strip. */
    div.page-stack > .button-row {
        flex-wrap: nowrap;
        gap: 8px;
        margin: 0 calc(var(--tf-gutter) * -1);
        padding: 2px var(--tf-gutter) 6px;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    div.page-stack > .button-row::-webkit-scrollbar {
        display: none;
    }

    div.page-stack > .button-row > * {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
        border-radius: 999px;
        padding: 0 18px;
    }

    /* Forms: 16px text so iOS never zooms, bigger fields. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
    select,
    textarea {
        font-size: 16px;
    }

    .field-group input:not([type="checkbox"]):not([type="radio"]),
    .field-group select,
    .field-group textarea {
        min-height: 48px;
        border-color: rgba(30, 39, 36, 0.22);
    }

    .field-group input[type="checkbox"],
    .checkbox-row input[type="checkbox"] {
        width: 22px;
        height: 22px;
        accent-color: #56733d;
    }

    .field-group label {
        font-size: 0.92rem;
    }

    .form-grid {
        gap: 14px;
    }

    /* Save bars float above the thumb zone while you fill in a form. */
    form.page-stack > .button-row:last-child:has(> button[type="submit"]:not(.button-danger)) {
        position: sticky;
        bottom: calc(12px + var(--tf-safe-b));
        z-index: 40;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        margin: 4px -6px 0;
        padding: 8px;
        border-radius: 22px;
        border: 1px solid var(--tf-edge-strong);
        background: rgba(255, 252, 246, 0.92);
        -webkit-backdrop-filter: blur(16px) saturate(1.6);
        backdrop-filter: blur(16px) saturate(1.6);
        box-shadow: 0 14px 34px rgba(27, 28, 24, 0.18);
    }

    body.tf-has-tabbar form.page-stack > .button-row:last-child:has(> button[type="submit"]:not(.button-danger)) {
        bottom: calc(var(--tf-tabbar-h) + 20px + var(--tf-safe-b));
    }

    form.page-stack > .button-row:last-child:has(> button[type="submit"]:not(.button-danger)) > :is(button, .button) {
        flex: 1 1 0;
        min-width: 0;
        padding: 0 8px;
        white-space: nowrap;
        font-size: 0.92rem;
        border-radius: 16px;
    }

    form.page-stack > .button-row:last-child:has(> button[type="submit"]:not(.button-danger)) > button[type="submit"]:not(.button-danger):first-of-type {
        flex-grow: 1.6;
        background: linear-gradient(135deg, #7fb043, #56733d);
        border-color: #4f6b37;
        color: #fff;
        box-shadow: 0 6px 14px rgba(63, 90, 44, 0.3);
    }

    /* Search fields lead their toolbars. */
    .clients-toolbar {
        gap: 8px;
    }

    .clients-toolbar .clients-search {
        order: -1;
        flex: 1 1 100%;
        max-width: none;
        min-height: 48px;
        margin: 0;
        padding-left: 42px;
        border-color: rgba(30, 39, 36, 0.22);
        background:
            url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235c675f' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m20 20-4.2-4.2'/%3E%3C/svg%3E") 14px 50% / 20px no-repeat,
            rgba(255, 255, 255, 0.95);
    }

    .clients-toolbar select.clients-search {
        order: 0;
        padding-left: 14px;
        background: rgba(255, 255, 255, 0.95);
    }

    .clients-toolbar > .button,
    .clients-toolbar > button {
        flex: 1 1 auto;
    }

    .message-recipient-wrap {
        max-height: 62vh;
        overscroll-behavior: contain;
    }

    /* Dashboard */
    .day-nav {
        gap: 8px;
    }

    .day-nav-arrow {
        width: 40px;
        height: 40px;
        border-radius: 14px;
        border-color: var(--tf-edge);
        background: #fff;
    }

    .session-row {
        grid-template-columns: 70px minmax(0, 1fr);
        gap: 12px;
        padding: 14px;
    }

    .session-time {
        font-size: 0.92rem;
    }

    .trend-card {
        padding: 14px;
    }

    .trend-card-head {
        flex-wrap: wrap;
        gap: 8px;
    }

    .trend-card-foot {
        gap: 2px;
    }

    .tf-swipe-hint {
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
        margin: -4px 0 12px;
        color: var(--muted);
        font-size: 0.78rem;
        font-weight: 600;
    }

    .tf-swipe-hint::before {
        content: "";
        width: 26px;
        height: 14px;
        background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 14' fill='none' stroke='%2356733d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 7h22M6 3 2 7l4 4M20 3l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
    }

    [data-tf-swipe] {
        touch-action: pan-y;
        will-change: transform;
    }

    /* Accordions */
    .report-accordion-summary {
        padding: 16px;
    }

    .report-accordion-body {
        padding: 0 16px 16px;
    }

    .week-accordion {
        border-radius: 20px;
        border-color: rgba(86, 115, 61, 0.22);
    }

    .week-accordion-summary {
        padding: 14px;
        gap: 10px;
    }

    .week-accordion-title {
        font-size: 1.1rem;
    }

    .week-accordion-body {
        padding: 10px;
    }

    /* Billing: filter forms with inline styles get a proper stacked layout. */
    .panel-header > form.report-filter-actions {
        width: 100%;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px !important;
    }

    .panel-header > form.report-filter-actions > select,
    .panel-header > form.report-filter-actions > button {
        grid-column: 1 / -1;
    }

    .panel-header > form.report-filter-actions > :is(select, input, button) {
        width: 100%;
        min-width: 0 !important;
        min-height: 48px !important;
        padding: 0 12px !important;
        border-radius: 14px !important;
        font-size: 16px !important;
        background-color: #fff !important;
    }

    .panel-header > form.report-filter-actions > button {
        background: linear-gradient(135deg, #7fb043, #56733d) !important;
        border-color: #4f6b37 !important;
        color: #fff;
    }

    .panel-grid[style*="repeat(3"] {
        grid-template-columns: 1fr !important;
    }

    .payment-row {
        display: grid;
        gap: 10px;
    }

    .payment-row p {
        margin: 4px 0 0;
    }

    .payment-row .payment-meta {
        align-items: center;
        padding-top: 10px;
        border-top: 1px dashed rgba(30, 39, 36, 0.14);
    }

    .payment-meta .table-cell-stack[style*="text-align: right"] {
        text-align: left !important;
    }

    .payment-row .button {
        min-height: 40px !important;
        padding: 0 18px !important;
        border-radius: 12px !important;
        font-size: 0.9rem !important;
    }

    .report-metric-strip span {
        padding: 10px 12px;
    }

    /* Enrollment cards */
    .enrollment-series-head {
        flex-wrap: wrap;
    }

    .enrollment-program-statuses {
        justify-content: flex-start;
    }

    /* FullCalendar */
    .calendar-shell {
        min-height: 0;
    }

    .fc {
        --fc-border-color: rgba(30, 39, 36, 0.14);
        --fc-button-bg-color: #ffffff;
        --fc-button-border-color: rgba(33, 49, 61, 0.2);
        --fc-button-text-color: #21313d;
        --fc-button-hover-bg-color: #f2efe6;
        --fc-button-hover-border-color: rgba(33, 49, 61, 0.28);
        --fc-button-active-bg-color: #56733d;
        --fc-button-active-border-color: #4f6b37;
        --fc-today-bg-color: rgba(141, 191, 77, 0.14);
        --fc-list-event-hover-bg-color: rgba(141, 191, 77, 0.14);
        --fc-neutral-bg-color: rgba(244, 240, 232, 0.9);
    }

    .fc .fc-toolbar.fc-header-toolbar {
        margin-bottom: 12px;
        gap: 8px;
    }

    .fc .fc-toolbar.fc-footer-toolbar {
        margin-top: 12px;
    }

    .fc .fc-toolbar-title {
        font-family: "Iowan Old Style", "Baskerville", serif;
        font-size: 1.12rem;
        font-weight: 600;
        color: var(--ink);
        text-align: center;
    }

    .fc .fc-button {
        min-height: 40px;
        padding: 0 12px;
        border-radius: 12px !important;
        font-weight: 700;
        font-size: 0.88rem;
        box-shadow: none !important;
        text-transform: none;
    }

    .fc .fc-button-group {
        gap: 6px;
    }

    .fc .fc-button-primary:not(:disabled).fc-button-active,
    .fc .fc-button-primary:not(:disabled):active {
        color: #fff;
    }

    .fc .fc-list {
        border-radius: 16px;
        overflow: hidden;
    }

    .fc .fc-list-day-cushion {
        padding: 10px 14px;
    }

    .fc .fc-list-event td {
        padding: 12px 14px;
    }

    .fc .fc-list-event-title {
        font-weight: 600;
        color: var(--ink);
    }

    /* Cross-document page transitions (Chrome / Safari 18.2+). */
    @media (prefers-reduced-motion: no-preference) {
        @view-transition {
            navigation: auto;
        }

        .tf-topbar {
            view-transition-name: tf-topbar;
        }

        .tf-tabbar {
            view-transition-name: tf-tabbar;
        }

        ::view-transition-old(root) {
            animation: tf-vt-out 0.16s ease both;
        }

        ::view-transition-new(root) {
            animation: tf-vt-in 0.34s var(--tf-ease) both;
        }
    }
}

/* =============================================================================
   PHONE (<= 720px): tables become cards
   ============================================================================= */
@media (max-width: 720px) {
    .table-wrap:has(> table.tf-cards) {
        overflow: visible;
    }

    table.tf-cards,
    table.tf-cards > tbody,
    table.tf-cards > tfoot {
        display: block;
        width: 100%;
    }

    table.tf-cards > thead {
        display: none;
    }

    table.tf-cards tr {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        margin: 0 0 10px;
        padding: 10px 14px 6px;
        border-radius: 18px;
        border: 1px solid var(--tf-edge);
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 6px 16px rgba(27, 28, 24, 0.07);
    }

    table.tf-cards tr:last-child {
        margin-bottom: 0;
    }

    table.tf-cards tr[hidden] {
        display: none !important;
    }

    table.data-table.tf-cards td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 14px;
        min-width: 0;
        padding: 8px 0;
        border-bottom: 1px dashed rgba(30, 39, 36, 0.14);
        white-space: normal;
        text-align: right !important;
        overflow-wrap: anywhere;
        color: var(--text);
    }

    table.data-table.tf-cards td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        max-width: 46%;
        text-align: left;
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--muted);
        overflow-wrap: normal;
    }

    table.data-table.tf-cards td:last-child {
        border-bottom: 0;
    }

    table.data-table.tf-cards td.tf-cell-title {
        display: block;
        padding: 4px 0 10px;
        border-bottom: 1px solid rgba(30, 39, 36, 0.14);
        text-align: left !important;
        font-size: 1.06rem;
        font-weight: 700;
        line-height: 1.25;
        color: var(--ink);
    }

    table.data-table.tf-cards td.tf-cell-title::before,
    table.data-table.tf-cards td.tf-cell-action::before,
    table.data-table.tf-cards td.tf-cell-bare::before {
        display: none;
    }

    table.data-table.tf-cards td.tf-cell-title .table-cell-stack span {
        font-size: 0.86rem;
        font-weight: 500;
    }

    table.data-table.tf-cards td .table-cell-stack {
        justify-items: end;
    }

    table.data-table.tf-cards td.tf-cell-title .table-cell-stack,
    table.data-table.tf-cards td.tf-cell-long .table-cell-stack {
        justify-items: start;
    }

    table.data-table.tf-cards td.tf-cell-long,
    table.data-table.tf-cards td.tf-cell-field {
        display: grid;
        gap: 4px;
        grid-template-columns: minmax(0, 1fr);
        justify-content: stretch;
        text-align: left !important;
    }

    table.data-table.tf-cards td.tf-cell-field {
        gap: 8px;
        padding: 10px 0;
    }

    table.data-table.tf-cards td.tf-cell-field > :is(select, input:not([type="checkbox"])) {
        width: 100%;
        min-height: 44px;
        padding: 8px 12px;
        border-radius: 12px;
        border: 1px solid rgba(30, 39, 36, 0.22);
        background: #fff;
    }

    table.data-table.tf-cards td.tf-cell-action {
        display: block;
        padding: 10px 0 8px;
        text-align: left !important;
    }

    table.data-table.tf-cards td.tf-cell-action :is(.button-row, .table-actions) {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
        gap: 8px;
    }

    table.data-table.tf-cards td.tf-cell-action :is(.button, button) {
        width: 100%;
        min-height: 42px;
        padding: 0 12px;
        font-size: 0.9rem;
    }

    table.data-table.tf-cards td.tf-cell-action .status-pill {
        justify-content: center;
    }

    table.data-table.tf-cards td.tf-cell-empty {
        display: none;
    }

    table.data-table.tf-cards td.tf-cell-bare {
        position: absolute;
        top: 12px;
        right: 12px;
        padding: 0;
        border: 0;
    }

    table.data-table.tf-cards td.tf-cell-bare input[type="checkbox"] {
        width: 26px;
        height: 26px;
        margin: 0;
        accent-color: #56733d;
    }

    table.tf-cards tr:has(> .tf-cell-bare) > .tf-cell-title {
        padding-right: 40px;
    }

    table.tf-cards tr.tf-selectable {
        cursor: pointer;
        transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    }

    table.tf-cards tr.tf-selectable:has(input[type="checkbox"]:checked) {
        border-color: rgba(86, 115, 61, 0.7);
        background: linear-gradient(140deg, rgba(141, 191, 77, 0.2), rgba(255, 255, 255, 0.94) 60%);
        box-shadow: 0 0 0 2px rgba(141, 191, 77, 0.45), 0 6px 16px rgba(27, 28, 24, 0.07);
    }

    table.tf-cards tr.message-row-disabled {
        background: rgba(244, 240, 232, 0.8);
        box-shadow: none;
    }

    /* Group-heading rows (e.g. the period rows in Reports). */
    table.tf-cards tr.tf-group-row {
        margin: 8px 0 8px;
        padding: 6px 4px 0;
        border: 0;
        background: none !important;
        box-shadow: none;
    }

    table.data-table.tf-cards tr.tf-group-row td {
        display: block;
        padding: 0 !important;
        border: 0;
        text-align: left !important;
    }

    table.data-table.tf-cards tr.tf-group-row td::before {
        display: none;
    }

    /* Processed sessions on Attendance keep their green identity as cards. */
    table.data-table.tf-cards tbody tr.session-row-processed {
        border-color: rgba(86, 115, 61, 0.38);
        background: linear-gradient(135deg, rgba(141, 191, 77, 0.22), rgba(255, 255, 255, 0.92) 62%);
        box-shadow: inset 5px 0 0 rgba(141, 191, 77, 0.7), 0 6px 16px rgba(27, 28, 24, 0.07);
    }

    table.data-table.tf-cards tbody tr.session-row-processed td {
        background: none;
        box-shadow: none;
        border-bottom-color: rgba(86, 115, 61, 0.18);
    }

    table.data-table.tf-cards tbody tr.session-row-processed td:last-child {
        border-bottom: 0;
    }

    /* Narrow tables (3 columns or fewer) stay tables, just wrap nicely. */
    table.tf-compact th,
    table.tf-compact td {
        padding: 11px 8px;
        white-space: normal;
    }

    table.tf-compact th {
        font-size: 0.7rem;
    }

    /* ---------------------------------------------- courtside attendance */
    .tf-att-tools {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }

    .tf-att-tools .button {
        flex: 1 1 auto;
        border-radius: 999px;
    }

    .tf-att-progress {
        flex: 0 0 auto;
        font-size: 0.85rem;
        font-weight: 700;
        color: var(--muted);
    }

    .tf-att-chips {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    button.tf-att-chip {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        min-height: 54px;
        padding: 4px;
        border-radius: 16px;
        border: 1.5px solid rgba(33, 49, 61, 0.2);
        background: #fff;
        color: var(--ink);
        font-size: 0.8rem;
        font-weight: 700;
        box-shadow: 0 2px 6px rgba(27, 28, 24, 0.06);
    }

    .tf-att-glyph {
        font-size: 1.1rem;
        line-height: 1;
    }

    button.tf-att-chip[data-value="present"][aria-pressed="true"] {
        background: linear-gradient(145deg, #7fb043, #4f7a33);
        border-color: #446a2c;
        color: #fff;
        animation: tf-flash 0.5s ease-out;
    }

    button.tf-att-chip[data-value="absent"][aria-pressed="true"] {
        background: linear-gradient(145deg, #d6855c, #a9532d);
        border-color: #95482a;
        color: #fff;
    }

    button.tf-att-chip[data-value="excused"][aria-pressed="true"] {
        background: linear-gradient(145deg, #f0d68a, #d9b44a);
        border-color: #b08a22;
        color: #3b2f0c;
    }

    table.data-table.tf-cards td.tf-cell-field > select.tf-att-select {
        min-height: 40px;
        color: var(--muted);
        font-size: 16px;
    }

    table.tf-cards tr[data-tf-status] {
        transition: box-shadow 0.25s ease, border-color 0.25s ease;
    }

    table.tf-cards tr[data-tf-status="present"] {
        border-color: rgba(86, 115, 61, 0.45);
        box-shadow: inset 5px 0 0 #6f9f3f, 0 6px 16px rgba(27, 28, 24, 0.07);
    }

    table.tf-cards tr[data-tf-status="absent"] {
        border-color: rgba(169, 83, 45, 0.4);
        box-shadow: inset 5px 0 0 #c96a3d, 0 6px 16px rgba(27, 28, 24, 0.07);
    }

    table.tf-cards tr[data-tf-status="excused"],
    table.tf-cards tr[data-tf-status="late_cancel"] {
        border-color: rgba(176, 138, 34, 0.4);
        box-shadow: inset 5px 0 0 #d9b44a, 0 6px 16px rgba(27, 28, 24, 0.07);
    }

    table.tf-cards tr[data-tf-status="makeup"],
    table.tf-cards tr[data-tf-status="trial"] {
        border-color: rgba(61, 106, 168, 0.4);
        box-shadow: inset 5px 0 0 #3d6aa8, 0 6px 16px rgba(27, 28, 24, 0.07);
    }

    .tf-att-summary {
        display: grid;
        gap: 1px;
        flex: 0 0 auto;
        padding: 0 6px;
        font-size: 0.72rem;
        font-weight: 700;
        line-height: 1.2;
        color: var(--muted);
        white-space: nowrap;
    }

    .tf-att-summary b {
        font-size: 0.95rem;
        color: var(--ink);
    }

    .tf-att-summary .tf-sum-present {
        color: #446a2c;
    }

    .tf-att-summary .tf-sum-absent {
        color: #a9532d;
    }
}

@media (max-width: 380px) {
    :root {
        --tf-gutter: 12px;
    }

    .tf-tile-grid {
        gap: 8px;
    }

    .tf-tile {
        min-height: 90px;
    }

    .tf-tab {
        font-size: 0.62rem;
    }

    .tf-tab .tf-icon {
        padding: 4px 10px;
    }

    .stat-card strong {
        font-size: 1.45rem;
    }
}
