/* A.I. COMPANY V5.9.1 — signed-in mobile visual corrections only.
   Applies at phone breakpoint. Does not touch backend, roles or desktop.
   Theme is explicitly dark or light; a card cannot keep legacy white styling in dark mode.
*/
@media (max-width:700px){
  body[data-aic-auth-role] .phone>.hero #appHomeBtn{
    box-sizing:border-box!important;display:grid!important;place-items:center!important;
    background:#173751!important;color:#e9f6ff!important;border:1px solid #456985!important;
    border-radius:9px!important;min-width:33px!important;width:33px!important;height:35px!important;
    flex:0 0 33px!important;opacity:1!important;
  }
  body[data-aic-auth-role] .phone>.hero #appHomeBtn::after{
    content:"⌂"!important;display:block!important;font:800 26px/1 Arial,sans-serif!important;
    color:inherit!important;opacity:1!important;visibility:visible!important;
  }
  body[data-aic-auth-role] .phone>.hero #appHomeBtn>span{display:none!important;}
  /* RWD: never show side-by-side CLIENT / SERVICE form and member directory on phone. */
  body[data-aic-auth-role="admin"][data-aic-admin-view="clients"] #tenantOrganizationManagement .aic-approved-people-cards,
  body[data-aic-auth-role="admin"][data-aic-admin-view="service"] #tenantOrganizationManagement .aic-approved-people-cards{
    display:grid!important;grid-template-columns:minmax(0,1fr)!important;
    width:100%!important;max-width:100%!important;min-width:0!important;gap:12px!important;
  }
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement .aic-people-content,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement .aic-approved-people-cards,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement .aic-approved-people-cards>section,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement .aic-person-body,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement .aic-contacts-list,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement #tenantMembersList,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement #aicPeopleContacts{
    box-sizing:border-box!important;min-width:0!important;max-width:100%!important;
  }
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement #tenantMembersList,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement #aicPeopleContacts{
    max-height:none!important;overflow-x:hidden!important;
  }
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement input,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement select,
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement textarea{
    max-width:100%!important;min-width:0!important;box-sizing:border-box!important;
  }
  body[data-aic-auth-role="admin"] #tenantOrganizationManagement .aic-approved-people-cards>section{
    width:100%!important;margin:0!important;
  }
  /* The phone viewport should never scroll horizontally, regardless of form content. */
  body[data-aic-auth-role] .phone>.content,
  body[data-aic-auth-role] .phone>.content #adminTodayPanel,
  body[data-aic-auth-role] .phone>.content #adminView,
  body[data-aic-auth-role] .phone>.content #employeeView,
  body[data-aic-auth-role] .phone>.content #clientView{min-width:0!important;max-width:100%!important;overflow-x:clip!important;}
}
/* DARK: all visible signed-in mobile surfaces stay dark, including legacy V5.8 cards. */
@media (max-width:700px){
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role]{
    --aic-v59-bg:#071725;--aic-v59-panel:#112940;--aic-v59-inset:#17354e;
    --aic-v59-line:#315575;--aic-v59-text:#eef7ff;--aic-v59-muted:#bdd5e9;
    color-scheme:dark;
  }
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone,
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.content,
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #adminTodayPanel,
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #employeeTodayPanel,
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #clientView{
    background:var(--aic-v59-bg)!important;color:var(--aic-v59-text)!important;
  }
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.hero{
    background:linear-gradient(125deg,#071827,#102d4b)!important;color:#f6fbff!important;
    border-color:#264764!important;
  }
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.bottom{
    background:#081a2a!important;border-color:#31516f!important;
  }
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.bottom button{color:#eaf7ff!important;}
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.content :is(
    .card,.stat,.client-auth-card,.company-info-card,.client-mini-calendar-card,
    .client-next-card,.client-contact-card,.client-messages-card,.admin-auth-card,
    .admin-jobs-live,.admin-workspace-left,.admin-workspace-right,.company-settings-card,
    .calendar-sync-card,.aic-dashboard-box,.aic-custom-push,.aic-push-preview,
    .aic-person-invite,.aic-people-placeholder,.aic-people-empty,.aic-invite-collapsible,
    .aic-member-row,.aic-person-card,.aic-person-body,.aic-contact-info,
    .aic-contacts-list>details,.client-history-item,.client-cal-item,.day-detail-card,
    .client-mini-day,.client-cal-panel,#clientHistoryPanel,#tenantOrganizationManagement,
    .aic-people-content,#aicPeopleContacts,.aic-approved-people-cards>section
  ){
    background:var(--aic-v59-panel)!important;color:var(--aic-v59-text)!important;
    border-color:var(--aic-v59-line)!important;box-shadow:none!important;
  }
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.content :is(
    .aic-person-body,.aic-contact-info,.aic-push-preview,.client-mini-day,.day-detail-card,
    .client-cal-item,.client-history-item,.aic-people-placeholder
  ){background:var(--aic-v59-inset)!important;}
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.content :is(
    h1,h2,h3,h4,h5,summary,strong,label,b,.name,.nm,.job-top .name,
    .aic-person-state,.aic-person-card>summary,.aic-contacts-list>details>summary,
    .aic-people-list-title strong,.aic-member-email,.aic-people-content .aic-member-name,
    .client-history-date,.company-settings-head h3
  ){color:var(--aic-v59-text)!important;}
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.content :is(
    p,small,.live-note,.aic-delete-review-note,.aic-contact-info b,
    .aic-people-removal small,.aic-people-placeholder,.aic-people-empty,
    .client-cal-item .dt,.aic-person-state
  ){color:var(--aic-v59-muted)!important;}
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.content :is(input,select,textarea){
    background:#0a1d30!important;color:#f0f8ff!important;border-color:#426584!important;
    -webkit-text-fill-color:#f0f8ff!important;
  }
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.content :is(input,textarea)::placeholder{color:#a7c0d8!important;opacity:1!important;}
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #tenantOrganizationManagement .aic-approved-people-cards>section,
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #tenantOrganizationManagement .aic-contacts-list>details,
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #tenantOrganizationManagement .aic-person-body,
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #tenantOrganizationManagement .aic-people-empty,
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #tenantOrganizationManagement .aic-people-placeholder{
    background:var(--aic-v59-panel)!important;color:var(--aic-v59-text)!important;
    border-color:var(--aic-v59-line)!important;
  }
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #tenantOrganizationManagement .aic-person-body{background:var(--aic-v59-inset)!important;}
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #tenantOrganizationManagement :is(
    .aic-person-card>summary,.aic-contacts-list>details>summary,.aic-people-list-title strong
  ){color:var(--aic-v59-text)!important;}
  html[data-aic-v59-theme="dark"] body[data-aic-auth-role] .phone>.hero #appHomeBtn{
    background:#173751!important;border-color:#456985!important;color:#e9f6ff!important;
  }
}
/* LIGHT: light surfaces, text, form fields and footer throughout the signed-in phone UI. */
@media (max-width:700px){
  html[data-aic-v59-theme="light"] body[data-aic-auth-role]{
    --aic-v59-bg:#eef4fa;--aic-v59-panel:#fff;--aic-v59-inset:#f3f8fd;
    --aic-v59-line:#d0e1f1;--aic-v59-text:#18344f;--aic-v59-muted:#54718e;
    color-scheme:light;
  }
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone,
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.content,
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] #adminTodayPanel,
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] #employeeTodayPanel,
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] #clientView{
    background:var(--aic-v59-bg)!important;color:var(--aic-v59-text)!important;
  }
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.bottom{
    background:#e7f2fc!important;border-color:#c7dcf0!important;
  }
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.bottom button{
    color:#17476e!important;
  }
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.hero #appHomeBtn{
    background:#d7e8f8!important;color:#163d61!important;border-color:#a4c0dc!important;
  }
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.content :is(
    .card,.stat,.client-auth-card,.company-info-card,.client-mini-calendar-card,
    .client-next-card,.client-contact-card,.client-messages-card,.admin-auth-card,
    .admin-jobs-live,.admin-workspace-left,.admin-workspace-right,.company-settings-card,
    .calendar-sync-card,.aic-dashboard-box,.aic-custom-push,.aic-push-preview,
    .aic-person-invite,.aic-people-placeholder,.aic-people-empty,.aic-invite-collapsible,
    .aic-member-row,.aic-person-card,.aic-person-body,.aic-contact-info,
    .aic-contacts-list>details,.client-history-item,.client-cal-item,.day-detail-card,
    .client-mini-day,.client-cal-panel,#clientHistoryPanel,#tenantOrganizationManagement,
    .aic-people-content,#aicPeopleContacts,.aic-approved-people-cards>section
  ){
    background:var(--aic-v59-panel)!important;color:var(--aic-v59-text)!important;
    border-color:var(--aic-v59-line)!important;box-shadow:none!important;
  }
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.content :is(
    .aic-person-body,.aic-contact-info,.aic-push-preview,.client-mini-day,.day-detail-card,
    .client-cal-item,.client-history-item,.aic-people-placeholder
  ){background:var(--aic-v59-inset)!important;}
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.content :is(
    h1,h2,h3,h4,h5,summary,strong,label,b,.name,.nm,.job-top .name,
    .aic-person-state,.aic-person-card>summary,.aic-contacts-list>details>summary,
    .aic-people-list-title strong,.aic-member-email,.client-history-date
  ){color:var(--aic-v59-text)!important;}
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.content :is(
    p,small,.live-note,.aic-contact-info b,.aic-people-removal small,
    .aic-people-placeholder,.aic-people-empty,.client-cal-item .dt,.aic-person-state
  ){color:var(--aic-v59-muted)!important;}
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.content :is(input,select,textarea){
    background:#fff!important;color:#1a3754!important;border-color:#c5d9ed!important;
    -webkit-text-fill-color:#1a3754!important;
  }
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] .phone>.content :is(input,textarea)::placeholder{color:#627e99!important;opacity:1!important;}
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] #tenantOrganizationManagement .aic-approved-people-cards>section,
  html[data-aic-v59-theme="light"] body[data-aic-auth-role] #tenantOrganizationManagement .aic-contacts-list>details{
    background:#fff!important;color:#18344f!important;border-color:#d0e1f1!important;
  }
}

