/* Phone layout: app bar, bottom tabs, rows instead of tables */
@media (max-width: 760px) {
  .app-body { --bar: 40px; --tabs: 66px; }
  .is-embed { --bar: 0px; }
  .app-body.is-embed { min-height: 100%; }
  .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: 0; z-index: 20; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 10px 6px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .m-bar > .m-icon:first-child { margin-left: -10px; }
  .m-bar .m-title { font: 700 19px/1.2 var(--head); }
  .m-bar > div { margin-left: auto; }
  .m-icon { width: 44px; height: 44px; }
  .app-body .content.m-content { padding: 14px 14px calc(var(--tabs) + 22px); }
  .app-body .m-app--fab .content.m-content { padding-bottom: calc(var(--tabs) + 92px); }
  .content > * + * { margin-top: 14px; }
  .m-tabs { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; height: var(--tabs); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .m-tabs ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: 100%; }
  .m-tabs a { display: grid; align-content: center; justify-items: center; gap: 2px; height: 100%; color: var(--ink-2); font-size: 12px; font-weight: 600; text-decoration: none; }
  .m-tabs i { position: relative; display: grid; place-items: center; width: 46px; height: 28px; border-radius: 8px; }
  .m-tabs i .icon { width: 21px; height: 21px; }
  .m-tabs .dot { position: absolute; top: -3px; right: 3px; min-width: 18px; border-radius: 99px; background: var(--danger); color: #fff; font: 700 12px/18px var(--font); font-style: normal; text-align: center; }
  .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: 24; right: 16px; bottom: calc(var(--tabs) + 16px); display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 16px; background: var(--accent); color: #fff; box-shadow: 0 12px 24px -10px rgba(34, 40, 12, .7); cursor: pointer; }
  .m-fab .icon { width: 26px; height: 26px; }
  .page-head { align-items: stretch; flex-direction: column; gap: 10px; }
  .page-head h1 { font-size: 23px; }
  .page-head p { font-size: 14px; }
  .page-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-actions > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .back { display: none; }
  .btn { min-height: 46px; text-align: center; }
  .btn-small { min-height: 40px; }
  .panel { padding: 14px; }
  .panel-flush { padding: 0; }
  .panel-head a { display: inline-flex; align-items: center; min-height: 32px; }
  .stats a { padding: 11px 13px 12px; }
  .stats strong { font-size: 23px; }
  .stats span, .stats small { font-size: 12.5px; }
  .building-bar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .building-bar .segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .segmented button { min-height: 40px; padding: 0 4px; }
  .building-bar > .btn { display: none; }
  .plan.panel { padding: 0; border: 0; background: none; }
  .floor { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 8px; }
  .floor-no { display: flex; align-items: baseline; gap: 5px; justify-content: flex-start; font-size: 15px; }
  .floor-no small { font-size: 13px; }
  .floor-units { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .cell { min-height: 80px; padding: 6px 8px 8px; }
  .cell-who, .cell-line { font-size: 13px; }
  .cell-line { font-size: 12px; }
  .peek-actions .btn { flex: 1 1 130px; }
  dialog .peek h2 { font-size: 20px; }
  .tabs .tab { min-height: 42px; }
  .searchfield { flex-basis: 100%; max-width: none; min-height: 46px; }
  .searchfield input { font-size: 16px; }
  .filter { flex: 1 1 130px; min-width: 0; }
  .filter select { width: 100%; min-height: 46px; }
  .m-list { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
  .m-list > li + li { border-top: 1px solid var(--line); }
  .m-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 66px; padding: 10px 13px; color: inherit; text-decoration: none; }
  .m-row:active { background: var(--soft); }
  .m-row-main { flex: 1; min-width: 0; }
  .m-row-main strong, .m-row-main > span, .m-row-main small { display: block; }
  .m-row-main strong { font-weight: 600; line-height: 1.3; }
  .m-row-main > span { font-size: 13.5px; color: var(--ink-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .m-row-main small { font-size: 12.5px; color: var(--ink-2); }
  .m-row-end { display: grid; justify-items: end; gap: 4px; max-width: 46%; text-align: right; font-size: 14px; }
  .m-row-end small { font-size: 12.5px; color: var(--ink-2); }
  .badge { font-size: 12px; }
  .m-row-end .badge { white-space: normal; text-align: right; }
  .steps { grid-auto-flow: row; grid-auto-columns: auto; padding: 14px; }
  .steps li { grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; justify-items: start; text-align: left; gap: 10px; padding: 7px 0; }
  .steps li + li::before { top: -9px; left: 8px; right: auto; width: 2px; height: 18px; }
  .steps b { margin: 0; }
  .steps span { text-align: right; }
  .facts > div { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  .facts dd a { display: inline-block; padding: 2px 0; }
  .note-form .btn { justify-self: stretch; }
  .callout > div:last-child, .callout .btn { width: 100%; }
  .balance { padding: 18px; }
  .balance strong { font-size: 38px; }
  .balance > div:last-child { display: grid; width: 100%; }
  .quick { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .job-actions > * { flex: 1; }
  .sub-head { font-size: 18px; }
  .m-me { display: flex; align-items: center; gap: 12px; }
  .m-me .avatar { width: 48px; height: 48px; font-size: 16px; }
  .m-me strong, .m-me div span { display: block; }
  .m-me div span { font-size: 13.5px; color: var(--ink-2); }
  .m-menu :is(a, button) { display: flex; align-items: center; gap: 13px; width: 100%; min-height: 56px; padding: 0 14px; border: 0; background: none; color: inherit; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; }
  .m-menu span { flex: 1; }
  .m-menu .icon:last-child { color: var(--ink-2); width: 16px; }
  .field input, .field select, .field textarea { min-height: 48px; font-size: 16px; }
  dialog { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; margin: 0; max-height: calc(100dvh - var(--bar, 0px) - 12px); border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  dialog form { max-height: calc(100dvh - var(--bar, 0px) - 12px); }
  dialog[open] { animation: m-up .24s cubic-bezier(.2, .8, .2, 1); }
  dialog .modal-head { position: relative; padding-top: 20px; }
  dialog .modal-head::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 99px; background: var(--line-2); }
  dialog .modal-foot > .btn { flex: 1; min-height: 50px; }
  .toasts { left: 12px; right: 12px; max-width: none; bottom: calc(var(--tabs, 0px) + 84px); }
  .locked { margin: 28px auto; }
}
@media (max-width: 350px) {
  .stats strong { font-size: 20px; }
  .m-tabs i { width: 38px; }
  .m-row-end { max-width: 42%; }
}
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(47, 56, 13, .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: #2f380d; 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(47, 56, 13, .25); }

  .app-body.is-preview { background: #e6e7de; }
  .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: 700 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, .signin .role-org { 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; }
}
