.sd-staff-portal {
    box-sizing: border-box;
    padding: 16px 0 calc( 64px + env(safe-area-inset-bottom, 0px) );
}

.sd-account-holder-portal.sd-staff-portal {
    position: relative;
    padding: 16px 0 calc( 64px + env(safe-area-inset-bottom, 0px) ) !important;
}

.admin-bar .sd-staff-portal {
    padding-bottom: calc( 60px + env(safe-area-inset-bottom, 0px) );
}

.sd-staff-portal .sd-portal__container {
    max-width: 1100px;
    margin: 0 auto;
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
}

.sd-staff-portal .sd-portal__header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.sd-staff-portal .sd-portal-card {
    border-top: 3px solid #2271b1;
}

.sd-staff-portal__subtitle,
.sd-staff-portal .description {
    color: #646970;
}

/* ── Top bar (staff name + action buttons) ─────── */

.sd-staff-portal__top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0 14px;
    border-bottom: 1px solid #eef0f2;
    margin-bottom: 16px;
}

.sd-staff-portal__top-bar-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    overflow: hidden;
}

.sd-staff-portal__top-bar-label {
    font-size: 10px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sd-staff-portal__top-bar-name {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sd-staff-portal__top-bar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.sd-staff-portal__top-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #374151;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-height: 34px;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sd-staff-portal__top-btn:hover,
.sd-staff-portal__top-btn:focus {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #111827;
    text-decoration: none;
}

.sd-staff-portal__top-btn--logout {
    background: #fff5f5;
    border-color: #fecaca;
    color: #dc2626;
}

.sd-staff-portal__top-btn--logout:hover,
.sd-staff-portal__top-btn--logout:focus {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
    text-decoration: none;
}

.sd-staff-portal__top-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Legacy: keep .sd-staff-portal__actions for backwards compat */
.sd-staff-portal__actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.sd-staff-portal__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 6px 0 10px;
}

.sd-staff-portal__stat {
    border: 1px solid #dcdcde;
    border-radius: 8px;
    background: #fff;
    min-height: 64px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sd-staff-portal__stat span {
    color: #646970;
    font-size: 12px;
}

.sd-staff-portal__stat strong {
    font-size: 24px;
    line-height: 1.2;
}

.sd-staff-portal__admin-link {
    display: inline-block;
    padding: 8px 16px;
    min-height: 40px;
    border: 1px solid #2271b1;
    border-radius: 6px;
    background: #fff;
    color: #2271b1;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.5;
    cursor: pointer;
    touch-action: manipulation;
}

.sd-staff-portal__admin-link:hover,
.sd-staff-portal__admin-link:focus {
    background: #f0f6fc;
    color: #0a4b78;
    border-color: #0a4b78;
    text-decoration: none;
}

.sd-staff-portal__card-title {
    margin: 0 0 10px;
}

/* ── Tab navigation — desktop: horizontal top strip; mobile: fixed bottom bar ── */

/* Tab bar — fixed at bottom on all screen sizes */
.sd-staff-portal__tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    background: #fff;
    border-top: 1px solid #dcdcde;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}

.sd-staff-portal__tab-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    background: none;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 10px 24px;
    min-height: 44px;
    min-width: 120px;
    touch-action: manipulation;
    position: relative;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.sd-staff-portal__tab-btn:active {
    opacity: 0.7;
}

.sd-staff-portal__tab-btn.is-active {
    color: #2271b1;
    box-shadow: inset 0 -2px 0 #2271b1;
}

.sd-staff-portal__tab-btn svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: block;
}

.sd-staff-portal__tab-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.sd-staff-portal__filter-form,
.sd-staff-portal__search-form {
    display: grid;
    gap: 10px;
    margin: 10px 0;
}

.sd-staff-portal__enroll-form,
.sd-staff-portal__client-edit-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    align-items: end;
}

.sd-staff-portal__enroll-form p,
.sd-staff-portal__client-edit-form p {
    margin: 0;
}

.sd-staff-portal__enroll-form p:last-child,
.sd-staff-portal__client-edit-form p:last-child {
    grid-column: 1 / -1;
}

/* ── New appointment form ── */
.sd-staff-portal__book-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 24px;
    align-items: start;
}

.sd-book-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.sd-book-field--full {
    grid-column: 1 / -1;
}

