/* =============================================
   Dr Pro AI - Patient Portal
   Builds on style.css tokens/components. Mobile first:
   top bar + bottom tab bar on phones, sidebar from 1024px.
   ============================================= */

body.portal {
    background:
        radial-gradient(900px 360px at 100% -80px, var(--secondary) 0%, transparent 70%),
        radial-gradient(700px 300px at -10% 0%, var(--primary-50) 0%, transparent 70%),
        var(--bg);
    background-attachment: fixed;
    min-height: 100dvh;
}

body.sheet-open {
    overflow: hidden;
}

.portal-shell {
    min-height: 100dvh;
}

/* ---------- Brand ---------- */

.portal-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: inherit;
    min-width: 0;
}

.portal-brand img {
    flex-shrink: 0;
    height: auto;
}

.portal-brand > span {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.portal-brand .brand-name {
    font-size: 1.05rem;
}

.portal-brand-clinic {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--secondary-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52vw;
}

.portal-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--secondary);
    color: var(--secondary-ink);
    font-family: var(--font-heading);
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.portal-avatar-link {
    width: 44px;
    height: 44px;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-sm);
}

/* ---------- Mobile chrome ---------- */

.portal-sidebar {
    display: none;
}

.portal-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: calc(0.6rem + var(--safe-top, env(safe-area-inset-top))) 1rem 0.6rem;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
}

.portal-content {
    padding: 1.25rem 1rem calc(96px + var(--safe-bottom, env(safe-area-inset-bottom)));
    max-width: 1120px;
    animation: portal-in 0.28s var(--ease-out) both;
}

.portal-content:focus {
    outline: none;
}

@keyframes portal-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.portal-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 0.35rem 0.4rem calc(0.35rem + var(--safe-bottom, env(safe-area-inset-bottom)));
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px -12px rgba(27, 42, 88, 0.25);
}

.portal-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    min-height: 54px;
    padding: 0.3rem 0.2rem;
    border: 0;
    background: none;
    border-radius: var(--radius);
    color: var(--gray-500);
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 600;
    transition: color 0.18s var(--ease-out), background 0.18s var(--ease-out);
}

.portal-tab i {
    font-size: 1.15rem;
    width: 48px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: background 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}

.portal-tab.active {
    color: var(--primary);
}

.portal-tab.active i {
    background: var(--secondary);
}

.portal-tab:active i {
    transform: scale(0.92);
}

/* More sheet */
.portal-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, 0.42);
    animation: sheet-fade 0.2s var(--ease-out) both;
}

.portal-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 0.5rem 0.75rem calc(1rem + var(--safe-bottom, env(safe-area-inset-bottom)));
    box-shadow: var(--shadow-xl);
    animation: sheet-up 0.26s var(--ease-out) both;
}

.portal-sheet[hidden],
.portal-sheet-backdrop[hidden] {
    display: none;
}

.portal-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: var(--gray-300);
    margin: 0.25rem auto 0.75rem;
}

.portal-sheet-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 56px;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius);
    color: var(--gray-800);
    font-weight: 600;
}

.portal-sheet-item:hover,
.portal-sheet-item.active {
    background: var(--secondary-light);
    color: var(--primary);
}

.portal-sheet-item.is-danger {
    color: var(--danger);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    margin-top: 0.35rem;
}

.portal-sheet-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-50);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.is-danger .portal-sheet-icon {
    background: var(--danger-light);
    color: var(--danger);
}

.portal-sheet-chev {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--gray-400);
}

@keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: none; }
}

@keyframes sheet-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.portal-flash {
    margin-bottom: 1.25rem;
}

/* ---------- Desktop chrome ---------- */

