/* Milestone Pay app layer. Components and tokens come from ds/tokens.css + ds/bundle.css (the design system);
   this file only adds app layout, interactive states for elements the boards draw statically, and the phone layout
   (the design system shows phones as separate frames; here they are media queries). Values use the tokens. */

html, body { min-height: 100%; }
body { min-height: 100vh; }
#app, .mp-app, .mp-auth { min-height: 100vh; }
a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mp-btn:disabled, .mp-btn[aria-disabled="true"] { background: var(--surface-sunken); color: var(--ink-disabled); border-color: transparent; cursor: not-allowed; }
.mp-btn--primary:hover:not(:disabled) { background: var(--ink-hover); }
.mp-btn--secondary:hover:not(:disabled), .mp-btn--ghost:hover:not(:disabled) { background: var(--surface-sunken); }
.mp-btn--danger-quiet:hover:not(:disabled) { background: var(--issue-bg); }
.mp-btn--danger-quiet:disabled { background: transparent; }
.mp-link-plain { color: inherit; text-decoration: none; }
.mp-link-plain:hover { text-decoration: underline; text-underline-offset: 3px; }
.mp-t-section.mp-link-plain, .mp-t-sub.mp-link-plain, .mp-ms__title.mp-link-plain { display: inline; }
.mp-lead { font-size: 17px; line-height: 26px; max-width: 460px; }
.mp-only-phone { display: none !important; }

/* top bar + avatar menu */
.mp-top { position: sticky; top: 0; z-index: 20; }
.mp-menuwrap { position: relative; }
.mp-menuwrap .mp-menu { right: 0; top: 52px; }
button.mp-menu__item { width: 100%; background: none; border: 0; text-align: left; cursor: pointer; font: inherit; font-size: 14px; font-weight: 500; }
button.mp-menu__item:hover, button.mp-menu__item:focus-visible { background: var(--surface-sunken); }
.mp-menu__item .mp-ok { display: inline-flex; gap: 4px; align-items: center; color: var(--success); }

/* interactive versions of statically drawn controls */
.mp-seg button { min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 6px; background: transparent; font-size: 14px; font-weight: 500; color: var(--ink-muted); cursor: pointer; }
.mp-seg button.on { background: var(--surface-raised); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--border-control); }
button.mp-tag { cursor: pointer; font-family: inherit; }
.mp-role-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a.mp-strip__item { text-decoration: none; color: inherit; }
a.mp-strip__item:hover { border-color: var(--border-control); }
.mp-drop { cursor: pointer; }
.mp-drop.is-over { border-color: var(--ink); background: var(--surface-raised); }
.mp-drop--compact { padding: var(--space-4); }
.mp-select--sm { min-height: 36px; width: auto; padding: 6px 32px 6px 10px; font-size: 14px; }
.mp-input--amount { text-align: right; max-width: 140px; }
.mp-affix { display: flex; align-items: center; gap: var(--space-2); }

/* page helpers */
.mp-narrow { width: 100%; max-width: 560px; margin: 0 auto; }
.mp-statrow { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--space-4); }
.mp-tablewrap { overflow-x: auto; }
.mp-toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; width: max-content; max-width: calc(100vw - 32px); }
.mp-overlay { position: fixed; inset: 0; z-index: 100; overflow-y: auto; }
.mp-overlay .mp-dialog { max-height: calc(100vh - 64px); overflow-y: auto; }

/* auth */
a.mp-pp-login { display: flex; align-items: center; justify-content: center; min-height: 52px; border-radius: 999px; background: var(--paypal-gold); color: var(--paypal-ink); text-decoration: none; font-size: 16px; font-weight: 500; }
a.mp-pp-login b { font-weight: 800; font-style: italic; letter-spacing: -0.01em; }
a.mp-pp-login:hover { filter: brightness(0.96); }
a.mp-pp-login.is-loading { opacity: .6; pointer-events: none; }
.mp-sender { display: flex; gap: 12px; align-items: center; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--ai-bg); }
.mp-testlogin summary, .mp-testbuyer summary, .mp-hood summary, .mp-inline-details summary { cursor: pointer; }
.mp-inline-details { display: inline; }
.mp-inline-details[open] code { display: block; margin-top: 4px; word-break: break-all; }

