/* Specialized workspaces on phones. Keep document export geometry unchanged. */
.employee-mobile-actions,
.employee-file-quick-actions .employee-mobile-open { display: none; }

@media screen and (max-width: 1024px) {
  :is(.hr-page-shell, .employee-profile-grid, .employee-profile-panel, .employee-tab-panel,
      .customer-profile-grid, .customer-profile-panel, .customer-bi-panel, .customer-agreement-group,
      .customer-agreement-table, .customer-document-table, .customer-account-table-wrap,
      .knowledge-shell, .knowledge-layout, .knowledge-content, .knowledge-categories-panel,
      .quote-workspace-pane, .quote-workspace-top-stats, .quote-templates-shell, .quote-template-card,
      .pricebook-shell, .sales-settings-shell, .sales-settings-card, .user-profile-shell,
      .user-profile-card, .users-admin-shell, .users-role-card) { min-width: 0; max-width: 100%; }
  :is(#page-candidates, #page-employees, #page-outsourced-employees, #page-employee-card, #page-customer-card,
      #page-knowledge, #page-users-admin, #page-sales-settings, #page-user-profile) .page-header { align-items: stretch; flex-direction: column; gap: 12px; }
  :is(#page-candidates, #page-employees, #page-outsourced-employees, #page-employee-card, #page-customer-card,
      #page-knowledge, #page-users-admin, #page-sales-settings, #page-user-profile) .page-header > div { min-width: 0; max-width: 100%; flex-wrap: wrap; }

  /* Authentication must scroll when the keyboard or a landscape viewport is short. */
  .auth-screen { padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); overflow-y: auto; align-items: flex-start; }
  .auth-screen-grid { width: min(100%, 468px); min-width: 0; margin-block: auto; }
  .auth-login-panel { padding: 30px 20px 24px; border-radius: 24px; }
  .auth-login-top { margin-bottom: 24px; }
  .auth-login-panel .form-input { font-size: 16px; }
  .auth-error { overflow-wrap: anywhere; }

  /* HR and employee cards. Existing permission and tab visibility rules still apply. */
  .hr-toolbar, .employee-toolbar, .employee-profile-grid, .employee-detail-grid,
  .employee-user-link-panel, .employee-form-grid, .candidate-form-grid,
  .candidate-detail-grid, .candidate-panel-status-card, .employee-folder-details-grid { grid-template-columns: minmax(0, 1fr); }
  .employee-form-full, .candidate-form-full, .employee-detail-field.wide, .employee-folder-detail.wide { grid-column: auto; }
  :is(#page-candidates, #page-employees, #page-outsourced-employees, #page-users-admin) :is(.card, .table-wrap, .users-admin-tab-panel) { min-width: 0; max-width: 100%; }
  :is(#page-candidates, #page-employees, #page-outsourced-employees, #page-users-admin) .table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
  :is(#page-candidates, #page-employees, #page-outsourced-employees, #page-users-admin) .table-wrap > table:not(.mobile-cards-table) { min-width: 720px; }
  .employee-profile-panel, .employee-tab-panel, .candidate-section { padding: 14px; border-radius: 16px; }
  .candidate-panel-hero { flex: 0 0 auto; max-height: 42dvh; overflow-y: auto; padding: max(18px, env(safe-area-inset-top)) 16px 18px; }
  .candidate-panel-hero-main { gap: 10px; padding-left: 44px; }
  .candidate-panel-name, .candidate-panel-role { overflow-wrap: anywhere; }
  .candidate-panel-name { font-size: 23px; }
  .candidate-panel-avatar { width: 46px; height: 46px; border-radius: 15px; }
  .candidate-panel-body { flex: 1 1 auto; min-height: 0; padding: 14px 16px max(20px, env(safe-area-inset-bottom)); }
  .employee-section-head, .candidate-section-head, .employee-table-footer,
  .candidate-resume-card, .candidate-upload-box, .employee-document-card,
  .user-admin-employee-card { flex-wrap: wrap; }
  .candidate-resume-main, .employee-account-card > div, .employee-section-head > div { min-width: 0; }
  .candidate-resume-name, .candidate-upload-name, .employee-account-name,
  .employee-account-meta, .employee-account-audit { white-space: normal; overflow-wrap: anywhere; }
  .employee-document-upload { width: 100%; align-items: stretch; }
  .employee-document-upload select { min-width: 0; width: 100%; flex-basis: 100%; }
  .employee-document-upload > button { flex: 1 1 120px; }
  .employee-document-breadcrumb { max-width: 100%; padding-inline: 8px; }
  .employee-document-breadcrumb-item { min-height: 44px; flex-shrink: 0; }
  .employee-document-desktop { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .employee-desktop-item { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 6px 12px; align-items: center; min-height: 0; padding: 12px; text-align: right; border-color: #dfe9ef; background: #fff; }
  .employee-desktop-item > :is(.employee-folder-icon, .employee-file-icon) { grid-column: 1; grid-row: 1 / 3; justify-self: center; }
  .employee-desktop-item > .employee-folder-icon { transform: scale(.76); transform-origin: center; }
  .employee-desktop-item > strong, .employee-desktop-item > small { grid-column: 2; }
  .employee-desktop-item > strong { font-size: 14px; }
  .employee-desktop-item > small { font-size: 11px; white-space: normal; overflow-wrap: anywhere; }
  .employee-mobile-actions, .employee-desktop-item .employee-file-quick-actions { position: static; grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; opacity: 1; margin-top: 8px; }
  .employee-mobile-actions button, .employee-file-quick-actions button { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; width: auto; min-height: 44px; height: auto; padding: 8px 12px; border: 1px solid #d8e4ec; border-radius: 9px; background: #f8fbfd; color: #38556d; font: 800 13px 'Assistant', sans-serif; cursor: pointer; }
  .employee-file-quick-actions .employee-mobile-open { display: inline-flex; }
  .employee-file-quick-actions button.danger { color: #b42318; }
  .employee-mobile-actions button:first-child, .employee-file-quick-actions .employee-mobile-open { flex: 1; }
  .employee-actions-menu-trigger { width: 44px; height: 44px; }
  .employee-actions-menu button, .employee-folder-context-menu button { min-height: 44px; white-space: normal; }
  .employee-folder-context-menu { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; }
  .employee-subordinate-card { grid-template-columns: auto minmax(0, 1fr); }
  .employee-subordinate-card > :not(.candidate-avatar):not(.employee-subordinate-copy) { grid-column: 2; }
  .employee-work-card-head, .candidate-note-head { flex-wrap: wrap; }

  /* Customer records, contacts, agreements and account details. */
  .customer-card-hero { padding: 18px 16px; border-radius: 18px; }
  .customer-card-hero-top, .customer-card-hero-main { align-items: flex-start; flex-direction: column; gap: 12px; }
  .customer-card-name { font-size: 25px; overflow-wrap: anywhere; }
  .customer-card-sub, .customer-card-meta { overflow-wrap: anywhere; }
  .customer-card-avatar { width: 56px; height: 56px; border-radius: 18px; }
  .customer-card-actions { width: 100%; justify-content: flex-start; gap: 8px; }
  .customer-period-wrap { flex-wrap: wrap; min-width: 0; max-width: 100%; }
  .customer-period-wrap select { min-width: 0; max-width: 100%; }
  .customer-card-hero-stats, .customer-account-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .customer-card-hero-stat { padding: 12px; border-radius: 12px; }
  .customer-card-hero-stat-value { font-size: 21px; overflow-wrap: anywhere; }
  .customer-profile-grid, .customer-editable-detail-grid, .customer-summary-grid, .customer-bi-grid { grid-template-columns: minmax(0, 1fr); }
  .customer-profile-panel, .customer-bi-panel { padding: 14px; border-radius: 16px; }
  .customer-profile-head, .customer-bi-head, .customer-agreement-section-head,
  .customer-account-section-head, .customer-work-head { flex-wrap: wrap; }
  .customer-contact-card { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px; }
  .customer-contact-person { grid-column: auto; }
  .customer-contact-inline { height: auto; min-height: 44px; }
  .customer-contact-badges, .customer-contact-actions { flex-wrap: wrap; justify-content: flex-start; }
  .customer-agreement-grid { grid-template-columns: minmax(0, 1fr); }
  .customer-agreement-card--compact, .customer-document-card { min-width: 0; grid-template-columns: minmax(0, 1fr); padding: 13px; }
  .customer-agreement-card--compact .customer-agreement-title,
  .customer-agreement-card--compact .customer-agreement-meta, .customer-document-title,
  .customer-document-file { white-space: normal; overflow-wrap: anywhere; }
  .customer-agreement-card--compact .customer-agreement-actions, .customer-document-actions { flex-wrap: wrap; white-space: normal; gap: 8px; }
  .customer-account-toolbar { align-items: stretch; flex-direction: column; }
  .customer-account-plan-row { grid-template-columns: minmax(0, 1fr); }
  .customer-account-actions { flex-wrap: wrap; white-space: normal; }
  .customer-account-plan-name { white-space: normal; overflow-wrap: anywhere; }
  .customer-account-table-wrap { overscroll-behavior-inline: contain; }
  .customer-page-tabs, .customer-panel-tabs { gap: 6px; }
  .customer-page-tabs > button, .customer-panel-tabs > button { min-height: 44px; white-space: normal; }

  /* Knowledge articles and editor: text reflows; wide authored tables scroll locally. */
  .knowledge-hero { padding: 18px 16px; border-radius: 18px; }
  .knowledge-title { font-size: 25px; }
  .knowledge-admin-actions, .knowledge-file-picker { flex-wrap: wrap; }
  .knowledge-admin-actions > button { flex: 1 1 130px; }
  .knowledge-search-wrap { padding-inline: 12px; min-height: 48px; }
  .knowledge-search { min-width: 0; font-size: 16px; }
  .knowledge-layout, .knowledge-grid, .knowledge-editor-grid, .knowledge-file-list, .knowledge-image-grid { grid-template-columns: minmax(0, 1fr); }
  .knowledge-editor-full { grid-column: auto; }
  .knowledge-categories-panel { position: static; padding: 12px; }
  .knowledge-category-list { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
  .knowledge-category-filter { min-height: 44px; flex-shrink: 0; }
  .knowledge-card-title, .knowledge-view-title { overflow-wrap: anywhere; }
  .knowledge-view-title { font-size: 23px; }
  .knowledge-view-meta { font-size: 12px; }
  .knowledge-view-body, .knowledge-editor-area { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
  .knowledge-view-body :is(img, video, iframe), .knowledge-editor-area :is(img, video, iframe) { max-width: 100%; }
  .knowledge-view-body :is(img, video), .knowledge-editor-area :is(img, video) { height: auto; }
  .knowledge-view-body pre, .knowledge-editor-area pre { white-space: pre-wrap; overflow-wrap: anywhere; }
  .knowledge-file-main, .knowledge-file-main > div { min-width: 0; }
  .knowledge-file-remove, .knowledge-article-menu-trigger { width: 44px; height: 44px; }
  .knowledge-article-menu-item, .knowledge-category-option { min-height: 44px; }
  .knowledge-image-button img, .knowledge-image-button:first-child img { height: 210px; }

  /* Quote and pricebook editors. The PDF itself retains its A4 export dimensions. */
  .quote-workspace-topbar, .quote-templates-hero, .quote-template-card-head,
  .pricebook-hero, .pricebook-table-title { align-items: stretch; flex-direction: column; }
  .quote-workspace-switch { display: flex; max-width: 100%; }
  .quote-workspace-btn { flex: 1; height: auto; min-height: 44px; padding: 8px; }
  .quote-workspace-top-stats { min-width: 0; width: 100%; }
  .quote-template-grid, .quote-form-grid, .quote-document-grid, .quote-service-grid,
  .quote-template-form-grid, .quote-template-signature-grid, .pricebook-modal-grid,
  .pricebook-clause-fields, .pricebook-price-row, .pricebook-price-row.is-pricing,
  .pricebook-picker-item { grid-template-columns: minmax(0, 1fr); }
  .quote-document-span-2 { grid-column: auto; }
  .quote-template-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quote-template-stat { padding: 12px; }
  .quote-pane, .quote-template-pane, .pricebook-pane { min-width: 0; padding: 13px; }
  .quote-service-row, .quote-template-card { padding: 13px; }
  .quote-service-row-head, .quote-template-annex-head, .quote-template-annex-item-head,
  .pricebook-clauses-head, .pricebook-clause-row-head { flex-wrap: wrap; }
  .quote-template-form-grid { flex: 1 1 auto; min-height: 0; max-height: none; padding: 0; overflow-y: auto; }
  .pricebook-modal-grid { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; align-items: start; }
  .pricebook-pane-details { position: static; }
  .pricebook-pane-clauses { height: auto; max-height: none; overflow: visible; }
  .pricebook-pane-clauses .pricebook-clauses-list { flex: initial; overflow: visible; }
  .pricebook-picker-scroll { max-height: none; min-height: 0; flex: 1; overflow-y: auto; }
  .pricebook-picker-qty { width: 100%; }
  .pricebook-search input { width: 100%; min-width: 0; }
  .pricebook-filter-btn { min-height: 44px; height: auto; white-space: normal; }
  .quote-template-preview-scroll { flex: 1; min-height: 0; max-height: none; max-width: 100%; padding: 12px; overflow: auto; overscroll-behavior: contain; direction: ltr; }
  .quote-template-preview-note { direction: rtl; }
  .quote-template-preview-document { direction: rtl; margin-inline: 0; }

  /* Administration, profile and integration setup. */
  .sales-settings-shell, .user-profile-shell, .user-profile-grid, .users-role-grid,
  .users-department-access-grid, .user-admin-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .users-admin-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .sales-settings-card, .user-profile-card, .users-role-card, .users-department-access { padding: 16px; border-radius: 16px; }
  .users-admin-card { padding: 13px; }
  .users-admin-tabs { gap: 6px; }
  .users-admin-tab-btn { flex: 1 1 120px; height: auto; min-height: 44px; padding: 8px 12px; }
  .sales-settings-card-head { flex-wrap: wrap; }
  .sales-settings-card-head > div, .sales-settings-flow-step > div, .users-department-access-item > div { min-width: 0; }
  .sales-settings-flow-step { grid-template-columns: 30px minmax(0, 1fr); }
  .sales-settings-status { max-width: 100%; white-space: normal; }
  .sales-settings-actions > button { flex: 1 1 120px; }
  .user-profile-name { font-size: 24px; overflow-wrap: anywhere; }
  .user-profile-email, .users-role-sub, .sales-settings-card-sub { overflow-wrap: anywhere; }
  .user-admin-groups-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-admin-group-option { min-height: 44px; padding: 8px; }
  .user-profile-avatar-overlay { opacity: 1; background: linear-gradient(transparent 45%, #0f1d3570); align-items: flex-end; padding-bottom: 5px; font-size: 17px; }
  .microsoft-onboarding { flex-wrap: wrap; padding: 13px; }
  .microsoft-onboarding-copy > div { min-width: 0; overflow-wrap: anywhere; }
  .microsoft-onboarding > button { width: 100%; min-height: 44px; }
  .microsoft-menu-btn { width: 44px; height: 44px; }
  .microsoft-menu { top: calc(100% + 7px); min-width: 0; width: min(280px, calc(100vw - 32px)); }
  .microsoft-menu-item { min-height: 44px; }
  .microsoft-status-pill, .microsoft-sync-inline { max-width: 100%; white-space: normal; }
}

@media screen and (max-width: 380px) {
  .customer-card-hero-stats, .customer-account-summary, .users-admin-summary,
  .quote-template-stats { grid-template-columns: minmax(0, 1fr); }
}

/* Phone refinements are intentionally isolated from tablet and desktop layouts. */
@media screen and (max-width: 760px) {
  /* Records keep a compact identity block and a swipeable, single-row tab bar. */
  .customer-card-hero { padding: 16px 14px; border-radius: 16px; }
  .customer-card-hero-main { flex-direction: row; align-items: center; gap: 12px; width: 100%; }
  .customer-card-hero-main > div { min-width: 0; }
  .customer-card-avatar { width: 48px; height: 48px; border-radius: 15px; font-size: 20px; }
  .customer-card-name { font-size: 23px; line-height: 1.3; }
  .customer-card-kicker { margin-bottom: 2px; font-size: 11px; }
  .customer-card-sub { font-size: 13px; line-height: 1.5; }
  .customer-card-meta { font-size: 11px; line-height: 1.5; }
  .customer-card-actions { gap: 8px; }
  .customer-period-wrap { flex: 1 1 170px; gap: 7px; padding: 4px 8px; border-radius: 10px; }
  .customer-period-wrap select { flex: 1; min-height: 44px; font-size: 16px; }
  .customer-card-actions > button { min-height: 44px; border-radius: 10px; padding: 9px 13px; }
  .customer-card-hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
  .customer-card-hero-stat { padding: 9px 11px; border-radius: 10px; }
  .customer-card-hero-stat-value { min-height: 26px; font-size: 21px; line-height: 1.25; }
  .customer-card-hero-stat-label { margin-top: 3px; font-size: 11px; line-height: 1.4; }
  :is(.customer-page-tabs, .customer-panel-tabs, .hour-bank-tabs, .users-admin-tabs, .ai-settings-tabs) {
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    gap: 7px;
    padding-block: 5px 8px;
    scrollbar-width: thin;
    scrollbar-color: #afc9d5 transparent;
  }
  :is(.customer-page-tabs, .customer-panel-tabs, .hour-bank-tabs, .users-admin-tabs, .ai-settings-tabs) > button {
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
    padding-inline: 12px;
  }
  :is(#customer-card-content, #employee-card-content, .customer-tab-shell) { min-width: 0; max-width: 100%; }
  .customer-tab-shell > .panel-section { padding: 14px; }
  .customer-profile-grid, .employee-profile-grid { gap: 12px; }
  :is(.customer-profile-head, .customer-bi-head, .employee-section-head) { gap: 8px; margin-bottom: 12px; padding-bottom: 10px; }
  .customer-summary-grid, .customer-bi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  :is(.customer-summary-card, .customer-bi-card, .employee-detail-field, .customer-editable-field) { min-width: 0; padding: 11px; border-radius: 10px; }
  .customer-bi-value { font-size: 23px; }
  .customer-bi-subline { font-size: 11px; overflow-wrap: anywhere; }
  .customer-summary-value, .customer-account-summary-value { font-size: 18px; white-space: normal; overflow-wrap: anywhere; }
  .customer-work-project-title { white-space: normal; line-height: 1.5; overflow-wrap: anywhere; }
  .customer-work-project-meta-text { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .customer-account-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .customer-account-plan-row > *, .customer-account-approver > * { min-width: 0; overflow-wrap: anywhere; }
  .customer-account-approver { align-items: flex-start; }
  .customer-agreement-table-cell-value { overflow-wrap: anywhere; }
  .customer-document-file { font-size: 13px; line-height: 1.5; }
  .customer-agreement-section-head > div, .customer-account-section-head > div { min-width: 0; }
  .customer-contact-name { white-space: normal; overflow-wrap: anywhere; }
  .customer-contact-inline > span:last-child { white-space: normal; overflow-wrap: anywhere; }
  .customer-contact-actions > button { min-height: 44px; min-width: 44px; }

  /* Hour-bank rows become labelled records; report/PDF tables are unaffected. */
  .hour-bank-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .hour-bank-card { min-width: 0; min-height: 0; padding: 11px; }
  .hour-bank-card-value { font-size: 19px; line-height: 1.4; overflow-wrap: anywhere; }
  .hour-bank-card-label { font-size: 11px; }
  .hour-bank-card-sub { font-size: 11px; line-height: 1.45; }
  .customer-hour-bank-actions { width: 100%; }
  .customer-hour-bank-actions > button { flex: 1 1 120px; justify-content: center; min-height: 44px; }
  .hour-bank-log-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; padding: 13px 12px; align-items: start; }
  .hour-bank-log-row > div { min-width: 0; overflow-wrap: anywhere; }
  .hour-bank-log-row > div:first-child { grid-column: 1 / -1; }
  .hour-bank-log-title { font-size: 14px; line-height: 1.5; }
  .hour-bank-log-subtitle { font-size: 12px; line-height: 1.5; }
  .hour-bank-log-row > :nth-child(n+2):nth-child(-n+6)::before { display: block; margin-bottom: 3px; color: #6c8393; font-size: 11px; font-weight: 600; }
  .hour-bank-log-row > :nth-child(2)::before { content: 'פרויקט'; }
  .hour-bank-log-row > :nth-child(3)::before { content: 'מיקום העבודה'; }
  .hour-bank-log-row > :nth-child(4)::before { content: 'עובד'; }
  .hour-bank-log-row > :nth-child(5)::before { content: 'נסגרה'; }
  .hour-bank-log-row > :nth-child(6)::before { content: 'זמן'; }
  .hour-bank-log-location { white-space: normal; line-height: 1.4; }
  .hour-bank-log-row > div:last-child { align-self: end; justify-self: end; }
  .hour-bank-log-edit { width: 44px; height: 44px; }

  /* Record journeys stay in one readable row; the body keeps its own scroll. */
  #lead-panel .lead-journey, :is(#task-panel, #project-panel) .record-journey {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: minmax(76px, 1fr);
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    padding-block: 10px;
  }
  #lead-panel .lead-journey-card, :is(#task-panel, #project-panel) .record-journey-card { padding: 13px 12px; }
  #lead-panel .lead-journey strong, :is(#task-panel, #project-panel) .record-journey strong { font-size: 12px; }
  #lead-panel .lead-journey small, :is(#task-panel, #project-panel) .record-journey small { font-size: 10px; line-height: 1.45; }
  #lead-panel .lead-card-heading, :is(#task-panel, #project-panel) .record-card-heading { flex-wrap: wrap; gap: 8px; }
  :is(#lead-panel, #task-panel, #project-panel) :is(.detail-cell-label, .lead-contact-item-label, .task-note-time) { font-size: 12px; }
  :is(#lead-panel, #task-panel, #project-panel) :is(.detail-cell-val, .lead-contact-item-value, .project-task-title, .task-note-title) { font-size: 14px; line-height: 1.5; }
  :is(#lead-panel, #task-panel, #project-panel) .task-note-text { color: #486579; font-size: 14px; line-height: 1.7; }
  :is(#lead-panel, #task-panel, #project-panel) .task-note-head { flex-wrap: wrap; gap: 8px; }
  :is(#lead-panel, #task-panel, #project-panel) .task-note-actions { flex-shrink: 0; }
  #project-panel .project-hours-legend { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  #project-panel .project-hours-legend > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  #project-panel .project-hours-legend-label, #project-panel .project-hours-row-label { font-size: 12px; }
  #project-panel .project-hours-row-value { font-size: 13px; }

  /* HR remains touch-operable without oversized empty sections. */
  .hr-toolbar { padding: 12px; gap: 10px; }
  .candidate-panel-hero { padding: max(14px, env(safe-area-inset-top)) 14px 14px; }
  .candidate-panel-role { line-height: 1.5; }
  .candidate-panel-body { padding: 12px 14px max(20px, env(safe-area-inset-bottom)); gap: 12px; align-content: start; }
  .candidate-panel-actions > button { flex: 1 1 110px; min-height: 44px; justify-content: center; }
  .candidate-resume-card > button, .candidate-upload-actions > button { min-height: 44px; }
  .candidate-note-delete { min-height: 44px; padding-inline: 8px; }
  .employee-document-browser, .employee-document-desktop { min-height: 0; }
  .employee-document-empty-desktop { min-height: 150px; padding: 18px 12px; }
  .employee-document-upload > button, .employee-document-upload > select { min-height: 44px; }
  .employee-subordinate-card { gap: 8px 12px; }
  .employee-subordinate-copy strong, .employee-subordinate-contact { white-space: normal; overflow-wrap: anywhere; }
  .employee-finished-fold > summary, .customer-finished-fold > summary { min-height: 44px; }

  /* Knowledge entries are concise previews; full content opens in the article. */
  #page-knowledge .knowledge-hero { padding: 16px 14px; }
  #page-knowledge .knowledge-title { font-size: 23px; }
  #page-knowledge .knowledge-search-wrap { margin-top: 12px; border-radius: 11px; }
  #page-knowledge .knowledge-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  #page-knowledge .knowledge-category-filter { width: auto; max-width: 100%; }
  #page-knowledge .knowledge-categories-panel { border-radius: 12px; padding: 10px; }
  #page-knowledge .knowledge-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #page-knowledge .knowledge-card { display: grid; grid-template-columns: 74px minmax(0, 1fr); min-height: 0; border-radius: 12px; }
  #page-knowledge .knowledge-card-image { height: 100%; min-height: 108px; font-size: 28px; }
  #page-knowledge .knowledge-card-body { min-width: 0; padding: 11px; gap: 6px; }
  #page-knowledge .knowledge-card-title { font-size: 16px; line-height: 1.45; }
  #page-knowledge .knowledge-card-excerpt { -webkit-line-clamp: 2; }
  #page-knowledge .knowledge-card-meta { flex-wrap: wrap; gap: 3px 8px; padding-top: 6px; line-height: 1.4; }
  .knowledge-view-body { font-size: 15px; line-height: 1.75; overflow-wrap: anywhere; }
  .knowledge-file-name { white-space: normal; overflow-wrap: anywhere; }
  .knowledge-attachment-button { min-width: 0; max-width: 100%; gap: 10px; flex-wrap: wrap; }
  .knowledge-editor-area { min-height: 200px; max-height: 50dvh; }
  .knowledge-category-manage-row { flex-wrap: wrap; gap: 10px; }
  .knowledge-category-manage-main { min-width: 0; overflow-wrap: anywhere; }
  .knowledge-category-manage-actions { flex-wrap: wrap; }
  .knowledge-category-manage-actions > button { min-height: 44px; }

  /* Admin and quality panels use readable text and controls on narrow screens. */
  :is(.ai-settings-shell, .ai-settings-main, .ai-settings-audit, .ai-settings-section, .sq-workspace) { min-width: 0; max-width: 100%; }
  .ai-settings-shell { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .ai-settings-main, .ai-settings-audit { padding: 14px; border-radius: 14px; }
  .ai-settings-section { padding: 12px; border-radius: 10px; }
  .ai-settings-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-settings-section-copy, .ai-settings-sub { font-size: 13px; }
  .ai-settings-lock { white-space: normal; align-self: flex-start; line-height: 1.5; }
  .ai-settings-toggle { min-height: 44px; font-size: 13px; }
  .ai-settings-audit-meta { flex-wrap: wrap; }
  .ai-settings-audit-row { overflow-wrap: anywhere; }
  .ai-settings-actions > button, .ai-settings-confirm-actions > button { flex: 1 1 120px; min-height: 44px; }
  .sales-settings-card { padding: 14px; }
  .sales-settings-endpoint { max-width: 100%; overflow-wrap: anywhere; }
  .users-admin-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .users-admin-summary > * { min-width: 0; padding: 12px; }
  .users-role-list, .users-department-access-sub { overflow-wrap: anywhere; }
  .user-profile-hero { padding-block: 18px; }
  .user-profile-label { font-size: 12px; }
  .user-profile-value { overflow-wrap: anywhere; }
  /* Quality CSS is lazy-loaded after this sheet, so scope these overrides. */
  :is(.page, #customer-panel) .sq-workspace { padding: 14px; border-radius: 14px; }
  .sq-workspace .sq-heading { flex-wrap: wrap; gap: 8px; }
  .sq-workspace .sq-heading h2 { font-size: 21px; }
  .sq-workspace .sq-overview { grid-template-columns: minmax(0, 1fr); gap: 12px; padding-block: 14px; margin-bottom: 14px; }
  .sq-workspace .sq-coaching-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 12px; }
  .sq-workspace .sq-coaching-metric:nth-child(-n+2) { grid-column: auto; }
  .sq-workspace :is(.sq-coaching-caption, .sq-coaching-reason) { font-size: 12px !important; line-height: 1.5; }
  .sq-workspace .sq-call summary { min-height: 44px; flex-wrap: wrap; gap: 7px; }
  .sq-workspace .sq-call summary > span { min-width: 0; overflow-wrap: anywhere; }
  :is(.sq-workspace, #lead-panel) .sq-proposal { grid-template-columns: minmax(0, 1fr); }
  :is(.sq-workspace, #lead-panel) .sq-proposal-actions { opacity: 1; flex-wrap: wrap; }
  :is(.sq-workspace, #lead-panel) :is(.sq-proposal-actions button, .sq-button) { min-width: 44px; min-height: 44px; }
  .sq-workspace .sq-paging { flex-wrap: wrap; gap: 8px; }
  .sq-workspace .sq-paging .sq-button { flex: 1; }

  /* Outrank the later customer skin only on phones; preserve stylesheet order. */
  body #page-customer-card .customer-card-hero { padding: 16px 14px; }
  body #page-customer-card .customer-card-hero-top { gap: 12px; }
  body #page-customer-card .customer-card-hero-main { flex-direction: row; gap: 12px; }
  body #page-customer-card .customer-card-avatar { width: 48px; height: 48px; }
  body #page-customer-card .customer-card-name { font-size: 23px; }
  body #page-customer-card .customer-period-wrap { flex: 1 1 160px; padding: 4px 8px; }
  body #page-customer-card .customer-hero-edit-btn { flex: 0 1 auto; }
  body #page-customer-card .customer-card-hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
  body #page-customer-card .customer-card-hero-stat { min-height: 0; padding: 9px 11px; }
  body #page-customer-card .customer-card-hero-stat-value { min-height: 26px; font-size: 21px; }
  body #page-customer-card .customer-page-tabs { padding-block: 5px 8px; }
  body #page-customer-card .customer-tab-btn { min-height: 44px !important; font-size: 13px; }
  body #page-customer-card .customer-card-page, body #page-customer-card .customer-profile-grid { gap: 12px; }
  body #page-customer-card :is(.customer-profile-panel, .customer-bi-panel, .customer-tab-shell > .panel-section) { padding: 14px; }
  body #page-customer-card :is(.customer-profile-head, .customer-bi-head) { margin-bottom: 12px; padding-bottom: 10px; }
  body #page-customer-card .customer-editable-field { padding: 11px; }
  body #page-customer-card .customer-editable-field-label { font-size: 12px; }
  body #page-customer-card .customer-editable-field-value { font-size: 14px; }
  body #page-customer-card .customer-bi-value { font-size: 23px; }
  body #page-customer-card .customer-bi-subline { font-size: 11px; }
}
