/* Compact dashboard header layout for phones and narrow tablets. */
@media (max-width: 768px) {
    /* Keep floating utilities above the mobile navigation bar. */
    #task-fab,
    .task-fab,
    #help-fab,
    .help-fab,
    #ai-chat-fab,
    .ai-chat-fab {
        bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    }

    #task-fab,
    .task-fab {
        left: 12px !important;
    }

    #help-fab,
    .help-fab {
        left: 60px !important;
    }

    #ai-chat-fab,
    .ai-chat-fab {
        right: 12px !important;
    }

    /* Prevent the consent checkbox from inheriting full-width form controls. */
    #patientForm #patientConsent {
        width: 20px !important;
        min-width: 20px !important;
        max-width: 20px !important;
        height: 20px !important;
        min-height: 20px !important;
        padding: 0 !important;
        flex: 0 0 20px;
    }

    #patientForm #patientConsent + span {
        min-width: 0;
        flex: 1 1 auto;
    }

    /* Turn profile navigation into a readable two-row mobile control. */
    .profile-hub-modal {
        width: calc(100% - 16px) !important;
        max-width: none !important;
        max-height: calc(100vh - 16px) !important;
        border-radius: 12px;
    }

    .profile-hero-banner {
        padding: 16px 14px !important;
    }

    .profile-hero-banner > div:first-of-type {
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .profile-avatar-circle {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .profile-hub-tabs-bar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        padding: 8px;
        overflow: visible;
    }

    .profile-hub-tab {
        min-width: 0;
        min-height: 44px;
        justify-content: center;
        padding: 8px 6px;
        font-size: 0.75rem;
        line-height: 1.15;
        white-space: normal;
        text-align: center;
        border: 1px solid #dbe3ec;
        border-radius: 7px;
    }

    .profile-hub-tab.active {
        border-color: #0284c7;
    }

    .profile-hub-body {
        padding: 14px;
    }

    .header {
        padding: 0.7rem 0.75rem 0.8rem;
    }

    .header-main-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .header-left {
        width: 100%;
        justify-content: flex-start;
    }

    .header-brand-lockup {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 0.65rem;
        width: 100%;
        text-align: left;
    }

    .brand-divider-pipe {
        display: none;
    }

    .brand-badge-link {
        padding: 4px 8px 4px 6px;
    }

    .brand-gem-icon {
        width: 26px;
        height: 26px;
        font-size: 0.85rem;
    }

    .brand-prefix,
    .brand-suffix {
        font-size: 1.05rem;
        letter-spacing: 0;
    }

    .brand-headline-block {
        align-items: flex-start;
        min-width: 0;
        text-align: left;
    }

    .header-title {
        font-size: 1.05rem;
        line-height: 1.12;
        letter-spacing: 0;
        max-width: 100%;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .header-sub-meta {
        justify-content: flex-start;
        gap: 5px;
        font-size: 0.7rem;
    }

    .header-subtitle {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-welcome-text,
    .header-meta-dot {
        display: none;
    }

    .header-right {
        align-items: stretch;
        width: 100%;
    }

    .header-utility-row {
        width: 100%;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 0.35rem;
    }

    .header-utility-row .user-info {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 0.45rem 0.65rem;
    }

    .header-utility-row .user-info #currentUserRole {
        display: none;
    }

    .header-utility-row .user-info #currentUserName {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-utility-row .logout-btn {
        padding: 0.5rem 0.65rem;
        white-space: nowrap;
    }

    .header-utility-row .logout-btn span {
        display: none;
    }

    .header-district-row {
        justify-content: stretch;
        width: 100%;
    }

    .district-scope-pill {
        width: 100%;
        justify-content: center;
    }

    .district-scope-select {
        min-width: 0;
        flex: 1 1 auto;
    }
}

@media (max-width: 380px) {
    .header-title {
        font-size: 0.95rem;
    }

    .header-utility-row .theme-toggle-btn {
        width: 34px;
        min-width: 34px;
        padding: 0.45rem;
    }
}