.sd-book-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sd-book-hint {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

.sd-book-field select,
.sd-book-field input[type="date"] {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 14px;
    background: #fff;
    box-sizing: border-box;
}

.sd-book-field select:focus,
.sd-book-field input[type="date"]:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.12);
}

.sd-book-field--recurring-toggle {
    border-top: 1px solid #f3f4f6;
    padding-top: 16px;
    margin-top: 4px;
}

.sd-book-recurring-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.sd-book-recurring-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
}

.sd-book-recurring-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.sd-book-recurring-fields[hidden] {
    display: none;
}

.sd-book-field--submit {
    border-top: 1px solid #f3f4f6;
    padding-top: 16px;
    margin-top: 4px;
}

.sd-book-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 28px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.sd-book-submit:hover {
    background: #135e96;
}

.sd-book-submit:active {
    background: #0d4e80;
}

.sd-staff-portal select,
.sd-staff-portal input[type="search"] {
    width: 100%;
    min-height: 44px;
}

.sd-staff-portal .button {
    min-height: 44px;
}

.sd-staff-session-card {
    margin-bottom: 16px;
}

.sd-staff-session-card__summary {
    font-weight: 600;
    cursor: pointer;
}

.sd-staff-session-card__content {
    margin-top: 10px;
}

.sd-staff-session-card__meta-links {
    margin: 0 0 10px;
}

.sd-staff-session-card__meta-links a {
    font-size: 13px;
}

.sd-staff-session-card__header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}

.sd-staff-session-card__header h3 {
    margin: 0;
}

.sd-staff-session-card__badge {
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    background: #e8f5e9;
    color: #1f7a1f;
}

.sd-staff-session-card__badge.is-ended {
    background: #fdecea;
    color: #a02222;
}

.sd-staff-session-card__badge.is-full {
    background: #fee2e2;
    color: #991b1b;
}

.sd-staff-capacity {
    margin: 10px 0 14px;
}