/* dashboards */
.mp-jobrow { padding: 0; overflow: hidden; }
.mp-jobrow__main { display: grid; grid-template-columns: minmax(0, 1fr) 260px auto; gap: var(--space-6); align-items: center; padding: var(--space-6); }
.mp-jobrow__money { display: flex; flex-direction: column; gap: var(--space-2); }
.mp-jobrow__banner { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-6); background: var(--pending-bg); border-top: 1px solid var(--border); font-size: 14px; }

/* agreement review */
.mp-review { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: var(--space-4); align-items: start; }
.mp-review__chat { position: sticky; top: 88px; }
.mp-chatcard__head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-4); flex-wrap: wrap; }
.mp-chatpane { max-height: calc(100vh - 220px); overflow-y: auto; border-top: 1px solid var(--border); background: var(--surface); }
.mp-msg.is-hl .mp-bubble { box-shadow: 0 0 0 2px var(--surface-raised), 0 0 0 4px var(--ink); }
.mp-ms--edit { grid-template-columns: 32px minmax(0, 1fr) auto; }
.mp-notecard { background: var(--pending-bg); border-color: var(--pending-bg); }
.mp-linkrow { flex-wrap: nowrap; }
.mp-linkrow .mp-input { flex: 1; min-width: 0; padding-right: 12px; }

/* paste chat, change requests */
.mp-chatbox { min-height: 260px; font-family: var(--font-sans); }
.mp-reading { max-width: 560px; }
.mp-changes { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: var(--space-4); align-items: start; }
.mp-crgrid { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: var(--space-3); }
.mp-crgrid .mp-input--amount { max-width: none; }

/* payments */
.mp-pp-host { min-height: 48px; }
.mp-hood { background: var(--surface); }
.mp-trace { white-space: pre-wrap; font-size: 12px; line-height: 16px; margin: 8px 0 0; max-height: 200px; overflow: auto; }
.mp-trace-list { margin: 4px 0 0; padding-left: 20px; font-size: 13px; color: var(--ink-2); }