@media (min-width: 1024px) {
    .portal-shell {
        display: grid;
        grid-template-columns: 264px minmax(0, 1fr);
    }

    .portal-sidebar {
        position: sticky;
        top: 0;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        padding: 1.5rem 1rem 1rem;
        background: rgba(255, 255, 255, 0.92);
        border-right: 1px solid var(--border);
    }

    .portal-sidebar .portal-brand {
        padding: 0 0.5rem;
    }

    .portal-sidebar .portal-brand-clinic {
        max-width: 170px;
    }

    .portal-nav {
        display: flex;
        flex-direction: column;
        gap: 0.2rem;
        flex: 1;
        overflow-y: auto;
    }

    .portal-nav-item {
        display: flex;
        align-items: center;
        gap: 0.8rem;
        min-height: 44px;
        padding: 0.55rem 0.85rem;
        border-radius: var(--radius);
        color: var(--gray-600);
        font-family: var(--font-heading);
        font-weight: 600;
        font-size: 0.925rem;
        transition: background 0.18s var(--ease-out), color 0.18s var(--ease-out);
    }

    .portal-nav-item i {
        width: 20px;
        text-align: center;
        color: var(--gray-400);
        transition: color 0.18s var(--ease-out);
    }

    .portal-nav-item:hover {
        background: var(--gray-50);
        color: var(--gray-900);
    }

    .portal-nav-item.active {
        background: var(--secondary);
        color: var(--primary-darker);
    }

    .portal-nav-item.active i,
    .portal-nav-item:hover i {
        color: var(--primary);
    }

    .portal-sidebar-foot {
        display: grid;
        gap: 0.75rem;
    }

    .portal-help {
        display: flex;
        gap: 0.6rem;
        align-items: center;
        padding: 0.75rem 0.85rem;
        border-radius: var(--radius);
        background: var(--primary-50);
        color: var(--gray-700);
        font-size: 0.8rem;
        line-height: 1.35;
    }

    .portal-help i {
        color: var(--primary);
    }

    .portal-help strong {
        display: block;
        color: var(--primary);
    }

    .portal-me {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border);
    }

    .portal-me-text {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        line-height: 1.3;
    }

    .portal-me-text strong {
        font-size: 0.875rem;
        color: var(--gray-900);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .portal-me-text small {
        font-size: 0.75rem;
        color: var(--gray-500);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .portal-topbar,
    .portal-tabbar,
    .portal-sheet,
    .portal-sheet-backdrop {
        display: none !important;
    }

    .portal-content {
        padding: 2.25rem 2.5rem 3rem;
        margin: 0 auto;
    }
}

/* Single-column grids must not grow to fit wide scrollers (day strip, tables) */
.pt-dash,
.pt-dash-main,
.pt-dash-side,
.book-grid,
.pt-stack {
    grid-template-columns: minmax(0, 1fr);
}

.book-grid > *,
.pt-two > *,
.portal-main {
    min-width: 0;
}

/* ---------- Page heading ---------- */

.pt-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.pt-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.pt-sub {
    color: var(--gray-500);
    margin: 0.25rem 0 0;
    font-size: 0.925rem;
}

.pt-hello {
    margin-bottom: 1.25rem;
}

.pt-hello-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.pt-hello-sub {
    margin: 0.3rem 0 0;
    color: var(--gray-500);
}

@media (min-width: 1024px) {
    .pt-hello-title,
    .pt-title {
        font-size: 2rem;
    }
}

.pt-section-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.pt-link {
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 32px;
}

.pt-link i {
    font-size: 0.75rem;
    transition: transform 0.18s var(--ease-out);
}

.pt-link:hover i {
    transform: translateX(2px);
}

.pt-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin: 0.4rem 0 0;
}

/* ---------- Dashboard ---------- */

.pt-dash {
    display: grid;
    gap: 1rem;
}

.pt-dash-main,
.pt-dash-side {
    display: grid;
    gap: 1rem;
    align-content: start;
}

@media (min-width: 900px) {
    .pt-dash {
        grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
        gap: 1.25rem;
    }

    .pt-dash-main,
    .pt-dash-side {
        gap: 1.25rem;
    }
}

.pt-card {
    padding: 1.15rem 1.15rem 1.25rem;
}

