/* Screen typography contract. Legacy sizes use max(original, --ui-font-min).
   Print keeps original document metrics. No scripts, remote fonts or brand recoloring. */
@media screen {
  :root {
    --ui-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    --ui-font-min: .8125rem;
    --ui-font-meta: .8125rem;
    --ui-font-label: .875rem;
    --ui-font-body: 1rem;
    --ui-font-section: 1.125rem;
    --ui-font-title: 1.5rem;
    --ui-line-body: 1.5;
    --ui-line-label: 1.4;
    --ui-muted: #52627a;
    --muted: var(--ui-muted);
    font-family: var(--ui-font-family);
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body { font-family: var(--ui-font-family); font-size: var(--ui-font-body); line-height: var(--ui-line-body); }
  /* Historical PM typography used 11–14px for ordinary controls/text.
     Only the formerly tiny 7–10px captions need a floor; public documents
     keep their separate typography contract. No page scaling is applied. */
  body.workspace-page, body.editor-page {
    --ui-font-min: .6875rem;
    --ui-font-meta: .6875rem;
    --ui-font-label: .75rem;
    --ui-line-body: 1.45;
    --ui-line-label: 1.35;
  }
  button, input, select, textarea { font-family: inherit; }
  small { font-size: max(.833333em, var(--ui-font-min)); }
  body :is(small, label, th, summary, figcaption, kbd) { line-height: var(--ui-line-label); }
  body p { line-height: var(--ui-line-body); }
  body label { font-size: var(--ui-font-label); }
  body label > span:first-child { font-size: inherit; }
  .primary-button, .secondary-button, .ghost-button { font-size: var(--ui-font-label); line-height: var(--ui-line-label); }
  .nav a b { font-size: var(--ui-font-label); }
  .eyebrow, .nav p { letter-spacing: .06em; }
  :is(h1,h2,h3,h4), .page-heading, .panel-head { min-width: 0; }
  :is(h1,h2,h3,h4) { overflow-wrap: anywhere; }
  .quote-shell .quote-hero h1, .portal-shell .hero h1 { line-height: 1.15; }
  /* Branded hero captions must not leak their pale foreground into white cards. */
  #quote-app .quote-body .quote-eyebrow,
  #quote-app .quote-body .section-title > span,
  #quote-app .quote-footer,
  #quote-app .comment time,
  #quote-app .status-card > small { color: var(--ui-muted); }
  .portal-shell :is(.portal-expiry,.doc-main small,.finance-caption,.finance-split span,.manager-line small,.safe-note,.portal-footer) {
    color: var(--ui-muted);
  }
  :is(.money,.line-total,.finance-total,[class*="-amount"],[class*="-money"],[class*="-total"]) { font-variant-numeric: tabular-nums; }
  button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
    outline: 3px solid #315eea;
    outline-offset: 3px;
  }
  .sidebar :is(a,button):focus-visible { outline-color: #b9ceff; }
  body.editor-page .project-context-facts > span:last-child { flex: 0 0 auto; }
  @media (min-width: 761px) {
    /* The formatted price covers the raw input only while it is not being edited. */
    body.editor-page:not(.client-view) #estimate-table-wrap[data-table-view="work"] .price-input-wrap:not(:focus-within) .price-input {
      color: transparent !important;
    }
  }
  @media (max-width: 720px) {
    :root { --ui-font-min: .875rem; --ui-font-meta: .875rem; }
    body.workspace-page, body.editor-page { --ui-font-min: .75rem; --ui-font-meta: .75rem; }
    body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]), select, textarea) {
      font-size: 1rem !important;
      min-height: 44px;
      line-height: 1.4;
    }
    .primary-button, .secondary-button, .ghost-button, .button, .format-button { min-height: 44px; line-height: 1.4; }
    .quote-shell :is(.primary-action,.secondary-action,.comment-form button) { min-height: 44px; font-size: 1rem; }
    .portal-shell .format-button { min-width: 44px; }
    .quote-number, .portal-expiry, .brand-lockup { min-width: 0; }
    .quote-number strong, .portal-expiry { overflow-wrap: anywhere; }
    .portal-topbar { flex-wrap: wrap; }
    body.editor-page.app-page .mobile-dock {
      grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(5.5rem, 1.2fr);
    }
    body.editor-page.app-page .mobile-dock small { white-space: nowrap; overflow-wrap: normal; }
    body.editor-page .project-context-facts { flex-wrap: wrap; gap: 4px 8px; }
    body.editor-page .project-context-facts > span:first-child { flex: 1 1 100%; }
    body.editor-page .project-context-facts b { flex-shrink: 0; }
  }
}
/* Priority cards: rank/status have their own row, the first card spans the grid. */
@media screen {
  body.workspace-page .home-focus.home-focus-v4 .home-focus-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-card {
    display: flex;
    flex-direction: column;
    grid-column: auto;
    gap: 10px;
    min-width: 0;
  }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-card.is-primary { grid-column: 1 / -1; }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-rank {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    text-align: left;
  }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-rank b { flex: 0 0 28px; }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-rank span { overflow-wrap: anywhere; }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-card > a { flex: 1; }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-card > a :is(small,strong,p) {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-card > a p {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
  }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-card > em { overflow-wrap: anywhere; }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-actions {
    min-width: 0;
    margin-top: auto;
    border-color: rgba(255,255,255,.18);
  }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-open {
    display: inline-flex;
    align-items: center;
    width: auto;
    min-height: 44px;
    padding: 6px 0;
    white-space: nowrap;
    color: #c3d5ff;
  }
  body.workspace-page .home-focus.home-focus-v4 .home-focus-actions .work-quick {
    min-height: 44px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  @media (max-width: 820px) {
    body.workspace-page .home-focus.home-focus-v4 .home-focus-grid { grid-template-columns: minmax(0, 1fr); }
  }
}

/* Compact mobile hierarchy, scoped to the home screen and estimate cards.
   Editable fields stay at 16px; desktop and printed documents keep their sizes. */
@media screen and (max-width: 760px) {
  body.workspace-page :is(.home-work-heading,.owner-tower,.home-focus),
  body.editor-page #estimate-groups { --ui-font-min: .75rem; --ui-font-meta: .75rem; }
  body.workspace-page .home-work-heading h1 { font-size: 1.5rem; line-height: 1.2; }
  body.workspace-page .owner-tower-head h2 { font-size: 1.25rem; line-height: 1.25; }
  body.workspace-page .owner-tower-priorities h3,
  body.workspace-page .home-focus h2 { font-size: 1.125rem; line-height: 1.3; }
  body.workspace-page :is(.home-work-heading,.owner-tower) .eyebrow,
  body.workspace-page .owner-tower-metric > span,
  body.workspace-page :is(.owner-tower-priorities,.owner-tower-team,.owner-tower-forecast) > header span,
  body.workspace-page .owner-tower-action div small {
    font-size: .75rem;
    line-height: 1.4;
    letter-spacing: .045em;
    color: #52627a;
  }
  body.workspace-page .owner-tower-metric strong { font-size: 1.1875rem; line-height: 1.25; }
  body.workspace-page .owner-tower-metric small,
  body.workspace-page .owner-tower-head :is(p,small),
  body.workspace-page .home-generated-at { font-size: .75rem; line-height: 1.4; color: #52627a; }
  body.editor-page #estimate-groups :is(.client-line-title,.line-title) strong {
    font-size: .9375rem !important;
    line-height: 1.3 !important;
  }
  body.editor-page #estimate-groups :is(.client-line-title,.line-title) small,
  body.editor-page #estimate-groups .client-line-qty > small {
    color: #53647d !important; /* Override the legacy pale metadata !important rule. */
    font-size: .75rem !important;
    line-height: 1.35 !important;
  }
  body.editor-page #estimate-groups :is(.line-card-label,.line-control > span) {
    font-size: .75rem !important;
    line-height: 1.3 !important;
  }
  body.editor-page #estimate-groups :is(.client-line-total,.line-total) {
    font-size: clamp(.875rem, 3.6vw, .9375rem) !important;
    line-height: 1.3;
  }
  body.editor-page #estimate-groups :is(.client-line-price,.client-line-qty) > b {
    font-size: .9375rem;
  }
  body.editor-page #estimate-groups .day-editor-button > b { font-size: .875rem; }
  body.editor-page #estimate-groups .day-editor-button > small { font-size: .75rem; }
  body.editor-page #estimate-groups :is(input:not([type="checkbox"]),select,textarea) {
    font-size: 1rem !important;
    min-height: 44px;
  }
}
@media print {
  :root { --ui-font-min: 0px; }
}