/* ------------------------------------------------------------------ phone (390px boards) */
@media (max-width: 760px) {
  .mp-only-phone { display: revert !important; }
  .mp-hide-phone { display: none !important; }
  .mp-top { padding: 0 var(--space-4); gap: var(--space-3); height: 56px; }
  .mp-top .mp-wordmark { font-size: 15px; }
  .mp-nav { display: none; }
  .mp-wordmark { white-space: nowrap; }
  .mp-page { padding: var(--space-6) var(--space-4) var(--space-12); gap: var(--space-6); }
  .mp-grid-2, .mp-grid-3, .mp-statrow, .mp-review, .mp-changes, .mp-crgrid, .mp-settings { grid-template-columns: minmax(0, 1fr); }
  .mp-review__chat { position: static; }
  .mp-chatpane { max-height: 420px; }
  .mp-sidenav { display: none; }
  .mp-hero { grid-template-columns: minmax(0, 1fr); padding: var(--space-6) var(--space-4); gap: var(--space-8); }
  .mp-hero__title { font-size: 32px; line-height: 38px; }
  .mp-cta-row { flex-direction: column; align-items: stretch; }
  .mp-auth__top { padding: 0 var(--space-4); }
  .mp-auth__main { place-items: start stretch; padding: var(--space-4); }
  .mp-authcard, .mp-authcard--wide { width: 100%; border: 0; background: transparent; box-shadow: none; padding: 0; }
  .mp-roles { grid-template-columns: minmax(0, 1fr); }
  .mp-roles .mp-role-card { min-height: 0; flex-direction: row; align-items: center; padding: var(--space-4); gap: var(--space-4); }
  .mp-roles .mp-role-card.on { padding: calc(var(--space-4) - 1px); }
  .mp-roles .mp-role-card__radio { position: static; order: -1; flex: none; }
  .mp-auth__foot { flex-wrap: wrap; gap: var(--space-3); }
  .mp-jobrow__main { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); padding: var(--space-4); }
  .mp-jobrow__banner { flex-wrap: wrap; padding: var(--space-3) var(--space-4); }
  .mp-next { flex-wrap: wrap; padding: var(--space-4); }
  .mp-next > .mp-btn, .mp-next > a.mp-btn { width: 100%; }
  .mp-ms, .mp-ms--edit { grid-template-columns: 32px minmax(0, 1fr); padding: var(--space-3) var(--space-4); }
  .mp-ms__right { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
  .mp-ms__body { grid-column: 1 / 3; }
  .mp-tl { grid-template-columns: 110px minmax(0, 1fr); font-size: 12px; }
  .mp-term { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .mp-card { padding: var(--space-4); }
  .mp-card--flush { padding: 0; }
  .mp-overlay { display: flex; align-items: flex-end; padding: 0; }
  .mp-overlay .mp-dialog { width: 100%; max-width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: var(--space-3) var(--space-6) var(--space-8); max-height: 92vh; }
  .mp-sticky-cta { position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding: var(--space-3) 0 var(--space-4); margin-bottom: calc(-1 * var(--space-4)); }
  .mp-toasts { bottom: 88px; }
  .mp-table th, .mp-table td { padding-left: 12px; padding-right: 12px; }
  .mp-input--amount { max-width: 110px; }
}
@media (prefers-reduced-motion: no-preference) {
  .mp-spinner { animation: mp-spin .8s linear infinite; }
  .mp-skel { background-size: 200% 100%; animation: mp-shimmer 1.4s ease-in-out infinite; }
}
@keyframes mp-spin { to { transform: rotate(360deg); } }
@keyframes mp-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
button.mp-back { background: none; border: 0; padding: 0; cursor: pointer; align-self: flex-start; font-family: inherit; }
a.mp-back { align-self: flex-start; }

/* ------------------------------------------------------------------ fix list 2026-11-10 */
/* profile pictures */
.mp-avatar--img, .mp-avatarbtn__img { overflow: hidden; padding: 0; background: var(--surface-sunken); }
.mp-avatar--img img, .mp-avatarbtn__img img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.mp-avatar--xl { width: 72px; height: 72px; font-size: 26px; }
.mp-avatarfield { gap: var(--space-4); align-items: center; flex-wrap: nowrap; }
.mp-profile__head { display: flex; gap: var(--space-4); align-items: center; }
.mp-dialog span.mp-tag { cursor: default; }
button.mp-person { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 36px; padding: 2px 10px 2px 2px; border-radius: 999px; border: 1px solid var(--border-control); background: var(--surface-raised); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
button.mp-person:hover { background: var(--surface-sunken); }

/* buttons with long labels wrap inside their card instead of spilling out of it (Gaps found) */
.mp-gap > .mp-grow { min-width: 0; }
.mp-gap .mp-btn { white-space: normal; text-align: left; justify-content: flex-start; height: auto; min-height: 36px; padding-top: 8px; padding-bottom: 8px; max-width: 100%; overflow-wrap: anywhere; }
.mp-card { min-width: 0; }
.mp-card__head { flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.mp-alert .mp-grow, .mp-next .mp-grow { min-width: 0; overflow-wrap: anywhere; }
.mp-bubble, .mp-ms__title, .mp-ms__crit li, .mp-term dd { overflow-wrap: anywhere; }
.mp-ms__crit li { min-width: 0; }

/* project rows: open + archive + delete */
.mp-jobrow__actions { display: flex; align-items: center; gap: var(--space-1); }
.mp-iconbtn--danger:hover { background: var(--issue-bg); color: var(--issue); }
.mp-iconbtn:disabled { opacity: .5; cursor: default; }
.mp-archived > summary { cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); color: var(--ink-2); padding: var(--space-2) 0; }
.mp-archived .mp-jobrow { opacity: .85; }

/* rename a project */
.mp-titleedit { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }
.mp-titleedit .mp-t-title { overflow-wrap: anywhere; min-width: 0; }
.mp-titleedit__input { flex: 1 1 280px; max-width: 520px; font-size: 20px; font-weight: 600; }

/* draft milestones: editable title, description and amount */
.mp-ms--draft { align-items: start; }
.mp-ms--draft .mp-ms__right { align-items: flex-end; gap: var(--space-2); }
.mp-ms__desc { min-height: 84px; resize: vertical; font-family: var(--font-sans); line-height: 20px; }
.mp-addtag { flex-wrap: nowrap; }
.mp-addtag .mp-input { flex: 1; min-width: 0; }
.mp-addtag[hidden] { display: none; }

/* project chat */
.mp-chatlog { max-height: 360px; overflow-y: auto; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.mp-chatlog__tag { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--issue); margin-bottom: 2px; }
.mp-chatlog__tag .mp-i { width: 14px; height: 14px; }
.mp-chatsend { display: flex; gap: var(--space-2); align-items: flex-end; }
.mp-chatsend .mp-input { flex: 1; min-width: 0; resize: vertical; }

/* client payments: two columns on desktop */
.mp-narrow { max-width: 640px; }
.mp-paypage { width: 100%; max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-6) var(--space-8); align-items: start; }
.mp-paypage__head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; }
.mp-paypage__side { position: sticky; top: 88px; }
.mp-paypage .mp-paypal { max-width: 480px; }
@media (max-width: 980px) {
  .mp-paypage { grid-template-columns: minmax(0, 1fr); max-width: 640px; }
  .mp-paypage__side { position: static; grid-row: 2; }
}
@media (max-width: 760px) {
  .mp-jobrow__actions { justify-content: space-between; }
  .mp-jobrow__actions > .mp-btn { flex: 1; }
  .mp-chatsend { flex-direction: column; align-items: stretch; }
  .mp-ms--draft .mp-ms__right { align-items: center; }
}