.pt-card-head,
.pt-next-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.pt-next {
    padding: 1.15rem;
    border-color: var(--primary-100);
    box-shadow: var(--shadow-md);
    position: relative;
}

.pt-next::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.pt-next-body {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.date-tile {
    flex-shrink: 0;
    width: 68px;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: var(--white);
    text-align: center;
    padding: 0.45rem 0 0.5rem;
    font-family: var(--font-heading);
    line-height: 1.05;
    box-shadow: 0 8px 18px -8px rgba(var(--primary-rgb), 0.6);
}

.date-tile-month,
.date-tile-dow {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--secondary);
}

.date-tile-day {
    display: block;
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0.1rem 0;
}

.date-tile.is-muted {
    background: var(--gray-100);
    color: var(--gray-700);
    box-shadow: none;
}

.date-tile.is-muted .date-tile-month,
.date-tile.is-muted .date-tile-dow {
    color: var(--gray-500);
}

.pt-next-info {
    min-width: 0;
    flex: 1;
}

.pt-next-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.pt-next-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.6rem;
}

.pt-next-meta i {
    width: 16px;
    color: var(--gray-400);
}

.pt-next-empty {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.35rem 0 0.25rem;
}

.pt-next-empty-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--secondary);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.pt-next-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.pt-next-actions .btn {
    flex: 1 1 auto;
    min-height: 46px;
}

/* tiles */
.pt-tiles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

@media (min-width: 900px) {
    .pt-tiles {
        gap: 1.25rem;
    }
}

.pt-tile {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    color: inherit;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out), border-color 0.2s var(--ease-out);
    min-width: 0;
}

.pt-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-100);
    color: inherit;
}

.pt-tile-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.pt-tile-icon.secondary { background: var(--secondary); color: var(--secondary-ink); }
.pt-tile-icon.warning { background: var(--warning-light); color: var(--warning); }
.pt-tile-icon.success { background: var(--success-light); color: var(--success); }
.pt-tile-icon.primary { background: var(--primary-50); color: var(--primary); }

.pt-tile-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-500);
}

.pt-tile-value {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--gray-900);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.pt-tile-foot {
    font-size: 0.78rem;
    color: var(--primary);
    font-weight: 600;
    margin-top: 0.15rem;
}

/* progress */
.pt-progress {
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    overflow: hidden;
}

.pt-progress > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    transform-origin: left;
    animation: bar-grow 0.7s var(--ease-out) both;
}

@keyframes bar-grow {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.pt-progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--gray-600);
    margin-top: 0.45rem;
}

.pt-progress-meta strong {
    color: var(--primary);
}

.pt-next-step {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    color: var(--gray-600);
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.pt-next-step i {
    color: var(--accent);
}

/* referral */
.pt-refer {
    position: relative;
}

.pt-refer-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--white);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.pt-refer .pt-section-title {
    margin-bottom: 0.35rem;
    padding-right: 2.75rem;
}

.pt-refer p {
    color: var(--gray-600);
    margin-bottom: 0.9rem;
}

.ref-code {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border: 1.5px dashed var(--secondary-dark);
    border-radius: var(--radius);
    background: var(--white);
    margin-bottom: 0.75rem;
}

.ref-code-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
}

.ref-code-value {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--primary-darker);
}

.pt-refer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

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

/* quick links */
.pt-quick {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.pt-quick-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 58px;
    padding: 0.6rem 1rem;
    color: var(--gray-800);
    font-weight: 600;
    font-size: 0.925rem;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s ease;
}

.pt-quick-item:last-child {
    border-bottom: 0;
}

.pt-quick-item:hover {
    background: var(--secondary-light);
    color: var(--primary);
}

.pt-quick-item > span:nth-child(2) {
    flex: 1;
}

.pt-quick-item > i {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.pt-quick-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--primary-50);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Segmented control ---------- */

.seg {
    display: inline-flex;
    padding: 4px;
    gap: 4px;
    background: var(--gray-100);
    border-radius: var(--radius-full);
    margin-bottom: 1rem;
}

