/* Shared mobile ergonomics. Loaded after domain styles to keep one touch baseline. */
.header-page-actions { display: contents; }
.phone-copy { display:none; }
.catchup-metrics { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-bottom:16px; }
.catchup-metrics > div { padding:16px; }

/* Secondary workflows use the same touch and reading rhythm as the main screens. */
@media screen and (max-width:767px) {
    .catchup-metrics { gap:8px; }
    .catchup-metrics > div { padding:12px 6px; }
    body.workspace .document-selectable { grid-template-columns:44px minmax(0,1fr); }
    body.workspace .document-selection-target { min-width:44px; min-height:44px; }
    body.workspace .billing-select,
    body.workspace #campaignEditor label:has(> input[type=checkbox]) { min-height:48px; }
    body.workspace #mailTemplateLibrary .template-icon-button { min-width:44px; min-height:44px; }
    body.workspace #campaignEditor input[type=checkbox] { flex-shrink:0; }
    body.workspace #opt-manual label { flex-wrap:wrap; gap:8px; }
    body.workspace #opt-manual label > span { min-width:0; overflow-wrap:anywhere; }
    body.workspace #opt-manual label > span:last-child { flex-basis:100%; padding-left:24px; }
    body.workspace :is(.campaign-recipient-mode,.billing-client) strong { font-size:15px; line-height:1.5; }
    body.workspace :is(.campaign-recipient-mode,.billing-client) small { font-size:13px; line-height:1.5; }
    body.workspace .recipient-controls :is(.tag-option,.tag-option-multi) .client-tag { min-height:48px; padding:10px 12px; font-size:14px; }
    body.workspace .recipient-controls .tag-option input:checked + .client-tag { transform:none; }
    body.workspace .recipient-controls .form-actions > form { flex:1 1 100px; }
    body.workspace .recipient-controls .form-actions > form .btn { width:100%; }
    body.workspace .recipient-controls .form-actions > .btn { flex:2 1 170px; white-space:normal; }
    body.workspace :is(.invoice-source-link,.share-breadcrumb a,.share-client-line a,.share-mail-alternative,.share-tracking-help summary,.director-portfolio-details dd > a) {
        display:inline-flex; align-items:center; min-height:44px; font-size:13px; line-height:1.5;
    }
    body.workspace .share-breadcrumb { gap:6px 10px; margin-bottom:12px; }
    body.workspace :is(.share-field-label,.share-section-heading > span,.share-client-line,.share-email-row small,.share-access-note,.share-stats dt,.share-dates dt,.share-tracking-help,.share-empty p,.share-inactive p) { font-size:13px; line-height:1.6; }
    body.workspace :is(.share-email-row strong,.share-dates dd,.share-current-state,.share-access p,.share-document-row .document-description p) { font-size:14px; line-height:1.6; }
    body.workspace .share-mail-alternative { width:100%; justify-content:center; }
    body.workspace .share-dates { grid-template-columns:minmax(0,1fr); }
    body.workspace .share-send-panel .document-copy { flex-wrap:wrap; gap:8px; }
    body.workspace .share-send-panel .document-copy input { flex:1 1 100%; font-size:16px; }
    body.workspace .share-send-panel .document-copy .btn { width:100%; justify-content:center; }
    body.workspace .share-document-row .document-actions { margin-left:0; width:100%; }
    body.workspace .share-document-row .document-actions > .btn { flex:1; }
    body.workspace .share-document-row .document-description { flex:1 1 150px; min-width:0; }
    body.workspace .share-access > .btn { width:100%; }

    /* The visual bar keeps its scale; its link occupies the entire month column. */
    body.workspace .director-chart { overflow-x:auto; overscroll-behavior-x:contain; padding-inline:8px; gap:8px; }
    body.workspace .director-chart-axis { width:32px; }
    body.workspace .director-chart-field { flex:none; width:calc(100% - 40px); min-width:calc(var(--visible-month-count, 6) * 48px - 4px); gap:4px; }
    body.workspace .director-column { min-width:44px; }
    body.workspace .director-bar { top:0; height:100%; width:100%; max-width:none; background:transparent; border-radius:4px; }
    body.workspace .director-column:last-child .director-bar,
    body.workspace .director-bar.is-negative,
    body.workspace .director-bar:is(:hover,:focus-visible) { background:transparent; }
    body.workspace .director-bar::before { content:''; position:absolute; left:50%; transform:translateX(-50%); top:var(--bar-top,100%); height:var(--bar-height,0%); min-height:3px; width:26px; background:#647cb5; border-radius:4px 4px 0 0; }
    body.workspace .director-column:last-child .director-bar::before { background:#91a1e6; }
    body.workspace .director-bar.is-negative::before { background:#bd865a; border-radius:0 0 4px 4px; }
    body.workspace .director-bar:focus-visible { outline:2px solid #5067a5; outline-offset:-2px; }
    body.workspace .director-bar:is(:hover,:focus-visible)::before { background:#425cc3; }
    body.workspace .director-tooltip { bottom:auto; top:4px; }
}

/* Phone review: readable records and controls that remain reachable while editing. */
@media screen and (max-width:767px) {
    /* A second floating toolbar covered fields above the permanent navigation. */
    body.workspace .editor-form > .form-actions {
        position:static; padding:16px; margin-top:20px; box-shadow:none;
    }
    /* Status never competes with actions; intrinsic button widths determine wrapping. */
    body.workspace .editor-form .form-actions {
        display:flex; flex-wrap:wrap; gap:10px; padding:16px;
    }
    body.workspace .editor-form .form-actions > .editor-status {
        flex:0 0 100%; width:100%; margin:0; align-self:stretch; line-height:1.5;
    }
    body.workspace .editor-form .form-actions > .btn {
        flex:1 0 auto; width:max-content; max-width:100%; min-width:0;
        min-height:48px; padding:12px 16px; white-space:normal; justify-content:center;
    }
    body.workspace .editor-form .form-row { gap:0; }
    body.workspace .editor-form .form-row > .form-group { margin-bottom:18px; }
    body.workspace .invoice-item .form-row { gap:10px; }
    body.workspace .invoice-item .form-row > .form-group { margin-bottom:12px; }
    /* The price group is flex: its gap must not add to the generated label's margin. */
    body.workspace .invoice-item .invoice-item-price-group { gap:0; }
    body.workspace .invoice-item .item-price-feedback { margin-top:6px; }
    body.workspace .editor-form .form-label { font-size:13px; }
    body.workspace .editor-status { font-size:12px; }

    /* Action labels set the minimum space, rather than equal columns squeezing them. */
    body.workspace .quote-actions { display:flex; flex-wrap:wrap; align-items:stretch; }
    body.workspace .quote-actions > :is(.btn,form) { flex:1 0 auto; width:max-content; max-width:100%; min-width:0; }
    body.workspace .quote-actions .btn { min-height:48px; justify-content:center; }
    body.workspace .client-link-copy > .btn,
    body.workspace .client-link-actions > form { flex:1 0 auto; width:max-content; max-width:100%; }
    body.workspace .client-link-panel .btn { min-height:48px; justify-content:center; }
    body.workspace .document-header-actions > .btn { flex:1 0 100%; min-height:48px; font-size:14px; padding:12px 16px; }
    body.workspace .message-tools > :is(.btn,details) { flex:1 0 auto; width:max-content; max-width:100%; }
    body.workspace .message-tools > details[open] { flex-basis:100%; }
    body.workspace .einvoices-detail .record-actions { grid-template-columns:minmax(0,1fr); }
    body.workspace .treatment-navigation .treatment-back { padding-inline:12px; }
    body.workspace :is(.modal-footer,.document-dialog footer,.settings-savebar) { flex-wrap:wrap; gap:10px; }
    body.workspace :is(.modal-footer,.document-dialog footer,.settings-savebar) > .btn {
        flex:1 0 auto; width:max-content; max-width:100%; min-width:0;
        min-height:48px; padding:12px 16px; white-space:normal; justify-content:center;
    }
    body.workspace .settings-savebar > .form-hint { flex-basis:100%; }

    /* Reduce branding height so the login fields fit on small phones. */
    body.public-page .login-brand-panel { padding:20px; }
    body.public-page .login-brand-logo { width:104px; }
    body.public-page .login-form-panel { padding:24px 20px; }
    body.public-page .auth-logo { margin-bottom:24px; }

    body.workspace .user-roster-actions .btn,
    body.workspace .user-roster-open,
    body.workspace .cal-toolbar .btn,
    body.workspace #todayButton,
    body.workspace .cal-period > .cal-mobile-filter-toggle,
    body.workspace .cal-live-clock {
        min-width:44px; min-height:44px;
    }
    body.workspace .cal-period > .cal-mobile-filter-toggle { width:44px; height:44px; flex-basis:44px; }
    body.workspace .user-roster-actions .btn { font-size:12px; }
    body.workspace .user-roster-help > summary { min-height:44px; display:flex; align-items:center; }

    body.workspace .director-segment button { min-height:44px; min-width:44px; font-size:12px; }
    body.workspace .director-classic .director-metric-label { font-size:12px; }
    body.workspace .director-classic .director-metric > small { font-size:12px; line-height:1.5; }
    body.workspace .director-classic .director-action-copy > strong { font-size:14px; line-height:1.4; }
    body.workspace .director-classic .director-action-copy > small,
    body.workspace .director-record-name small,
    body.workspace .director-schedule-row small { font-size:12px; line-height:1.5; }
    body.workspace .director-section-foot a,
    body.workspace .director-sync-line a,
    body.workspace .director-portfolio-details summary,
    body.workspace .director-definition summary { min-height:44px; display:flex; align-items:center; font-size:13px; }
    body.workspace .director-sync-line { flex-wrap:wrap; }
    body.workspace .director-classic .director-portfolio-details summary { padding-block:10px; }

    body.workspace .memo > header > a,
    body.workspace .memo > footer > a,
    body.workspace .document-description > span > a,
    body.workspace .detail-subtitle > a,
    body.workspace .assistant-setup-notice > a,
    body.workspace .profile-heading p > a {
        display:inline-flex; align-items:center; min-height:44px; line-height:1.5;
    }
    body.workspace .memo > footer > a { font-size:12px; }
    body.workspace .credential-service-link {
        display:inline-flex; align-items:center; justify-content:center;
        min-width:44px; min-height:44px; vertical-align:middle;
    }
    body.workspace .campaign-list-title { align-items:flex-start; }
    body.workspace .campaign-list-title h3 { min-width:0; overflow-wrap:anywhere; }
    body.workspace .campaign-list-actions { display:flex; flex-wrap:wrap; width:100%; }
    body.workspace .campaign-list-actions > :is(.btn,form) { flex:1 0 auto; width:max-content; max-width:100%; min-width:0; }
    body.workspace .campaign-list-actions .btn { width:100%; white-space:normal; }
    body.workspace .campaign-list-actions > form:last-child { flex-basis:100%; }
    body.workspace .recipient-preview { position:static; }
    body.workspace #recipientMessageFrame { height:260px; min-height:0; }
}
/* Touch actions must not wait for double-tap zoom or move away from the finger. */
@media (hover:none) and (pointer:coarse) {
    a[href], button, input[type=submit], input[type=button], input[type=reset],
    [role=button], [role=option], summary { touch-action: manipulation; }
    body .btn:active { transform: none; }
}

@media screen and (max-width: 767px) {
    html { scroll-padding-block: 150px calc(110px + env(safe-area-inset-bottom)); }
    body { -webkit-text-size-adjust: 100%; }
    .main-content { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }

    /* Keep page commands on their own row so the page title remains readable. */
    .workspace .header { height: auto; }
    .workspace .header-content { display: flex; flex-wrap: wrap; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
    .workspace .header-title { flex: 1 1 100px; overflow-wrap: normal; font-size: 16px; }
    .workspace .header-actions { display: contents; }
    .workspace .header-page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; order: 2; width: 100%; min-width: 0; }
    .header-page-actions > form { min-width: 0; }
    .workspace .header-page-actions .btn { font-size: 13px; min-height:44px; min-width:44px; }
    .workspace .page-return a { width: 44px; height: 44px; }
    .workspace .user-btn, .workspace .notification-button { width: 44px; height: 44px; flex-shrink: 0; }
    .workspace .user-btn { display: grid; place-items: center; }
    .workspace .user-dropdown { position:absolute; top:calc(100% + 8px); right:0; max-height: calc(100dvh - 164px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
    .workspace .user-menu-item { min-height: 44px; }

    /* 44px is the comfort target; inline prose links and calendar cells are separate. */
    body.workspace .btn, body.workspace .btn-sm, body.workspace .btn-icon,
    body .modal-close, body .flash-close, body .btn-toggle-password,
    body .credential-copy-btn, body .tag-add-btn, body .tag-filter,
    body .pagination-number, body .filter-summary-close,
    body .invoice-price-toggle-btn, body .bank-status,
    body .bank-settings-trigger, body .assistant-new, body .assistant-send,
    body .cal-icon-button, body .cal-text-button, body .cal-view-switch button,
    body .notification-panel button, body .notification-toast button,
    body .period-switch button, body .agenda-open {
        min-height: 44px; min-width: 44px;
    }
    body .flash-close, body .filter-summary-close { flex-shrink: 0; }
    body .list-filter-summary { min-height: 60px; padding-right: 58px; }
    body:has(.mobile-filters-ready) .list-filter-summary { padding-right: 58px; }
    body .bank-status, body .tag-filter, body .pagination-number { display: inline-flex; align-items: center; justify-content: center; }
    body .bank-status { white-space: nowrap; }
    body .memo-colors label, body .cal-check, body .cal-choice,
    body .notification-preferences label, body .notification-preferences summary { min-height: 44px; }
    body .btn-toggle-password { right: 0; }
    body .credential-field .form-input { padding-right: 52px; }
    body .notification-close { flex-shrink: 0; }

    /* iOS can focus inputs without automatically zooming a small font. */
    body input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
    body select, body textarea { font-size: 16px; max-width: 100%; }
    body input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not(.app-select-source),
    body select:not(.app-select-source) { min-height: 44px; }
    body .form-label, body .form-hint { font-size: 13px; line-height: 1.5; }
    .form-input, .search-box, .editor-form, .record-body, .card-body > form { min-width: 0; }
    .form-row { grid-template-columns: minmax(0, 1fr); }
    .form-row .form-group:empty { display: none; }
    .form-actions { gap: 10px; }
    .editor-status { flex-basis: 100%; }
    .editor-form > .form-actions > .btn { flex: 1 1 120px; }
    .list-item-title, .detail-title, .quote-line p, .commercial-link strong { overflow-wrap: anywhere; }
    .list-item-title { white-space: normal; }
    body[data-page="tags.index"] .list-item { flex-wrap: wrap; }
    body[data-page="tags.index"] .list-item > .flex { margin-left: auto; }
    .card-header { gap: 12px; flex-wrap: wrap; }
    .card-title { min-width: 0; }
    .list-pagination { flex-wrap: wrap; gap: 12px; }
    .list-pagination > div { flex-wrap: wrap; }

    /* Dialogs remain scrollable when the viewport is short or the keyboard is open. */
    .modal-overlay { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
    .modal-overlay .modal { max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; border-radius: 14px; }
    .modal-overlay .modal-body { max-height: none; overflow: visible; padding: 16px; }
    .modal-header { padding: 12px 16px; gap: 12px; }
    .modal-title { overflow-wrap: anywhere; min-width: 0; }
    .modal-footer { flex-wrap: wrap; padding: 16px; }
    .modal-footer > .btn { flex: 1 1 120px; }
    body dialog { max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overscroll-behavior: contain; }
    .cal-dialog-footer > div { flex-wrap: wrap; }
    .cal-dialog .cal-field-row { grid-template-columns: minmax(0, 1fr); }
    .cal-dialog .cal-title-input { font-size: 18px; }
    .notification-panel .notification-filters { flex-wrap: wrap; }
    .notification-panel .notification-tools { flex-wrap: wrap; gap: 8px; }
    .notification-toast { bottom: calc(100px + env(safe-area-inset-bottom)); }
    .cal-toast { bottom: calc(100px + env(safe-area-inset-bottom)); }

    /* Keep operational labels readable without enlarging chart axes or decoration. */
    .director .director-link, .director .agenda-foot a,
    .director .director-section-footer a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; }
    .director .period-switch button { font-size: 12px; }
    .director .agenda-event-copy > strong { font-size: 14px; }
    .director .agenda-event-copy > small, .director .agenda-time,
    .director .agenda-kind, .director .agenda-foot { font-size: 12px; }
    .director .agenda-time b { font-size: 11px; }
    .assistant-suggestions { grid-template-columns: minmax(0, 1fr); }
    .assistant-suggestions strong { font-size: 14px; }
    .assistant-suggestions small, .assistant-welcome-copy { font-size: 13px; }
    .assistant-welcome-hint { font-size: 12px; }
    .assistant-composer { min-width: 0; }

    @media (hover: none) {
        .btn:hover { transform: none; }
    }
}

/* Focus must not disappear behind a sticky header or a bottom toolbar. */
body.has-overlay { overflow: hidden; }

@media screen and (max-width:767px) {
    body .client-tag-removable, body .tag-selector-item,
    body .btn-remove-item, body .assistant-icon-button,
    body .assistant-message-actions button, body .assistant-latest { min-width:44px; min-height:44px; }
    .client-tag-removable .tag-remove { opacity:1; }
    .tag-selector { gap:8px; }
}
@media screen and (max-width:767px) {
    #tagModal .form-group > .flex { flex-wrap:wrap; }
    #tagModal #newTagName { flex:1 1 100% !important; width:100%; }
    #tagModal .app-select { flex:1 1 120px; width:auto; }
    .workspace .bank-settings-trigger { min-height:44px; }
}

/* Phone navigation: four destinations and a complete, scrollable directory. */
.mobile-dock, .mobile-section-picker, .mobile-section-toggle { display:none; }
.mobile-menu { border:0; padding:0; color:var(--color-text); }
.mobile-menu:not([open]) { display:none; }
@media screen and (max-width:767px) {
    :root { --mobile-dock-height:70px; }
    .workspace .nav-bottom { display:none; }
    .workspace .messaging-header-link, .workspace .user-menu-mobile { display:none; }
    .mobile-dock {
        position:fixed; z-index:1000; display:flex;
        left:max(12px, env(safe-area-inset-left));
        right:max(12px, env(safe-area-inset-right));
        bottom:calc(10px + env(safe-area-inset-bottom));
        height:var(--mobile-dock-height); padding:6px; gap:3px;
        background:#f5f7fc; border:1px solid #ffffffc9; border-radius:24px;
        box-shadow:0 8px 32px #202b4924, 0 2px 8px #202b490a, inset 0 1px 0 #fff;
        isolation:isolate;
    }
    @supports ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))) {
        .mobile-dock {
            background:linear-gradient(135deg,#ffffffc9,#edf1fbb3);
            -webkit-backdrop-filter:blur(24px) saturate(160%);
            backdrop-filter:blur(24px) saturate(160%);
        }
    }
    .mobile-dock > :is(a,button) {
        touch-action: manipulation;
        position:relative; flex:1; min-width:0; display:flex; flex-direction:column;
        align-items:center; justify-content:center; gap:4px; padding:6px 1px; min-height:56px;
        background:transparent; border:1px solid transparent; border-radius:18px; color:#566279;
        font:inherit; font-size:10px; line-height:1.3; font-weight:600; text-decoration:none; cursor:pointer;
    }
    .mobile-dock > :is([aria-current=page],.is-current,[aria-expanded=true]) {
        color:#344b88; border-color:#ffffffb3;
        background:linear-gradient(145deg,#e0e8ffeb,#ccd9f6b8);
        box-shadow:0 2px 6px #5067a514, inset 0 1px 0 #ffffff99;
    }
    .mobile-dock > :is(a,button) > svg { width:21px; height:21px; }
    .mobile-dock > [aria-current=page] > svg { transform:translateY(-1px); stroke-width:2; }
    .mobile-dock > :is(a,button) { transition:background-color 160ms, color 160ms, transform 160ms; }
    @media (hover:hover) and (pointer:fine) {
        .mobile-dock > :is(a,button):active { transform:scale(.96); }
    }
    .mobile-dock > :is(a,button):active { background:#e2e9fa; }
    .mobile-dock > :is(a,button):focus-visible { outline:2px solid #5067a5; outline-offset:-2px; }
    .mobile-more-symbol { height:22px; font-size:27px; line-height:13px; letter-spacing:2px; }
    .mobile-dock .messaging-unread { position:absolute; top:1px; left:calc(50% + 5px); right:auto; min-width:17px; height:17px; padding:0 4px; font-size:10px; border:2px solid #fff; }
    body .mobile-menu {
        position:fixed; inset:auto 0 0; width:100%; max-width:none; margin:0;
        max-height:calc(100dvh - max(32px, env(safe-area-inset-top)));
        border-radius:24px 24px 0 0; background:#f7f8fc; box-shadow:0 -12px 48px #17243c26;
        overflow:hidden;
    }
    .mobile-menu[open] { display:flex; flex-direction:column; }
    .mobile-menu::backdrop { background:#14213b70; backdrop-filter:blur(3px); }
    .mobile-menu-header { display:flex; flex:none; align-items:center; justify-content:space-between; gap:12px; padding:22px 20px 16px; border-bottom:1px solid var(--color-border); background:#fff; }
    .mobile-menu-header > div > span { font-size:10px; font-weight:650; letter-spacing:.12em; color:#718099; }
    .mobile-menu-header h2 { font-size:21px; letter-spacing:-.035em; margin-top:4px; }
    .mobile-menu-header .modal-close { display:grid; place-items:center; border:1px solid var(--color-border); background:#f7f8fc; color:#52617c; }
    .mobile-menu-body { overflow-y:auto; overscroll-behavior:contain; padding:8px 16px max(24px, env(safe-area-inset-bottom)); }
    .mobile-menu-body section { margin-bottom:10px; }
    .mobile-menu-body h3 { margin:18px 4px 8px; font-size:12px; color:#64728a; font-weight:600; }
    .mobile-menu-link { display:flex; align-items:center; gap:12px; min-height:70px; padding:12px; color:var(--color-text); text-decoration:none; background:#fff; border-bottom:1px solid #edf0f5; }
    .mobile-menu-link:nth-child(2) { border-radius:12px 12px 0 0; }
    .mobile-menu-link:last-child { border-radius:0 0 12px 12px; border-bottom:0; }
    .mobile-menu-icon { display:grid; place-items:center; flex:none; width:38px; height:38px; border-radius:10px; background:#f0f3fa; color:#6077a6; }
    .mobile-menu-link > span:nth-child(2) { flex:1; min-width:0; }
    .mobile-menu-link strong { display:block; font-size:14px; font-weight:600; }
    .mobile-menu-link small { display:block; font-size:12px; line-height:1.4; color:#6b7890; margin-top:3px; }
    .mobile-menu-link > svg { color:#8995a9; }
    .mobile-menu-link[aria-current=page] { background:#eaf0ff; }
    .mobile-menu-current { font-size:11px; color:#354e88; font-weight:600; }
    .mobile-menu-link:active { background:#eaf0ff; }
    body.mobile-menu-open { overflow:hidden; }
    .main-content.with-nav { padding-bottom:calc(108px + env(safe-area-inset-bottom)); }

    /* Section selection exposes every destination, including long labels. */
    .mobile-section-picker { display:block; margin:0 0 18px; }
    .mobile-section-picker > span { display:block; font-size:12px; font-weight:600; color:#64728a; margin-bottom:6px; }
    .mobile-section-picker select { width:100%; min-height:48px; background-color:#fff; font-weight:600; }
    .mobile-section-source { display:none !important; }
    .mobile-collapsible > .card-header > .card-title { display:none; }
    .mobile-collapsible > .card-header { padding:0; }
    .mobile-section-toggle { display:flex; align-items:center; justify-content:space-between; gap:16px; width:100%; min-height:56px; padding:14px 16px; text-align:left; border:0; background:transparent; color:var(--color-text); font-size:14px; font-weight:600; }
    .mobile-section-indicator::before { content:'+'; font-size:22px; font-weight:400; color:#6077a6; }
    .mobile-section-toggle[aria-expanded=true] .mobile-section-indicator::before { content:'−'; }
    .mobile-collapsible:has(.mobile-section-toggle[aria-expanded=false]) > .card-header { border-bottom:0; }

    /* The page title and immediate task come before secondary context. */
    .workspace .header-content { gap:6px; min-height:60px; }
    .workspace .header-page-actions { justify-content:flex-start; }
    .workspace .header-page-actions > .btn { flex:1 1 auto; }
    .workspace .header-page-actions > form { flex:1 1 auto; }
    .workspace .header-page-actions > form > .btn { width:100%; }
    .collection-intro { margin-bottom:16px; }
    .collection-intro .collection-title-group > div > p:not(.eyebrow) { font-size:12px; line-height:1.5; }
    .card-body { padding:16px; }
    .card-header { padding:14px 16px; }
    .form-group { margin-bottom:18px; }
    .editor-form > .form-actions, .invoice-summary > .form-actions { display:flex; gap:8px; padding:14px 0; }
    .editor-form > .form-actions > .btn, .invoice-summary > .form-actions > .btn { flex:1; }
    .record-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
    .record-actions > form > .btn { width:100%; }
    .record-actions .btn { width:100%; }
    .record-actions > .btn-primary { grid-column:1/-1; }
    .detail-row { align-items:flex-start; gap:14px; }
    .detail-value { overflow-wrap:anywhere; min-width:0; }
    .list-pagination { justify-content:center; }
    .list-pagination > span { flex-basis:100%; text-align:center; }

    /* Lists become scannable records, with commands below the information. */
    .document-selectable { grid-template-columns:32px minmax(0,1fr); padding:14px 0; }
    .document-selectable > .document-thumbnail { display:none; }
    .document-selectable .document-selection-target { grid-row:1/4; align-self:start; padding-top:2px; }
    .document-selectable .document-description { grid-column:2; }
    .document-selectable .document-actions { display:flex; gap:8px; margin-top:4px; }
    .document-selectable .document-actions > .btn { flex:1 1 auto; }
    .document-description strong { font-size:14px; }
    .document-share-bar { padding:12px; background:#edf1fd; border-radius:10px; }
    .document-header-actions { gap:8px; }
    .document-header-actions .btn { flex:1 1 140px; font-size:12px; padding:10px; }
    .document-help { font-size:12px; }
    .user-roster-item { gap:12px; }
    .user-roster-actions { flex-wrap:wrap; }
    .settings-intro { margin-bottom:18px; }
    .settings-intro h2 { font-size:22px; }
    .settings-intro > p:last-child { display:none; }
    .settings-panel-heading { margin-bottom:16px; }
    .settings-panel-heading p { font-size:12px; }
    .notes-toolbar { gap:8px; }
    .notes-toolbar > label { flex-basis:100%; }
    .notes-toolbar > .btn { flex:1; }
    .campaign-history-preview iframe, .sent-message-preview iframe { max-height:60dvh; }
    .message-preview #messageFrame { min-height:320px; height:55dvh; flex:none; }
    .message-tools { gap:6px; }
    .message-tools > .btn, .message-tools > details { flex:1; }
    .message-tools > details > summary { width:100%; }
    .overview-heading h2 { font-size:23px; line-height:1.25; }
    .overview-subtitle { line-height:1.5; }
    .empty-state { padding:28px 16px; }
    .empty-state > svg { width:40px; height:40px; margin-bottom:12px; }
}
@media (max-width:359px) {
    .mobile-dock { padding-inline:4px; }
    .mobile-dock > :is(a,button) { font-size:9px; }
    .mobile-menu-header { padding-inline:16px; }
}
@media (max-width:767px) and (prefers-reduced-motion:no-preference) {
    .mobile-menu[open] { animation:mobile-menu-enter 180ms ease-out; }
    @keyframes mobile-menu-enter { from { transform:translateY(32px); opacity:0; } to { transform:none; opacity:1; } }
}
@media print { .mobile-dock, .mobile-menu, .mobile-section-picker { display:none !important; } }
@media (max-width:767px) {
    body.msg-conversation-open .mobile-dock,
    body.msg-keyboard-open .mobile-dock,
    body.assistant-keyboard .mobile-dock { display:none; }
}
.mobile-note-composer > summary, .mobile-document-tools > button { display:none; }
.mobile-document-tools { display:none; }
@media (max-width:767px) {
    .mobile-document-tools { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-top:8px; }
    .mobile-document-tools > button { display:inline-flex; font-size:12px; }
    .mobile-document-tools .document-result-count { width:auto; margin:0; font-size:12px; }
    .document-filter-panel .list-filter-controls { margin-top:10px; }
    .document-filter-panel .list-filter-controls > .document-result-count { display:none; }
    .mobile-note-composer { margin:0 0 20px; }
    .mobile-note-composer > summary { display:flex; align-items:center; justify-content:center; gap:8px; min-height:48px; padding:12px; border-radius:10px; background:var(--accent-blue); color:var(--accent-blue-ink); font-size:14px; font-weight:600; cursor:pointer; list-style:none; }
    .mobile-note-composer > summary::-webkit-details-marker { display:none; }
    .mobile-note-composer[open] > summary { border-radius:10px 10px 0 0; }
    .mobile-note-composer[open] .memo-quick { border-top-left-radius:0; border-top-right-radius:0; }
    .notes-toolbar { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
    .notes-toolbar > label { grid-column:1/-1; }
    .notes-toolbar > .app-select, .notes-toolbar > select { width:100%; min-width:0; }
    .notes-toolbar > button { grid-column:1/-1; }
    .notes-toolbar > a { grid-column:1/-1; }
    .invoice-item .form-row { grid-template-columns:80px minmax(0,1fr); gap:10px; }
    .invoice-item .form-row > .form-group::before { display:block; font-size:12px; font-weight:600; color:#64728a; margin-bottom:6px; }
    .invoice-item .form-row > .form-group:first-child::before { content:'Quantité'; }
    .invoice-item .invoice-item-price-group::before { content:'Prix unitaire'; }
    .invoice-item .form-group { margin-bottom:12px; }
    .invoice-item textarea.form-input { min-height:76px; }
    body .einvoice-connection-status { grid-template-columns:minmax(0,1fr) !important; gap:12px !important; }
    .einvoice-connection-status > div { display:flex; justify-content:space-between; gap:12px; }
    .einvoice-connection-status strong { text-align:right; }
}
@media (max-width:767px) {
    .mobile-section-meta { display:block; color:#69768c; font-size:11px; font-weight:400; line-height:1.5; margin-top:5px; }
    .quote-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
    .quote-actions > form:has(.btn-primary) { grid-column:1/-1; }
    .quote-actions .btn { width:100%; }
    .settings-savebar { gap:8px; flex-wrap:wrap; }
    .settings-savebar > .btn-primary { flex:1; }
}
@media (max-width:767px) {
    body.mobile-keyboard-open .mobile-dock { display:none; }
}

@media (prefers-reduced-motion:reduce) {
    .mobile-dock > :is(a,button) { transition:none; }
    .mobile-dock > :is(a,button):active { transform:none; }
}

/* Transient document transfer feedback in the installed WebView only. */
.native-file-status {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(94px + env(safe-area-inset-bottom, 0px));
    z-index: 10050;
    max-width: 520px;
    margin-inline: auto;
    padding: 14px 18px;
    border: 1px solid #dce3f0;
    border-radius: 12px;
    background: #fff;
    color: #24314b;
    box-shadow: 0 4px 20px #17203314;
    font-size: 14px;
    line-height: 1.5;
}
.native-file-status[hidden] { display: none; }

/* Mobile workspace: one clear scroll area, with reachable menus and actions. */
@media screen and (max-width:767px) {
    :root { --mobile-bottom-space:calc(var(--mobile-dock-height, 70px) + 26px + env(safe-area-inset-bottom)); }
    html { scroll-padding-top:calc(var(--mobile-header-height, 64px) + 12px); scroll-padding-bottom:var(--mobile-bottom-space); }
    .main-content.with-nav { padding-bottom:var(--mobile-bottom-space); }
    .workspace .user-dropdown {
        top:calc(100% + 8px);
        max-height:calc(var(--mobile-viewport-height, 100dvh) - var(--mobile-header-height, 64px) - var(--mobile-bottom-space));
    }
    body.has-overlay .mobile-dock,
    body:has(dialog[open]) .mobile-dock { visibility:hidden; pointer-events:none; }
    body.mobile-keyboard-open { --mobile-bottom-space:16px; }
    body dialog:not(.mobile-menu) {
        max-height:calc(var(--mobile-viewport-height, 100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
    body .cal-dialog #eventForm { max-height:inherit; }
    body.mobile-keyboard-open dialog[open]:not(.mobile-menu) {
        top:calc(var(--mobile-viewport-top, 0px) + 12px + env(safe-area-inset-top));
        bottom:auto; margin-block:0;
    }
    .modal-overlay { top:var(--mobile-viewport-top, 0px); height:var(--mobile-viewport-height, 100dvh); bottom:auto; }
    .modal-overlay .modal { max-height:100%; }
    .modal-overlay .modal-footer { position:sticky; bottom:-1px; background:#fff; z-index:1; }
    .workspace .header-page-actions:empty { display:none; }

    /* Expand secondary tools in the document instead of over the next controls. */
    .message-tools { flex-wrap:wrap; }
    .message-tools > details[open] { flex-basis:100%; }
    .message-tools .message-variables,
    .message-tools #messageLinkEditor,
    #campaignVariables .message-variables,
    #campaignLinkPanel,
    .template-variable-popover,
    .bank-settings-body,
    .bank-auto-settings-body,
    .billing-automation > div {
        position:static; width:100%; max-width:100%; margin-top:8px;
        max-height:min(360px, 50dvh); overflow-y:auto; overscroll-behavior:contain;
        box-shadow:none;
    }
    .bank-home-tools:has(details[open]), .bank-tool-actions:has(details[open]) { flex-wrap:wrap; width:100%; }
    .bank-heading-actions:has(details[open]),
    .bank-settings-menu[open], .bank-auto-settings[open],
    .billing-automation[open] { width:100%; }
    .message-tools .message-variables button,
    .service-suggestions button, .memo-client-list button,
    .bank-settings-trigger, .billing-automation > summary { min-height:44px; }
    .message-tools .message-variables button { padding-block:12px; }
    .msg-compose-row .msg-add-file { width:44px; height:44px; flex-basis:44px; }
    .msg-thread-title button { min-height:44px; }
    .msg-preview-dialog header > div { flex-wrap:wrap; gap:8px; }
    .memo-dialog footer, .memo-dialog footer > div { flex-wrap:wrap; gap:8px; }
    .memo-dialog footer .btn { flex:1 1 auto; }
    .settings-savebar { position:static; }
    /* Client results stay next to their field, including with the keyboard open. */
    body .autocomplete-dropdown, .memo-client-list {
        position:static; width:100% !important;
        max-height:min(260px, 40dvh); overscroll-behavior:contain;
        box-shadow:none;
    }
    .autocomplete-item { min-height:44px; }

}

/* Messaging uses one focused mobile screen and the workspace's existing palette. */
.msg-mobile-only { display:none; }
@media (max-width:767px) {
    body[data-page="messaging.index"].msg-conversation-open > .header { display:none; }
    .msg-mobile-only { display:inline-flex; }
    .msg-inbox-heading { padding:18px 16px 12px; }
    .msg-inbox-heading h2 { font-size:22px; margin:0; }
    .msg-inbox .msg-search { border-radius:var(--radius-lg); }
    .msg-conversations { padding:0 12px 12px; }
    .msg-conversation { min-height:84px; padding:14px 4px; margin:0; gap:12px; border-radius:0; border-bottom:1px solid var(--color-border); }
    .msg-conversation:last-child { border-bottom:0; }
    .msg-conversation > .msg-avatar { width:48px; height:48px; flex-basis:48px; border-radius:16px; }
    .msg-conversation strong { font-size:15px; }
    .msg-conversation time { font-size:11px; }
    .msg-conversation-preview > span:first-child { font-size:13px; line-height:1.5; }
    .msg-count { min-width:20px; padding:2px 6px; }
    .msg-thread-header {
        padding:max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
        gap:8px; min-height:64px;
    }
    .msg-thread-header > .msg-avatar { display:inline-flex; width:36px; height:36px; flex-basis:36px; border-radius:12px; }
    .msg-thread-header #msgSearchToggle, .msg-thread-header #msgSharedToggle { display:none; }
    .msg-thread-title { position:relative; min-height:44px; display:flex; flex-direction:column; justify-content:center; }
    .msg-thread-title h2 { font-size:15px; line-height:1.35; margin:0 0 2px; }
    body .msg-thread-title button { min-height:0; font-size:11px; line-height:1.4; }
    .msg-thread-title button::after { content:''; position:absolute; inset:0; }
    .msg-thread-title:focus-within { outline:2px solid var(--accent-blue); outline-offset:2px; border-radius:var(--radius-sm); }
    .msg-thread { background:var(--color-bg); }
    .msg-timeline { padding:16px 12px 8px; scroll-padding-block:12px; }
    .msg-day { font-size:11px; margin:8px 0 20px; }
    .msg-message { margin-bottom:16px; }
    .msg-message-identity .msg-avatar { display:none; }
    .msg-message.own .msg-message-identity { display:none; }
    .msg-message-sender { font-size:12px; }
    .msg-bubble { max-width:90%; border-radius:4px 16px 16px; padding:10px 12px; }
    .own .msg-bubble { border-radius:16px 4px 16px 16px; background:var(--accent-blue-soft); }
    .msg-text { font-size:15px; line-height:1.5; }
    .msg-meta { gap:8px; flex-wrap:wrap; }
    .msg-reply-button, .msg-retry, .msg-older, .msg-jump,
    .msg-attachment-actions a, .msg-chip button { min-width:44px; min-height:44px; }
    .msg-meta .msg-reply-button { padding:8px; font-size:11px; }
    .msg-resource-card { min-height:52px; }
    .msg-attachment-actions { flex-wrap:wrap; gap:8px; }

    /* A single compose row: attachments, growing text, then send or microphone. */
    body .msg-composer {
        display:grid; grid-template-columns:44px minmax(0,1fr) 44px; align-items:end; column-gap:6px; row-gap:0;
        margin:0; padding:10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
        border:0; border-top:1px solid var(--color-border); border-radius:0; box-shadow:none; background:#fff;
    }
    .msg-composer .msg-compose-row, .msg-composer .msg-compose-footer, .msg-composer .msg-compose-tools { display:contents; }
    .msg-composer #msgAdd { grid-column:1; grid-row:3; border-radius:50%; background:var(--color-bg); color:var(--color-primary-dark); }
    .msg-composer #msgBody {
        grid-column:2; grid-row:3; min-height:44px; max-height:100px; padding:11px 12px;
        border:1px solid var(--color-border); border-radius:20px; background:var(--color-bg); line-height:22px; font-size:16px;
    }
    .msg-composer #msgBody:focus { border-color:var(--color-primary); }
    .msg-composer #msgAttach, .msg-composer #msgResource { display:none; }
    .msg-composer #msgRecord, .msg-composer #msgSend { grid-column:3; grid-row:3; width:44px; height:44px; padding:0; justify-content:center; border-radius:50%; }
    .msg-composer #msgRecord { display:none; }
    .msg-composer.can-record:not(.has-content) #msgRecord { display:inline-flex; }
    .msg-composer.can-record:not(.has-content) #msgSend { display:none; }
    .msg-composer #msgReply { grid-column:1/-1; grid-row:1; margin:0 0 8px; border-radius:var(--radius-sm); }
    .msg-composer #msgAttachments { grid-column:1/-1; grid-row:2; margin:0 0 8px; max-height:min(96px, calc(var(--mobile-viewport-height, 100dvh) * .2)); overflow:auto; }
    .msg-composer #msgVoicePanel { grid-column:1/-1; grid-row:3; }
    .msg-composer:has(#msgVoicePanel:not([hidden])) :is(#msgAdd,#msgBody,#msgRecord,#msgSend) { display:none; }
    body.msg-keyboard-open .msg-composer { padding-bottom:8px; }
    .msg-thread-search { padding:8px 12px; gap:6px; }
    .msg-thread-search .btn span { display:none; }
    .msg-thread-search .btn { width:44px; min-width:44px; padding:0; justify-content:center; }
    .msg-shared { inset:0; width:100%; border:0; padding:max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); box-shadow:none; }
    .msg-shared header { top:calc(-1 * max(12px, env(safe-area-inset-top))); min-height:56px; padding:8px 0; }
    .msg-shared h3 { font-size:17px; }

    /* Dialogs have the same rounded surface, spacing and action rhythm. */
    body :is(.cal-dialog,.msg-dialog,.memo-dialog,.notification-panel) {
        width:calc(100% - 24px); max-width:560px; border-radius:var(--radius-lg);
        border:1px solid var(--color-border); box-shadow:var(--shadow-lg);
    }
    body :is(.cal-dialog,.msg-dialog,.memo-dialog)::backdrop { background:#14213b70; }
    body :is(.cal-dialog-header,.msg-dialog > header,.msg-dialog form > header,.memo-dialog header) { padding:16px; gap:12px; }
    body :is(.cal-dialog-header h3,.msg-dialog h2,.memo-dialog h3) { font-size:18px; line-height:1.3; margin:0; }
    body .cal-dialog-header .cal-eyebrow { display:none; }
    body .msg-dialog header p { margin-top:6px; font-size:13px; line-height:1.5; }
    body :is(.cal-icon-button,.msg-icon,.modal-close) { width:44px; height:44px; min-width:44px; min-height:44px; flex-shrink:0; border-radius:var(--radius-md); }
    body :is(.cal-dialog-footer,.msg-dialog footer,.memo-dialog footer) { padding:12px 16px; gap:8px; background:var(--color-bg-secondary); }
    body :is(.cal-dialog-footer,.msg-dialog footer,.memo-dialog footer) .btn { min-height:44px; font-size:13px; border-radius:var(--radius-md); }
    .msg-dialog footer > .btn-primary { flex:1 1 100%; justify-content:center; }
    .msg-dialog #msgNewForm { display:flex; flex-direction:column; max-height:inherit; }
    .msg-dialog #msgNewForm > :not(.msg-new-body) { flex-shrink:0; }
    .msg-dialog .msg-people { flex:1; min-height:0; max-height:none; }
    .msg-dialog .msg-person { min-height:56px; font-size:14px; }
    .msg-picker .msg-resource-types { display:flex; overflow-x:auto; flex-wrap:nowrap; padding-bottom:6px; }
    .msg-picker .msg-resource-types button { flex:0 0 auto; min-height:44px; }
    #msgOptionsDialog footer .btn { justify-content:flex-start; gap:12px; padding:12px; }
    .msg-action-sheet { inset:auto 0 max(12px, env(safe-area-inset-bottom)); margin:0 auto; }
    .msg-sheet-actions { padding:0 12px 12px; display:grid; gap:8px; }
    .msg-sheet-actions button { display:flex; align-items:center; gap:14px; padding:14px; border:0; border-radius:var(--radius-md); background:var(--color-bg-secondary); color:var(--color-text); text-align:left; min-height:68px; }
    .msg-sheet-actions button > svg { color:var(--color-primary); }
    .msg-sheet-actions strong { display:block; font-size:14px; }
    .msg-sheet-actions small { display:block; margin-top:4px; color:var(--color-text-light); font-size:12px; }
    .msg-sheet-actions button:active { background:var(--accent-blue-soft); }
    .msg-dialog .msg-group-label { margin:0 16px 12px; }
}
.msg-message-menu { display:none; }
@media (min-width:768px) {
    #msgAdd, #msgMobileSearch, #msgMobileShared { display:none; }
}
@media (max-width:767px) {
    .msg-message { position:relative; }
    .msg-bubble { max-width:calc(100% - 40px); }
    .msg-message > .msg-message-menu { display:inline-flex; position:absolute; right:-4px; top:24px; color:var(--color-text-light); }
    .msg-message.own > .msg-message-menu { right:auto; left:-4px; top:0; }
    .msg-meta > .msg-reply-button { display:none; }
    .msg-meta { min-height:18px; margin-top:5px; }
    .msg-action-excerpt { margin:0 16px 14px; padding:12px; border-radius:var(--radius-md); background:var(--color-bg); color:var(--color-text-light); overflow-wrap:anywhere; max-height:100px; overflow:auto; font-size:13px; }
}
@media (max-width:767px) {
    body .cal-dialog .cal-title-input { padding:12px; border:1px solid var(--color-border); border-radius:var(--radius-md); background:#fff; font-size:16px; font-weight:400; }
    body .cal-toolbar-actions #newEvent { min-height:44px; font-size:13px; }
    body .cal-toolbar-actions #newEvent svg { width:16px; height:16px; }
}
@media (max-width:767px) {
    body .notification-panel { inset:auto 12px max(12px, env(safe-area-inset-bottom)); margin:0 auto; }
    .cal-toolbar-actions { grid-template-columns:auto 44px minmax(0,1fr); }
    .cal-jump, .cal-jump input { width:44px; height:44px; }
}

/* iOS keyboard: only the history/list scrolls, never the messaging document.
   Fixed pane origin and height track VisualViewport independently during panning. */
@media (max-width:767px) {
    html.msg-mobile-viewport { height:100%; overflow:hidden; overscroll-behavior:none; }
    body[data-page="messaging.index"] { position:fixed; inset:0; width:100%; height:100%; overflow:hidden; overscroll-behavior:none; }
    body[data-page="messaging.index"] #mainContent { min-height:0; margin:0; padding:0; view-transition-name:none; }
    body[data-page="messaging.index"] .messenger {
        position:fixed; top:var(--msg-top, 0px); left:0; right:0;
        height:var(--msg-height, 100dvh); min-height:0; width:100%;
    }
    .msg-inbox, .msg-thread { min-height:0; overflow:hidden; }
    .msg-timeline, .msg-conversations { overscroll-behavior-y:contain; -webkit-overflow-scrolling:touch; }
    .msg-composer #msgBody { max-height:var(--msg-compose-max, 100px); overflow-y:auto; }
}

@media (max-width:767px) {
    /* One safe-area inset only; no legacy margin underneath the composer. */
    body[data-page="messaging.index"] .msg-composer {
        margin:0; width:100%; padding-inline:max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
        padding-top:6px; padding-bottom:max(6px, env(safe-area-inset-bottom));
        box-shadow:none;
    }
    body[data-page="messaging.index"].msg-keyboard-open .msg-composer { padding-bottom:4px; }

    .memo-dialog #noteEditorForm { display:flex; flex-direction:column; max-height:inherit; }
    .memo-dialog .memo-editor-body { min-height:0; overflow-y:auto; }
    .memo-dialog header, .memo-dialog footer { flex-shrink:0; }

    /* The keyboard covers form sheets. It does not squeeze their body and footer. */
    body.mobile-keyboard-open :is(dialog.cal-dialog,dialog.memo-dialog,#msgNewDialog) {
        height:var(--mobile-dialog-resting-height, auto);
        max-height:calc(var(--mobile-layout-height, 100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        top:calc(var(--mobile-viewport-top, 0px) + max(8px, env(safe-area-inset-top)));
        bottom:auto; margin-block:0;
    }
    body.mobile-keyboard-open .modal-overlay { height:var(--mobile-layout-height, 100dvh); }
    body.mobile-keyboard-open :is(.cal-dialog-body,.memo-editor-body,#msgNewForm .msg-new-body,.modal-overlay .modal-body) {
        padding-bottom:calc(20px + var(--mobile-keyboard-overlap, 0px));
        scroll-behavior:auto;
    }
    body :is(#eventDialog,#eventSummary,#accessDialog,.memo-dialog) footer { flex-wrap:nowrap; align-items:center; }
    body :is(.cal-dialog-footer,.memo-dialog footer) > div { display:contents; }
    body :is(.cal-dialog-footer,.memo-dialog footer) .btn { white-space:nowrap; min-width:0; }
    body :is(.cal-dialog-footer,.memo-dialog footer) .btn-primary { flex:1; justify-content:center; }
    body .mobile-icon-action { flex:0 0 44px !important; width:44px; min-width:44px; height:44px; padding:0; justify-content:center; }
    .mobile-icon-action .mobile-action-label { display:none; }
    body .cal-dialog-footer #saveEvent { font-size:0; }
    #saveEvent::after { content:attr(data-mobile-label); font-size:13px; }
    body .cal-dialog-footer #saveAccess { font-size:0; gap:0; }
    #saveAccess > svg { display:none; }
    #saveAccess::after { content:'Enregistrer'; font-size:13px; }
    #accessFeedback:empty { display:none; }
}

.mobile-short-label { display:none; }
@media (max-width:767px) {
    #eventSummaryEdit .mobile-action-label { display:none; }
    #eventSummaryEdit .mobile-short-label { display:inline; }
    body :is(.cal-dialog-footer,.memo-dialog footer) .btn { padding-inline:10px; }
    body :is(.cal-dialog-footer,.memo-dialog footer) .mobile-icon-action { padding:0; }
    body :is(.cal-dialog-footer,.memo-dialog footer) .btn > svg { flex-shrink:0; }
}

@media (max-width:767px) {
    /* Keep summary actions visible while its details scroll. */
    #eventSummary[open], #proposalsDialog[open] { display:flex; flex-direction:column; }
    :is(#eventSummary,#proposalsDialog) > :is(header,footer) { flex-shrink:0; }
    /* Invitation workflows can have five distinct actions: retain their rows. */
    body #proposalActions { flex-wrap:wrap; }
    body #proposalActions .btn { white-space:normal; flex:1 1 auto; overflow-wrap:anywhere; }
    #composeProposal .mobile-action-label { display:none; }
    #composeProposal .mobile-short-label { display:inline; }
}

@media (max-width:767px) {
    #msgNewDialog { overflow:hidden; }
    #msgNewForm .msg-new-body { min-height:0; overflow-y:auto; overscroll-behavior:contain; }
    #msgNewForm .msg-people { overflow:visible; max-height:none; }
    #msgNewForm .msg-group-label { display:block; }
    #msgNewForm .msg-group-label[hidden] { display:none; }
}

@media (hover:none) and (pointer:coarse) {
    .workspace .user-btn:hover { box-shadow:none; }
    .workspace .user-btn[aria-expanded="true"] { box-shadow:0 0 0 4px #5067a514; }
}

@media (max-width:767px) {
    body :is(.flash-container,.notification-toast,.cal-toast) {
        position:fixed; top:var(--feedback-top,calc(var(--mobile-header-height,64px) + 8px)); bottom:auto;
        left:max(12px,env(safe-area-inset-left)); right:max(12px,env(safe-area-inset-right));
        width:auto; max-width:none; margin:0; transform:none;
        max-height:var(--feedback-limit,180px); overflow-y:auto; overscroll-behavior:contain;
        overflow-wrap:anywhere;
    }
    body .flash-container { pointer-events:none; }
    body .flash-container .flash { pointer-events:auto; flex-shrink:0; margin:0; border-radius:var(--radius-lg); }
    body .flash-close { min-width:44px; min-height:44px; flex-shrink:0; }
    body :is(.notification-toast,.cal-toast) { padding:12px; border-radius:var(--radius-lg); }
    body .notification-toast { gap:8px; flex-wrap:wrap; }
    body .notification-toast > div { min-width:100px; }
    body .notification-toast button { min-height:44px; }
}

/* Phone reading rhythm: records, editing and secondary information share a scale.
   Scope these rules to the workspace; desktop tables and public contracts keep theirs. */
@media screen and (max-width:767px) {
    .phone-copy { display:inline; }
    .desktop-copy { display:none; }
    body.workspace { font-size:15px; line-height:1.5; }
    body.workspace .btn { font-size:14px; padding:11px 14px; }
    body.workspace .btn-icon { padding:10px; flex-shrink:0; }
    body.workspace .header-page-actions .btn { font-size:14px; }
    body.workspace .collection-intro { gap:12px; margin-bottom:20px; }
    body.workspace .collection-intro h2 { font-size:22px; line-height:1.3; letter-spacing:-.025em; }
    body.workspace .collection-intro p:not(.eyebrow) { font-size:14px; line-height:1.6; margin-top:8px; }
    body.workspace .collection-count { font-size:13px; white-space:normal; }
    body.workspace:has(.mobile-filters-ready) .collection-intro { flex-wrap:nowrap; margin-bottom:14px; }
    body.workspace:has(.mobile-filters-ready) .collection-count { margin:0; flex-shrink:0; }
    body.workspace .tab { font-size:14px; padding:12px 14px; }
    body.workspace .card-title { font-size:15px; line-height:1.4; }
    body.workspace .list-item { padding:18px 16px; }
    body.workspace .list-item-title { font-size:15px; line-height:1.45; font-weight:600; }
    body.workspace :is(.list-item-subtitle,.list-item-meta,.invoice-record-number) { font-size:13px; line-height:1.55; }
    body.workspace .list-item-amount { font-size:16px; line-height:1.4; }
    body.workspace .badge { font-size:12px; line-height:1.5; padding:4px 8px; white-space:normal; }
    body.workspace .invoice-record { gap:8px 12px; }
    body.workspace .invoice-record-money { max-width:145px; }
    body.workspace .invoice-record-status { max-width:145px; justify-self:end; }
    body.workspace .client-item { gap:12px; }
    body.workspace .client-billing-cell { padding-left:0; font-size:13px; }
    body.workspace .client-balance-cell { font-size:15px; max-width:50%; }
    body.workspace :is(.client-billing-cell,.client-balance-cell) small { font-size:12px; line-height:1.5; }
    body.workspace .client-late-badge { font-size:12px; }
    body.workspace .record-total { padding:18px; }
    body.workspace .record-total span { font-size:12px; }
    body.workspace .record-total strong { font-size:32px; line-height:1.2; margin-top:6px; }
    body.workspace .record-summary :is(.detail-label,.detail-value) { font-size:14px; line-height:1.5; }
    body.workspace .record-summary .detail-row { padding-block:12px; gap:12px; }
    body.workspace .record-summary .detail-value { text-align:right; overflow-wrap:anywhere; }
    body.workspace .record-body .section-title { font-size:16px; }
    body.workspace .detail-title { font-size:24px; line-height:1.3; }
    body.workspace .detail-subtitle { font-size:14px; }

    /* Keep hints close to fields and a visible focus ring on every editing surface. */
    body.workspace :is(.editor-form,.settings-form) .card-header { padding:16px; }
    body.workspace :is(.editor-form,.settings-form) .form-input { min-height:48px; font-size:16px; padding:12px; }
    body.workspace :is(.editor-form,.settings-form,.message-editor) .form-label { font-size:14px; line-height:1.5; }
    body.workspace :is(.editor-form,.settings-form) .form-hint { font-size:13px; line-height:1.6; }
    body.workspace .settings-form .form-row { gap:0; }
    body.workspace .settings-form .form-row > .form-group { margin-bottom:18px; }
    body.workspace .editor-form .field-error { font-size:13px; }
    body.workspace .form-input:focus-visible { outline:2px solid #5067a5; outline-offset:2px; }
    body.workspace .invoice-item { padding:16px; }
    body.workspace .invoice-item textarea { min-height:88px; line-height:1.55; }
    body.workspace .summary-total > span,
    body.workspace .summary-breakdown :is(dt,dd),
    body.workspace .summary-help { font-size:13px; line-height:1.6; }
    body.workspace .list-filter-help summary { min-height:44px; display:flex; align-items:center; font-size:13px; }
    body.workspace :is(.mobile-section-picker,.mobile-section-toggle) { font-size:14px; }
    body.workspace .editor-form .mobile-collapsible > .card-header { padding:0; }
    body.workspace .mobile-section-meta { font-size:13px; line-height:1.6; margin-top:6px; }
    body.workspace .empty-state { padding:36px 16px; }
    body.workspace .empty-state-text { font-size:14px; line-height:1.6; }

    /* Documents have a readable file identity, followed by retrieval then deletion. */
    body.workspace .document-selectable { padding:18px 12px; margin-block:12px; border:1px solid var(--color-border); border-radius:14px; background:#fff; }
    body.workspace .document-description strong { font-size:15px; line-height:1.5; }
    body.workspace .document-description span { font-size:13px; line-height:1.6; }
    body.workspace .document-state { font-size:12px; }
    body.workspace .document-actions { gap:8px; }
    body.workspace .document-actions > :not([data-document-delete]) { flex:1 1 110px; justify-content:center; }
    body.workspace .document-actions > [data-document-delete] { margin-left:auto; color:#984052; background:transparent; border-color:transparent; }
    body.workspace .document-link-row { padding:18px 12px; margin-block:12px; background:#fff; border:1px solid var(--color-border); border-radius:14px; }
    body.workspace .document-link-outcome { font-size:13px; line-height:1.5; }
    body.workspace .document-help { font-size:13px; margin-block:12px; }
    body.workspace .memo { padding:18px; border-left:3px solid var(--memo-color); }
    body.workspace .memo > header > a { font-size:15px; font-weight:600; }
    body.workspace .memo-open > span { font-size:15px; line-height:1.7; }
    body.workspace .memo-open > small { font-size:13px; }
    body.workspace .memo > footer { font-size:12px; line-height:1.5; }
    body.workspace .memo > footer time { flex-basis:100%; }
    body.workspace .memo-colors label { font-size:13px; }
    body.workspace .notes-toolbar { gap:10px; }
    body.workspace .notes-toolbar > .btn { flex:1 1 100px; }

    /* The service name must keep room beside the two security actions. */
    body[data-page="passwords.client_passwords"] .list-item { flex-wrap:wrap; gap:10px; }
    body[data-page="passwords.client_passwords"] .list-item-content { min-width:100px; }
    body[data-page="passwords.client_passwords"] .list-item > .flex { margin-left:auto; }
    body[data-page="passwords.client_passwords"] .fab { display:none; }
    body.workspace :is(.user-roster-email,.user-role-option small) { font-size:13px; line-height:1.5; }
    body.workspace .audit-time { font-size:12px; }
    body.workspace .audit-entry .list-item-title { font-size:15px; }
    body.workspace .audit-entry .list-item-subtitle { font-size:13px; }
    body.workspace :is(.audit-category-badge,.audit-action-badge,.audit-day-header span) { font-size:12px; }
    body.workspace .audit-entry-tags { gap:6px; flex-wrap:wrap; }
    body.workspace .campaign-list-main > p { font-size:14px; line-height:1.6; }
    body.workspace .campaign-list-main > small { display:block; font-size:13px; line-height:1.6; margin-top:8px; }
    body.workspace .campaign-list-schedule { font-size:13px; line-height:1.6; }
    body.workspace .campaign-list-title h3 { font-size:17px; line-height:1.4; }
    body.workspace .campaign-list-title h3 > a { display:flex; align-items:center; min-height:44px; }
    body.workspace .campaign-list-actions > form:last-child .btn { border-color:transparent; background:transparent; color:#984052; }
    body.workspace :is(.message-preview-note,.message-preview-meta span,.message-option-section p) { font-size:13px; line-height:1.6; }
    body.workspace .message-editor textarea { min-height:220px; line-height:1.65; }
    body.workspace .message-preview #messageFrame,
    body.workspace #campaignFrame,
    body.workspace .campaign-history-preview iframe,
    body.workspace .sent-message-preview iframe { flex:none; height:340px; min-height:0; }
    body.workspace .template-preview iframe { flex:none; height:400px; min-height:0; }
    body[data-page="tags.index"] .list-item { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:10px 12px; }
    body[data-page="tags.index"] .list-item > .client-tag { justify-self:start; white-space:normal; overflow-wrap:anywhere; font-size:13px; }
    body[data-page="tags.index"] .list-item > .list-item-content { grid-column:1/-1; grid-row:2; }
    body[data-page="tags.index"] .list-item > .flex { grid-column:2; grid-row:1; }
    body.workspace :is(.bank-topbar-sync,.bank-topbar-sync > span,.bank-ledger .list-item-subtitle) { font-size:12px; line-height:1.6; }
    body.workspace .bank-topbar-sync { max-width:180px; text-align:left; }
    body.workspace .bank-status { font-size:13px; padding:10px 12px; }
    body.workspace .bank-setup-facts dt { font-size:13px; }
    body.workspace .einvoices-connection-shell .einvoices-connection { padding:0; margin-bottom:0; }
    body.workspace .einvoices :is(dt,.einvoices-connection-heading p,.einvoices-filters label) { font-size:13px; line-height:1.6; }
    body.workspace .einvoices :is(dd,.einvoices-connection h2) { font-size:15px; }
    body.workspace .einvoices-tabs a { min-height:48px; font-size:14px; }
    body.workspace .profile-card p { font-size:14px; line-height:1.6; }
    body.workspace :is(.profile-help,.user-roster .user-roster-login,.user-roster .user-role,.user-roster .user-account-state,.user-roster .user-roster-you) { font-size:12px; line-height:1.6; }
    body.workspace .cal-list-day h4 { font-size:14px; margin-bottom:12px; }
    body.workspace .cal-list-summary strong { font-size:15px; line-height:1.5; }
    body.workspace .cal-list-summary small { font-size:13px; line-height:1.55; }
    body.workspace .cal-list-time { font-size:12px; line-height:1.5; }
    body.workspace .cal-caption { font-size:12px; }
    body.workspace .cal-list-event { min-height:80px; }
    body.workspace .cal-list-event:focus-visible { outline:2px solid #5067a5; outline-offset:2px; }
    body.workspace .bank-learning-summary { font-size:13px; line-height:1.6; }
    body.workspace .bank-row-identity strong { font-size:15px; }
    body.workspace .bank-row-state { font-size:13px; }
    body.workspace .treatment-footer { position:static; margin-top:20px; padding:16px; box-shadow:none; }
    body.workspace .treatment-transfer h2 { font-size:20px; line-height:1.4; }
    body.workspace .treatment-transfer p:not(.eyebrow) { font-size:14px; line-height:1.6; }
    body.workspace .treatment-transfer-amount { text-align:left; }
    body.workspace .treatment-navigation .treatment-back { font-size:14px; }
    body.workspace .director-classic .director-action-copy > small { font-size:13px; }
    body.workspace .director-schedule-row strong { font-size:14px; }
    body.workspace :is(.director-aging-grid a > span,.director-aging-grid small,.director-portfolio-main > span,.director-schedule-note,.director-data-status strong,.director-data-status p) { font-size:13px; line-height:1.55; }
    body.workspace .assistant-setup-notice { font-size:13px; line-height:1.6; flex-wrap:wrap; }
    body.workspace .assistant-suggestions strong { font-size:15px; }
    body.workspace .assistant-suggestions small { font-size:14px; line-height:1.5; }
    body.workspace .assistant-footer { font-size:12px; color:#657084; }
}

/* Feedback stays on the tapped control; no floating loading indicator. */
a[data-navigation-pending], button[data-navigation-pending] { opacity:.6; }
html[data-navigation-pending] { cursor:progress; }
.assistant-keyboard-dismiss { display:none; }

@media (max-width:767px), (pointer:coarse) and (max-width:1023px) and (max-height:500px) {
    html.assistant-mobile-viewport { height:100%; overflow:hidden; overscroll-behavior:none; }
    body[data-page="assistant.index"] { position:fixed; inset:0; width:100%; height:100%; overflow:hidden; }
    body[data-page="assistant.index"] #mainContent { min-height:0; margin:0; padding:0; }
    body[data-page="assistant.index"] .assistant-workspace {
        position:fixed; top:var(--assistant-top, var(--mobile-header-height, 68px)); left:var(--assistant-left, 0px); right:0;
        height:var(--assistant-height, calc(100dvh - 160px)); min-height:0; overflow:hidden;
    }
    .assistant-scroll { -webkit-overflow-scrolling:touch; }
    .assistant-composer-area { flex-shrink:0; }
    body.assistant-keyboard .assistant-toolbar,
    body.assistant-keyboard .assistant-footer,
    body.assistant-keyboard .assistant-setup-notice { display:none; }
    body.assistant-keyboard .assistant-composer-area { padding-bottom:6px; }
    body.assistant-keyboard .assistant-keyboard-dismiss {
        display:inline-flex; align-items:center; justify-content:center; flex-shrink:0;
        width:44px; height:44px; border:0; border-radius:12px; background:#f1f4fa; color:#506485; cursor:pointer;
    }
    .assistant-keyboard-dismiss svg { transform:rotate(90deg); }
    body[data-page="assistant.index"] .assistant-composer textarea { font-size:16px; }
}
/* A landscape phone must still fit its composer above the iOS keyboard. */
@media (min-width:768px) and (max-width:1023px) and (max-height:500px) and (pointer:coarse) {
    body[data-page="assistant.index"].assistant-keyboard > .nav-bottom { display:none; }
    body[data-page="assistant.index"].assistant-keyboard > .header { margin-left:0; }
    body[data-page="assistant.index"] .assistant-composer-area {
        padding:6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    }
    body[data-page="assistant.index"].assistant-keyboard .assistant-composer { display:flex; align-items:flex-end; gap:12px; padding:8px 12px; }
    body[data-page="assistant.index"].assistant-keyboard .assistant-composer textarea { flex:1; min-width:0; }
    body[data-page="assistant.index"].assistant-keyboard .assistant-composer-footer { flex-shrink:0; }
    body[data-page="assistant.index"].assistant-keyboard .assistant-composer-hint { display:none; }
    body[data-page="assistant.index"].assistant-keyboard .assistant-scroll { padding-top:0; padding-bottom:0; }
}
@media (max-width:767px) {
    .einvoices-heading, .einvoices-collection, .einvoices-routing-visible > div,
    .einvoices-address, .einvoices-filter-form { min-width:0; max-width:100%; }
    .einvoices-address code { min-width:0; max-width:100%; font-size:16px; letter-spacing:0; }
    .einvoices-heading > form, .einvoices-actions, .einvoices-actions > form,
    .einvoices-toolbar > form { width:100%; }
    .einvoices-heading .btn, .einvoices-actions .btn, .einvoices-toolbar > form .btn {
        width:100%; white-space:normal; overflow-wrap:anywhere; justify-content:center;
    }
    .einvoices-toolbar { align-items:stretch; }
    .einvoices-tabs { width:100%; gap:12px; }
    .einvoices-tabs a { flex:1; min-width:0; display:flex; align-items:center; flex-wrap:wrap; gap:4px; }
    .einvoices-tabs span { margin:0; }
    .einvoices-filters .app-select { width:100%; min-width:0; }
    .einvoices-filters :is(input,select,.app-select-trigger) { min-width:0; max-width:100%; font-size:16px; }
    .einvoices-filters input[type=date] { display:block; appearance:none; -webkit-appearance:none; min-inline-size:0; max-inline-size:100%; width:100%; overflow:hidden; }
    .einvoices-pagination { flex-wrap:wrap; gap:8px; }
}
@media (max-width:430px) {
    .einvoices-filters, .einvoices-data { grid-template-columns:minmax(0,1fr); }
    .einvoices-row { grid-template-columns:minmax(0,1fr); gap:9px; padding:16px; }
    .einvoices-row > :is(.einvoices-supplier,.einvoices-due,.einvoices-state,.einvoices-amount) {
        grid-column:1; grid-row:auto; max-width:none; min-width:0; text-align:left; overflow-wrap:anywhere;
    }
    .einvoices-row .einvoices-supplier { grid-row:1; }
    .einvoices-row .einvoices-amount { grid-row:2; font-size:20px; }
    .einvoices-row .einvoices-due { grid-row:3; }
    .einvoices-row .einvoices-state { grid-row:4; }
}