/* invoice links on a paid milestone */
.mp-invoice { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.mp-ms__body .mp-invoice { padding-top: var(--space-3); margin-top: var(--space-2); border-top: 1px solid var(--border); }
.mp-ms__body > .mp-invoice:first-child { margin-top: 0; }

/* ------------------------------------------------------------------ fix list 2 (items 18-24) */
/* account menu: a long email wraps inside the menu */
.mp-menu { max-width: calc(100vw - 16px); }
.mp-menu__who { min-width: 0; }
.mp-menu__id { min-width: 0; flex: 1; }
.mp-menu__id > * { overflow-wrap: anywhere; word-break: break-word; }

/* project page */
.mp-pagelinks { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mp-iconbtn--sm { width: 32px; height: 32px; }
.mp-iconbtn--sm .mp-i { width: 16px; height: 16px; }
.mp-copied { font-size: 12px; font-weight: 600; color: var(--success); }
.mp-slim { padding-top: var(--space-2); padding-bottom: var(--space-2); align-items: center; }
.mp-slim .mp-link { white-space: nowrap; }
.mp-msx__toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px 0 8px; margin-left: -8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.mp-msx__toggle:hover { background: var(--surface-sunken); }
.mp-msx__toggle .mp-i { width: 16px; height: 16px; }
.mp-msx__panel { padding-top: var(--space-2); }
.mp-msx__panel[hidden] { display: none; }
.mp-flip { transform: rotate(180deg); }

/* change requests */
.mp-how { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); font-size: 14px; color: var(--ink-2); }
.mp-howstep { display: inline-flex; align-items: center; gap: var(--space-2); }
.mp-howstep b { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-sunken); color: var(--ink); font-size: 12px; }
.mp-corner { position: fixed; right: 24px; bottom: 24px; z-index: 30; box-shadow: var(--shadow-overlay); }
.mp-corner--open { width: 360px; max-width: calc(100vw - 32px); background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.mp-reqlist { padding-top: 0; padding-bottom: 0; }
.mp-reqitem { padding: var(--space-4) 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.mp-reqlist .mp-reqitem:first-child, .mp-card--current .mp-reqitem { border-top: 0; }
.mp-card--current .mp-reqitem { padding: 0; }
.mp-reqitem__text { overflow-wrap: anywhere; font-weight: 500; }
@media (max-width: 760px) {
  .mp-pagelinks .mp-btn { flex: 1 1 auto; }
  .mp-corner { right: 16px; bottom: 16px; }
  .mp-slim { flex-wrap: wrap; }
}
#sendQuote { white-space: normal; max-width: 100%; height: auto; padding-top: 10px; padding-bottom: 10px; text-align: left; }

/* ------------------------------------------------------------------ phone pass: nothing wider than the screen, tap targets >= 40px */
@media (max-width: 760px) {
  .mp-ms__right { flex-wrap: wrap; gap: var(--space-2); min-width: 0; }
  .mp-ms__right .mp-badge { white-space: normal; text-align: left; max-width: 100%; }
  .mp-badge { max-width: 100%; }
  button.mp-chip { min-height: 40px; padding-left: 12px; padding-right: 12px; }
  .mp-msx__toggle { min-height: 44px; }
  .mp-iconbtn--sm { width: 44px; height: 44px; }
  button.mp-back, a.mp-back { min-height: 44px; display: inline-flex; align-items: center; }
  .mp-btn--sm { min-height: 40px; }
  button.mp-person { min-height: 40px; }
  .mp-tag { min-height: 40px; }
}

.mp-tl__st { color: var(--ink-muted); font-size: 12px; }
.mp-tl__name { display: flex; flex-direction: column; min-width: 0; padding-right: var(--space-2); overflow-wrap: anywhere; }
@media (max-width: 760px) {
  /* totals: two across instead of three tall cards */
  .mp-statrow, .mp-grid-3:has(> .mp-stat) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); }
  .mp-statrow > :first-child, .mp-grid-3:has(> .mp-stat) > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .mp-stat { padding: var(--space-3) var(--space-4); min-width: 0; }
  .mp-stat__value { font-size: 22px; line-height: 28px; }
  /* client payments: what to do comes first, the summary after */
  .mp-paypage__side { grid-row: auto; }
  /* timeline: bars show the icon; the status is written under the name */
  .mp-tl { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .mp-tl__txt { display: none; }
  .mp-tl__bar { justify-content: center; padding: 0; min-width: 22px; }
  .mp-tl__axis span:not(:first-child):not(:last-child) { display: none; }
  /* settings rows: text above its button */
  .mp-setrow { flex-direction: column; align-items: stretch; gap: var(--space-2); }
  .mp-setrow > .mp-btn, .mp-setrow > div > .mp-btn { align-self: flex-start; }
  /* tables that read as cards on a phone */
  .mp-table--stack thead { display: none; }
  .mp-table--stack, .mp-table--stack tbody { display: block; }
  .mp-table--stack tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }
  .mp-table--stack tr:first-child { border-top: 0; }
  .mp-table--stack td { display: contents; }
  .mp-table--stack td::before { content: attr(data-label); font-size: 12px; color: var(--ink-muted); }
  .mp-table--stack td:first-child::before { display: none; }
  .mp-table--stack td:first-child { display: block; grid-column: 1 / -1; padding: 0; border: 0; font-weight: 600; overflow-wrap: anywhere; }
  /* room under the page for the floating corner button */
  .mp-page:has(.mp-corner) { padding-bottom: 104px; }
  .mp-corner--open { left: 16px; right: 16px; width: auto; max-width: none; }
}

@media (max-width: 760px) {
  .mp-table--stack tr { justify-items: start; align-items: center; }
  .mp-table--stack td[data-label=""]::before { display: none; }
  .mp-table--stack td.num { text-align: left; }
}