.seg a {
    min-height: 38px;
    padding: 0.4rem 1.1rem;
    border-radius: var(--radius-full);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-600);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.seg a.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.seg .count {
    font-size: 0.72rem;
    background: var(--primary-50);
    color: var(--primary);
    border-radius: var(--radius-full);
    padding: 0 0.45rem;
}

/* ---------- Visit list ---------- */

.visit-list {
    display: grid;
    gap: 0.75rem;
}

.visit {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.visit .date-tile {
    width: 58px;
}

.visit .date-tile-day {
    font-size: 1.5rem;
}

.visit-info {
    flex: 1;
    min-width: 0;
}

.visit-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.visit-meta {
    font-size: 0.84rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.9rem;
}

.visit-meta i {
    color: var(--gray-400);
    margin-right: 0.2rem;
}

.visit-notes {
    font-size: 0.82rem;
    color: var(--gray-500);
    margin: 0.4rem 0 0;
}

.visit-actions {
    margin-top: 0.75rem;
}

.visit.is-past {
    background: var(--gray-50);
    box-shadow: none;
}

/* ---------- Booking ---------- */

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

@media (min-width: 900px) {
    .book-grid {
        grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
        gap: 1.25rem;
        align-items: start;
    }

    .book-summary {
        position: sticky;
        top: 2rem;
    }
}

.book-step {
    padding: 1.15rem;
}

.book-step + .book-step {
    margin-top: 1rem;
}

.book-step-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.85rem;
}

.book-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
}

.choice {
    position: relative;
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice span {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 48px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.3;
}

.choice span:hover {
    border-color: var(--primary-100);
    background: var(--primary-50);
}

.choice input:checked + span {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 6px 14px -6px rgba(var(--primary-rgb), 0.6);
}

.choice input:focus-visible + span {
    box-shadow: var(--ring);
}

.day-strip {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding: 2px 2px 0.6rem;
    margin: 0 -2px;
    scrollbar-width: thin;
}

@media (pointer: coarse) {
    /* contain:paint: Android WebView (the app) otherwise paints the content above a scroll row a few px low */
    .day-strip { scrollbar-width: none; contain: paint; }
    .day-strip::-webkit-scrollbar { display: none; }
}

.day-pill {
    flex: 0 0 auto;
    scroll-snap-align: start;
    width: 62px;
    min-height: 74px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    background: var(--white);
    color: var(--gray-700);
    font-family: var(--font-heading);
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, transform 0.15s var(--ease-out);
}

.day-pill small {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
}

.day-pill strong {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.1;
}

.day-pill:hover {
    border-color: var(--primary-100);
    background: var(--primary-50);
    color: var(--primary);
}

.day-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    box-shadow: 0 8px 16px -8px rgba(var(--primary-rgb), 0.6);
}

.day-pill.active small {
    color: var(--secondary);
}

.day-pill.is-closed {
    background: var(--gray-50);
    color: var(--gray-400);
    border-style: dashed;
    pointer-events: none;
}

.day-pill.is-closed small {
    color: var(--gray-400);
}

.slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 0.5rem;
}

.slot-grid .choice span {
    font-variant-numeric: tabular-nums;
}

.slot-group-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--gray-500);
    margin: 0.85rem 0 0.45rem;
}

.slot-group-label:first-child {
    margin-top: 0;
}

.slots-empty {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--gray-50);
    color: var(--gray-600);
    font-size: 0.875rem;
}

.slots-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.book-summary {
    padding: 1.15rem;
}

.summary-list {
    display: grid;
    gap: 0.65rem;
    margin: 0.75rem 0 1rem;
}

.summary-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.9rem;
}

.summary-row i {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--primary-50);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.summary-row span {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    min-width: 0;
}