.sd-staff-capacity__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.sd-staff-capacity__bar {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.sd-staff-capacity__fill {
    display: block;
    height: 100%;
    transition: width 0.2s ease;
}

.sd-staff-capacity__fill.is-green {
    background: #22c55e;
}

.sd-staff-capacity__fill.is-orange {
    background: #f59e0b;
}

.sd-staff-capacity__fill.is-red {
    background: #ef4444;
}

.sd-staff-session-card__clients {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sd-staff-session-card__clients li {
    border-top: 1px solid #e2e4e7;
    padding: 10px 0;
    min-height: 44px;
}

.sd-staff-session-card__clients li label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.sd-staff-client-name {
    font-weight: 600;
}

.sd-staff-client-meta {
    margin-left: 28px;
    margin-top: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
    color: #646970;
    font-size: 13px;
}

.sd-staff-client-badge {
    display: inline-block;
    border: 1px solid #dcdcde;
    border-radius: 999px;
    padding: 2px 8px;
    background: #f6f7f7;
}

.sd-staff-client-badge--scheduled {
    background: #e8f3ff;
    border-color: #badcff;
    color: #0b3f75;
}

.sd-staff-client-badge--walkin {
    background: #fff5df;
    border-color: #f4d89c;
    color: #7b4c00;
}

.sd-staff-client-badge--enrolled {
    background: #f6f7f7;
    border-color: #c3c4c7;
    color: #50575e;
}

.sd-staff-client-count {
    margin: 10px 0;
    color: #646970;
    font-size: 13px;
}

.sd-staff-load-more {
    margin-top: 10px;
}

.sd-staff-load-more[disabled] {
    opacity: 0.65;
    cursor: wait;
}

.sd-staff-session-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.sd-staff-session-card__footer-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Schedule tab ─────────────────────────────── */

.sd-staff-schedule__day {
    margin-bottom: 10px;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    overflow: hidden;
}

.sd-staff-schedule__day-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    font-weight: 600;
    cursor: pointer;
    background: #f6f7f7;
    list-style: none;
    touch-action: manipulation;
    min-height: 44px;
}

.sd-staff-schedule__day-title::-webkit-details-marker {
    display: none;
}

.sd-staff-schedule__day-count {
    background: #2271b1;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.sd-staff-schedule__sessions {
    padding: 4px 0;
}

.sd-staff-schedule__session {
    padding: 10px 14px;
    border-top: 1px solid #e2e4e7;
}

.sd-staff-schedule__session-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.sd-staff-schedule__time {
    font-weight: 700;
    white-space: nowrap;
    min-width: 70px;
}

.sd-staff-schedule__service-name {
    flex: 1;
    font-weight: 600;
}

.sd-staff-schedule__client-count {
    background: #f0f0f1;
    color: #3c434a;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    white-space: nowrap;
}

.sd-staff-schedule__clients {
    list-style: none;
    margin: 0;
    padding: 0 0 0 80px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sd-staff-schedule__client {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 28px;
}

.sd-staff-schedule__client-name {
    flex: 1;
    font-size: 13px;
}

.sd-staff-schedule__empty {
    padding-left: 80px;
    margin: 2px 0 0;
}

.sd-staff-schedule__status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid #dcdcde;
    background: #f6f7f7;
}

.sd-staff-schedule__status--confirmed,
.sd-staff-schedule__status--scheduled {
    background: #e8f3ff;
    border-color: #badcff;
    color: #0b3f75;
}

.sd-staff-schedule__status--attended,
.sd-staff-schedule__status--completed {
    background: #e8f5e9;
    border-color: #a8d5ab;
    color: #1f7a1f;
}

.sd-staff-schedule__status--pending,
.sd-staff-schedule__status--pending_payment {
    background: #fff5df;
    border-color: #f4d89c;
    color: #7b4c00;
}

/* ── Touch-action on all interactive elements ─── */

.sd-staff-portal button,
.sd-staff-portal a,
.sd-staff-portal select,
.sd-staff-portal input,
.sd-staff-portal textarea,
.sd-staff-portal label {
    touch-action: manipulation;
}



/* ── Compact filter bar (replaces 3 filter cards) */

.sd-staff-filter-section {
    margin-bottom: 16px;
}

.sd-staff-filter-bar {
    border: 1px solid #dcdcde;
    border-radius: 8px;
    background: #f6f7f7;
    margin-bottom: 8px;
}

.sd-staff-filter-bar__toggle {
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
    font-size: 13px;
    font-weight: 600;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
    touch-action: manipulation;
    user-select: none;
}

.sd-staff-filter-bar__toggle::-webkit-details-marker {
    display: none;
}

.sd-staff-filter-bar__toggle::after {
    content: '▼';
    font-size: 9px;
    margin-left: auto;
    opacity: 0.45;
    flex-shrink: 0;
}

.sd-staff-filter-bar[open] > .sd-staff-filter-bar__toggle::after {
    content: '▲';
}

.sd-staff-filter-bar__body {
    padding: 10px 14px 14px;
    border-top: 1px solid #dcdcde;
    background: #fff;
    border-radius: 0 0 8px 8px;
}

.sd-staff-filter-bar__form {
    display: grid;
    gap: 10px;
    align-items: end;
}

.sd-staff-filter-bar__form p {
    margin: 0;
}

.sd-staff-filter-bar__form select,
.sd-staff-filter-bar__form input[type="date"] {
    width: 100%;
    min-height: 40px;
    box-sizing: border-box;
}

/* Session count summary line */
.sd-staff-session-summary {
    font-size: 13px;
    color: #646970;
    margin: 0 0 12px;
    padding: 0 2px;
}

/* ── New appointment collapsible ─────────────── */

.sd-staff-new-appt {
    margin-bottom: 16px;
}

.sd-staff-new-appt__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    font-size: 14px;
    font-weight: 600;
    min-height: 44px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    touch-action: manipulation;
    user-select: none;
}

.sd-staff-new-appt[open] > .sd-staff-new-appt__toggle {
    border-radius: 8px 8px 0 0;
    border-bottom-color: transparent;
}

.sd-staff-new-appt__toggle::-webkit-details-marker {
    display: none;
}

.sd-staff-new-appt__toggle::after {
    content: '▼';
    font-size: 9px;
    margin-left: auto;
    opacity: 0.45;
}

.sd-staff-new-appt[open] > .sd-staff-new-appt__toggle::after {
    content: '▲';
}

.sd-staff-new-appt > .sd-portal-card {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
    border-top: none;
}