/* Contrast fix for legacy high-specificity headings and controls in Clients/Service. */
@media(max-width:700px){
 html[data-aic-v59-theme="dark"] body[data-aic-auth-role="admin"] #tenantOrganizationManagement :is(
   h1,h2,h3,h4,strong,summary,label,.aic-people-list-title strong
 ){color:#eff8ff!important;}
 html[data-aic-v59-theme="dark"] body[data-aic-auth-role="admin"] #tenantOrganizationManagement :is(
   p,.live-note,.aic-member-email,.aic-person-state,.aic-people-removal small
 ){color:#bdd7ee!important;}
 html[data-aic-v59-theme="light"] body[data-aic-auth-role="admin"] #tenantOrganizationManagement :is(
   h1,h2,h3,h4,strong,summary,label,.aic-people-list-title strong
 ){color:#173754!important;}
 html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #v59ServiceCalendar .v59-calendar-tabs button,
 html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #v59ServiceCalendar .v59-date-nav button{
   background:#1b3955!important;color:#eff7ff!important;border:1px solid #3b6284!important;
 }
 html[data-aic-v59-theme="dark"] body[data-aic-auth-role] #v59ServiceCalendar .v59-calendar-tabs button[aria-pressed="true"]{
   background:#0b75d7!important;color:#fff!important;border-color:#309af3!important;
 }
 html[data-aic-v59-theme="light"] body[data-aic-auth-role] #v59ServiceCalendar .v59-calendar-tabs button,
 html[data-aic-v59-theme="light"] body[data-aic-auth-role] #v59ServiceCalendar .v59-date-nav button{
   background:#e6f1fb!important;color:#18416b!important;border:1px solid #bcd7ed!important;
 }
 html[data-aic-v59-theme="light"] body[data-aic-auth-role] #v59ServiceCalendar .v59-calendar-tabs button[aria-pressed="true"]{
   background:#0b75d7!important;color:#fff!important;border-color:#0b75d7!important;
 }
}
