/* The phone app layout, used below 761px and inside the desktop phone preview. */
@media (max-width: 760px) {
  .app-body { --tabs: calc(62px + env(safe-area-inset-bottom, 0px)); font-size: 15px; }
  .is-embed { user-select: none; -webkit-user-select: none; }
  .is-embed :is(input, textarea) { user-select: text; -webkit-user-select: text; }
  .app-body.is-embed { --bar: 0px; }
  .is-embed .demo-bar { display: none; }
  html:has(.is-embed) { scrollbar-width: none; }
  html:has(.is-embed)::-webkit-scrollbar { display: none; }

  .m-bar { position: sticky; top: var(--bar); z-index: 12; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 14px; background: var(--navy); color: #fff; }
  .m-bar .m-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 22px/1.3 var(--head); }
  .m-app.is-detail .m-bar, .m-bar:has(> .m-icon) { padding-left: 4px; gap: 2px; }
  .m-icon { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: var(--radius); color: #fff; }
  .m-icon .icon { width: 22px; height: 22px; }
  .app-body .content { padding: 14px 14px calc(var(--tabs) + 24px); }
  .app-body .m-app.has-fab .content { padding-bottom: calc(var(--tabs) + 92px); }
  .m-app.is-detail:has(.totalbar) .content { padding-bottom: calc(var(--tabs) + 96px); }

  .m-tabs { position: fixed; z-index: 14; left: 0; right: 0; bottom: 0; height: var(--tabs); padding: 0 4px env(safe-area-inset-bottom, 0px); background: var(--surface); border-top: 1px solid var(--line); }
  .m-tabs ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; height: 100%; }
  .m-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%; color: var(--ink-2); font-size: 12px; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap; }
  .m-tabs i { position: relative; display: grid; place-items: center; width: 46px; height: 26px; border-radius: 99px; font-style: normal; }
  .m-tabs i .icon { width: 19px; height: 19px; }
  .m-tabs .pill { position: absolute; top: -4px; right: 0; min-width: 17px; padding: 0 4px; font-size: 12px; line-height: 17px; box-shadow: 0 0 0 2px #fff; }
  .m-tabs a.is-on { color: var(--accent-dark); }
  .m-tabs a.is-on i { background: var(--accent-tint); }
  .m-fab { position: fixed; z-index: 13; right: 16px; bottom: calc(var(--tabs) + 16px); display: grid; place-items: center; width: 56px; height: 56px; border: 0; border-radius: 16px; background: var(--accent); color: #fff; box-shadow: 0 12px 24px -8px rgba(60, 34, 16, .7); cursor: pointer; }
  .m-fab .icon { width: 26px; height: 26px; }

  .btn { min-height: 46px; font-size: 15px; }
  .btn-small { min-height: 42px; font-size: 14px; }
  .card { padding: 14px; border-radius: 10px; }
  .card-flush, .card-list { padding: 0; }
  .card-list > .card-head { padding: 12px 14px 0; }
  .card-head a:not(.btn) { display: inline-flex; align-items: center; min-height: 36px; }
  .columns { gap: 12px; }
  .column { gap: 12px; }

  /* The title bar names the screen, so list headings move off view and their button becomes the add button */
  .page-head { gap: 10px; }
  .page-head h1 { font-size: 25px; }
  .page-head > .page-actions:has(> [data-act="new-request"], > [data-act="client-new"], > [data-act="item-new"], > [data-act="fu-new"]) { display: none; }
  .page-head > .page-actions { width: 100%; }
  .page-head > .page-actions > * { flex: 1; }
  .record-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .record-head > div:first-child { flex: none; }
  .record-head h1 { font-size: 25px; }
  .back { display: none; }
  .actionbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actionbar > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .actionbar .btn { padding: 0 8px; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 11px 12px; }
  .stat-value { font-size: 27px; }
  .stat-sub, .stat-name { font-size: 13px; overflow-wrap: anywhere; }

  .toolbar > .tabs, .toolbar > .filter-selects { width: 100%; }
  .content .toolbar > .tabs { margin-inline: -14px; width: calc(100% + 28px); max-width: none; padding: 2px 14px; gap: 8px; background: none; }
  .content .toolbar > .tabs .tab { min-height: 42px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--surface); color: var(--ink); box-shadow: none; }
  .content .toolbar > .tabs .tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
  .searchfield { flex: 1 1 100%; max-width: none; min-height: 46px; }
  .searchfield input { height: 44px; font-size: 16px; }
  .filter-selects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .filter-selects > :only-child, .filter-selects .filter:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .filter select { width: 100%; min-height: 44px; font-size: 16px; }

  .bid { padding: 12px; column-gap: 12px; grid-template-columns: 56px minmax(0, 1fr); grid-template-areas: "leaf main" "leaf status" "leaf value"; }
  .leaf { width: 56px; }
  .leaf small, .leaf em { font-size: 12px; }
  .bid-value { justify-self: start; }
  .bid-status { justify-content: flex-start; }
  .bid-main small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .no-leaf .bid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "status" "value"; }
  .badge { font-size: 12.5px; }
  .board a .board-foot small { font-size: 12.5px; }
  .ref, .pill, .board small, .board a > span, .cell > span, .gauge-key, .history small, .versions small, .paper th, .paper td small, .paper-sign span, .ask-figs dt, .board a > span { font-size: max(12px, .84em); }

  .fu-act { width: 100%; margin-left: 44px; }
  .fu-act .btn { flex: 1; }
  .fu-act .icon-btn { width: 42px; height: 42px; }

  .quote { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .rail, .quote-col { display: contents; }
  .sheet { order: 0; padding: 16px 14px 18px; }
  .quote-extra { order: 2; grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .quote-extra > .card-history { max-height: none; }
  .totals { order: 1; position: static; }
  .sheet-meta { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .sheet-lines-head > span { width: 100%; }
  .sheet-lines-head > span .btn { flex: 1 1 auto; }
  .line-tap { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 0; border: 0; background: none; text-align: left; cursor: pointer; }
  .line-tap:active { background: var(--accent-tint); }
  .line-tap small { font-size: 13px; }
  .totalbar { position: fixed; z-index: 13; left: 0; right: 0; bottom: var(--tabs); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 14px; background: var(--surface); border-top: 2px solid var(--accent); box-shadow: 0 -10px 20px -16px rgba(20, 22, 26, .5); }
  .totalbar > span { display: grid; min-width: 0; line-height: 1.3; }
  .totalbar small { color: var(--ink-2); font-size: 12.5px; }
  .totalbar small i { font-style: normal; }
  .totalbar b { font: 600 22px/1.2 var(--head); font-variant-numeric: lining-nums tabular-nums; }
  .totalbar .btn { flex: none; }

  .cmp-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 14px; }
  .cmp-headrow { display: none; }
  .cmp-name { grid-column: 1 / -1; }
  .cmp-side::before { content: "Version " attr(data-v); color: var(--ink-2); font-size: 12px; font-weight: 600; }
  .cmp-diff { grid-column: 1 / -1; text-align: left; }
  .cmp-diff::before { content: "Difference: "; color: var(--ink-2); font-weight: 400; }

  .paper { padding: 20px 16px; }
  .paper-sign { grid-template-columns: minmax(0, 1fr); gap: 34px; margin-top: 40px; }
  .asks { grid-template-columns: minmax(0, 1fr); }
  .ask-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ask-act .btn { flex: 1 1 40%; }

  .board { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: minmax(0, 1fr); overflow: visible; }
  .rows a { padding: 12px; gap: 12px; }
  .rows-lib .ref { width: auto; }
  .rows-end { max-width: 120px; text-align: right; }

  .field :is(input, select, textarea), .cell input { min-height: 46px; font-size: 16px; }
  .form-grid.thirds { grid-template-columns: minmax(0, 1fr); }

  dialog { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; margin: 0; max-height: calc(100dvh - var(--bar) - 36px); border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  dialog form { max-height: calc(100dvh - var(--bar) - 36px); }
  dialog.is-tall form { height: calc(100dvh - var(--bar) - 36px); }
  dialog[open] { animation: m-up .24s cubic-bezier(.2, .8, .2, 1); }
  .icon-btn { width: 44px; height: 44px; }
  .modal-foot > .btn { flex: 1; }
  .toasts { left: 12px; right: 12px; max-width: none; bottom: calc(var(--tabs, 0px) + 84px); }

  .m-me { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
  .m-me .avatar { width: 50px; height: 50px; font-size: 16px; }
  .m-me div { display: grid; }
  .m-me strong { font-size: 18px; }
  .m-me span:not(.avatar) { color: var(--ink-2); font-size: 14px; }
  .m-menu { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
  .m-menu li + li { border-top: 1px solid var(--line); }
  .m-menu :is(a, button) { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 0 16px; border: 0; background: none; color: var(--ink); font-size: 16px; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; }
  .m-menu :is(a, button) > span:not(.pill) { flex: 1; }
  .m-menu .icon:last-child { color: var(--ink-2); }

  .signin { padding: 28px 16px 40px; }
}
@media (max-width: 350px) {
  .actionbar { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 23px; }
  .sumlines .grand dd { font-size: 22px; }
  .totalbar b { font-size: 19px; }
}
body.is-grabbing, body.is-grabbing * { cursor: grabbing !important; }
.tabs, .table-wrap { -webkit-overflow-scrolling: touch; }
@keyframes m-up { from { transform: translateY(40px); opacity: .4; } }

/* Desktop and phone switch in the demo bar */
.view-switch { display: none; }
.preview { display: none; }
@media (min-width: 900px) {
  .view-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 99px; background: rgba(64, 38, 20, .13); }
  .view-switch button { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 13px; border: 0; border-radius: 99px; background: none; color: #402614; font-size: 13.5px; font-weight: 700; cursor: pointer; }
  .view-switch button .icon { width: 15px; height: 15px; }
  .view-switch button[aria-pressed="true"] { background: #fff; box-shadow: 0 1px 3px rgba(64, 38, 20, .25); }

  .app-body.is-preview { background: #e4e7e9; }
  .is-preview #app, .is-preview > dialog, .is-preview .toasts { display: none; }
  .is-preview .preview { display: flex; align-items: center; justify-content: center; gap: clamp(32px, 6vw, 96px); min-height: calc(100vh - var(--bar)); padding: 20px 32px; }
  .preview-notes { max-width: 360px; }
  .preview-notes h2 { font: 600 clamp(28px, 2.8vw, 38px)/1.12 var(--head); }
  .preview-notes > p { margin-top: 10px; color: var(--ink-2); font-size: 17px; }
  .preview-notes ul { margin-top: 20px; border-top: 1px solid var(--line-2); }
  .preview-notes li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
  .preview-notes li .icon { margin-top: 2px; color: var(--accent); }

  .device { --h: 844px; flex: none; width: 414px; padding: 11px; border-radius: 56px; background: #141517; box-shadow: 0 40px 70px -30px rgba(20, 21, 23, .65), inset 0 0 0 2px #45474c; }
  .device-screen { position: relative; display: flex; flex-direction: column; width: 392px; height: var(--h); border-radius: 45px; overflow: hidden; background: var(--surface); isolation: isolate; }
  .device-status { display: flex; align-items: center; justify-content: space-between; flex: none; height: 44px; padding: 0 30px; background: var(--surface); font-size: 15px; font-weight: 700; }
  .device-status::after { content: ""; width: 25px; height: 12px; border: 1.5px solid var(--ink); border-radius: 4px; background: linear-gradient(var(--ink), var(--ink)) 2px 50% / 16px 6px no-repeat; }
  .device-island { position: absolute; top: 10px; left: 50%; width: 108px; height: 26px; margin-left: -54px; border-radius: 99px; background: #141517; }
  .device iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--bg); }
  .device-home { flex: none; height: 12px; background: var(--surface); }
}

@media (max-width: 760px) {
  /* Role screen: both roles are visible at once, each as one large row */
  .signin .roles { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 22px; }
  .signin h1 { margin-top: 22px; font-size: 25px; text-wrap: balance; }
  .signin-sub { margin-inline: auto; font-size: 15px; text-wrap: balance; }
  .signin .role-points { display: none; }
  .signin .role { display: grid; grid-template-columns: 46px minmax(0, 1fr) 10px; grid-template-areas: "ico title go" "ico name go" "ico short go"; align-content: center; align-items: center; column-gap: 14px; row-gap: 1px; height: auto; min-height: 104px; padding: 16px; text-align: left; }
  .signin .role::after { content: ""; grid-area: go; width: 8px; height: 8px; border: solid currentColor; border-width: 2px 2px 0 0; transform: rotate(45deg); opacity: .55; }
  .signin .role-icon { grid-area: ico; align-self: center; }
  .signin .role-title { grid-area: title; margin: 0; font-size: 18px; line-height: 1.25; }
  .signin .role-name { grid-area: name; font-size: 14px; line-height: 1.35; }
  .signin .role-short { grid-area: short; display: block; font-size: 13.5px; line-height: 1.35; color: var(--ink-2); }
}

/* Desktop and Mobile switch sits in the exact middle of the bar */
@media (min-width: 900px) {
  .app-body .demo-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .app-body .demo-bar > p { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .app-body .demo-bar > .view-switch { justify-self: center; }
  .app-body .demo-bar > nav { justify-self: end; }
}