/* Edit appointments card heading */
.sd-staff-edit-appts > h3 {
    margin-top: 0;
}

/* ── Responsive: tablet/mobile (≤ 782px) — switch to fixed bottom nav ──────── */

@media (max-width: 782px) {
    .sd-staff-portal {
        padding: 12px 12px calc( 64px + env(safe-area-inset-bottom, 0px) );
    }

    .sd-account-holder-portal.sd-staff-portal {
        padding: 12px 12px calc( 64px + env(safe-area-inset-bottom, 0px) ) !important;
    }

    /* Mobile: stack icon + label vertically, reduce text size */
    .sd-staff-portal__tab-btn {
        flex: 1;
        flex-direction: column;
        gap: 2px;
        font-size: 10px;
        padding: 8px 4px;
    }

    .sd-staff-portal__tab-btn svg {
        width: 22px;
        height: 22px;
    }

    .sd-staff-portal__tab-btn.is-active {
        box-shadow: none;
    }

    .sd-staff-portal__tab-badge {
        top: 6px;
        right: calc(50% - 20px);
    }

    /* Header: one compact row */
    .sd-staff-portal .sd-portal__header {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
        padding-bottom: 12px;
        margin-bottom: 16px;
    }

    .sd-staff-header__main {
        flex: 1;
        min-width: 0;
    }

    .sd-staff-portal .sd-portal__title {
        font-size: 1.25rem;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Actions: side by side, not stacked */
    .sd-staff-portal__actions {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 6px;
        width: auto;
        flex-shrink: 0;
    }

    /* Stats: 2 columns always */
    .sd-staff-portal__stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }

    .sd-staff-portal__stat {
        min-height: 54px;
        padding: 8px 10px;
    }

    .sd-staff-portal__stat strong {
        font-size: 20px;
    }

    /* Session card footer: stack on small screens */
    .sd-staff-session-card__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .sd-staff-session-card__footer-actions {
        flex-direction: row;
        justify-content: stretch;
    }

    .sd-staff-session-card__footer-actions .button {
        flex: 1;
    }

    /* Full-width only for submit buttons inside forms, not for all .button */
    .sd-staff-portal form[method="post"] > p > .button,
    .sd-staff-load-more {
        width: 100%;
    }

    /* Form grids: single column */
    .sd-staff-portal__enroll-form,
    .sd-staff-portal__client-edit-form,
    .sd-staff-portal__book-form {
        grid-template-columns: 1fr;
    }

    .sd-book-recurring-fields {
        grid-template-columns: 1fr;
    }

    .sd-staff-schedule__clients {
        padding-left: 0;
    }

    .sd-staff-schedule__empty {
        padding-left: 0;
    }

    .sd-staff-schedule__session-header {
        flex-wrap: wrap;
    }

    /* Filter bar form: single column on mobile */
    .sd-staff-filter-bar__form {
        grid-template-columns: 1fr;
    }
}

/* ── Responsive: phone (≤ 480px) ─────────────── */

@media (max-width: 480px) {
    .sd-staff-portal {
        padding: 10px 10px calc( 64px + env(safe-area-inset-bottom, 0px) );
    }

    .sd-account-holder-portal.sd-staff-portal {
        padding: 10px 10px calc( 64px + env(safe-area-inset-bottom, 0px) ) !important;
    }

    .sd-staff-portal select,
    .sd-staff-portal input[type="search"],
    .sd-staff-portal input[type="text"],
    .sd-staff-portal input[type="email"],
    .sd-staff-portal input[type="date"],
    .sd-staff-portal textarea {
        font-size: 16px;
        min-height: 44px;
    }

    .sd-staff-portal__tab-btn {
        font-size: 9px;
    }

    .sd-staff-portal__header h1,
    .sd-staff-portal .sd-portal__title {
        font-size: 1.1rem;
    }

    .sd-staff-portal__stat strong {
        font-size: 18px;
    }

    .sd-staff-session-card__header {
        flex-direction: column;
        gap: 6px;
    }

    .sd-staff-client-meta {
        flex-wrap: wrap;
    }

    /* Admin link: hide label, show compact on very small */
    .sd-portal__admin-link {
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* ── Desktop: filter bar form 3-column ─────────── */

@media (min-width: 783px) {
    .sd-staff-filter-bar__form {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr) auto;
    }
}