.summary-row small {
    font-size: 0.72rem;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-row strong {
    color: var(--gray-900);
}

.summary-row .is-empty {
    color: var(--gray-400);
    font-weight: 500;
}

/* ---------- Treatment plans ---------- */

.plan-card {
    padding: 1.15rem;
}

.plan-card + .plan-card {
    margin-top: 1rem;
}

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

.plan-title {
    font-size: 1.1rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.plan-meta {
    font-size: 0.82rem;
    color: var(--gray-500);
    margin: 0.2rem 0 0;
}

.plan-money {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.plan-money div {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
}

.plan-money small {
    display: block;
    font-size: 0.72rem;
    color: var(--gray-500);
    font-weight: 600;
}

.plan-money strong {
    font-family: var(--font-heading);
    font-size: 1.05rem;
}

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.step {
    position: relative;
    display: flex;
    gap: 0.85rem;
    padding-bottom: 1rem;
}

.step:last-child {
    padding-bottom: 0;
}

.step::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.step:last-child::before {
    display: none;
}

.step-dot {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    background: var(--white);
    border: 2px solid var(--gray-300);
    color: var(--gray-400);
    position: relative;
    z-index: 1;
}

.step.is-completed .step-dot {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
}

.step.is-completed::before {
    background: var(--success);
}

.step.is-in_progress .step-dot {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-50);
}

.step.is-skipped .step-dot {
    border-style: dashed;
}

.step-body {
    flex: 1;
    min-width: 0;
    padding-top: 0.25rem;
}

.step-title {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.925rem;
}

.step.is-skipped .step-title {
    color: var(--gray-400);
    text-decoration: line-through;
}

.step-meta {
    font-size: 0.8rem;
    color: var(--gray-500);
    display: flex;
    flex-wrap: wrap;
    gap: 0.1rem 0.75rem;
}

.plan-summary {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.plan-summary summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.plan-summary-text {
    font-size: 0.875rem;
    color: var(--gray-600);
    white-space: pre-line;
    margin-top: 0.5rem;
    max-height: 320px;
    overflow-y: auto;
    overflow-wrap: anywhere;
}

/* ---------- Billing ---------- */

.money-hero {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.money-hero > div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.8rem 0.9rem;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.money-hero small {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--gray-500);
}

.money-hero strong {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gray-900);
    overflow-wrap: anywhere;
}

.money-hero .is-due {
    background: var(--warning-light);
    border-color: #F5D7A4;
}

.money-hero .is-due strong {
    color: #7A4508;
}

@media (max-width: 480px) {
    .money-hero {
        grid-template-columns: 1fr 1fr;
    }

    .money-hero > div:first-child {
        grid-column: 1 / -1;
    }
}

.inv {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.inv > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 1rem;
    cursor: pointer;
    min-height: 64px;
}

.inv > summary::-webkit-details-marker {
    display: none;
}

.inv-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-50);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.inv-main {
    flex: 1;
    min-width: 0;
}

.inv-no {
    font-weight: 700;
    color: var(--gray-900);
    font-size: 0.925rem;
}

.inv-date {
    font-size: 0.78rem;
    color: var(--gray-500);
}

.inv-amt {
    text-align: right;
    font-family: var(--font-heading);
    font-weight: 700;
    white-space: nowrap;
}

.inv-amt small {
    display: block;
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.inv-chev {
    color: var(--gray-400);
    font-size: 0.75rem;
    transition: transform 0.2s var(--ease-out);
}

.inv[open] .inv-chev {
    transform: rotate(180deg);
}

.inv-body {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--gray-100);
}

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

.line-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.45rem 0;
    font-size: 0.875rem;
    border-bottom: 1px dashed var(--gray-200);
}

.line-list li:last-child {
    border-bottom: 0;
}

.line-list .muted {
    color: var(--gray-500);
}

.line-list .tot {
    font-weight: 700;
    color: var(--gray-900);
}

.sub-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--gray-500);
    margin-top: 1rem;
}

/* ---------- Videos ---------- */

.chip-row {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    margin-bottom: 1rem;
}

.chip-row .chip {
    flex-shrink: 0;
    min-height: 40px;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.video-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.video-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--primary-darker);
}

.video-frame iframe,
.video-frame .video-facade {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.video-facade {
    display: block;
    padding: 0;
    cursor: pointer;
    background: var(--primary-darker) center / cover no-repeat;
}

.video-facade::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(15, 23, 42, 0.55));
}

.video-play {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 1;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    padding-left: 4px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s var(--ease-out);
}

.video-facade:hover .video-play {
    transform: scale(1.08);
}

.video-info {
    padding: 0.85rem 1rem 1rem;
}

.video-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.video-desc {
    font-size: 0.82rem;
    color: var(--gray-500);
    margin: 0;
}

/* ---------- Rewards ---------- */

.reward-hero {
    position: relative;
    overflow: hidden;
    padding: 1.35rem 1.25rem;
    border-radius: var(--radius-xl);
    color: var(--white);
    background:
        radial-gradient(80% 120% at 100% 0%, rgba(224, 240, 240, 0.25) 0%, transparent 60%),
        radial-gradient(60% 80% at 0% 100%, rgba(26, 133, 133, 0.55) 0%, transparent 70%),
        linear-gradient(140deg, var(--primary) 0%, var(--primary-dark) 60%, var(--primary-darker) 100%);
    box-shadow: var(--shadow-lg);
    margin-bottom: 1rem;
}

.reward-hero::after {
    content: '';
    position: absolute;
    right: -12%;
    bottom: -18%;
    width: 70%;
    aspect-ratio: 967 / 364;
    background: url('../img/logo-mark-white.png') no-repeat center / contain;
    opacity: 0.08;
    pointer-events: none;
}

.reward-hero small {
    color: var(--secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.reward-points {
    font-family: var(--font-heading);
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0.2rem 0;
}

.reward-points span {
    font-size: 1rem;
    font-weight: 600;
    color: var(--secondary);
    letter-spacing: 0;
}

.reward-value {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

.earn-list {
    display: grid;
    gap: 0.6rem;
}

.earn {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    font-size: 0.875rem;
}

.earn-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--secondary);
    color: var(--secondary-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.earn strong {
    display: block;
    color: var(--gray-900);
}

.earn span {
    color: var(--gray-500);
    font-size: 0.8rem;
}

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

.ledger li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.ledger li:last-child {
    border-bottom: 0;
}

.ledger-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--primary-50);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.ledger-main {
    flex: 1;
    min-width: 0;
}

.ledger-main strong {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-900);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.ledger-main span {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.ledger-pts {
    font-family: var(--font-heading);
    font-weight: 800;
    white-space: nowrap;
}

.ledger-pts.is-plus { color: var(--success); }
.ledger-pts.is-minus { color: var(--danger); }

/* ---------- Generic stacks ---------- */

.pt-stack {
    display: grid;
    gap: 1rem;
}

@media (min-width: 900px) {
    .pt-two {
        display: grid;
        grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
        gap: 1.25rem;
        align-items: start;
    }
}

.pt-two > * + * {
    margin-top: 1rem;
}

@media (min-width: 900px) {
    .pt-two > * + * {
        margin-top: 0;
    }
}

.pt-empty {
    background: var(--surface);
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-lg);
}

.pt-form .btn-primary {
    min-height: 46px;
}

/* ---------- Standalone (unlinked / denied) ---------- */

.portal-standalone {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

.portal-standalone-card {
    max-width: 480px;
    width: 100%;
}

.portal-standalone-card .card-body {
    padding: 2.25rem 1.5rem;
}

/* ---------- Register (inside auth layout) ---------- */

.auth-form .form-row-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

@media (max-width: 480px) {
    .auth-form .form-row-1-1 {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

.ref-applied {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius);
    background: var(--secondary-light);
    border: 1px solid var(--secondary-dark);
    color: var(--secondary-ink);
    font-size: 0.85rem;
    margin-bottom: 1.1rem;
}
